Interface Authenticator

All Known Implementing Classes:
DatabaseAuthenticator, LdapAuthenticator

public interface Authenticator
This interface defines an API that can be used to authenticate users and check for access roles.
Author:
rdoherty
  • Method Details

    • getAuthenticatedUser

      User getAuthenticatedUser(String username, String password) throws AuthenticationException
      Checks the password for the passed user. If valid, returns user attributes and all known roles. If not, returns null. Note that the caller is responsible for encrypting the password using the same algorithm used to store the password originally. No password transformation is performed.
      Parameters:
      username - username to check
      password - password to check
      Returns:
      authenticated user, or null
      Throws:
      AuthenticationException - if an error occurs while authenticating
    • getUnauthenticatedUser

      User getUnauthenticatedUser(String username) throws AuthenticationException
      Looks up user attributes without authenticating, and returns them. If no user with the passed name can be found, returns null
      Parameters:
      username - user for which to search
      Returns:
      unauthenticated user, or null
      Throws:
      AuthenticationException - if an error occurs while searching for the user
    • isValidUser

      boolean isValidUser(String username, String password) throws AuthenticationException
      Checks if the given username and password represents a valid user. Same rules as getAuthenticatedUser().
      Parameters:
      username - username to check
      password - to check
      Returns:
      true if valid user, else false
      Throws:
      AuthenticationException - if an error occurs while authenticating
    • userHasRole

      boolean userHasRole(String username, String role) throws AuthenticationException
      Returns true if user has the passed role, else false.
      Parameters:
      username - user to check
      role - role to check
      Returns:
      true if user has role, else false
      Throws:
      AuthenticationException - if an error occurs while looking up user or roles