/** {@inheritDoc} */ protected void processChildElement(XMLObject parentXMLObject, XMLObject childXMLObject) throws UnmarshallingException { Fault fault = (Fault) parentXMLObject; if(childXMLObject instanceof XSQName){ fault.setCode((FaultCode) childXMLObject); }else if(childXMLObject instanceof XSString){ fault.setMessage((FaultString) childXMLObject); }else if(childXMLObject instanceof XSURI){ fault.setActor((FaultActor) childXMLObject); }else if(childXMLObject instanceof Detail){ fault.setDetail((Detail) childXMLObject); } }
private String[] getPrincipalIdFromSamlEcpFault(final Fault fault) { val result = new ToStringBuilder(this, ToStringStyle.NO_CLASS_NAME_STYLE) .append("actor", fault.getActor().getValue()) .append("message", fault.getMessage().getValue()) .toString(); return new String[]{result}; } }
/** {@inheritDoc} */ protected void processChildElement(XMLObject parentXMLObject, XMLObject childXMLObject) throws UnmarshallingException { Envelope envelope = (Envelope) parentXMLObject; if (childXMLObject instanceof Header) { envelope.setHeader((Header) childXMLObject); } else if (childXMLObject instanceof Body) { envelope.setBody((Body) childXMLObject); } else { envelope.getUnknownXMLObjects().add(childXMLObject); } }
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; }
/** * 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; } }
@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); } }
/** * 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; }
/** * Determine the value of the SOAPAction HTTP header to send. * * <p> * The default behavior is to return the value of the SOAP Envelope's WS-Addressing Action header, * if present. * </p> * * @return a SOAPAction HTTP header URI value */ protected String getSOAPAction() { Envelope env = getSOAPEnvelope(); Header header = env.getHeader(); if (header == null) { return null; } List<XMLObject> objList = header.getUnknownXMLObjects(Action.ELEMENT_NAME); if (objList == null || objList.isEmpty()) { return null; } else { return ((Action)objList.get(0)).getValue(); } }
/** {@inheritDoc} */ protected void processChildElement(XMLObject parentXMLObject, XMLObject childXMLObject) throws UnmarshallingException { Body body = (Body) parentXMLObject; body.getUnknownXMLObjects().add(childXMLObject); }
/** * Select the Action URI value to return for the given {@link Fault}. * * @param fault the fault * @return the selected Action URI */ @Nonnull protected String selectActionURIForFault(@Nonnull final Fault fault) { QName faultCode = null; if (fault.getCode() != null && fault.getCode().getValue() != null) { faultCode = fault.getCode().getValue(); } if (faultCode != null && WSAddressingConstants.WS_ADDRESSING_FAULTS.contains(faultCode)) { return WSAddressingConstants.ACTION_URI_FAULT; } else { return WSAddressingConstants.ACTION_URI_SOAP_FAULT; } }
/** * Build and attach {@link FaultString} element. * * @param fault the element to attach to * @param message the message to set */ private void buildFaultString(@Nonnull final Fault fault, @Nonnull @NotEmpty final String message) { final XMLObjectBuilder<FaultString> faultStringBuilder = XMLObjectProviderRegistrySupport.getBuilderFactory().<FaultString>getBuilderOrThrow( FaultString.DEFAULT_ELEMENT_NAME); final FaultString fs = faultStringBuilder.buildObject(FaultString.DEFAULT_ELEMENT_NAME); fs.setValue(message); fault.setMessage(fs); }
/** {@inheritDoc} */ protected void processChildElement(XMLObject parentXMLObject, XMLObject childXMLObject) throws UnmarshallingException { Header header = (Header) parentXMLObject; header.getUnknownXMLObjects().add(childXMLObject); }
/** {@inheritDoc} */ protected void processChildElement(XMLObject parentXMLObject, XMLObject childXMLObject) throws UnmarshallingException { Detail detail = (Detail) parentXMLObject; detail.getUnknownXMLObjects().add(childXMLObject); }
/** {@inheritDoc} */ protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException { Detail detail = (Detail) xmlObject; QName attribQName = QNameSupport.constructQName(attribute.getNamespaceURI(), attribute.getLocalName(), attribute .getPrefix()); if (attribute.isId()) { detail.getUnknownAttributes().registerID(attribQName); } detail.getUnknownAttributes().put(attribQName, attribute.getValue()); }
/** {@inheritDoc} */ protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException { Header header = (Header) xmlObject; QName attribQName = QNameSupport.constructQName(attribute.getNamespaceURI(), attribute.getLocalName(), attribute .getPrefix()); if (attribute.isId()) { header.getUnknownAttributes().registerID(attribQName); } header.getUnknownAttributes().put(attribQName, attribute.getValue()); }
/** {@inheritDoc} */ protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException { Envelope envelope = (Envelope) xmlObject; QName attribQName = QNameSupport.constructQName(attribute.getNamespaceURI(), attribute.getLocalName(), attribute .getPrefix()); if (attribute.isId()) { envelope.getUnknownAttributes().registerID(attribQName); } envelope.getUnknownAttributes().put(attribQName, attribute.getValue()); }
/** {@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()); }
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; }
/** * Determine the value of the SOAPAction HTTP header to send. * * <p> * The default behavior is to return the value of the SOAP Envelope's WS-Addressing Action header, * if present. * </p> * * @return a SOAPAction HTTP header URI value */ protected String getSOAPAction() { final Envelope env = getSOAPEnvelope(); final Header header = env.getHeader(); if (header == null) { return null; } final List<XMLObject> objList = header.getUnknownXMLObjects(Action.ELEMENT_NAME); if (objList == null || objList.isEmpty()) { return null; } else { return ((Action)objList.get(0)).getValue(); } }
/** {@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)); }