Java Code Examples for org.opensaml.common.binding.SAMLMessageContext#setRelayState()
The following examples show how to use
org.opensaml.common.binding.SAMLMessageContext#setRelayState() .
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: HTTPArtifactDecoder.java From lams with GNU General Public License v2.0 | 6 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(); String relayState = DatatypeHelper.safeTrim(inTransport.getParameterValue("RelayState")); samlMsgCtx.setRelayState(relayState); processArtifact(samlMsgCtx); populateMessageContext(samlMsgCtx); }
Example 2
Source File: HTTPArtifactDecoder.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Decodes the TARGET parameter and adds it to the message context. * * @param samlMsgCtx current message context * * @throws MessageDecodingException thrown if there is a problem decoding the TARGET parameter. */ protected void decodeTarget(SAMLMessageContext samlMsgCtx) throws MessageDecodingException { HTTPInTransport inTransport = (HTTPInTransport) samlMsgCtx.getInboundMessageTransport(); String target = DatatypeHelper.safeTrim(inTransport.getParameterValue("TARGET")); if (target == null) { log.error("URL TARGET parameter was missing or did not contain a value."); throw new MessageDecodingException("URL TARGET parameter was missing or did not contain a value."); } samlMsgCtx.setRelayState(target); }
Example 3
Source File: HTTPPostDecoder.java From lams with GNU General Public License v2.0 | 5 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"); } String relayState = inTransport.getParameterValue("TARGET"); samlMsgCtx.setRelayState(relayState); log.debug("Decoded SAML relay state (TARGET parameter) of: {}", relayState); String base64Message = inTransport.getParameterValue("SAMLResponse"); byte[] decodedBytes = Base64.decode(base64Message); if (decodedBytes == null) { log.error("Unable to Base64 decode SAML message"); throw new MessageDecodingException("Unable to Base64 decode SAML message"); } SAMLObject inboundMessage = (SAMLObject) unmarshallMessage(new ByteArrayInputStream(decodedBytes)); samlMsgCtx.setInboundMessage(inboundMessage); samlMsgCtx.setInboundSAMLMessage(inboundMessage); log.debug("Decoded SAML message"); populateMessageContext(samlMsgCtx); }
Example 4
Source File: HTTPRedirectDeflateDecoder.java From lams with GNU General Public License v2.0 | 5 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(); String relayState = inTransport.getParameterValue("RelayState"); samlMsgCtx.setRelayState(relayState); log.debug("Decoded RelayState: {}", relayState); InputStream samlMessageIns; if (!DatatypeHelper.isEmpty(inTransport.getParameterValue("SAMLRequest"))) { samlMessageIns = decodeMessage(inTransport.getParameterValue("SAMLRequest")); } else if (!DatatypeHelper.isEmpty(inTransport.getParameterValue("SAMLResponse"))) { samlMessageIns = decodeMessage(inTransport.getParameterValue("SAMLResponse")); } else { throw new MessageDecodingException( "No SAMLRequest or SAMLResponse query path parameter, invalid SAML 2 HTTP Redirect message"); } SAMLObject samlMessage = (SAMLObject) unmarshallMessage(samlMessageIns); samlMsgCtx.setInboundSAMLMessage(samlMessage); samlMsgCtx.setInboundMessage(samlMessage); log.debug("Decoded SAML message"); populateMessageContext(samlMsgCtx); }
Example 5
Source File: HTTPPostDecoder.java From lams with GNU General Public License v2.0 | 5 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"); } String relayState = inTransport.getParameterValue("RelayState"); samlMsgCtx.setRelayState(relayState); log.debug("Decoded SAML relay state of: {}", relayState); InputStream base64DecodedMessage = getBase64DecodedMessage(inTransport); SAMLObject inboundMessage = (SAMLObject) unmarshallMessage(base64DecodedMessage); samlMsgCtx.setInboundMessage(inboundMessage); samlMsgCtx.setInboundSAMLMessage(inboundMessage); log.debug("Decoded SAML message"); populateMessageContext(samlMsgCtx); }