Class AuthenticationRequiredHandlerImpl

java.lang.Object
org.craftercms.security.authentication.impl.AuthenticationRequiredHandlerImpl
All Implemented Interfaces:
AuthenticationRequiredHandler

public class AuthenticationRequiredHandlerImpl extends Object implements AuthenticationRequiredHandler
Default implementation of AuthenticationRequiredHandler:
  1. Saves the current request so it can be reused after successful login.
  2. Redirects to the login form URL.
Author:
Alfonso Vásquez
  • Field Details

    • loginFormUrl

      protected String loginFormUrl
    • requestCache

      protected org.springframework.security.web.savedrequest.RequestCache requestCache
  • Constructor Details

    • AuthenticationRequiredHandlerImpl

      public AuthenticationRequiredHandlerImpl()
      Default constructor
  • Method Details

    • setLoginFormUrl

      public void setLoginFormUrl(String loginFormUrl)
      Sets the URL of the login form page.
    • getLoginFormUrl

      protected String getLoginFormUrl()
    • setRequestCache

      public void setRequestCache(org.springframework.security.web.savedrequest.RequestCache requestCache)
      Sets the cache where the current request is saved.
    • handle

      public void handle(org.craftercms.commons.http.RequestContext context, AuthenticationException e) throws SecurityProviderException, IOException
      Saves the current request in the request cache and then redirects to the login form page.
      Specified by:
      handle in interface AuthenticationRequiredHandler
      Parameters:
      context - the request security context
      e - the exception with the reason for requiring authentication
      Throws:
      SecurityProviderException
      IOException
    • saveRequest

      protected void saveRequest(org.craftercms.commons.http.RequestContext context)
    • sendError

      protected void sendError(AuthenticationException e, org.craftercms.commons.http.RequestContext context) throws IOException
      Throws:
      IOException