Search in sources :

Example 1 with Body

use of org.opensaml.soap.soap11.Body in project cas by apereo.

the class SamlProfileSamlSoap11FaultResponseBuilder method build.

@Override
public Envelope build(final AuthnRequest authnRequest, final HttpServletRequest request, final HttpServletResponse response, final org.jasig.cas.client.validation.Assertion casAssertion, final SamlRegisteredService service, final SamlRegisteredServiceServiceProviderMetadataFacade adaptor) throws SamlException {
    final Header header = newSoapObject(Header.class);
    final Body body = newSoapObject(Body.class);
    final Fault fault = newSoapObject(Fault.class);
    final FaultCode faultCode = newSoapObject(FaultCode.class);
    faultCode.setValue(FaultCode.SERVER);
    fault.setCode(faultCode);
    final FaultActor faultActor = newSoapObject(FaultActor.class);
    faultActor.setValue(SamlIdPUtils.getIssuerFromSamlRequest(authnRequest));
    fault.setActor(faultActor);
    final FaultString faultString = newSoapObject(FaultString.class);
    faultString.setValue(request.getAttribute(SamlIdPConstants.REQUEST_ATTRIBUTE_ERROR).toString());
    fault.setMessage(faultString);
    body.getUnknownXMLObjects().add(fault);
    final Envelope envelope = newSoapObject(Envelope.class);
    envelope.setHeader(header);
    envelope.setBody(body);
    encodeFinalResponse(request, response, service, adaptor, envelope);
    return envelope;
}
Also used : FaultCode(org.opensaml.soap.soap11.FaultCode) FaultActor(org.opensaml.soap.soap11.FaultActor) Header(org.opensaml.soap.soap11.Header) Fault(org.opensaml.soap.soap11.Fault) FaultString(org.opensaml.soap.soap11.FaultString) Envelope(org.opensaml.soap.soap11.Envelope) Body(org.opensaml.soap.soap11.Body)

Example 2 with Body

use of org.opensaml.soap.soap11.Body in project cas by apereo.

the class CasHttpSoap11Encoder method buildAndStoreSOAPMessage.

@Override
protected void buildAndStoreSOAPMessage(final XMLObject payload) {
    final XMLObjectBuilderFactory builderFactory = XMLObjectProviderRegistrySupport.getBuilderFactory();
    final SOAPObjectBuilder<Envelope> envBuilder = (SOAPObjectBuilder<Envelope>) builderFactory.getBuilder(Envelope.DEFAULT_ELEMENT_NAME);
    final Envelope envelope = envBuilder.buildObject(SOAPConstants.SOAP11_NS, Envelope.DEFAULT_ELEMENT_LOCAL_NAME, OPENSAML_11_SOAP_NS_PREFIX);
    final SOAPObjectBuilder<Body> bodyBuilder = (SOAPObjectBuilder<Body>) builderFactory.getBuilder(Body.DEFAULT_ELEMENT_NAME);
    final Body body = bodyBuilder.buildObject(SOAPConstants.SOAP11_NS, Body.DEFAULT_ELEMENT_LOCAL_NAME, OPENSAML_11_SOAP_NS_PREFIX);
    if (!body.getUnknownXMLObjects().isEmpty()) {
        LOGGER.warn("Existing SOAP Envelope Body already contained children");
    }
    body.getUnknownXMLObjects().add(payload);
    envelope.setBody(body);
    this.storeSOAPEnvelope(envelope);
}
Also used : SOAPObjectBuilder(org.opensaml.soap.common.SOAPObjectBuilder) XMLObjectBuilderFactory(org.opensaml.core.xml.XMLObjectBuilderFactory) Envelope(org.opensaml.soap.soap11.Envelope) Body(org.opensaml.soap.soap11.Body)

Example 3 with Body

use of org.opensaml.soap.soap11.Body in project ddf by codice.

the class SamlProtocol method createSoapMessage.

public static Envelope createSoapMessage(SignableSAMLObject signableSAMLObject) {
    Body body = soapBodyBuilder.buildObject();
    body.getUnknownXMLObjects().add(signableSAMLObject);
    Envelope envelope = soapEnvelopeBuilder.buildObject();
    envelope.setBody(body);
    Header header = soapHeaderBuilder.buildObject();
    envelope.setHeader(header);
    return envelope;
}
Also used : Header(org.opensaml.soap.soap11.Header) Envelope(org.opensaml.soap.soap11.Envelope) Body(org.opensaml.soap.soap11.Body)

Example 4 with Body

use of org.opensaml.soap.soap11.Body in project cas by apereo.

the class SamlProfileSamlSoap11ResponseBuilder method buildResponse.

@Override
protected Envelope buildResponse(final Assertion assertion, final org.jasig.cas.client.validation.Assertion casAssertion, final AuthnRequest authnRequest, final SamlRegisteredService service, final SamlRegisteredServiceServiceProviderMetadataFacade adaptor, final HttpServletRequest request, final HttpServletResponse response) throws SamlException {
    final Response ecpResponse = newEcpResponse(adaptor.getAssertionConsumerService().getLocation());
    final Header header = newSoapObject(Header.class);
    header.getUnknownXMLObjects().add(ecpResponse);
    final Body body = newSoapObject(Body.class);
    final org.opensaml.saml.saml2.core.Response saml2Response = (org.opensaml.saml.saml2.core.Response) saml2ResponseBuilder.build(authnRequest, request, response, casAssertion, service, adaptor);
    body.getUnknownXMLObjects().add(saml2Response);
    final Envelope envelope = newSoapObject(Envelope.class);
    envelope.setHeader(header);
    envelope.setBody(body);
    return envelope;
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(org.opensaml.saml.saml2.ecp.Response) Header(org.opensaml.soap.soap11.Header) Envelope(org.opensaml.soap.soap11.Envelope) Body(org.opensaml.soap.soap11.Body)

Aggregations

Body (org.opensaml.soap.soap11.Body)4 Envelope (org.opensaml.soap.soap11.Envelope)4 Header (org.opensaml.soap.soap11.Header)3 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 XMLObjectBuilderFactory (org.opensaml.core.xml.XMLObjectBuilderFactory)1 Response (org.opensaml.saml.saml2.ecp.Response)1 SOAPObjectBuilder (org.opensaml.soap.common.SOAPObjectBuilder)1 Fault (org.opensaml.soap.soap11.Fault)1 FaultActor (org.opensaml.soap.soap11.FaultActor)1 FaultCode (org.opensaml.soap.soap11.FaultCode)1 FaultString (org.opensaml.soap.soap11.FaultString)1