Class GenericAuthentication

java.lang.Object
io.inverno.mod.security.internal.authentication.GenericAuthentication
All Implemented Interfaces:
Authentication

public class GenericAuthentication extends Object implements Authentication

Generic Authentication implementation.

Since:
1.5
Author:
Jeremy Kuhn
  • Field Details

    • ANONYMOUS

      public static final GenericAuthentication ANONYMOUS
      The anonymous authentication (unauthenticated with no cause of authentication failure).
    • GRANTED

      public static final GenericAuthentication GRANTED
      The granted authentication.
    • DENIED

      public static final GenericAuthentication DENIED
      The denied authentication.
  • Constructor Details

    • GenericAuthentication

      public GenericAuthentication(boolean authenticated)

      Creates a generic authentication.

      Parameters:
      authenticated - true to create an authenticated authentication, false otherwise
    • GenericAuthentication

      public GenericAuthentication(SecurityException cause)

      Creates an unauthenticated authentication with the specified cause of authentication failure.

      Parameters:
      cause - the cause of the failed authentication
  • Method Details

    • 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