Top Description Fields Constructors Methods
org.eclipse.jetty.security.jaas

public Class JAASLoginService

extends ContainerLifeCycle
implements LoginService
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.security.LoginService
Imports
java.io.IOException, java.security.Principal, java.util.ArrayList, .Arrays, .Collection, .LinkedHashSet, .List, .Set, java.util.function.Function, javax.security.auth.Subject, javax.security.auth.callback.Callback, .CallbackHandler, .NameCallback, .UnsupportedCallbackException, javax.security.auth.login.Configuration, .FailedLoginException, .LoginContext, .LoginException, org.eclipse.jetty.security.DefaultIdentityService, .IdentityService, .LoginService, .UserIdentity, org.eclipse.jetty.security.jaas.callback.DefaultCallbackHandler, org.eclipse.jetty.server.Request, .Session, org.eclipse.jetty.util.ArrayUtil, .Loader, org.eclipse.jetty.util.component.ContainerLifeCycle, org.slf4j.Logger, .LoggerFactory

Implementation of jetty's LoginService that works with JAAS for authorization and authentication.

Field Summary

Modifier and TypeField and Description
protected String
protected Configuration
protected JAASUserPrincipal
protected IdentityService
protected String
protected String
protected String[]
public static final String
public static final String[]
public static final ThreadLocal<JAASLoginService>
private static final Logger

Constructor Summary

AccessConstructor and Description
public
public
JAASLoginService(String
the name of the realm
name
)

Method Summary

Modifier and TypeMethod and Description
protected void
doStart()

Overrides org.eclipse.jetty.util.component.ContainerLifeCycle.doStart.

Starts the managed lifecycle beans in the order they were added.

public Configuration

Returns:

the configuration
getConfiguration
()

Get the configuration.

protected String[]

Returns:

all the names of groups that the user is in, or 0 length array if none
getGroups
(Subject
the Subject representing the user
subject
)

Get all of the groups for the user.

public IdentityService

Returns:

the identityService
getIdentityService
()

Implements org.eclipse.jetty.security.LoginService.getIdentityService.

Get the identityService.

public String

Returns:

name or null if not set.
getName
()

Implements org.eclipse.jetty.security.LoginService.getName.

Get the name of the realm.

public String[]
private String
getUserName(CallbackHandler callbackHandler)

private static boolean

Returns:

true if the class is a role class
isRoleClass
(Class<?>
the class to check
clazz
,
List<String>
the list of classnames that represent roles
roleClassNames
)

Check whether the class, its superclasses or any interfaces they implement is one of the classes that represents a role.

public UserIdentity
login(String
The username.
username
,
Object
The users credentials.
credentials
,
Request
The request or null
request
,
Function<Boolean, Session>
function to retrieve or create a session.
getOrCreateSession
)

Implements org.eclipse.jetty.security.LoginService.login.

Login a user.

public void
public void
public void
setConfiguration(Configuration
the configuration to set
configuration
)

Set the configuration to set.

public void
setIdentityService(IdentityService
the identityService to set
identityService
)

Implements org.eclipse.jetty.security.LoginService.setIdentityService.

Set the identityService.

public void
setLoginModuleName(String
a String value
name
)

Set the name to use to index into the config file of LoginModules.

public void
setName(String
a String value
name
)

Set the name of the realm

public void
setRoleClassNames(String[] classnames)

public boolean
validate(UserIdentity
The user to validate
user
)

Implements org.eclipse.jetty.security.LoginService.validate.

Validate a user identity.

Inherited from org.eclipse.jetty.util.component.ContainerLifeCycle:
addBeanaddBeanaddEventListeneraddManagedcontainsdestroydoStopdumpdumpdumpdumpObjectsdumpStdErrgetBeangetBeansgetBeansgetContainedBeansgetContainedBeansisAutoisManagedisUnmanagedmanageremoveBeanremoveBeansremoveEventListenersetBeansstartstopunmanageupdateBeanupdateBeanupdateBeansupdateBeans

Field Detail

_callbackHandlerClassback to summary
protected String _callbackHandlerClass
_configurationback to summary
protected Configuration _configuration
_defaultUserback to summary
protected JAASUserPrincipal _defaultUser
_identityServiceback to summary
protected IdentityService _identityService
_loginModuleNameback to summary
protected String _loginModuleName
_realmNameback to summary
protected String _realmName
_roleClassNamesback to summary
protected String[] _roleClassNames
DEFAULT_ROLE_CLASS_NAMEback to summary
public static final String DEFAULT_ROLE_CLASS_NAME
DEFAULT_ROLE_CLASS_NAMESback to summary
public static final String[] DEFAULT_ROLE_CLASS_NAMES
INSTANCEback to summary
public static final ThreadLocal<JAASLoginService> INSTANCE
LOGback to summary
private static final Logger LOG

Hides org.eclipse.jetty.util.component.ContainerLifeCycle.LOG.

Constructor Detail

JAASLoginServiceback to summary
public JAASLoginService()
JAASLoginServiceback to summary
public JAASLoginService(String name)
Parameters
name:String

the name of the realm

Method Detail

doStartback to summary
protected void doStart() throws Exception

Overrides org.eclipse.jetty.util.component.ContainerLifeCycle.doStart.

Doc from org.eclipse.jetty.util.component.ContainerLifeCycle.doStart.

Starts the managed lifecycle beans in the order they were added.

Annotations
@Override
Exceptions
Exception:

Doc from org.eclipse.jetty.util.component.AbstractLifeCycle.doStart.

If there was a problem starting. Will cause a transition to FAILED state

getConfigurationback to summary
public Configuration getConfiguration()

Get the configuration.

Returns:Configuration

the configuration

getGroupsback to summary
protected String[] getGroups(Subject subject)

Get all of the groups for the user.

Parameters
subject:Subject

the Subject representing the user

Returns:String[]

all the names of groups that the user is in, or 0 length array if none

getIdentityServiceback to summary
public IdentityService getIdentityService()

Implements org.eclipse.jetty.security.LoginService.getIdentityService.

Get the identityService.

Returns:IdentityService

the identityService

Annotations
@Override
getNameback to summary
public String getName()

Implements org.eclipse.jetty.security.LoginService.getName.

Get the name of the realm.

Returns:String

name or null if not set.

Annotations
@Override
getRoleClassNamesback to summary
public String[] getRoleClassNames()
getUserNameback to summary
private String getUserName(CallbackHandler callbackHandler) throws IOException, UnsupportedCallbackException
isRoleClassback to summary
private static boolean isRoleClass(Class<?> clazz, List<String> roleClassNames)

Check whether the class, its superclasses or any interfaces they implement is one of the classes that represents a role.

Parameters
clazz:Class<?>

the class to check

roleClassNames:List<String>

the list of classnames that represent roles

Returns:boolean

true if the class is a role class

loginback to summary
public UserIdentity login(String username, Object credentials, Request request, Function<Boolean, Session> getOrCreateSession)

Implements org.eclipse.jetty.security.LoginService.login.

Doc from org.eclipse.jetty.security.LoginService.login.

Login a user.

Parameters
username:String

The username.

credentials:Object

The users credentials.

request:Request

The request or null

getOrCreateSession:Function<Boolean, Session>

function to retrieve or create a session.

Returns:UserIdentity

A UserIdentity if the credentials matched, otherwise null

Annotations
@Override
logoutback to summary
public void logout(UserIdentity user)

Implements org.eclipse.jetty.security.LoginService.logout.

Annotations
@Override
setCallbackHandlerClassback to summary
public void setCallbackHandlerClass(String classname)
setConfigurationback to summary
public void setConfiguration(Configuration configuration)

Set the configuration to set.

Parameters
configuration:Configuration

the configuration to set

setIdentityServiceback to summary
public void setIdentityService(IdentityService identityService)

Implements org.eclipse.jetty.security.LoginService.setIdentityService.

Set the identityService.

Parameters
identityService:IdentityService

the identityService to set

Annotations
@Override
setLoginModuleNameback to summary
public void setLoginModuleName(String name)

Set the name to use to index into the config file of LoginModules.

Parameters
name:String

a String value

setNameback to summary
public void setName(String name)

Set the name of the realm

Parameters
name:String

a String value

setRoleClassNamesback to summary
public void setRoleClassNames(String[] classnames)
validateback to summary
public boolean validate(UserIdentity user)

Implements org.eclipse.jetty.security.LoginService.validate.

Doc from org.eclipse.jetty.security.LoginService.validate.

Validate a user identity. Validate that a UserIdentity previously created by a call to login(String, Object, Request, Function) is still valid.

Parameters
user:UserIdentity

The user to validate

Returns:boolean

true if authentication has not been revoked for the user.

Annotations
@Override