Class SAMLBindingSupport
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
checkRelayState
(String relayState) Checks that the relay state is 80 bytes or less if it is not null.static int
convertSAML2ArtifactEndpointIndex
(byte[] artifactEndpointIndex) Convert a 2-byte artifact endpoint index byte[] as typically used by SAML 2 artifact types to an integer, appropriate for use withIndexedEndpoint
impls.static String
getActualReceiverEndpointURI
(MessageContext messageContext, javax.servlet.http.HttpServletRequest request) Extract the transport endpoint URI at which this message was received.static URI
getEndpointURL
(MessageContext messageContext) Get the response URL from the relying party endpoint.static String
getIntendedDestinationEndpointURI
(MessageContext messageContext) Extract the message information which indicates to what receiver endpoint URI the SAML message was intended to be delivered.static String
getRelayState
(MessageContext messageContext) Get the SAML protocol relay state from a message context.static boolean
isIntendedDestinationEndpointURIRequired
(MessageContext messageContext) Determine whether the binding in use requires the presence within the message of information indicating the intended message destination endpoint URI.static boolean
isMessageSigned
(MessageContext messageContext) Determine whether the SAML message represented by the message context is digitally signed.static boolean
isMessageSigned
(MessageContext messageContext, boolean presenceSatisfies) Determine whether the SAML message represented by the message context is digitally signed.static boolean
isSigningCapableBinding
(MessageContext messageContext) Determine whether the SAML binding to be used by the message context supports signatures at the binding layer.static void
setRelayState
(MessageContext messageContext, String relayState) Set the SAML protocol relay state on a message context.static void
setSAML1ResponseRecipient
(SAMLObject outboundMessage, String endpointURL) Sets the destination attribute on the outbound message if it is aResponseAbstractType
message.static void
setSAML2Destination
(SAMLObject outboundMessage, String endpointURL) Sets the destination attribute on an outbound message if it is either aRequestAbstractType
or aStatusResponseType
message.
-
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 aResponseAbstractType
message.- 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 aRequestAbstractType
or aStatusResponseType
message.- 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
presenceSatisfies
is 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-nullSignature
member 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
BindingDescriptor
from 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 javax.servlet.http.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
@Nonnull 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 withIndexedEndpoint
impls.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
-