Class JAASLoginService

All Implemented Interfaces:
LoginService, Container, Destroyable, Dumpable, Dumpable.DumpableContainer, LifeCycle

public class JAASLoginService extends ContainerLifeCycle implements LoginService
JAASLoginService Implementation of jetty's LoginService that works with JAAS for authorization and authentication.
  • Field Details

    • DEFAULT_ROLE_CLASS_NAME

      public static final String DEFAULT_ROLE_CLASS_NAME
      See Also:
    • DEFAULT_ROLE_CLASS_NAMES

      public static final String[] DEFAULT_ROLE_CLASS_NAMES
    • INSTANCE

      public static final ThreadLocal<JAASLoginService> INSTANCE
    • _roleClassNames

      protected String[] _roleClassNames
    • _callbackHandlerClass

      protected String _callbackHandlerClass
    • _realmName

      protected String _realmName
    • _loginModuleName

      protected String _loginModuleName
    • _defaultUser

      protected JAASUserPrincipal _defaultUser
    • _identityService

      protected IdentityService _identityService
    • _configuration

      protected Configuration _configuration
  • Constructor Details

    • JAASLoginService

      public JAASLoginService()
    • JAASLoginService

      public JAASLoginService(String name)
      Parameters:
      name - the name of the realm
  • Method Details

    • getName

      public String getName()
      Get the name of the realm.
      Specified by:
      getName in interface LoginService
      Returns:
      name or null if not set.
    • setName

      public void setName(String name)
      Set the name of the realm
      Parameters:
      name - a String value
    • getConfiguration

      public Configuration getConfiguration()
      Returns:
      the configuration
    • setConfiguration

      public void setConfiguration(Configuration configuration)
      Parameters:
      configuration - the configuration to set
    • getIdentityService

      public IdentityService getIdentityService()
      Get the identityService.
      Specified by:
      getIdentityService in interface LoginService
      Returns:
      the identityService
    • setIdentityService

      public void setIdentityService(IdentityService identityService)
      Set the identityService.
      Specified by:
      setIdentityService in interface LoginService
      Parameters:
      identityService - the identityService to set
    • setLoginModuleName

      public void setLoginModuleName(String name)
      Set the name to use to index into the config file of LoginModules.
      Parameters:
      name - a String value
    • setCallbackHandlerClass

      public void setCallbackHandlerClass(String classname)
    • setRoleClassNames

      public void setRoleClassNames(String[] classnames)
    • getRoleClassNames

      public String[] getRoleClassNames()
    • doStart

      protected void doStart() throws Exception
      Description copied from class: ContainerLifeCycle
      Starts the managed lifecycle beans in the order they were added.
      Overrides:
      doStart in class ContainerLifeCycle
      Throws:
      AbstractLifeCycle.StopException - If thrown, the lifecycle will immediately be stopped.
      Exception - If there was a problem starting. Will cause a transition to FAILED state
    • login

      public UserIdentity login(String username, Object credentials, jakarta.servlet.ServletRequest request)
      Description copied from interface: LoginService
      Login a user.
      Specified by:
      login in interface LoginService
      Parameters:
      username - The user name
      credentials - The users credentials
      request - TODO
      Returns:
      A UserIdentity if the credentials matched, otherwise null
    • validate

      public boolean validate(UserIdentity user)
      Description copied from interface: LoginService
      Validate a user identity. Validate that a UserIdentity previously created by a call to LoginService.login(String, Object, ServletRequest) is still valid.
      Specified by:
      validate in interface LoginService
      Parameters:
      user - The user to validate
      Returns:
      true if authentication has not been revoked for the user.
    • logout

      public void logout(UserIdentity user)
      Specified by:
      logout in interface LoginService
    • getGroups

      protected String[] getGroups(Subject subject)
      Get all of the groups for the user.
      Parameters:
      subject - the Subject representing the user
      Returns:
      all the names of groups that the user is in, or 0 length array if none