Package org.wildfly.security.http.bearer
Class BearerTokenAuthenticationMechanism
- java.lang.Object
-
- org.wildfly.security.http.bearer.BearerTokenAuthenticationMechanism
-
- All Implemented Interfaces:
HttpServerAuthenticationMechanism
final class BearerTokenAuthenticationMechanism extends Object implements HttpServerAuthenticationMechanism
A
HttpServerAuthenticationMechanism
capable to perform authentication based on a bearer token.This mechanisms expects bearer tokens to be sent along with a
Authorization
request header as follows:GET /resource-server HTTP/1.1 Host: elytron.org Authorization: Bearer hgTasdMNMMAsii
- Author:
- Pedro Igor
-
-
Field Summary
Fields Modifier and Type Field Description private CallbackHandler
callbackHandler
-
Constructor Summary
Constructors Constructor Description BearerTokenAuthenticationMechanism(CallbackHandler callbackHandler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
evaluateRequest(HttpServerRequest request)
Evaluate the current request and attempt to authenticate if appropriate.String
getMechanismName()
Get the name of this mechanism, where appropriate this should be the IANA registered name.private String
getRealmName()
private void
handleCallback(Callback callback)
private void
unauthorizedResponse(HttpServerResponse response)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.wildfly.security.http.HttpServerAuthenticationMechanism
dispose, getNegotiatedProperty, getNegotiationProperty
-
-
-
-
Field Detail
-
callbackHandler
private final CallbackHandler callbackHandler
-
-
Constructor Detail
-
BearerTokenAuthenticationMechanism
BearerTokenAuthenticationMechanism(CallbackHandler callbackHandler)
-
-
Method Detail
-
getMechanismName
public String getMechanismName()
Description copied from interface:HttpServerAuthenticationMechanism
Get the name of this mechanism, where appropriate this should be the IANA registered name.- Specified by:
getMechanismName
in interfaceHttpServerAuthenticationMechanism
- Returns:
- the name of the mechanism.
-
evaluateRequest
public void evaluateRequest(HttpServerRequest request) throws HttpAuthenticationException
Description copied from interface:HttpServerAuthenticationMechanism
Evaluate the current request and attempt to authenticate if appropriate. The mechanism should call the appropriate callback methods on the {link HttpServerResponse} to both indicate the outcome of the evaluation and to register anyHttpServerMechanismsResponder
as required.- Specified by:
evaluateRequest
in interfaceHttpServerAuthenticationMechanism
- Parameters:
request
- representation of the HTTP request.- Throws:
HttpAuthenticationException
- if there is an internal failure handling the authentication.
-
handleCallback
private void handleCallback(Callback callback) throws HttpAuthenticationException
- Throws:
HttpAuthenticationException
-
unauthorizedResponse
private void unauthorizedResponse(HttpServerResponse response) throws HttpAuthenticationException
- Throws:
HttpAuthenticationException
-
getRealmName
private String getRealmName() throws HttpAuthenticationException
- Throws:
HttpAuthenticationException
-
-