parameters: (self, credentials)
return_statement: return authentication_result
docstring: See IAuthenticationPlugin.
  
      o We expect the credentials to be those returned by
        ILoginPasswordExtractionPlugin.
docstring_summary: See IAuthenticationPlugin.
docstring_tokens: See IAuthenticationPlugin .
function: def authenticateCredentials(self, credentials):
      """ See IAuthenticationPlugin.
  
      o We expect the credentials to be those returned by
        ILoginPasswordExtractionPlugin.
      """
      login = credentials.get('login')
      ignore_password = False
      if not login:
        # fallback to support plugins using external tools to extract login
        # those are not using login/password pair, they just extract login
        # from remote system (eg. SSL certificates)
        login = credentials.get('external_login')
        ignore_password = True
      # Forbidden the usage of the super user.
      if login == ERP5Security.SUPER_USER:
        return None
  
      @UnrestrictedMethod
      def _authenticateCredentials(login, password, path,
        ignore_password=False):
        if not login or not (password or ignore_password):
          return None
  
        user_list = self.getUserByLogin(login)
  
        if not user_list:
          raise _AuthenticationFailure()
  
        user = user_list[0]
  
        try:
  
          if (ignore_password or pw_validate(user.getPassword(), password)) and \
              len(getValidAssignmentList(user)) and user  \
              .getValidationState() != 'deleted': #user.getCareerRole() == 'internal':
            return login, login # use same for user_id and login
        finally:
          pass
        raise _AuthenticationFailure()
  
      _authenticateCredentials = CachingMethod(
        _authenticateCredentials,
        id='ERP5UserManager_authenticateCredentials',
        cache_factory='erp5_content_short')
      try:
        authentication_result = _authenticateCredentials(
          login=login,
          password=credentials.get('password'),
          path=self.getPhysicalPath(),
          ignore_password=ignore_password)
  
      except _AuthenticationFailure:
        authentication_result = None
  
      if not self.getPortalObject().portal_preferences.isAuthenticationPolicyEnabled():
        # stop here, no authentication policy enabled
        # so just return authentication check result
        return authentication_result
  
      # authentication policy enabled, we need person object anyway
      user_list = self.getUserByLogin(credentials.get('login'))
      if not user_list:
        # not an ERP5 Person object
        return None
      user = user_list[0]
  
      if authentication_result is None:
        # file a failed authentication attempt
        user.notifyLoginFailure()
        return None
  
      # check if password is expired
      if user.isPasswordExpired():
        user.notifyPasswordExpire()
        return None
  
      # check if user account is blocked
      if user.isLoginBlocked():
        return None
  
      return authentication_result
function_tokens: def authenticateCredentials ( self , credentials ) : login = credentials . get ( 'login' ) ignore_password = False if not login : # fallback to support plugins using external tools to extract login # those are not using login/password pair, they just extract login # from remote system (eg. SSL certificates) login = credentials . get ( 'external_login' ) ignore_password = True # Forbidden the usage of the super user. if login == ERP5Security . SUPER_USER : return None @ UnrestrictedMethod def _authenticateCredentials ( login , password , path , ignore_password = False ) : if not login or not ( password or ignore_password ) : return None user_list = self . getUserByLogin ( login ) if not user_list : raise _AuthenticationFailure ( ) user = user_list [ 0 ] try : if ( ignore_password or pw_validate ( user . getPassword ( ) , password ) ) and len ( getValidAssignmentList ( user ) ) and user . getValidationState ( ) != 'deleted' : #user.getCareerRole() == 'internal': return login , login # use same for user_id and login finally : pass raise _AuthenticationFailure ( ) _authenticateCredentials = CachingMethod ( _authenticateCredentials , id = 'ERP5UserManager_authenticateCredentials' , cache_factory = 'erp5_content_short' ) try : authentication_result = _authenticateCredentials ( login = login , password = credentials . get ( 'password' ) , path = self . getPhysicalPath ( ) , ignore_password = ignore_password ) except _AuthenticationFailure : authentication_result = None if not self . getPortalObject ( ) . portal_preferences . isAuthenticationPolicyEnabled ( ) : # stop here, no authentication policy enabled # so just return authentication check result return authentication_result # authentication policy enabled, we need person object anyway user_list = self . getUserByLogin ( credentials . get ( 'login' ) ) if not user_list : # not an ERP5 Person object return None user = user_list [ 0 ] if authentication_result is None : # file a failed authentication attempt user . notifyLoginFailure ( ) return None # check if password is expired if user . isPasswordExpired ( ) : user . notifyPasswordExpire ( ) return None # check if user account is blocked if user . isLoginBlocked ( ) : return None return authentication_result