Example usage for javax.xml.soap SOAPHeaderElement getChildElements

List of usage examples for javax.xml.soap SOAPHeaderElement getChildElements

Introduction

In this page you can find the example usage for javax.xml.soap SOAPHeaderElement getChildElements.

Prototype

public Iterator<Node> getChildElements();

Source Link

Document

Returns an Iterator over all the immediate child Node s of this element.

Usage

From source file:be.fedict.eid.idp.protocol.ws_federation.sts.WSSecuritySoapHandler.java

private void handleInboundMessage(SOAPMessageContext context) throws SOAPException {
    SOAPMessage soapMessage = context.getMessage();
    SOAPPart soapPart = soapMessage.getSOAPPart();
    SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
    SOAPHeader soapHeader = soapEnvelope.getHeader();
    if (null == soapHeader) {
        return;//from   www .  j a  v  a 2 s . c  o m
    }
    Iterator<SOAPHeaderElement> headerIterator = soapHeader.examineAllHeaderElements();
    while (headerIterator.hasNext()) {
        SOAPHeaderElement soapHeaderElement = headerIterator.next();
        if (false == WSTrustConstants.WS_SECURITY_NAMESPACE.equals(soapHeaderElement.getNamespaceURI())) {
            continue;
        }
        if (false == "Security".equals(soapHeaderElement.getLocalName())) {
            continue;
        }
        Iterator<SOAPElement> securityElementIterator = soapHeaderElement.getChildElements();
        while (securityElementIterator.hasNext()) {
            SOAPElement securityElement = securityElementIterator.next();
            if (false == WSTrustConstants.SAML2_NAMESPACE.equals(securityElement.getNamespaceURI())) {
                continue;
            }
            if (false == "Assertion".equals(securityElement.getLocalName())) {
                continue;
            }
            LOG.debug("putting SAML token on JAX-WS context");
            context.put(SAML_TOKEN_CONTEXT_ATTRIBUTE, securityElement);
            context.setScope(SAML_TOKEN_CONTEXT_ATTRIBUTE, Scope.APPLICATION);
        }
    }
}