Java Code Examples for org.opensaml.ws.soap.soap11.Envelope#getHeader()
The following examples show how to use
org.opensaml.ws.soap.soap11.Envelope#getHeader() .
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: SOAP11Decoder.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Check that all headers which carry the <code>soap11:mustUnderstand</code> attribute * and which are targeted to this SOAP node via the <code>soap11:actor</code> were understood by the * decoder. * * @param messageContext the message context being processed * * @throws MessageDecodingException thrown if a SOAP header requires understanding by * this node but was not understood */ private void checkUnderstoodSOAPHeaders(MessageContext messageContext) throws MessageDecodingException { Envelope envelope = (Envelope) messageContext.getInboundMessage(); Header soapHeader = envelope.getHeader(); if (soapHeader == null) { log.debug("SOAP Envelope contained no Header"); return; } List<XMLObject> headers = soapHeader.getUnknownXMLObjects(); if (headers == null || headers.isEmpty()) { log.debug("SOAP Envelope header list was either null or empty"); return; } for (XMLObject header : headers) { //TODO } }
Example 2
Source File: SOAPHelper.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Get a header block from the SOAP 1.1 envelope. * * @param envelope the SOAP 1.1 envelope to process * @param headerName the name of the header block to return * @param targetNodes the explicitly specified SOAP node actors for which the header is desired * @param isFinalDestination true specifies that headers targeted for message final destination should be returned, * false specifies they should not be returned * @return the list of matching header blocks */ public static List<XMLObject> getSOAP11HeaderBlock(Envelope envelope, QName headerName, Set<String> targetNodes, boolean isFinalDestination) { Header envelopeHeader = envelope.getHeader(); if (envelopeHeader == null) { return Collections.emptyList(); } ArrayList<XMLObject> headers = new ArrayList<XMLObject>(); for (XMLObject header : envelopeHeader.getUnknownXMLObjects(headerName)) { if (isSOAP11HeaderTargetedToNode(header, targetNodes, isFinalDestination)) { headers.add(header); } } return headers; }
Example 3
Source File: HTTPSOAP11Encoder.java From lams with GNU General Public License v2.0 | 5 votes |
/** * 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> * * @param messageContext the current message context being processed * @return a SOAPAction HTTP header URI value */ protected String getSOAPAction(MessageContext messageContext) { Envelope env = (Envelope) messageContext.getOutboundMessage(); 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(); } }
Example 4
Source File: SOAPHelper.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Add a header to the SOAP 1.1 Envelope. * * @param envelope the SOAP 1.1 envelope to process * @param headerBlock the header to add */ public static void addSOAP11HeaderBlock(Envelope envelope, XMLObject headerBlock) { Header envelopeHeader = envelope.getHeader(); if (envelopeHeader == null) { envelopeHeader = (Header) Configuration.getBuilderFactory().getBuilder(Header.DEFAULT_ELEMENT_NAME) .buildObject(Header.DEFAULT_ELEMENT_NAME); envelope.setHeader(envelopeHeader); } envelopeHeader.getUnknownXMLObjects().add(headerBlock); }
Example 5
Source File: HTTPSOAP11Decoder.java From lams with GNU General Public License v2.0 | 4 votes |
/** {@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 6
Source File: HTTPSOAP11Decoder.java From lams with GNU General Public License v2.0 | 4 votes |
/** {@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); }