Class JAASLoginService

java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
org.eclipse.jetty.security.jaas.JAASLoginService
All Implemented Interfaces:
LoginService, org.eclipse.jetty.util.component.Container, org.eclipse.jetty.util.component.Destroyable, org.eclipse.jetty.util.component.Dumpable, org.eclipse.jetty.util.component.Dumpable.DumpableContainer, org.eclipse.jetty.util.component.LifeCycle

public class JAASLoginService extends org.eclipse.jetty.util.component.ContainerLifeCycle implements LoginService
Implementation of jetty's LoginService that works with JAAS for authorization and authentication.
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener, org.eclipse.jetty.util.component.AbstractLifeCycle.StopException

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container

    org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.Listener

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable

    org.eclipse.jetty.util.component.Dumpable.DumpableContainer, org.eclipse.jetty.util.component.Dumpable.DumpAppendable

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle

    org.eclipse.jetty.util.component.LifeCycle.Listener
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected String
     
    protected Configuration
     
     
    protected IdentityService
     
    protected String
     
    protected String
     
    protected String[]
     
    static final String
     
    static final String[]
     
     

    Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    FAILED, STARTED, STARTING, STOPPED, STOPPING

    Fields inherited from interface org.eclipse.jetty.util.component.Dumpable

    LEGEND
  • Constructor Summary

    Constructors
    Constructor
    Description
     
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
     
    Get the configuration.
    protected String[]
    getGroups(Subject subject)
    Get all of the groups for the user.
    Get the identityService.
    Get the name of the realm.
     
    login(String username, Object credentials, org.eclipse.jetty.server.Request request, Function<Boolean, org.eclipse.jetty.server.Session> getOrCreateSession)
    Login a user.
    void
     
    void
     
    void
    Set the configuration to set.
    void
    Set the identityService.
    void
    Set the name to use to index into the config file of LoginModules.
    void
    Set the name of the realm
    void
    setRoleClassNames(String[] classnames)
     
    boolean
    Validate a user identity.

    Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle

    addBean, addBean, addEventListener, addManaged, contains, destroy, doStop, dump, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, installBean, installBean, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, start, stop, unmanage, updateBean, updateBean, updateBeans, updateBeans

    Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stop, toString

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.eclipse.jetty.util.component.Container

    getCachedBeans, getEventListeners

    Methods inherited from interface org.eclipse.jetty.util.component.Dumpable

    dumpSelf

    Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer

    isDumpable

    Methods inherited from interface LoginService

    getUserIdentity
  • 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()
      Get the configuration.
      Returns:
      the configuration
    • setConfiguration

      public void setConfiguration(Configuration configuration)
      Set the configuration to set.
      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
      Overrides:
      doStart in class org.eclipse.jetty.util.component.ContainerLifeCycle
      Throws:
      Exception
    • login

      public UserIdentity login(String username, Object credentials, org.eclipse.jetty.server.Request request, Function<Boolean, org.eclipse.jetty.server.Session> getOrCreateSession)
      Description copied from interface: LoginService
      Login a user.
      Specified by:
      login in interface LoginService
      Parameters:
      username - The username.
      credentials - The users credentials.
      request - The request or null
      getOrCreateSession - function to retrieve or create a session.
      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, Request, Function) 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