java.lang.Object
cloud.piranha.core.impl.DefaultAuthenticatedIdentity
- All Implemented Interfaces:
AuthenticatedIdentity
,Principal
Default implementation of AuthenticatedIdentity.
This implementation is an immutable structure, with a facility to store it in TLS. It's the responsibility of the context, e.g. the HTTP request handler, to remove the identity from TLS at the end of the context (e.g. end of the HTTP request), or at any other appropriate time (e.g. when logging out mid-request).
- Author:
- Arjan Tijms
-
Constructor Summary
ConstructorDescriptionDefaultAuthenticatedIdentity
(Principal callerPrincipal, Set<String> groups) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
clear()
Clear identity and subject.Returns the caller principal, which represents the primary name of the calling entity (aka the "caller") to a server.static AuthenticatedIdentity
Returns the current identity.static Subject
Returns the current subject.The groups the caller is in.static void
setCurrentIdentity
(AuthenticatedIdentity identity) Set the current identity.static void
setCurrentIdentity
(Principal callerPrincipal, Set<String> groups) Set the current identity.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface cloud.piranha.core.api.AuthenticatedIdentity
getName
-
Constructor Details
-
DefaultAuthenticatedIdentity
Constructor.- Parameters:
callerPrincipal
- the caller principal.groups
- the groups.
-
-
Method Details
-
setCurrentIdentity
Set the current identity.- Parameters:
callerPrincipal
- the caller principal.groups
- the groups.
-
setCurrentIdentity
Set the current identity.- Parameters:
identity
- the identity.
-
getCurrentSubject
Returns the current subject.- Returns:
- the current subject
-
getCurrentIdentity
Returns the current identity.- Returns:
- the current identity
-
clear
public static void clear()Clear identity and subject. -
getCallerPrincipal
Description copied from interface:AuthenticatedIdentity
Returns the caller principal, which represents the primary name of the calling entity (aka the "caller") to a server.- Specified by:
getCallerPrincipal
in interfaceAuthenticatedIdentity
- Returns:
- the caller principal, or null if authentication has not (yet) completed successfully.
-
getGroups
Description copied from interface:AuthenticatedIdentity
The groups the caller is in.If group to role mapping is not active (the default) groups are equal to roles.
- Specified by:
getGroups
in interfaceAuthenticatedIdentity
- Returns:
- the set of groups the caller is in, never null.
-