Package alpine.auth
Class ApiKeyAuthenticationService
- java.lang.Object
-
- alpine.auth.ApiKeyAuthenticationService
-
- All Implemented Interfaces:
AuthenticationService
public class ApiKeyAuthenticationService extends Object implements AuthenticationService
Authentication service that validates API keys.- Since:
- 1.0.0
- Author:
- Steve Springett
-
-
Constructor Summary
Constructors Constructor Description ApiKeyAuthenticationService(org.glassfish.jersey.server.ContainerRequest request)Given the specified ContainerRequest, the constructor retrieves a header named 'X-Api-Key', if it exists.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Principalauthenticate()Authenticates the API key (if it was specified in the X-Api-Key header) and returns a Principal if authentication is successful.booleanisSpecified()Returns whether an API key was specified or not.
-
-
-
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:
isSpecifiedin interfaceAuthenticationService- 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:
authenticatein interfaceAuthenticationService- Returns:
- a Principal of which ApiKey is an instance of
- Throws:
AuthenticationException- upon an authentication failure- Since:
- 1.0.0
-
-