Package alpine.auth

Class ApiKeyAuthenticationService

    • Constructor Detail

      • ApiKeyAuthenticationService

        public ApiKeyAuthenticationService​(org.glassfish.jersey.server.ContainerRequest request)
        Given the specified ContainerRequest, the constructor retrieves a header named 'X-Api-Key', if it exists.
        Parameters:
        request - the ContainerRequest object
        Since:
        1.0.0
    • Method Detail

      • isSpecified

        public boolean isSpecified()
        Returns whether an API key was specified or not.
        Specified by:
        isSpecified in interface AuthenticationService
        Returns:
        true if API key was specified, false if not
        Since:
        1.0.0
      • authenticate

        public Principal authenticate()
                               throws AuthenticationException
        Authenticates the API key (if it was specified in the X-Api-Key header) and returns a Principal if authentication is successful. Otherwise, returns an AuthenticationException.
        Specified by:
        authenticate in interface AuthenticationService
        Returns:
        a Principal of which ApiKey is an instance of
        Throws:
        AuthenticationException - upon an authentication failure
        Since:
        1.0.0