/** {@inheritDoc} */ protected void processChildElement(XMLObject parentXMLObject, XMLObject childXMLObject) throws UnmarshallingException { Body body = (Body) parentXMLObject; body.getUnknownXMLObjects().add(childXMLObject); }
/** {@inheritDoc} */ protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException { Body body = (Body) xmlObject; QName attribQName = QNameSupport.constructQName(attribute.getNamespaceURI(), attribute.getLocalName(), attribute .getPrefix()); if (attribute.isId()) { body.getUnknownAttributes().registerID(attribQName); } body.getUnknownAttributes().put(attribQName, attribute.getValue()); }
/** * Return the Fault element from the SOAP message, if any. * * @param soapMessage the SOAP 1.1. Envelope being processed * @return the first Fault element found, or null */ protected Fault getFault(Envelope soapMessage) { if (soapMessage.getBody() != null) { List<XMLObject> faults = soapMessage.getBody().getUnknownXMLObjects(Fault.DEFAULT_ELEMENT_NAME); if (!faults.isEmpty()) { return (Fault) faults.get(0); } else { return null; } } else { return null; } }
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException { Body body = (Body) xmlObject; Attr attribute; for (Entry<QName, String> entry : body.getUnknownAttributes().entrySet()) { attribute = AttributeSupport.constructAttribute(domElement.getOwnerDocument(), entry.getKey()); attribute.setValue(entry.getValue()); domElement.setAttributeNodeNS(attribute); if (XMLObjectProviderRegistrySupport.isIDAttribute(entry.getKey()) || body.getUnknownAttributes().isIDAttribute(entry.getKey())) { attribute.getOwnerElement().setIdAttributeNode(attribute, true); } } }
/** {@inheritDoc} */ protected void doInvoke(MessageContext messageContext) throws MessageHandlerException { Envelope env = (Envelope) messageContext.getSubcontext(SOAP11Context.class).getEnvelope(); List<XMLObject> bodyChildren = env.getBody().getUnknownXMLObjects(); if (bodyChildren == null || bodyChildren.isEmpty()) { throw new MessageHandlerException("SOAP Envelope Body contained no children"); } else if (bodyChildren.size() > 1) { log.warn("SOAP Envelope Body contained more than one child. Returning the first as the message"); } messageContext.setMessage(env.getBody().getUnknownXMLObjects().get(0)); }
private String[] getPrincipalIdFromSamlEcpResponse(final Envelope envelope) { val objects = envelope.getBody().getUnknownXMLObjects(); if (objects.isEmpty()) { return ArrayUtils.EMPTY_STRING_ARRAY; } val object = objects.get(0); if (object instanceof Response) { return getPrincipalIdFromSamlResponse((Response) object); } if (object instanceof Fault) { return getPrincipalIdFromSamlEcpFault((Fault) object); } return ArrayUtils.EMPTY_STRING_ARRAY; }
/** * Builds the SOAP message to be encoded. * * @param payload body of the SOAP message */ protected void buildAndStoreSOAPMessage(@Nonnull final XMLObject payload) { Envelope envelope = getSOAPEnvelope(); if (envelope == null) { envelope = envBuilder.buildObject(); storeSOAPEnvelope(envelope); } Body body = envelope.getBody(); if (body == null) { body = bodyBuilder.buildObject(); envelope.setBody(body); } if (!body.getUnknownXMLObjects().isEmpty()) { log.warn("Existing SOAP Envelope Body already contained children"); } body.getUnknownXMLObjects().add(payload); }
/** * Builds the SOAP message to be encoded. * * @param payload body of the SOAP message */ protected void buildAndStoreSOAPMessage(@Nonnull final XMLObject payload) { Envelope envelope = getSOAPEnvelope(); if (envelope == null) { envelope = envBuilder.buildObject(); storeSOAPEnvelope(envelope); } Body body = envelope.getBody(); if (body == null) { body = bodyBuilder.buildObject(); envelope.setBody(body); } if (!body.getUnknownXMLObjects().isEmpty()) { log.warn("Existing SOAP Envelope Body already contained children"); } body.getUnknownXMLObjects().add(payload); }
/** * Builds the SOAP message to be encoded. * * @param payload body of the SOAP message */ protected void buildAndStoreSOAPMessage(@Nonnull final XMLObject payload) { Envelope envelope = getSOAPEnvelope(); if (envelope == null) { envelope = envBuilder.buildObject(); storeSOAPEnvelope(envelope); } Body body = envelope.getBody(); if (body == null) { body = bodyBuilder.buildObject(); envelope.setBody(body); } if (!body.getUnknownXMLObjects().isEmpty()) { log.warn("Existing SOAP Envelope Body already contained children"); } body.getUnknownXMLObjects().add(payload); }
@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); }
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; }
final List<XMLObject> soapBodyChildren = soapMessage.getBody().getUnknownXMLObjects(); if (soapBodyChildren.size() < 1 || soapBodyChildren.size() > 1) { log.error("Unexpected number of children in the SOAP body, " + soapBodyChildren.size()
final List<XMLObject> soapBodyChildren = soapMessage.getBody().getUnknownXMLObjects(); if (soapBodyChildren.size() < 1 || soapBodyChildren.size() > 1) { log.error("Unexpected number of children in the SOAP body, " + soapBodyChildren.size()
/** * Get the HTTP response status code to return. * * @return the HTTP response status code */ protected int getHTTPResponseStatusCode() { Integer contextStatus = getMessageContext().getSubcontext(SOAP11Context.class, true).getHTTPResponseStatus(); if (contextStatus != null) { return contextStatus; } Envelope envelope = getSOAPEnvelope(); if (envelope != null && envelope.getBody() != null) { Body body = envelope.getBody(); List<XMLObject> faults = body.getUnknownXMLObjects(Fault.DEFAULT_ELEMENT_NAME); if (!faults.isEmpty()) { return HttpServletResponse.SC_INTERNAL_SERVER_ERROR; } } return HttpServletResponse.SC_OK; }
/** * Get the HTTP response status code to return. * * @return the HTTP response status code */ protected int getHTTPResponseStatusCode() { final Integer contextStatus = getMessageContext().getSubcontext(SOAP11Context.class, true).getHTTPResponseStatus(); if (contextStatus != null) { return contextStatus; } final Envelope envelope = getSOAPEnvelope(); if (envelope != null && envelope.getBody() != null) { final Body body = envelope.getBody(); final List<XMLObject> faults = body.getUnknownXMLObjects(Fault.DEFAULT_ELEMENT_NAME); if (!faults.isEmpty()) { return HttpServletResponse.SC_INTERNAL_SERVER_ERROR; } } return HttpServletResponse.SC_OK; }
@Override public Envelope build(final RequestAbstractType authnRequest, final HttpServletRequest request, final HttpServletResponse response, final Object casAssertion, final SamlRegisteredService service, final SamlRegisteredServiceServiceProviderMetadataFacade adaptor, final String binding, final MessageContext messageContext) throws SamlException { val header = newSoapObject(Header.class); val body = newSoapObject(Body.class); val query = (AttributeQuery) authnRequest; val saml2Response = buildSaml2Response(casAssertion, query, service, adaptor, request, SAMLConstants.SAML2_POST_BINDING_URI, messageContext); body.getUnknownXMLObjects().add(saml2Response); val envelope = newSoapObject(Envelope.class); envelope.setHeader(header); envelope.setBody(body); SamlUtils.logSamlObject(this.configBean, envelope); return encodeFinalResponse(request, response, service, adaptor, envelope, binding, authnRequest, casAssertion); } }
final List<XMLObject> faults = response.getBody().getUnknownXMLObjects(Fault.DEFAULT_ELEMENT_NAME); if (faults.size() < 1) { throw new SOAPClientException("HTTP status code was 500 but SOAP response did not contain a Fault");
val body = bodyBuilder.buildObject(); envelope.setBody(body); body.getUnknownXMLObjects().add(samlLogoutRequest);
val saml2Response = buildSaml2Response(casAssertion, authnRequest, service, adaptor, request, binding, messageContext); body.getUnknownXMLObjects().add(saml2Response); val envelope = newSoapObject(Envelope.class); envelope.setHeader(header);
fault.setMessage(faultString); body.getUnknownXMLObjects().add(fault);