Class Identity


  • public class Identity
    extends java.lang.Object
    A class that represents a user identity.

    The identity is the result of an authentication process. Although the most common authentication method (password authentication) only returns a user name, other methods (such as OAuth, client SSL certificates, or an authentication reverse proxy server) may return more information.

    At the very least, the user is identified using a unique ID, and it optionally also contains name and email address information.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static Identity Invalid
      An invalid identity constant.
      static java.lang.String LoginName
      The login name identity.
      static java.lang.String MultiFactor
      The default multi-factor identity.
    • Constructor Summary

      Constructors 
      Constructor Description
      Identity()
      Default constructor.
      Identity​(java.lang.String provider, java.lang.String id, java.lang.String name, java.lang.String email, boolean emailVerified)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getEmail()
      Returns an email address.
      java.lang.String getId()
      Returns the id.
      java.lang.String getName()
      Returns the name.
      java.lang.String getProvider()
      Returns the provider name.
      boolean isEmailVerified()
      Returns whether the email address has been verified.
      boolean isValid()
      Returns whether the identity is valid.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • Invalid

        public static final Identity Invalid
        An invalid identity constant.

        This is an identity that is not isValid().

      • LoginName

        public static final java.lang.String LoginName
        The login name identity.

        This is a provider name for the (usually user-controlled) identity, used for example for password-based authentication.

        See Also:
        Constant Field Values
      • MultiFactor

        public static final java.lang.String MultiFactor
        The default multi-factor identity.

        This is the name used for the default implementation of JWt for MFA. While the actual implementation of any additional factor can be changed, the default implementation (using TOTP), will use this identity name.

        It will dictate what the identity entry in the database will be called. Which stores the TOTP secret key in the database.

        Note: This entry is not encrypted or obfuscated in any way.

        See Also:
        Constant Field Values
    • Constructor Detail

      • Identity

        public Identity()
        Default constructor.

        Creates an invalid identity.

      • Identity

        public Identity​(java.lang.String provider,
                        java.lang.String id,
                        java.lang.String name,
                        java.lang.String email,
                        boolean emailVerified)
        Constructor.
    • Method Detail

      • isValid

        public boolean isValid()
        Returns whether the identity is valid.

        An invalid identity is used to indicate for example that no identity information could be obtained.

      • getProvider

        public java.lang.String getProvider()
        Returns the provider name.

        This is a unique id that names the source for this identity (e.g. "google-oauth", or "LDAP", or "user" (for a user-chosen identity).

      • getId

        public java.lang.String getId()
        Returns the id.

        Returns a unique identifier for the user within the scope of this provider.

      • getName

        public java.lang.String getName()
        Returns the name.

        Returns the user's name, or an empty string if not provided.

      • getEmail

        public java.lang.String getEmail()
        Returns an email address.

        Returns the user's email address, or an empty string if not provided.

        See Also:
        isEmailVerified()
      • isEmailVerified

        public boolean isEmailVerified()
        Returns whether the email address has been verified.

        The third party provider may be able to guarantee that the user indeed also control's the given email address (e.g. because the third party hosts that email account for the user).

        See Also:
        getEmail()