/** {@inheritDoc} */ public boolean providesMessageConfidentiality(MessageContext messageContext) throws MessageEncodingException { if (messageContext.getOutboundMessageTransport().isConfidential()) { return true; } return false; }
/** {@inheritDoc} */ public boolean providesMessageIntegrity(MessageContext messageContext) throws MessageEncodingException { if (messageContext.getOutboundMessageTransport().isIntegrityProtected()) { return true; } return false; }
/** {@inheritDoc} */ public boolean providesMessageConfidentiality(MessageContext messageContext) throws MessageEncodingException { if (messageContext.getOutboundMessageTransport().isConfidential()) { return true; } return false; }
/** {@inheritDoc} */ public boolean providesMessageConfidentiality(MessageContext messageContext) throws MessageEncodingException { if (notConfidential) { return false; } return messageContext.getOutboundMessageTransport().isConfidential(); }
/** {@inheritDoc} */ public boolean providesMessageIntegrity(MessageContext messageContext) throws MessageEncodingException { if (messageContext.getOutboundMessageTransport().isIntegrityProtected()) { return true; } return false; }
/** {@inheritDoc} */ public boolean providesMessageIntegrity(MessageContext messageContext) throws MessageEncodingException { return messageContext.getOutboundMessageTransport().isIntegrityProtected(); }
/** {@inheritDoc} */ public boolean providesMessageConfidentiality(MessageContext messageContext) throws MessageEncodingException { return messageContext.getOutboundMessageTransport().isConfidential(); }
/** {@inheritDoc} */ public boolean providesMessageIntegrity(MessageContext messageContext) throws MessageEncodingException { return messageContext.getOutboundMessageTransport().isIntegrityProtected(); }
public boolean providesMessageIntegrity(MessageContext messageContext) throws MessageEncodingException { return messageContext.getOutboundMessageTransport().isIntegrityProtected(); }
public boolean providesMessageConfidentiality(MessageContext messageContext) throws MessageEncodingException { return messageContext.getOutboundMessageTransport().isConfidential(); }
/** {@inheritDoc} */ public void encode(MessageContext messageContext) throws MessageEncodingException { log.debug("Beginning encode message to outbound transport of type: {}", messageContext .getOutboundMessageTransport().getClass().getName()); doEncode(messageContext); logEncodedMessage(messageContext); log.debug("Successfully encoded message."); }
/** {@inheritDoc} */ protected void doEncode(MessageContext messageContext) throws MessageEncodingException { if (!(messageContext.getOutboundMessageTransport() instanceof HTTPOutTransport)) { log.error("Invalid outbound message transport type, this encoder only support HTTPOutTransport"); throw new MessageEncodingException( "Invalid outbound message transport type, this encoder only support HTTPOutTransport"); } super.doEncode(messageContext); }
/** * Validates that the message context is a {@link SAMLMessageContext} and that its outbound transport is HTTP. * * @param messageContext current message context * * @throws MessageEncodingException thrown if the message context conditions are not met */ protected void validateMessageContent(MessageContext messageContext) throws MessageEncodingException { if (!(messageContext instanceof SAMLMessageContext)) { log.error("Invalid message context type, this encoder only support SAMLMessageContext"); throw new MessageEncodingException( "Invalid message context type, this encoder only support SAMLMessageContext"); } if (!(messageContext.getOutboundMessageTransport() instanceof HTTPOutTransport)) { log.error("Invalid outbound message transport type, this encoder only support HTTPOutTransport"); throw new MessageEncodingException( "Invalid outbound message transport type, this encoder only support HTTPOutTransport"); } } }
/** {@inheritDoc} */ protected void doEncode(MessageContext messageContext) throws MessageEncodingException { if (!(messageContext instanceof SAMLMessageContext)) { log.error("Invalid message context type, this encoder only support SAMLMessageContext"); throw new MessageEncodingException( "Invalid message context type, this encoder only support SAMLMessageContext"); } if (!(messageContext.getOutboundMessageTransport() instanceof HTTPOutTransport)) { log.error("Invalid outbound message transport type, this encoder only support HTTPOutTransport"); throw new MessageEncodingException( "Invalid outbound message transport type, this encoder only support HTTPOutTransport"); } prepareMessageContext(messageContext); processOutboundHandlerChain(messageContext); encodeToTransport(messageContext); }
/** {@inheritDoc} */ protected void encodeToTransport(MessageContext messageContext) throws MessageEncodingException { Element envelopeElem = marshallMessage(messageContext.getOutboundMessage()); preprocessTransport(messageContext); try { OutTransport outTransport = messageContext.getOutboundMessageTransport(); Writer out = new OutputStreamWriter(outTransport.getOutgoingStream(), "UTF-8"); XMLHelper.writeNode(envelopeElem, out); out.flush(); } catch (UnsupportedEncodingException e) { log.error("JVM does not support required UTF-8 encoding"); throw new MessageEncodingException("JVM does not support required UTF-8 encoding"); } catch (IOException e) { log.error("Unable to write message content to outbound stream", e); throw new MessageEncodingException("Unable to write message content to outbound stream", e); } }
/** * Encode the message context to the transport. * * @param messageContext the message context to process * @throws MessageEncodingException thrown if there is a problem encoding the message context * to the transport */ protected void encodeToTransport(MessageContext messageContext) throws MessageEncodingException { Element envelopeElem = marshallMessage(messageContext.getOutboundMessage()); preprocessTransport(messageContext); try { OutTransport outTransport = messageContext.getOutboundMessageTransport(); Writer out = new OutputStreamWriter(outTransport.getOutgoingStream(), "UTF-8"); XMLHelper.writeNode(envelopeElem, out); out.flush(); } catch (UnsupportedEncodingException e) { log.error("JVM does not support required UTF-8 encoding"); throw new MessageEncodingException("JVM does not support required UTF-8 encoding"); } catch (IOException e) { log.error("Unable to write message content to outbound stream", e); throw new MessageEncodingException("Unable to write message content to outbound stream", e); } }
/** {@inheritDoc} */ protected void doEncode(MessageContext messageContext) throws MessageEncodingException { if (!(messageContext instanceof SAMLMessageContext)) { log.error("Invalid message context type, this encoder only support SAMLMessageContext"); throw new MessageEncodingException( "Invalid message context type, this encoder only support SAMLMessageContext"); } if (!(messageContext.getOutboundMessageTransport() instanceof HTTPOutTransport)) { log.error("Invalid outbound message transport type, this encoder only support HTTPOutTransport"); throw new MessageEncodingException( "Invalid outbound message transport type, this encoder only support HTTPOutTransport"); } SAMLMessageContext artifactContext = (SAMLMessageContext) messageContext; HTTPOutTransport outTransport = (HTTPOutTransport) artifactContext.getOutboundMessageTransport(); outTransport.setCharacterEncoding("UTF-8"); if (postEncoding) { postEncode(artifactContext, outTransport); } else { getEncode(artifactContext, outTransport); } }
/** * <p> * This implementation performs the following actions on the context's {@link HTTPOutTransport}: * <ol> * <li>Adds the HTTP header: "Cache-control: no-cache, no-store"</li> * <li>Adds the HTTP header: "Pragma: no-cache"</li> * <li>Sets the character encoding to: "UTF-8"</li> * <li>Sets the content type to: "text/xml"</li> * <li>Sets the SOAPAction HTTP header</li> * </ol> * </p> * * @param messageContext the current message context being processed * * @throws MessageEncodingException thrown if there is a problem preprocessing the transport */ protected void preprocessTransport(MessageContext messageContext) throws MessageEncodingException { HTTPOutTransport outTransport = (HTTPOutTransport) messageContext.getOutboundMessageTransport(); HTTPTransportUtils.addNoCacheHeaders(outTransport); HTTPTransportUtils.setUTF8Encoding(outTransport); HTTPTransportUtils.setContentType(outTransport, "text/xml"); outTransport.setHeader("SOAPAction", "http://www.oasis-open.org/committees/security"); }
/** {@inheritDoc} */ protected void doEncode(MessageContext messageContext) throws MessageEncodingException { if (!(messageContext instanceof SAMLMessageContext)) { log.error("Invalid message context type, this encoder only support SAMLMessageContext"); throw new MessageEncodingException( "Invalid message context type, this encoder only support SAMLMessageContext"); } if (!(messageContext.getOutboundMessageTransport() instanceof HTTPOutTransport)) { log.error("Invalid outbound message transport type, this encoder only support HTTPOutTransport"); throw new MessageEncodingException( "Invalid outbound message transport type, this encoder only support HTTPOutTransport"); } SAMLMessageContext samlMsgCtx = (SAMLMessageContext) messageContext; String endpointURL = getEndpointURL(samlMsgCtx).buildURL(); setResponseDestination(samlMsgCtx.getOutboundSAMLMessage(), endpointURL); removeSignature(samlMsgCtx); String encodedMessage = deflateAndBase64Encode(samlMsgCtx.getOutboundSAMLMessage()); String redirectURL = buildRedirectURL(samlMsgCtx, endpointURL, encodedMessage); HTTPOutTransport out = (HTTPOutTransport) messageContext.getOutboundMessageTransport(); HTTPTransportUtils.addNoCacheHeaders(out); HTTPTransportUtils.setUTF8Encoding(out); out.sendRedirect(redirectURL); }
/** {@inheritDoc} */ protected void doEncode(MessageContext messageContext) throws MessageEncodingException { if (!(messageContext instanceof SAMLMessageContext)) { log.error("Invalid message context type, this encoder only support SAMLMessageContext"); throw new MessageEncodingException( "Invalid message context type, this encoder only support SAMLMessageContext"); } if (!(messageContext.getOutboundMessageTransport() instanceof HTTPOutTransport)) { log.error("Invalid outbound message transport type, this encoder only support HTTPOutTransport"); throw new MessageEncodingException( "Invalid outbound message transport type, this encoder only support HTTPOutTransport"); } SAMLMessageContext samlMsgCtx = (SAMLMessageContext) messageContext; SAMLObject outboundMessage = samlMsgCtx.getOutboundSAMLMessage(); if (outboundMessage == null) { throw new MessageEncodingException("No outbound SAML message contained in message context"); } String endpointURL = getEndpointURL(samlMsgCtx).buildURL(); if (samlMsgCtx.getOutboundSAMLMessage() instanceof StatusResponseType) { ((StatusResponseType) samlMsgCtx.getOutboundSAMLMessage()).setDestination(endpointURL); } signMessage(samlMsgCtx); samlMsgCtx.setOutboundMessage(outboundMessage); postEncode(samlMsgCtx, endpointURL); }