Class User


  • public final class User
    extends Object
    A user to be utilized with security APIs. Can be an existing authenticated user or it can be a new user to be enrolled to the native realm.
    • Constructor Detail

      • User

        public User​(String username,
                    Collection<String> roles,
                    Map<String,​Object> metadata,
                    @Nullable
                    String fullName,
                    @Nullable
                    String email)
        Builds the user to be utilized with security APIs.
        Parameters:
        username - the username, also known as the principal, unique for in the scope of a realm
        roles - the roles that this user is assigned
        metadata - a map of additional user attributes that may be used in templating roles
        fullName - the full name of the user that may be used for display purposes
        email - the email address of the user
      • User

        public User​(String username,
                    Collection<String> roles)
        Builds the user to be utilized with security APIs.
        Parameters:
        username - the username, also known as the principal, unique for in the scope of a realm
        roles - the roles that this user is assigned
    • Method Detail

      • getUsername

        public String getUsername()
        Returns:
        The principal of this user - effectively serving as the unique identity of the user. Can never be null.
      • getRoles

        public Set<String> getRoles()
        Returns:
        The roles this user is associated with. The roles are identified by their unique names and each represents as set of permissions. Can never be null.
      • getMetadata

        public Map<String,​Object> getMetadata()
        Returns:
        The metadata that is associated with this user. Can never be null.
      • getFullName

        @Nullable
        public String getFullName()
        Returns:
        The full name of this user. May be null.
      • getEmail

        @Nullable
        public String getEmail()
        Returns:
        The email of this user. May be null.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object