Interface UserAuthentication<A extends Identity>
- Type Parameters:
A
- the identity type
- All Superinterfaces:
Authentication
,GroupAwareAuthentication
,PrincipalAuthentication
An authentication resulting from the authentication of a user uniquely identified by a username in a UserAuthenticator
.
It extends the PrincipalAuthentication
by exposing the identity of the authenticated user (if any) and the groups it belongs to. This implementation is then allows to create a complete
SecurityContext
with an Authentication
, an Identity
and an AccessController
(i.e. RoleBasedAccessController
).
For example, an application could then build its security context using a UserAuthenticator
, a UserIdentityResolver
and a GroupsRoleBasedAccessControllerResolver
. Note that
the API is flexible and allow other combinations as well.
- Since:
- 1.5
- Author:
- Jeremy Kuhn
-
Method Summary
Modifier and TypeMethodDescriptionReturns the user's identity.static <A extends Identity>
UserAuthentication<A> Creates a user authentication from the specified user.static <A extends Identity>
UserAuthentication<A> Creates a user authentication with the specified name, identity and groups.static <A extends Identity>
UserAuthentication<A> of
(String username, A identity, Collection<String> groups) Creates a user authentication with the specified name, identity and groups.static <A extends Identity>
UserAuthentication<A> of
(String username, SecurityException cause) Returns a new denied user authentication for the specified username and cause.static <A extends Identity>
UserAuthentication<A> Creates a user authentication with the specified name and groups.static <A extends Identity>
UserAuthentication<A> of
(String username, Collection<String> groups) Creates a user authentication with the specified name and groups.Methods inherited from interface io.inverno.mod.security.authentication.Authentication
getCause, isAnonymous, isAuthenticated
Methods inherited from interface io.inverno.mod.security.authentication.GroupAwareAuthentication
getGroups
Methods inherited from interface io.inverno.mod.security.authentication.PrincipalAuthentication
getUsername
-
Method Details
-
getIdentity
A getIdentity()Returns the user's identity.
- Returns:
- the user identity or null if none was resolved during the authentication process.
-
of
Creates a user authentication with the specified name and groups.
This is a conveninence method that should be used with care and only used after a successful authentication to generate the resulting authentication.
- Type Parameters:
A
- the identity type- Parameters:
username
- a usernamegroups
- an array of groups- Returns:
- a new user authentication
-
of
Returns a new denied user authentication for the specified username and cause.
- Type Parameters:
A
- the identity type- Parameters:
username
- a usernamecause
- the cause of the failed authentication- Returns:
- a denied user authentication
-
of
Creates a user authentication with the specified name and groups.
This is a conveninence method that should be used with care and only used after a successful authentication to generate the resulting authentication.
- Type Parameters:
A
- the identity type- Parameters:
username
- a usernamegroups
- a collection of groups- Returns:
- a new user authentication
-
of
Creates a user authentication with the specified name, identity and groups.
This is a conveninence method that should be used with care and only used after a successful authentication to generate the resulting authentication.
- Type Parameters:
A
- the identity type- Parameters:
username
- a usernameidentity
- the identity of the usergroups
- an array of groups- Returns:
- a new user authentication
-
of
static <A extends Identity> UserAuthentication<A> of(String username, A identity, Collection<String> groups) Creates a user authentication with the specified name, identity and groups.
This is a conveninence method that should be used with care and only used after a successful authentication to generate the resulting authentication.
- Type Parameters:
A
- the identity type- Parameters:
username
- a usernameidentity
- the identity of the usergroups
- a collection of groups- Returns:
- a new user authentication
-
of
Creates a user authentication from the specified user.
This is a conveninence method that should be used with care. In order to respect the
Authentication
contract it is important to make sure that the specified user has been previously authenticated by anAuthenticator
.The resulting authentication is authenticated if the specified user is not locked.
- Type Parameters:
A
- the identity type- Parameters:
user
- an authenticated user- Returns:
- a new user authentication
-