Class JwtAuthenticationService

java.lang.Object
alpine.server.auth.JwtAuthenticationService
All Implemented Interfaces:
AuthenticationService

public class JwtAuthenticationService extends Object implements AuthenticationService
An AuthenticationService implementation for JWTs that authenticates users based on a token presented in the request. Tokens must be presented using the Authorization Bearer header.
Since:
1.0.0
Author:
Steve Springett
  • Constructor Summary

    Constructors
    Constructor
    Description
    JwtAuthenticationService(org.glassfish.jersey.server.ContainerRequest request)
    Constructs a new JwtAuthenticationService.
  • Method Summary

    Modifier and Type
    Method
    Description
    Defines an authentication method which returns a Principal if authentication is successful or an AuthorizationException if not.
    boolean
    Defines a method which returns if the specified piece of data, required to perform authentication is present.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JwtAuthenticationService

      public JwtAuthenticationService(org.glassfish.jersey.server.ContainerRequest request)
      Constructs a new JwtAuthenticationService.
      Parameters:
      request - a ContainerRequest object to parse
  • Method Details

    • isSpecified

      public boolean isSpecified()
      Defines a method which returns if the specified piece of data, required to perform authentication is present.
      Specified by:
      isSpecified in interface AuthenticationService
      Returns:
      true if the authentication data was specified, false if not
    • authenticate

      public Principal authenticate() throws AuthenticationException
      Defines an authentication method which returns a Principal if authentication is successful or an AuthorizationException if not.
      Specified by:
      authenticate in interface AuthenticationService
      Returns:
      a Principal of the authenticated user
      Throws:
      AuthenticationException - an authentication failure