Class JWEAuthentication<A extends Authentication>

Type Parameters:
A - the original authentication type
All Implemented Interfaces:
Authentication, TokenAuthentication

public class JWEAuthentication<A extends Authentication> extends Object implements TokenAuthentication

A token authentication that wraps the original authentication in a JWE and uses its compact representation as token value.

Jeremy Kuhn
  • Constructor Details

    • JWEAuthentication

      public JWEAuthentication(JWE<A> jwe)

      Creates a JWE authentication with the specified JWE.

      jwe - a JWE wrapping the original authentication
    • JWEAuthentication

      public JWEAuthentication(SecurityException cause)

      Creates a denied JWE authentication with the specified security error.

      cause - a security error or null
  • Method Details

    • getJwe

      public JWE<A> getJwe()

      Returns the JWE.

      the JWE or null if unauthenticated
    • getToken

      public String getToken()

      Returns the JWE compact representation.

      Specified by:
      getToken in interface TokenAuthentication
      the JWE compact representation or null if unauthenticated
    • 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
      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
      an optional returning the cause of the failed authentication, or an empty optional if there was no authentication or if the authentication was successful