public class AuthenticatedRequestHandler extends RequestHandlerComposite
LoginEndpoint
,
LogoutEndpoint
Constructor and Description |
---|
AuthenticatedRequestHandler(SessionAuthenticator authenticator,
java.lang.String root)
Constructs the request handler.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getRoot()
Gets the root of this handler.
|
protected java.lang.String |
getSessionID(HTTPRequest request,
java.util.Map<java.lang.String,java.lang.String> attributes)
Retrieves the session ID from the cookies of the request.
|
protected boolean |
match(HTTPRequest request)
Determines whether or not the request matches this handler.
|
protected HTTPResponse |
onFailedAuthentication(HTTPRequest request,
java.util.Map<java.lang.String,java.lang.String> attributes)
Constructs the response upon failed authentication.
|
protected HTTPResponse |
onSuccessfulAuthentication(HTTPRequest request,
java.util.Map<java.lang.String,java.lang.String> attributes,
java.lang.String username,
java.lang.String sessionID)
Constructs the response upon successful authentication.
|
HTTPResponse |
process(HTTPRequest request,
java.util.Map<java.lang.String,java.lang.String> attributes)
Processes the request and creates the appropriate response, or null if this request handler doesn't match the
request.
|
addRequestHandler
public AuthenticatedRequestHandler(SessionAuthenticator authenticator, java.lang.String root)
authenticator
- the SessionAuthenticator
used to authenticate users.root
- the URI root used to match the request.public java.lang.String getRoot()
public HTTPResponse process(HTTPRequest request, java.util.Map<java.lang.String,java.lang.String> attributes)
RequestHandler
process
in interface RequestHandler
process
in class RequestHandlerComposite
request
- the HTTPRequest
to process.attributes
- the attributes of the request.HTTPResponse
to send, or null if not handled by this RequestHandler
.protected boolean match(HTTPRequest request)
The handler matches requests to URIs prefixed by the root path. Override this method to change the behavior.
request
- the request to match.true
true
if the request matches this handler, false
otherwise.protected java.lang.String getSessionID(HTTPRequest request, java.util.Map<java.lang.String,java.lang.String> attributes)
request
- the HTTPRequest
.attributes
- the attributes populated by the request processing.protected HTTPResponse onSuccessfulAuthentication(HTTPRequest request, java.util.Map<java.lang.String,java.lang.String> attributes, java.lang.String username, java.lang.String sessionID)
request
- the HTTPRequest
.attributes
- the attributes populated by the request processing.username
- the username of the authenticated user.sessionID
- the ID of the session.protected HTTPResponse onFailedAuthentication(HTTPRequest request, java.util.Map<java.lang.String,java.lang.String> attributes)
request
- the HTTPRequest
.attributes
- the attributes populated by the request processing.