Class User<A extends Identity>
- Type Parameters:
A
- the identity type
- All Implemented Interfaces:
Credentials
,LoginCredentials
,PrincipalCredentials
An application user that can be authenticated in an application using password credentials.
A user may belong to one or more groups of users, it is typically authenticated in a UserAuthenticator
resulting in a UserAuthentication
which exposes the user groups. A
GroupsRoleBasedAccessControllerResolver
can then be used obtain a role-based access controller.
A user may also have an identity, also exposed in the resulting UserAuthentication
, an UserIdentityResolver
can then be used to extract it.
- Since:
- 1.5
- Author:
- Jeremy Kuhn
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
User.Builder<A extends Identity>
A builder used to build users. -
Field Summary
-
Constructor Summary
ConstructorDescriptionCreates a new user with the specified username, identity, password and groups.Creates a new user with the specified username, identity, password, groups and lock flag.Creates a new user with the specified username, password and groups. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns the user groups.Returns the identity of the user.Password
<?, ?> Returns the user password.Returns the username which uniquely identifies the user.int
hashCode()
boolean
isLocked()
Determines whether the user is locked.static <A extends Identity>
User.Builder<A> Returns a user builder with the specified username.protected void
Sets the user groups.protected void
setIdentity
(A identity) Sets the user identity.protected void
setLocked
(boolean locked) Locks/unlocks the user.protected void
setPassword
(Password<?, ?> password) Sets the user password
-
Field Details
-
username
The username which uniquely identifies the user.
-
-
Constructor Details
-
User
Creates a new user with the specified username, password and groups.
- Parameters:
username
- a username which uniquely identifies the userpassword
- a passwordgroups
- a set of groups
-
User
Creates a new user with the specified username, identity, password and groups.
- Parameters:
username
- a username which uniquely identifies the useridentity
- an identitypassword
- a passwordgroups
- a set of groups
-
User
public User(String username, A identity, Password<?, ?> password, Set<String> groups, boolean locked) Creates a new user with the specified username, identity, password, groups and lock flag.
- Parameters:
username
- a username which uniquely identifies the useridentity
- an identitypassword
- a passwordgroups
- a set of groupslocked
- true to create a locked user, false otherwise
-
-
Method Details
-
of
Returns a user builder with the specified username.
- Type Parameters:
A
- the identity type- Parameters:
username
- a username which uniquely identifies the user- Returns:
- a user builder
-
getUsername
Returns the username which uniquely identifies the user.
- Specified by:
getUsername
in interfacePrincipalCredentials
- Returns:
- the username
-
getIdentity
Returns the identity of the user.
- Returns:
- the user identity or null
-
setIdentity
Sets the user identity.
- Parameters:
identity
- an identity
-
getPassword
Returns the user password.
- Specified by:
getPassword
in interfaceLoginCredentials
- Returns:
- the user password
-
setPassword
Sets the user password
- Parameters:
password
- the password to set
-
getGroups
Returns the user groups.
- Returns:
- a set of groups
-
setGroups
Sets the user groups.
- Parameters:
groups
- a set of groups
-
isLocked
public boolean isLocked()Determines whether the user is locked.
- Specified by:
isLocked
in interfaceCredentials
- Returns:
- true if the user is locked, false otherwise
-
setLocked
protected void setLocked(boolean locked) Locks/unlocks the user.
- Parameters:
locked
- true to lock the user, false otherwise
-
hashCode
public int hashCode() -
equals
-