Java Code Examples for org.opensaml.xml.XMLObject#getElementQName()

The following examples show how to use org.opensaml.xml.XMLObject#getElementQName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseMessageEncoder.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Helper method that marshalls the given message.
 * 
 * @param message message the marshall and serialize
 * 
 * @return marshalled message
 * 
 * @throws MessageEncodingException thrown if the give message can not be marshalled into its DOM representation
 */
protected Element marshallMessage(XMLObject message) throws MessageEncodingException {
    log.debug("Marshalling message");

    try {
        Marshaller marshaller = Configuration.getMarshallerFactory().getMarshaller(message);
        if (marshaller == null) {
            log.error("Unable to marshall message, no marshaller registered for message object: "
                    + message.getElementQName());
            throw new MessageEncodingException(
                    "Unable to marshall message, no marshaller registered for message object: "
                    + message.getElementQName());
        }
        Element messageElem = marshaller.marshall(message);
        if (log.isTraceEnabled()) {
            log.trace("Marshalled message into DOM:\n{}", XMLHelper.nodeToString(messageElem));
        }
        return messageElem;
    } catch (MarshallingException e) {
        log.error("Encountered error marshalling message to its DOM representation", e);
        throw new MessageEncodingException("Encountered error marshalling message into its DOM representation", e);
    }
}
 
Example 2
Source File: HTTPSOAP11Decoder.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Checks that, if any SOAP headers, require understand that they are in the understood header list.
 * 
 * @param headers SOAP headers to check
 * 
 * @throws MessageDecodingException thrown if a SOAP header requires understanding but is not understood by the
 *             decoder
 */
protected void checkUnderstoodSOAPHeaders(List<XMLObject> headers) throws MessageDecodingException {
    if (headers == null || headers.isEmpty()) {
        return;
    }

    AttributeExtensibleXMLObject attribExtensObject;
    for (XMLObject header : headers) {
        if (header instanceof AttributeExtensibleXMLObject) {
            attribExtensObject = (AttributeExtensibleXMLObject) header;
            if (DatatypeHelper.safeEquals("1", attribExtensObject.getUnknownAttributes().get(soapMustUnderstand))) {
                if (!understoodHeaders.contains(header.getElementQName())) {
                    throw new MessageDecodingException("SOAP decoder encountered a header, "
                            + header.getElementQName()
                            + ", that requires understanding however this decoder does not understand that header");
                }
            }
        }
    }
}
 
Example 3
Source File: HTTPSOAP11Decoder.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Checks that, if any SOAP headers, require understand that they are in the understood header list.
 * 
 * @param headers SOAP headers to check
 * 
 * @throws MessageDecodingException thrown if a SOAP header requires understanding but is not understood by the
 *             decoder
 */
protected void checkUnderstoodSOAPHeaders(List<XMLObject> headers) throws MessageDecodingException {
    if (headers == null || headers.isEmpty()) {
        return;
    }

    AttributeExtensibleXMLObject attribExtensObject;
    for (XMLObject header : headers) {
        if (header instanceof AttributeExtensibleXMLObject) {
            attribExtensObject = (AttributeExtensibleXMLObject) header;
            if (DatatypeHelper.safeEquals("1", attribExtensObject.getUnknownAttributes().get(soapMustUnderstand))) {
                if (!understoodHeaders.contains(header.getElementQName())) {
                    throw new MessageDecodingException("SOAP decoder encountered a  header, "
                            + header.getElementQName()
                            + ", that requires undestanding however this decoder does not understand that header");
                }
            }
        }
    }
}
 
Example 4
Source File: AbstractXMLObjectMarshaller.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Prepares the given DOM caching XMLObject for adoption into another document. If the XMLObject has a parent then
 * all visible namespaces used by the given XMLObject and its descendants are declared within that subtree and the
 * parent's DOM is invalidated.
 * 
 * @param domCachingObject the XMLObject to prepare for adoption
 * 
 * @throws MarshallingException thrown if a namespace within the XMLObject's DOM subtree can not be resolved.
 */
private void prepareForAdoption(XMLObject domCachingObject) throws MarshallingException {
    if (domCachingObject.getParent() != null) {
        log.trace("Rooting all visible namespaces of XMLObject {} before adding it to new parent Element",
                domCachingObject.getElementQName());
        try {
            XMLHelper.rootNamespaces(domCachingObject.getDOM());
        } catch (XMLParserException e) {
            String errorMsg =
                    "Unable to root namespaces of cached DOM element, " + domCachingObject.getElementQName();
            log.error(errorMsg, e);
            throw new MarshallingException(errorMsg, e);
        }

        log.trace("Release DOM of XMLObject parent");
        domCachingObject.releaseParentDOM(true);
    }
}
 
Example 5
Source File: AbstractXMLObjectMarshaller.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Checks to make sure the given XMLObject's schema type or element QName matches the target parameters given at
 * marshaller construction time.
 * 
 * @param xmlObject the XMLObject to marshall
 * 
 * @throws MarshallingException thrown if the given object is not or the required type
 */
protected void checkXMLObjectIsTarget(XMLObject xmlObject) throws MarshallingException {
    if (targetQName == null) {
        log.trace("Targeted QName checking is not available for this marshaller, XMLObject {} was not verified",
                xmlObject.getElementQName());
        return;
    }

    log.trace("Checking that {} meets target criteria", xmlObject.getElementQName());
    QName type = xmlObject.getSchemaType();
    if (type != null && type.equals(targetQName)) {
        log.trace("{} schema type matches target", xmlObject.getElementQName());
        return;
    } else {
        QName elementQName = xmlObject.getElementQName();
        if (elementQName.equals(targetQName)) {
            log.trace("{} element QName matches target", xmlObject.getElementQName());
            return;
        }
    }

    String errorMsg =
            "This marshaller only operations on " + targetQName + " elements not " + xmlObject.getElementQName();
    log.error(errorMsg);
    throw new MarshallingException(errorMsg);
}
 
Example 6
Source File: Decrypter.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Ensure that the XMLObject is marshalled.
 * 
 * @param xmlObject the object to check and marshall
 * @throws DecryptionException thrown if there is an error when marshalling the XMLObject
 */
protected void checkAndMarshall(XMLObject xmlObject) throws DecryptionException {
    Element targetElement = xmlObject.getDOM();
    if (targetElement == null) {
        Marshaller marshaller = Configuration.getMarshallerFactory().getMarshaller(xmlObject);
        if (marshaller == null) {
            marshaller =
                    Configuration.getMarshallerFactory().getMarshaller(Configuration.getDefaultProviderQName());
            if (marshaller == null) {
                String errorMsg = "No marshaller available for " + xmlObject.getElementQName();
                log.error(errorMsg);
                throw new DecryptionException(errorMsg);
            }
        }
        try {
            targetElement = marshaller.marshall(xmlObject);
        } catch (MarshallingException e) {
            log.error("Error marshalling target XMLObject", e);
            throw new DecryptionException("Error marshalling target XMLObject", e);
        }
    }
}
 
Example 7
Source File: AttributeUnmarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
        throws UnmarshallingException {

    Attribute attribute = (Attribute) parentSAMLObject;

    QName childQName = childSAMLObject.getElementQName();
    if (childQName.getLocalPart().equals("AttributeValue")
            && childQName.getNamespaceURI().equals(SAMLConstants.SAML20_NS)) {
        attribute.getAttributeValues().add(childSAMLObject);
    } else {
        super.processChildElement(parentSAMLObject, childSAMLObject);
    }
}
 
Example 8
Source File: AttributeUnmarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
        throws UnmarshallingException {

    Attribute attribute = (Attribute) parentSAMLObject;

    QName childQName = childSAMLObject.getElementQName();
    if (childQName.getLocalPart().equals("AttributeValue")
            && childQName.getNamespaceURI().equals(SAMLConstants.SAML1_NS)) {
        attribute.getAttributeValues().add(childSAMLObject);
    } else {
        super.processChildElement(parentSAMLObject, childSAMLObject);
    }
}
 
Example 9
Source File: AbstractXMLObjectMarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Marshalls the child elements of the given XMLObject.
 * 
 * @param xmlObject the XMLObject whose children will be marshalled
 * @param domElement the DOM element that will recieved the marshalled children
 * 
 * @throws MarshallingException thrown if there is a problem marshalling a child element
 */
protected void marshallChildElements(XMLObject xmlObject, Element domElement) throws MarshallingException {
    log.trace("Marshalling child elements for XMLObject {}", xmlObject.getElementQName());

    List<XMLObject> childXMLObjects = xmlObject.getOrderedChildren();
    if (childXMLObjects != null && childXMLObjects.size() > 0) {
        for (XMLObject childXMLObject : childXMLObjects) {
            if (childXMLObject == null) {
                continue;
            }

            log.trace("Getting marshaller for child XMLObject {}", childXMLObject.getElementQName());
            Marshaller marshaller = marshallerFactory.getMarshaller(childXMLObject);

            if (marshaller == null) {
                marshaller = marshallerFactory.getMarshaller(Configuration.getDefaultProviderQName());

                if (marshaller == null) {
                    String errorMsg =
                            "No marshaller available for " + childXMLObject.getElementQName() + ", child of "
                                    + xmlObject.getElementQName();
                    log.error(errorMsg);
                    throw new MarshallingException(errorMsg);
                } else {
                    log.trace("No marshaller was registered for {}, child of {}. Using default marshaller",
                            childXMLObject.getElementQName(), xmlObject.getElementQName());
                }
            }

            log.trace("Marshalling {} and adding it to DOM", childXMLObject.getElementQName());
            marshaller.marshall(childXMLObject, domElement);
        }
    } else {
        log.trace("No child elements to marshall for XMLObject {}", xmlObject.getElementQName());
    }
}
 
Example 10
Source File: AbstractXMLObjectUnmarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Unmarshalls given Element's children. For each child an unmarshaller is retrieved using
 * {@link UnmarshallerFactory#getUnmarshaller(Element)}. The unmarshaller is then used to unmarshall the child
 * element and the resultant XMLObject is passed to {@link #processChildElement(XMLObject, XMLObject)} for further
 * processing.
 * 
 * @param xmlObject the parent object of the unmarshalled children
 * @param childElement the child element to be unmarshalled
 * 
 * @throws UnmarshallingException thrown if an error occurs unmarshalling the chilren elements
 */
protected void unmarshallChildElement(XMLObject xmlObject, Element childElement) throws UnmarshallingException {
    log.trace("Unmarshalling child elements of XMLObject {}", xmlObject.getElementQName());

    Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(childElement);

    if (unmarshaller == null) {
        unmarshaller = unmarshallerFactory.getUnmarshaller(Configuration.getDefaultProviderQName());
        if (unmarshaller == null) {
            String errorMsg = "No unmarshaller available for " + XMLHelper.getNodeQName(childElement)
                    + ", child of " + xmlObject.getElementQName();
            log.error(errorMsg);
            throw new UnmarshallingException(errorMsg);
        } else {
            if (log.isTraceEnabled()) {
                log.trace("No unmarshaller was registered for {}, child of {}. Using default unmarshaller.",
                        XMLHelper.getNodeQName(childElement), xmlObject.getElementQName());
            }
        }
    }

    if (log.isTraceEnabled()) {
        log.trace("Unmarshalling child element {}with unmarshaller {}", XMLHelper.getNodeQName(childElement),
                unmarshaller.getClass().getName());
    }
    processChildElement(xmlObject, unmarshaller.unmarshall(childElement));
}
 
Example 11
Source File: EncryptionPropertySchemaValidator.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validate that all children are from another namespace.
 * 
 * @param xmlObject the object to validate
 * @throws ValidationException thrown if the object is invalid
 */
protected void validateChildrenNamespaces(EncryptionProperty xmlObject) throws ValidationException {
    // Validate that any children are from another namespace.
    for (XMLObject child : xmlObject.getUnknownXMLObjects()) {
        QName childName = child.getElementQName();
        if (XMLConstants.XMLENC_NS.equals(childName.getNamespaceURI())) {
            throw new ValidationException("EncryptionProperty contains an illegal child extension element: " + childName);
        }
    }
}
 
Example 12
Source File: ReferenceTypeSchemaValidator.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validate that all children are from another namespace.
 * 
 * @param xmlObject the object to validate
 * @throws ValidationException thrown if the object is invalid
 */
protected void validateChildrenNamespaces(ReferenceType xmlObject) throws ValidationException {
    // Validate that any children are from another namespace.
    for (XMLObject child : xmlObject.getUnknownXMLObjects()) {
        QName childName = child.getElementQName();
        if (XMLConstants.XMLENC_NS.equals(childName.getNamespaceURI())) {
            throw new ValidationException("ReferenceType contains an illegal child extension element: " + childName);
        }
    }
}
 
Example 13
Source File: X509DataSchemaValidator.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validate that all children are either ones defined within the XML Signature schema,
 * or are from another namespace.
 * 
 * @param xmlObject the object to validate
 * @throws ValidationException thrown if the object is invalid
 */
protected void validateChildrenNamespaces(X509Data xmlObject) throws ValidationException {
    // Validate that any children are either the ones from the dsig schema,
    // or are from another namespace.
    for (XMLObject child : xmlObject.getXMLObjects()) {
        QName childName = child.getElementQName();
        if (! getValidDSChildNames().contains(childName) 
                && XMLConstants.XMLSIG_NS.equals(childName.getNamespaceURI())) {
            throw new ValidationException("X509Data contains an illegal child extension element: " + childName);
        }
    }
}
 
Example 14
Source File: KeyValueSchemaValidator.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validate that the extension child, if present, is from another namespace.
 * 
 * @param xmlObject the object to validate
 * @throws ValidationException thrown if the object is invalid
 */
protected void validateExtensionChildNamespace(KeyValue xmlObject) throws ValidationException {
    // Validate that the unknown child is not from the dsig namespace
    // or are from another namespace.
    XMLObject unknownChild = xmlObject.getUnknownXMLObject();
    if (unknownChild == null) {
        return;
    }
    QName childName = unknownChild.getElementQName();
    if (XMLConstants.XMLSIG_NS.equals(childName.getNamespaceURI())) {
        throw new ValidationException("KeyValue contains an illegal child extension element: " + childName);
    }
}
 
Example 15
Source File: SPKIDataSchemaValidator.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validate that all children are either ones defined within the XML Signature schema,
 * or are from another namespace.
 * 
 * @param xmlObject the object to validate
 * @throws ValidationException thrown if the object is invalid
 */
protected void validateChildrenNamespaces(SPKIData xmlObject) throws ValidationException {
    // Validate that any children are either the ones from the dsig schema,
    // or are from another namespace.
    for (XMLObject child : xmlObject.getXMLObjects()) {
        QName childName = child.getElementQName();
        if (! SPKISexp.DEFAULT_ELEMENT_NAME.equals(childName) 
                && XMLConstants.XMLSIG_NS.equals(childName.getNamespaceURI())) {
            throw new ValidationException("PGPData contains an illegal child extension element: " + childName);
        }
    }
}
 
Example 16
Source File: KeyInfoTypeSchemaValidator.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validate that all children are either ones defined within the XML Signature schema,
 * or are from another namespace.
 * 
 * @param xmlObject the object to validate
 * @throws ValidationException thrown if the object is invalid
 */
protected void validateChildrenNamespaces(KeyInfoType xmlObject) throws ValidationException {
    // Validate that any children are either the ones from the dsig schema,
    // or are from another namespace.
    for (XMLObject child : xmlObject.getXMLObjects()) {
        QName childName = child.getElementQName();
        if (! getValidDSChildNames().contains(childName) 
                && XMLConstants.XMLSIG_NS.equals(childName.getNamespaceURI())) {
            throw new ValidationException("KeyInfoType contains an illegal child extension element: " + childName);
        }
    }
}
 
Example 17
Source File: PGPDataSchemaValidator.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Validate that all children are either ones defined within the XML Signature schema,
 * or are from another namespace.
 * 
 * @param xmlObject the object to validate
 * @throws ValidationException thrown if the object is invalid
 */
protected void validateChildrenNamespaces(PGPData xmlObject) throws ValidationException {
    // Validate that any unknown children are from another namespace.
    for (XMLObject child : xmlObject.getUnknownXMLObjects()) {
        QName childName = child.getElementQName();
        if (! getValidDSChildNames().contains(childName) 
                && XMLConstants.XMLSIG_NS.equals(childName.getNamespaceURI())) {
            throw new ValidationException("PGPData contains an illegal child extension element: " + childName);
        }
    }
}
 
Example 18
Source File: AbstractXMLObjectMarshaller.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates the XSI type, schemaLocation, and noNamespaceSchemaLocation attributes for an XMLObject.
 * 
 * @param xmlObject the XMLObject
 * @param domElement the DOM element the namespaces will be added to
 * 
 * @throws MarshallingException thrown if the schema type information is invalid
 */
protected void marshallSchemaInstanceAttributes(XMLObject xmlObject, Element domElement)
        throws MarshallingException {

    if (!DatatypeHelper.isEmpty(xmlObject.getSchemaLocation())) {
        log.trace("Setting xsi:schemaLocation for XMLObject {} to {}", xmlObject.getElementQName(),
                xmlObject.getSchemaLocation());
        domElement.setAttributeNS(XMLConstants.XSI_NS, XMLConstants.XSI_PREFIX + ":schemaLocation",
                xmlObject.getSchemaLocation());
    }

    if (!DatatypeHelper.isEmpty(xmlObject.getNoNamespaceSchemaLocation())) {
        log.trace("Setting xsi:noNamespaceSchemaLocation for XMLObject {} to {}", xmlObject.getElementQName(),
                xmlObject.getNoNamespaceSchemaLocation());
        domElement.setAttributeNS(XMLConstants.XSI_NS, XMLConstants.XSI_PREFIX + ":noNamespaceSchemaLocation",
                xmlObject.getNoNamespaceSchemaLocation());
    }

    if (xmlObject.isNilXSBoolean() != null && xmlObject.isNil()) {
        log.trace("Setting xsi:nil for XMLObject {} to true", xmlObject.getElementQName());
        domElement.setAttributeNS(XMLConstants.XSI_NS, XMLConstants.XSI_PREFIX + ":nil", xmlObject.isNilXSBoolean()
                .toString());
    }

    QName type = xmlObject.getSchemaType();
    if (type == null) {
        return;
    }

    log.trace("Setting xsi:type attribute with for XMLObject {}", xmlObject.getElementQName());
    String typeLocalName = DatatypeHelper.safeTrimOrNullString(type.getLocalPart());
    String typePrefix = DatatypeHelper.safeTrimOrNullString(type.getPrefix());

    if (typeLocalName == null) {
        throw new MarshallingException("The type QName on XMLObject " + xmlObject.getElementQName()
                + " may not have a null local name");
    }

    if (type.getNamespaceURI() == null) {
        throw new MarshallingException("The type URI QName on XMLObject " + xmlObject.getElementQName()
                + " may not have a null namespace URI");
    }

    String attributeValue;
    if (typePrefix == null) {
        attributeValue = typeLocalName;
    } else {
        attributeValue = typePrefix + ":" + typeLocalName;
    }

    domElement.setAttributeNS(XMLConstants.XSI_NS, XMLConstants.XSI_PREFIX + ":type", attributeValue);
}
 
Example 19
Source File: HTTPSOAP11Decoder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
protected void doDecode(MessageContext messageContext) throws MessageDecodingException {
    if (!(messageContext instanceof SAMLMessageContext)) {
        log.error("Invalid message context type, this decoder only support SAMLMessageContext");
        throw new MessageDecodingException(
                "Invalid message context type, this decoder only support SAMLMessageContext");
    }

    if (!(messageContext.getInboundMessageTransport() instanceof HTTPInTransport)) {
        log.error("Invalid inbound message transport type, this decoder only support HTTPInTransport");
        throw new MessageDecodingException(
                "Invalid inbound message transport type, this decoder only support HTTPInTransport");
    }

    SAMLMessageContext samlMsgCtx = (SAMLMessageContext) messageContext;

    HTTPInTransport inTransport = (HTTPInTransport) samlMsgCtx.getInboundMessageTransport();
    if (!inTransport.getHTTPMethod().equalsIgnoreCase("POST")) {
        throw new MessageDecodingException("This message decoder only supports the HTTP POST method");
    }

    log.debug("Unmarshalling SOAP message");
    Envelope soapMessage = (Envelope) unmarshallMessage(inTransport.getIncomingStream());
    samlMsgCtx.setInboundMessage(soapMessage);

    Header messageHeader = soapMessage.getHeader();
    if (messageHeader != null) {
        checkUnderstoodSOAPHeaders(soapMessage.getHeader().getUnknownXMLObjects());
    }

    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()
                + ".  Unable to extract SAML message");
        throw new MessageDecodingException(
                "Unexpected number of children in the SOAP body, unable to extract SAML message");
    }

    XMLObject incommingMessage = soapBodyChildren.get(0);
    if (!(incommingMessage instanceof SAMLObject)) {
        log.error("Unexpected SOAP body content.  Expected a SAML request but recieved {}", incommingMessage
                .getElementQName());
        throw new MessageDecodingException("Unexpected SOAP body content.  Expected a SAML request but recieved "
                + incommingMessage.getElementQName());
    }

    SAMLObject samlMessage = (SAMLObject) incommingMessage;
    log.debug("Decoded SOAP messaged which included SAML message of type {}", samlMessage.getElementQName());
    samlMsgCtx.setInboundSAMLMessage(samlMessage);

    populateMessageContext(samlMsgCtx);
}
 
Example 20
Source File: HTTPSOAP11Decoder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
protected void doDecode(MessageContext messageContext) throws MessageDecodingException {
    if (!(messageContext instanceof SAMLMessageContext)) {
        log.error("Invalid message context type, this decoder only support SAMLMessageContext");
        throw new MessageDecodingException(
                "Invalid message context type, this decoder only support SAMLMessageContext");
    }

    if (!(messageContext.getInboundMessageTransport() instanceof HTTPInTransport)) {
        log.error("Invalid inbound message transport type, this decoder only support HTTPInTransport");
        throw new MessageDecodingException(
                "Invalid inbound message transport type, this decoder only support HTTPInTransport");
    }

    SAMLMessageContext samlMsgCtx = (SAMLMessageContext) messageContext;

    HTTPInTransport inTransport = (HTTPInTransport) samlMsgCtx.getInboundMessageTransport();
    if (!inTransport.getHTTPMethod().equalsIgnoreCase("POST")) {
        throw new MessageDecodingException("This message decoder only supports the HTTP POST method");
    }

    log.debug("Unmarshalling SOAP message");
    Envelope soapMessage = (Envelope) unmarshallMessage(inTransport.getIncomingStream());
    samlMsgCtx.setInboundMessage(soapMessage);

    Header messageHeader = soapMessage.getHeader();
    if (messageHeader != null) {
        checkUnderstoodSOAPHeaders(soapMessage.getHeader().getUnknownXMLObjects());
    }

    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()
                + ".  Unable to extract SAML message");
        throw new MessageDecodingException(
                "Unexpected number of children in the SOAP body, unable to extract SAML message");
    }

    XMLObject incommingMessage = soapBodyChildren.get(0);
    if (!(incommingMessage instanceof SAMLObject)) {
        log.error("Unexpected SOAP body content.  Expected a SAML request but recieved {}", incommingMessage
                .getElementQName());
        throw new MessageDecodingException("Unexpected SOAP body content.  Expected a SAML request but recieved "
                + incommingMessage.getElementQName());
    }

    SAMLObject samlMessage = (SAMLObject) incommingMessage;
    log.debug("Decoded SOAP messaged which included SAML message of type {}", samlMessage.getElementQName());
    samlMsgCtx.setInboundSAMLMessage(samlMessage);

    populateMessageContext(samlMsgCtx);
}