Class WSSecuritySAML20AssertionTokenSecurityHandler

java.lang.Object
net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
org.opensaml.messaging.handler.AbstractMessageHandler
org.opensaml.saml.saml2.wssecurity.messaging.impl.WSSecuritySAML20AssertionTokenSecurityHandler
All Implemented Interfaces:
Component, DestructableComponent, InitializableComponent, MessageHandler

public class WSSecuritySAML20AssertionTokenSecurityHandler extends AbstractMessageHandler
A security handler which resolves SAML 2.0 Assertion tokens from a SOAP envelope's wsse:Security header, validates them, and makes them available via via the WSSecurityContext.
  • Field Details

  • Constructor Details

    • WSSecuritySAML20AssertionTokenSecurityHandler

      public WSSecuritySAML20AssertionTokenSecurityHandler()
      Constructor.
  • Method Details

    • getValidationContextBuilder

      Get the function that builds a ValidationContext instance based on a SAML20AssertionTokenValidationInput instance.

      Defaults to an instance of DefaultSAML20AssertionValidationContextBuilder.

      Returns:
      the builder function
    • setValidationContextBuilder

      public void setValidationContextBuilder(@Nonnull Function<SAML20AssertionTokenValidationInput,ValidationContext> builder)
      Set the function that builds a ValidationContext instance based on a SAML20AssertionTokenValidationInput instance.

      Defaults to an instance of DefaultSAML20AssertionValidationContextBuilder.

      Parameters:
      builder - the builder function
    • getHttpServletRequest

      @Nullable public javax.servlet.http.HttpServletRequest getHttpServletRequest()
      Get the current HTTP request if available.
      Returns:
      current HTTP request
    • getHttpServletRequestSupplier

      @Nullable public NonnullSupplier<javax.servlet.http.HttpServletRequest> getHttpServletRequestSupplier()
      Get the supplier for HTTP request if available.
      Returns:
      current HTTP request
    • setHttpServletRequestSupplier

      public void setHttpServletRequestSupplier(@Nullable NonnullSupplier<javax.servlet.http.HttpServletRequest> requestSupplier)
      Set the current HTTP request Supplier.
      Parameters:
      requestSupplier - Supplier for the current HTTP request
    • isInvalidFatal

      public boolean isInvalidFatal()
      Get flag which indicates whether a failure of Assertion validation should be considered a fatal processing error.

      Defaults to: true.

      Returns:
      Returns the invalidFatal.
    • setInvalidFatal

      public void setInvalidFatal(boolean flag)
      Set flag which indicates whether a failure of Assertion validation should be considered a fatal processing error.

      Defaults to: true.

      Parameters:
      flag - The invalidFatal to set.
    • getAssertionValidator

      @Nullable public SAML20AssertionValidator getAssertionValidator()
      Get the locally-configured Assertion validator.
      Returns:
      the local Assertion validator, or null
    • setAssertionValidator

      public void setAssertionValidator(@Nullable SAML20AssertionValidator validator)
      Set the locally-configured Assertion validator.
      Parameters:
      validator - the local Assertion validator, may be null
    • getAssertionValidatorLookup

      @Nullable public Function<Pair<MessageContext,Assertion>,SAML20AssertionValidator> getAssertionValidatorLookup()
      Get the Assertion validator lookup function.
      Returns:
      the Assertion validator lookup function, or null
    • setAssertionValidatorLookup

      public void setAssertionValidatorLookup(@Nullable Function<Pair<MessageContext,Assertion>,SAML20AssertionValidator> function)
      Set the Assertion validator lookup function.
      Parameters:
      function - the Assertion validator lookup function, may be null
    • doInitialize

      protected void doInitialize() throws ComponentInitializationException
      Overrides:
      doInitialize in class AbstractInitializableComponent
      Throws:
      ComponentInitializationException
    • doInvoke

      protected void doInvoke(@Nonnull MessageContext messageContext) throws MessageHandlerException
      Performs the handler logic.
      Specified by:
      doInvoke in class AbstractMessageHandler
      Parameters:
      messageContext - the message context on which to invoke the handler
      Throws:
      MessageHandlerException - if there is an error invoking the handler on the message context
    • processResult

      protected void processResult(@Nonnull ValidationContext validationContext, @Nonnull ValidationResult validationResult, @Nonnull SAML20AssertionToken token, @Nonnull MessageContext messageContext) throws MessageHandlerException
      Process the result of the token validation.
      Parameters:
      validationContext - the Assertion validation context
      validationResult - the Assertion validation result
      token - the token being produced
      messageContext - the current message context
      Throws:
      MessageHandlerException - if the Assertion was invalid or indeterminate and idInvalidFatal is true
    • resolveValidator

      @Nullable protected SAML20AssertionValidator resolveValidator(@Nonnull MessageContext messageContext, @Nonnull Assertion assertion)
      Resolve the Assertion token validator to use with the specified Assertion.
      Parameters:
      messageContext - the current message context
      assertion - the assertion being evaluated
      Returns:
      the token validator
    • buildValidationContext

      @Nonnull protected ValidationContext buildValidationContext(@Nonnull MessageContext messageContext, @Nonnull Assertion assertion) throws MessageHandlerException
      Build the Assertion ValidationContext.
      Parameters:
      messageContext - the current message context
      assertion - the assertion which is to be validated
      Returns:
      the new Assertion validation context to use
      Throws:
      MessageHandlerException - if no validation context instance could be built
    • resolveAssertions

      @Nonnull protected List<Assertion> resolveAssertions(@Nonnull MessageContext messageContext)
      Resolve the SAML 2.0 Assertions token from the SOAP envelope.
      Parameters:
      messageContext - the current message context
      Returns:
      the list of resolved Assertions, or an empty list