Class FederatedAuthenticationSuccessHandler

java.lang.Object
com.irurueta.authserver.authorization.api.web.social.FederatedAuthenticationSuccessHandler
All Implemented Interfaces:
org.springframework.security.web.authentication.AuthenticationSuccessHandler

public class FederatedAuthenticationSuccessHandler extends Object implements org.springframework.security.web.authentication.AuthenticationSuccessHandler
Success handler of the sign-in with an external provider. The framework's authentication carries no factor authority, so this handler grants the federated factor through FactorGrantor (the strong one when the provider is trusted, see FederatedFactorSelector), makes the result the current authentication, saves the security context again (the filter saved the first one before calling the handler), and then lets the usual handler resume the saved request, for example the /oauth2/authorize that sent the user to the login page.

When the answer of the provider completed a link (PendingIdentityLinks.linkedBy(jakarta.servlet.http.HttpServletRequest)), nobody signs in: the authentication the session had before is put back and saved, no factor is granted, and the browser returns to the identities page with the status linked.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final org.springframework.security.web.authentication.AuthenticationSuccessHandler
    The handler that resumes the saved request.
    private final FactorGrantor
    Adds the factor authority.
    Chooses the factor.
    private final org.springframework.security.core.context.SecurityContextHolderStrategy
    Holder of the security context of the thread.
    (package private) static final String
    Query of the identities page after a link.
    private final PendingIdentityLinks
    The link markers of the explicit link flow.
    private final org.springframework.security.web.context.SecurityContextRepository
    Saves the security context, the same repository the sign-in filter uses.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    onAuthenticationSuccess(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.core.Authentication authentication)
    Grants the factor and continues.
    private void
    save(org.springframework.security.core.Authentication authentication, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
    Makes an authentication the current one and saves it in the session.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.security.web.authentication.AuthenticationSuccessHandler

    onAuthenticationSuccess
  • Field Details

    • LINKED_STATUS

      static final String LINKED_STATUS
      Query of the identities page after a link.
      See Also:
    • factorGrantor

      private final FactorGrantor factorGrantor
      Adds the factor authority.
    • factorSelector

      private final FederatedFactorSelector factorSelector
      Chooses the factor.
    • securityContextRepository

      private final org.springframework.security.web.context.SecurityContextRepository securityContextRepository
      Saves the security context, the same repository the sign-in filter uses.
    • delegate

      private final org.springframework.security.web.authentication.AuthenticationSuccessHandler delegate
      The handler that resumes the saved request.
    • holderStrategy

      private final org.springframework.security.core.context.SecurityContextHolderStrategy holderStrategy
      Holder of the security context of the thread.
  • Constructor Details

    • FederatedAuthenticationSuccessHandler

      public FederatedAuthenticationSuccessHandler()
  • Method Details

    • onAuthenticationSuccess

      public void onAuthenticationSuccess(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.core.Authentication authentication) throws IOException, jakarta.servlet.ServletException
      Grants the factor and continues.
      Specified by:
      onAuthenticationSuccess in interface org.springframework.security.web.authentication.AuthenticationSuccessHandler
      Parameters:
      request - the request.
      response - the response.
      authentication - the authentication of the sign-in.
      Throws:
      IOException - if the redirect fails.
      jakarta.servlet.ServletException - if the redirect fails.
    • save

      private void save(org.springframework.security.core.Authentication authentication, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
      Makes an authentication the current one and saves it in the session.
      Parameters:
      authentication - the authentication.
      request - the request.
      response - the response.