Class SAMLBindingSupport
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancheckRelayState(String relayState) Checks that the relay state is 80 bytes or less if it is not null.static intconvertSAML2ArtifactEndpointIndex(byte[] artifactEndpointIndex) Convert a 2-byte artifact endpoint index byte[] as typically used by SAML 2 artifact types to an integer, appropriate for use withIndexedEndpointimpls.static StringgetActualReceiverEndpointURI(MessageContext messageContext, HttpServletRequest request) Extract the transport endpoint URI at which this message was received.static URIgetEndpointURL(MessageContext messageContext) Get the response URL from the relying party endpoint.static StringgetIntendedDestinationEndpointURI(MessageContext messageContext) Extract the message information which indicates to what receiver endpoint URI the SAML message was intended to be delivered.static StringgetRelayState(MessageContext messageContext) Get the SAML protocol relay state from a message context.static booleanisIntendedDestinationEndpointURIRequired(MessageContext messageContext) Determine whether the binding in use requires the presence within the message of information indicating the intended message destination endpoint URI.static booleanisMessageSigned(MessageContext messageContext) Determine whether the SAML message represented by the message context is digitally signed.static booleanisMessageSigned(MessageContext messageContext, boolean presenceSatisfies) Determine whether the SAML message represented by the message context is digitally signed.static booleanisSigningCapableBinding(MessageContext messageContext) Determine whether the SAML binding to be used by the message context supports signatures at the binding layer.static voidsetRelayState(MessageContext messageContext, String relayState) Set the SAML protocol relay state on a message context.static voidsetSAML1ResponseRecipient(SAMLObject outboundMessage, String endpointURL) Sets the destination attribute on the outbound message if it is aResponseAbstractTypemessage.static voidsetSAML2Destination(SAMLObject outboundMessage, String endpointURL) Sets the destination attribute on an outbound message if it is either aRequestAbstractTypeor aStatusResponseTypemessage.
-
Field Details
-
LOG
@Nonnull private static final org.slf4j.Logger LOGLogger.
-
-
Constructor Details
-
SAMLBindingSupport
private SAMLBindingSupport()Constructor.
-
-
Method Details
-
getRelayState
Get the SAML protocol relay state from a message context.- Parameters:
messageContext- the message context on which to operate- Returns:
- the relay state or null
-
setRelayState
public static void setRelayState(@Nonnull MessageContext messageContext, @Nullable String relayState) Set the SAML protocol relay state on a message context.- Parameters:
messageContext- the message context on which to operaterelayState- the relay state to set
-
checkRelayState
Checks that the relay state is 80 bytes or less if it is not null.- Parameters:
relayState- relay state to check- Returns:
- true if the relay state is not empty and is less than 80 bytes
-
getEndpointURL
@Nonnull public static URI getEndpointURL(@Nonnull MessageContext messageContext) throws BindingException Get the response URL from the relying party endpoint. If the SAML message is a response and the relying party endpoint contains a response location then that location is returned otherwise the normal endpoint location is returned.- Parameters:
messageContext- current message context- Returns:
- response URL from the relying party endpoint
- Throws:
BindingException- throw if no relying party endpoint is available
-
setSAML1ResponseRecipient
public static void setSAML1ResponseRecipient(@Nonnull SAMLObject outboundMessage, @Nonnull @NotEmpty String endpointURL) Sets the destination attribute on the outbound message if it is aResponseAbstractTypemessage.- Parameters:
outboundMessage- outbound SAML messageendpointURL- destination endpoint
-
setSAML2Destination
public static void setSAML2Destination(@Nonnull SAMLObject outboundMessage, @Nonnull @NotEmpty String endpointURL) Sets the destination attribute on an outbound message if it is either aRequestAbstractTypeor aStatusResponseTypemessage.- Parameters:
outboundMessage- outbound SAML messageendpointURL- destination endpoint
-
isMessageSigned
Determine whether the SAML message represented by the message context is digitally signed.First the SAML protocol message is examined as to whether an XML signature is present at the DOM level; if yes return true. Finally, the presence of a binding signature is evaluated by looking at
SAMLBindingContext.hasBindingSignature().- Parameters:
messageContext- current message context- Returns:
- true if the message is considered to be digitally signed, false otherwise
-
isMessageSigned
public static boolean isMessageSigned(@Nonnull MessageContext messageContext, boolean presenceSatisfies) Determine whether the SAML message represented by the message context is digitally signed.First the SAML protocol message is examined as to whether an XML signature is present at the DOM level; if yes return true. Next if
presenceSatisfiesis true, thenSignableXMLObject.getSignature()is evaluated for a non-null value; if yes return true. Finally, the presence of a binding signature is evaluated by looking atSAMLBindingContext.hasBindingSignature().- Parameters:
messageContext- current message contextpresenceSatisfies- whether the presence of a non-nullSignaturemember satisfies the evaluation- Returns:
- true if the message is considered to be digitally signed, false otherwise
-
isSigningCapableBinding
Determine whether the SAML binding to be used by the message context supports signatures at the binding layer.The capability of the binding is determined by extracting a
BindingDescriptorfrom aSAMLBindingContext.- Parameters:
messageContext- current message context- Returns:
- true if the message is considered to be digitally signed, false otherwise
-
isIntendedDestinationEndpointURIRequired
public static boolean isIntendedDestinationEndpointURIRequired(@Nonnull MessageContext messageContext) Determine whether the binding in use requires the presence within the message of information indicating the intended message destination endpoint URI.- Parameters:
messageContext- current SAML message context- Returns:
- true if the intended message destination endpoint is required, false if not
-
getIntendedDestinationEndpointURI
@Nullable public static String getIntendedDestinationEndpointURI(@Nonnull MessageContext messageContext) throws MessageException Extract the message information which indicates to what receiver endpoint URI the SAML message was intended to be delivered.- Parameters:
messageContext- the SAML message context being processed- Returns:
- the value of the intended destination endpoint URI, or null if not present or empty
- Throws:
MessageException- thrown if the message is not an instance of SAML message that could be processed by the decoder
-
getActualReceiverEndpointURI
@Nonnull public static String getActualReceiverEndpointURI(@Nonnull MessageContext messageContext, @Nonnull HttpServletRequest request) throws MessageException Extract the transport endpoint URI at which this message was received.- Parameters:
messageContext- current message contextrequest- the HttpServletRequest being evaluated- Returns:
- string representing the transport endpoint URI at which the current message was received
- Throws:
MessageException- thrown if the endpoint can not be looked up from the message context and converted to a string representation
-
convertSAML2ArtifactEndpointIndex
public static int convertSAML2ArtifactEndpointIndex(@Nonnull byte[] artifactEndpointIndex) Convert a 2-byte artifact endpoint index byte[] as typically used by SAML 2 artifact types to an integer, appropriate for use withIndexedEndpointimpls.The max input value supported is 0x7FFF (32767), which is the largest possible unsigned 16 bit value. This should be more than sufficient for typical SAML cases.
- Parameters:
artifactEndpointIndex- the endpoint index byte array, must have length == 2, and big endian byte order.- Returns:
- the convert integer value
-