java.lang.Object
io.inverno.mod.security.authentication.user.User<A>
Type Parameters:
A - the identity type
All Implemented Interfaces:
Credentials, LoginCredentials, PrincipalCredentials

public class User<A extends Identity> extends Object implements LoginCredentials

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

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    A builder used to build users.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final String
    The username which uniquely identifies the user.
  • Constructor Summary

    Constructors
    Constructor
    Description
    User(String username, A identity, Password<?,?> password, String... groups)
    Creates a new user with the specified username, identity, password and groups.
    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.
    User(String username, Password<?,?> password, String... groups)
    Creates a new user with the specified username, password and groups.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    Returns the user groups.
    Returns the identity of the user.
    Returns the user password.
    Returns the username which uniquely identifies the user.
    int
     
    boolean
    Determines whether the user is locked.
    static <A extends Identity>
    User.Builder<A>
    of(String username)
    Returns a user builder with the specified username.
    protected void
    setGroups(Set<String> groups)
    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

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • username

      protected final String username
      The username which uniquely identifies the user.
  • Constructor Details

    • User

      public User(String username, Password<?,?> password, String... groups)

      Creates a new user with the specified username, password and groups.

      Parameters:
      username - a username which uniquely identifies the user
      password - a password
      groups - a set of groups
    • User

      public User(String username, A identity, Password<?,?> password, String... groups)

      Creates a new user with the specified username, identity, password and groups.

      Parameters:
      username - a username which uniquely identifies the user
      identity - an identity
      password - a password
      groups - 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 user
      identity - an identity
      password - a password
      groups - a set of groups
      locked - true to create a locked user, false otherwise
  • Method Details

    • of

      public static <A extends Identity> User.Builder<A> of(String username)

      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

      public String getUsername()

      Returns the username which uniquely identifies the user.

      Specified by:
      getUsername in interface PrincipalCredentials
      Returns:
      the username
    • getIdentity

      public A getIdentity()

      Returns the identity of the user.

      Returns:
      the user identity or null
    • setIdentity

      protected void setIdentity(A identity)

      Sets the user identity.

      Parameters:
      identity - an identity
    • getPassword

      public Password<?,?> getPassword()

      Returns the user password.

      Specified by:
      getPassword in interface LoginCredentials
      Returns:
      the user password
    • setPassword

      protected void setPassword(Password<?,?> password)

      Sets the user password

      Parameters:
      password - the password to set
    • getGroups

      public Set<String> getGroups()

      Returns the user groups.

      Returns:
      a set of groups
    • setGroups

      protected void setGroups(Set<String> groups)

      Sets the user groups.

      Parameters:
      groups - a set of groups
    • isLocked

      public boolean isLocked()

      Determines whether the user is locked.

      Specified by:
      isLocked in interface Credentials
      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()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object