Package org.eclipse.jetty.security
Class DefaultIdentityService
java.lang.Object
org.eclipse.jetty.security.DefaultIdentityService
- All Implemented Interfaces:
IdentityService
The default
IdentityService
, which creates and uses DefaultUserIdentity
s.
The associate(UserIdentity, RunAsToken)
method ignores the
user
, but will associate the IdentityService.RunAsToken
with the current thread
until IdentityService.Association.close()
is called.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.jetty.security.IdentityService
IdentityService.Association, IdentityService.RunAsToken
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionassociate
(UserIdentity user, IdentityService.RunAsToken runAsToken) Associate a runas Token with the current user and thread.static boolean
isRoleAssociated
(String role) newRunAsToken
(String roleName) Create a new RunAsToken from a runAsName (normally a role).newUserIdentity
(Subject subject, Principal userPrincipal, String[] roles) Create a new UserIdentity for use with this identity service.void
onLogout
(UserIdentity user) Called to notify that a user has been logged out.
-
Constructor Details
-
DefaultIdentityService
public DefaultIdentityService()
-
-
Method Details
-
isRoleAssociated
-
associate
public IdentityService.Association associate(UserIdentity user, IdentityService.RunAsToken runAsToken) Description copied from interface:IdentityService
Associate a runas Token with the current user and thread.- Specified by:
associate
in interfaceIdentityService
- Parameters:
user
- The UserIdentityrunAsToken
- The runAsToken to associate, obtained fromIdentityService.newRunAsToken(String)
, or null.- Returns:
- A
Closeable
that, when closed, will disassociate the token and restore any prior associations.
-
onLogout
Description copied from interface:IdentityService
Called to notify that a user has been logged out. The service may, among other actions, close anyIdentityService.Association
for the calling thread.- Specified by:
onLogout
in interfaceIdentityService
- Parameters:
user
- The user that has logged out
-
newRunAsToken
Description copied from interface:IdentityService
Create a new RunAsToken from a runAsName (normally a role).- Specified by:
newRunAsToken
in interfaceIdentityService
- Parameters:
roleName
- a role name- Returns:
- A token that can be passed to
IdentityService.associate(UserIdentity, RunAsToken)
.
-
getSystemUserIdentity
- Specified by:
getSystemUserIdentity
in interfaceIdentityService
-
newUserIdentity
Description copied from interface:IdentityService
Create a new UserIdentity for use with this identity service. The UserIdentity should be immutable and able to be cached.- Specified by:
newUserIdentity
in interfaceIdentityService
- Parameters:
subject
- Subject to include in UserIdentityuserPrincipal
- Principal to include in UserIdentity. This will be returned from getUserPrincipal callsroles
- set of roles to include in UserIdentity.- Returns:
- A new immutable UserIdententity
-