Class SamlServiceProviderAuthenticator

java.lang.Object
org.apache.catalina.util.LifecycleBase
org.apache.catalina.util.LifecycleMBeanBase
org.apache.catalina.valves.ValveBase
org.apache.catalina.authenticator.AuthenticatorBase
org.apache.catalina.authenticator.FormAuthenticator
org.gatein.sso.saml.plugin.valve.BaseFormAuthenticator
org.gatein.sso.saml.plugin.valve.AbstractSPFormAuthenticator
org.gatein.sso.saml.plugin.valve.ServiceProviderAuthenticator
org.exoplatform.addons.saml.extensions.SamlServiceProviderAuthenticator
All Implemented Interfaces:
jakarta.security.auth.message.config.RegistrationListener, MBeanRegistration, org.apache.catalina.Authenticator, org.apache.catalina.Contained, org.apache.catalina.JmxEnabled, org.apache.catalina.Lifecycle, org.apache.catalina.Valve

public class SamlServiceProviderAuthenticator extends org.gatein.sso.saml.plugin.valve.ServiceProviderAuthenticator
The ServiceProviderAuthenticator of the SAML workflow, with a SamlPrincipal for the user it authenticates.

Optional: with it, HybridSAML2LogoutFilter still starts the SAML logout of a user whose portal session expired while they kept a session in another web application and was recreated by Tomcat's single sign-on valve. The single sign-on valve of Tomcat must replay the principal it is given: with requireReauthentication="true" on that valve, Tomcat authenticates the user again instead, and the marker is not kept. The JBoss branch of the parent valve does not call this method either. Configure it with gatein.sso.valve.class=org.exoplatform.addons.saml.extensions.SamlServiceProviderAuthenticator

It also brings the user back to the page they asked for when the IDP and the SP are not on the same site. The stock valve keeps that page in the session, and a SameSite=Lax session cookie is not sent with the cross-site POST of the IDP: the session is a new one and the user lands on the home page. This valve sends an id of that page as the RelayState, that the IDP gives back in the POST, and puts the page in the new session (see SamlRelayStates). The signed query string of the HTTP-Redirect binding already holds its RelayState: it is left as it is.

  • Nested Class Summary

    Nested classes/interfaces inherited from class org.apache.catalina.authenticator.AuthenticatorBase

    org.apache.catalina.authenticator.AuthenticatorBase.AllowCorsPreflight, org.apache.catalina.authenticator.AuthenticatorBase.SsoReauthenticationMode

    Nested classes/interfaces inherited from interface org.apache.catalina.Lifecycle

    org.apache.catalina.Lifecycle.SingleUse
  • Field Summary

    Fields inherited from class org.gatein.sso.saml.plugin.valve.AbstractSPFormAuthenticator

    jbossEnv

    Fields inherited from class org.gatein.sso.saml.plugin.valve.BaseFormAuthenticator

    auditHelper, canonicalizationMethod, chain, chainConfigOptions, chainLock, configFile, configProvider, enableAudit, identityURL, idpAddress, idpCertificate, issuerID, keyManager, logger, picketLinkConfiguration, samlHandlerChainClass, saveRestoreRequest, serviceURL, spConfiguration, timer, timerInterval

    Fields inherited from class org.apache.catalina.authenticator.FormAuthenticator

    authenticationSessionTimeout, characterEncoding, landingPage

    Fields inherited from class org.apache.catalina.authenticator.AuthenticatorBase

    alwaysUseSession, AUTH_HEADER_NAME, cache, changeSessionIdOnAuthentication, context, disableProxyCaching, jaspicCallbackHandlerClass, REALM_NAME, securePagesWithPragma, secureRandomAlgorithm, secureRandomClass, secureRandomProvider, sendAuthInfoResponseHeaders, sessionIdGenerator, sm, sso

    Fields inherited from class org.apache.catalina.valves.ValveBase

    asyncSupported, container, containerLog, next

    Fields inherited from interface org.apache.catalina.Lifecycle

    AFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected Principal
    getGenericPrincipal(org.apache.catalina.connector.Request request, String username, List<String> roles)
     
    protected boolean
    matchRequest(org.apache.catalina.connector.Request request)
    The first thing the parent valve asks of a request, before it reads the SAML answer (if (saveRestoreRequest && matchRequest(request))), whatever the method Tomcat calls to authenticate: the page asked for is restored here.
    protected void
    sendRequestToIDP(String destination, Document samlDocument, String relayState, org.apache.catalina.connector.Request request, org.apache.catalina.connector.Response response, boolean willSendRequest, String destinationQueryStringWithSignature)
     

    Methods inherited from class org.gatein.sso.saml.plugin.valve.ServiceProviderAuthenticator

    getContextPath, startInternal

    Methods inherited from class org.gatein.sso.saml.plugin.valve.AbstractSPFormAuthenticator

    authenticate, doAuthenticate, getBinding, getContext, initKeyProvider, isHttpPostBinding, isPOSTBindingResponse, restoreRequest, sendHttpPostBindingRequest, sendHttpRedirectRequest, startPicketLink

    Methods inherited from class org.gatein.sso.saml.plugin.valve.BaseFormAuthenticator

    doSupportSignature, getConfigFile, getConfiguration, getIdentityURL, getIdpCertificate, getIDPSSODescriptor, handleMetadata, handleMetadata, initializeHandlerChain, localAuthentication, populateChainConfig, processConfiguration, processIDPMetadataFile, sendToLogoutPage, setAuditHelper, setConfigFile, setConfigProvider, setConfigProvider, setIdpAddress, setIssuerID, setLogOutPage, setSamlHandlerChainClass, setSaveRestoreRequest, setServiceURL, setTimerInterval, testStart, validate

    Methods inherited from class org.apache.catalina.authenticator.FormAuthenticator

    forwardToErrorPage, forwardToLoginPage, getAuthenticationSessionTimeout, getAuthMethod, getCharacterEncoding, getLandingPage, isContinuationRequired, matchRequest, register, savedRequestURL, saveRequest, setAuthenticationSessionTimeout, setCharacterEncoding, setLandingPage

    Methods inherited from class org.apache.catalina.authenticator.AuthenticatorBase

    allowCorsPreflightBypass, associate, changeSessionID, checkForCachedAuthentication, doLogin, getAllowCorsPreflight, getAlwaysUseSession, getCache, getChangeSessionIdOnAuthentication, getContainer, getDisableProxyCaching, getJaspicCallbackHandlerClass, getRealmName, getSecurePagesWithPragma, getSecureRandomAlgorithm, getSecureRandomClass, getSecureRandomProvider, getSsoReauthenticationMode, invoke, isPreemptiveAuthPossible, isSendAuthInfoResponseHeaders, login, logout, notify, reauthenticateFromSSO, register, setAllowCorsPreflight, setAlwaysUseSession, setCache, setChangeSessionIdOnAuthentication, setContainer, setDisableProxyCaching, setJaspicCallbackHandlerClass, setSecurePagesWithPragma, setSecureRandomAlgorithm, setSecureRandomClass, setSecureRandomProvider, setSendAuthInfoResponseHeaders, setSsoReauthenticationMode, stopInternal

    Methods inherited from class org.apache.catalina.valves.ValveBase

    backgroundProcess, getDomainInternal, getNext, getObjectNameKeyProperties, initInternal, isAsyncSupported, setAsyncSupported, setNext, toString

    Methods inherited from class org.apache.catalina.util.LifecycleMBeanBase

    destroyInternal, getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister, unregister

    Methods inherited from class org.apache.catalina.util.LifecycleBase

    addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stop

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SamlServiceProviderAuthenticator

      public SamlServiceProviderAuthenticator()
  • Method Details

    • matchRequest

      protected boolean matchRequest(org.apache.catalina.connector.Request request)
      The first thing the parent valve asks of a request, before it reads the SAML answer (if (saveRestoreRequest && matchRequest(request))), whatever the method Tomcat calls to authenticate: the page asked for is restored here.
      Overrides:
      matchRequest in class org.apache.catalina.authenticator.FormAuthenticator
    • sendRequestToIDP

      protected void sendRequestToIDP(String destination, Document samlDocument, String relayState, org.apache.catalina.connector.Request request, org.apache.catalina.connector.Response response, boolean willSendRequest, String destinationQueryStringWithSignature) throws org.picketlink.common.exceptions.ProcessingException, org.picketlink.common.exceptions.ConfigurationException, IOException
      Overrides:
      sendRequestToIDP in class org.gatein.sso.saml.plugin.valve.AbstractSPFormAuthenticator
      Throws:
      org.picketlink.common.exceptions.ProcessingException
      org.picketlink.common.exceptions.ConfigurationException
      IOException
    • getGenericPrincipal

      protected Principal getGenericPrincipal(org.apache.catalina.connector.Request request, String username, List<String> roles)
      Overrides:
      getGenericPrincipal in class org.gatein.sso.saml.plugin.valve.AbstractSPFormAuthenticator