Class GenericPrincipalAuthentication

java.lang.Object
io.inverno.mod.security.internal.authentication.GenericPrincipalAuthentication
All Implemented Interfaces:
Authentication, PrincipalAuthentication

public class GenericPrincipalAuthentication extends Object implements PrincipalAuthentication

Generic PrincipalAuthentication implementation.

Since:
1.5
Author:
Jeremy Kuhn
  • Constructor Details

    • GenericPrincipalAuthentication

      public GenericPrincipalAuthentication(String username, boolean authenticated)

      Creates a generic principal authentication with the specified username.

      Parameters:
      username - the username
      authenticated - true to create an authenticated authentication, false otherwise
  • Method Details

    • setCause

      public void setCause(SecurityException cause)

      Sets the cause of the failed authentication.

      This also sets the authenticated flag to false when the specified cause is not null.

      Parameters:
      cause - a security exception resulting from the failed authentication
    • getUsername

      public String getUsername()
      Description copied from interface: PrincipalAuthentication

      Returns the unique username of the authenticated entity.

      Specified by:
      getUsername in interface PrincipalAuthentication
      Returns:
      a username
    • isAuthenticated

      public boolean isAuthenticated()
      Description copied from interface: Authentication

      Determine whether the authentication is authenticated.

      A non-authenticated authentication might indicates that no authentication took place (i.e. anonymous access) or that the authentication failed. In case of a failed authentication, the cause is exposed by Authentication.getCause().

      Specified by:
      isAuthenticated in interface Authentication
      Returns:
      true if the the authentication is authenticated, false otherwise
    • getCause

      public Optional<SecurityException> getCause()
      Description copied from interface: Authentication

      Returns the cause of a failed authentication.

      A non-authenticated authentication with no cause indicates that no authentication took place (i.e. anonymous access).

      A non-authenticated authentication with a cause indicates a failed authentication.

      Specified by:
      getCause in interface Authentication
      Returns:
      an optional returning the cause of the failed authentication, or an empty optional if there was no authentication or if the authentication was successful
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

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