Package org.eclipse.jetty.jaas
Class JAASLoginService
- java.lang.Object
-
- org.eclipse.jetty.util.component.AbstractLifeCycle
-
- org.eclipse.jetty.util.component.ContainerLifeCycle
-
- org.eclipse.jetty.jaas.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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
Container.InheritedListener, Container.Listener
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
_callbackHandlerClass
protected javax.security.auth.login.Configuration
_configuration
protected JAASUserPrincipal
_defaultUser
protected IdentityService
_identityService
protected java.lang.String
_loginModuleName
protected java.lang.String
_realmName
protected java.lang.String[]
_roleClassNames
static java.lang.String
DEFAULT_ROLE_CLASS_NAME
static java.lang.String[]
DEFAULT_ROLE_CLASS_NAMES
static java.lang.ThreadLocal<JAASLoginService>
INSTANCE
-
Constructor Summary
Constructors Constructor Description JAASLoginService()
JAASLoginService(java.lang.String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
doStart()
Starts the managed lifecycle beans in the order they were added.javax.security.auth.login.Configuration
getConfiguration()
protected java.lang.String[]
getGroups(javax.security.auth.Subject subject)
Get all of the groups for the user.IdentityService
getIdentityService()
Get the identityService.java.lang.String
getName()
Get the name of the realm.java.lang.String[]
getRoleClassNames()
UserIdentity
login(java.lang.String username, java.lang.Object credentials, javax.servlet.ServletRequest request)
Login a user.void
logout(UserIdentity user)
void
setCallbackHandlerClass(java.lang.String classname)
void
setConfiguration(javax.security.auth.login.Configuration configuration)
void
setIdentityService(IdentityService identityService)
Set the identityService.void
setLoginModuleName(java.lang.String name)
Set the name to use to index into the config file of LoginModules.void
setName(java.lang.String name)
Set the name of the realmvoid
setRoleClassNames(java.lang.String[] classnames)
boolean
validate(UserIdentity user)
Validate a user identity.-
Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, destroy, doStop, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpObjects, dumpStdErr, dumpThis, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeans
-
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
-
-
-
-
Field Detail
-
DEFAULT_ROLE_CLASS_NAME
public static final java.lang.String DEFAULT_ROLE_CLASS_NAME
- See Also:
- Constant Field Values
-
DEFAULT_ROLE_CLASS_NAMES
public static final java.lang.String[] DEFAULT_ROLE_CLASS_NAMES
-
INSTANCE
public static final java.lang.ThreadLocal<JAASLoginService> INSTANCE
-
_roleClassNames
protected java.lang.String[] _roleClassNames
-
_callbackHandlerClass
protected java.lang.String _callbackHandlerClass
-
_realmName
protected java.lang.String _realmName
-
_loginModuleName
protected java.lang.String _loginModuleName
-
_defaultUser
protected JAASUserPrincipal _defaultUser
-
_identityService
protected IdentityService _identityService
-
_configuration
protected javax.security.auth.login.Configuration _configuration
-
-
Method Detail
-
getName
public java.lang.String getName()
Get the name of the realm.- Specified by:
getName
in interfaceLoginService
- Returns:
- name or null if not set.
-
setName
public void setName(java.lang.String name)
Set the name of the realm- Parameters:
name
- aString
value
-
getConfiguration
public javax.security.auth.login.Configuration getConfiguration()
- Returns:
- the configuration
-
setConfiguration
public void setConfiguration(javax.security.auth.login.Configuration configuration)
- Parameters:
configuration
- the configuration to set
-
getIdentityService
public IdentityService getIdentityService()
Get the identityService.- Specified by:
getIdentityService
in interfaceLoginService
- Returns:
- the identityService
-
setIdentityService
public void setIdentityService(IdentityService identityService)
Set the identityService.- Specified by:
setIdentityService
in interfaceLoginService
- Parameters:
identityService
- the identityService to set
-
setLoginModuleName
public void setLoginModuleName(java.lang.String name)
Set the name to use to index into the config file of LoginModules.- Parameters:
name
- aString
value
-
setCallbackHandlerClass
public void setCallbackHandlerClass(java.lang.String classname)
-
setRoleClassNames
public void setRoleClassNames(java.lang.String[] classnames)
-
getRoleClassNames
public java.lang.String[] getRoleClassNames()
-
doStart
protected void doStart() throws java.lang.Exception
Description copied from class:ContainerLifeCycle
Starts the managed lifecycle beans in the order they were added.- Overrides:
doStart
in classContainerLifeCycle
- Throws:
java.lang.Exception
-
login
public UserIdentity login(java.lang.String username, java.lang.Object credentials, javax.servlet.ServletRequest request)
Description copied from interface:LoginService
Login a user.- Specified by:
login
in interfaceLoginService
- Parameters:
username
- The user namecredentials
- The users credentialsrequest
- 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 toLoginService.login(String, Object, ServletRequest)
is still valid.- Specified by:
validate
in interfaceLoginService
- 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 interfaceLoginService
-
getGroups
protected java.lang.String[] getGroups(javax.security.auth.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
-
-