Class AuthenticationManager

java.lang.Object
com.jalios.jcms.authentication.AuthenticationManager

public final class AuthenticationManager extends Object
This singleton manages all the authentication process in JCMS.

It is responsible to store and invoke all the AuthenticationHandler.
Since:
jcms-5.7.0
Author:
Olivier Jaquemet
  • Method Details

    • getInstance

      public static final AuthenticationManager getInstance()
    • init

      public void init()
      Initialize the AuthenticationManager.
      This method can be called multiple time during the lifetime of the site, for example on properties change.
      Since:
      jcms-5.7.0
    • readOrdersFromProperties

      public void readOrdersFromProperties()
      Read Authentication Handlers order from properties.
    • addAuthenticationHandler

      public void addAuthenticationHandler(AuthenticationHandler authHdlr)
      Add the specified AuthenticationHandler to the handlers collection already managed by the AuthenticationManager.
      Parameters:
      authHdlr - the AuthenticationHandler to be added
      Since:
      jcms-5.7.0
    • removeAuthenticationHandler

      public void removeAuthenticationHandler(AuthenticationHandler authHdlr)
      Remove the specified AuthenticationHandler from the handlers managed by the AuthenticationManager.
      Parameters:
      authHdlr - the AuthenticationHandler to be removed
      Since:
      jcms-5.7.0
    • getAuthenticationHandlerSet

      public SortedSet<AuthenticationHandler> getAuthenticationHandlerSet()
      Retrieve the internal set of AuthenticationHandler managed by the AuthenticationManager.
      Modify only if you are sure of what you do...
      Returns:
      a SortedSet of AuthenticationHandler
    • isAuthenticationRequired

      public boolean isAuthenticationRequired()
      Returns true if the authentication is required in this site.
      Defined by value of property channel.is-authentication-required.
      Returns:
      true if authentication is required for JCMS acces, false otherwise.
      Since:
      jcms-5.7.0
    • isLoginCaseSensitive

      public boolean isLoginCaseSensitive()
      Returns true if login should be treated as case sensitive (myLogin != mylogin). Defined by value of property channel.login-casesensitive.
      Returns:
      true if login is case sensitive
      Since:
      jcms-5.7.0
    • isLoginAccentSensitive

      public boolean isLoginAccentSensitive()
      Returns true if login should be treated as accent sensitive (mylogin != mylogìn). Defined by value of property channel.login-accentsensitive.
      Returns:
      true if login is accent sensitive
      Since:
      jcms-8.0.2
    • isShowingPersistentOption

      public boolean isShowingPersistentOption()
      Defined by value of property auth-mgr.persistent.show-option.
      Returns:
      true if we show the persistent option in the login form, false if we hide it.
      Since:
      jcms-5.7.0
    • getDefaultPersistentValue

      public boolean getDefaultPersistentValue()
      Defined by value of property auth-mgr.persistent.default-value.
      Returns:
      the default persistent value, true is persistent, false is not.
      Since:
      jcms-5.7.0
    • getLoginParameter

      public String getLoginParameter()
      Retrieve the parameter name used for the user's login.
      Defined by value of property auth-mgr.login-param.login.
      Returns:
      the request parameter name used to send/retrieve the login of the user to authenticate.
      Since:
      jcms-5.7.0
    • getPasswordParameter

      public String getPasswordParameter()
      Retrieve the parameter name used for the user's password.
      Defined by value of property auth-mgr.login-param.password.
      Returns:
      the request parameter name used to send/retrieve the password of the user to authenticate.
      Since:
      jcms-5.7.0
    • getPersistentParameter

      public String getPersistentParameter()
      Retrieve the parameter name used for the user's persistent login preference.
      Defined by value of property auth-mgr.login-param.persistent.
      Returns:
      the request parameter name used to send/retrieve whether user to authenticate has requested to have a persistent authentication or not.
      Since:
      jcms-5.7.0
    • getOpLoginParameter

      public String getOpLoginParameter()
      Retrieve the parameter name used to indicate a login action is requested (login form submitted).
      Defined by value of property auth-mgr.login-param.op-login.
      Returns:
      the request parameter name used to send/retrieve whether a login action has been requested (usually when a form is submitted).
      Since:
      jcms-5.7.0
    • login

      public Member login(String login, String password) throws IOException
      Retrieve a member from a login/password pair.

      Current implementation invoke the authentication handler login chain with current servlet request if available otherwise with a fake request, and a fake response.
      Parameters:
      login - the user login
      password - the user's clear text password
      Returns:
      the authenticated Member, (or null on error)
      Throws:
      IOException - if the login operation could not be performed due to IO problem (HTTP headers in response, cookie error, ...)
      Since:
      jcms-5.7.0
    • login

      public LoginResult login(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String userLang) throws IOException
      Authenticate a member for each request.
      Invoke the authentication handler chain and return the authenticated Member.
      Parameters:
      request - the current HttpServletRequest being processed
      response - the HttpServletResponse bound to current request
      userLang - the current language guessed from browser preference or session
      Returns:
      the LoginResult containing the logged Member
      Throws:
      IOException - if the login operation could not be performed due to IO problem (HTTP headers in response, cookie error, ...)
      Since:
      jcms-5.7.0
    • login

      public LoginResult login(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Locale userLocale) throws IOException
      Authenticate a member for each request.
      Invoke the authentication handler chain and return the authenticated Member.
      Parameters:
      request - the current HttpServletRequest being processed
      response - the HttpServletResponse bound to current request
      userLocale - the current Locale guessed from browser preference or session
      Returns:
      the LoginResult containing the logged Member
      Throws:
      IOException - if the login operation could not be performed due to IO problem (HTTP headers in response, cookie error, ...)
      Since:
      jcms-7.1.0
    • logout

      public void logout(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String userLang, Member loggedMember) throws IOException
      Logout the current loggedMember from this session. It may not be called if user simply close its browser. Don't rely on this for critical operation
      Parameters:
      request - the current HttpServletRequest being processed
      response - the HttpServletResponse bound to current request
      userLang - the current language guessed from browser preference or session
      loggedMember - the member currently logged in
      Throws:
      IOException - if the logout operation could not be performed due to IO problem (HTTP headers in response, cookie error, ...)
      Since:
      jcms-5.7.0
    • logout

      public void logout(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Locale userLocale, Member loggedMember) throws IOException
      Logout the current loggedMember from this session. It may not be called if user simply close its browser. Don't rely on this for critical operation
      Parameters:
      request - the current HttpServletRequest being processed
      response - the HttpServletResponse bound to current request
      userLocale - the current Locale guessed from browser preference or session
      loggedMember - the member currently logged in
      Throws:
      IOException - if the logout operation could not be performed due to IO problem (HTTP headers in response, cookie error, ...)
      Since:
      jcms-7.1.0