Authentication request/response handler.
The handler reads an authentication request and
parses the request message when parseRequest() is called.
It generates an Authentication Token object when getRequest().generateAuthToken() is called, and
sends an authentication response.
If AuthenticationRequestMessage.generateAuthToken() is not called before close(),
an authentication failure error code is sent.
AuthenticationHandler handler = new AuthenticationHandler(config, inputStream, outputStream);
try {
handler.parseRequest();
AuthenticationRequestMessage request = handler.getRequest();
AuthenticationData authData = request.getUserCredentials();
if (authData instanceof UserPassAuthenticationData) {
// Determine if username/password are valid
// If so, request.generateAuthToken(), if not request.setErrorData()
}
} catch (HandlerParsingException e) {
// Use e.getErrorData() for info on the error which will be sent to the user
// Do not attempt to call any handler methods except close()
} finally {
// Always call close in a finally statement to ensure a response is sent to the client
handler.close();
}
Constructor Summary
AuthenticationHandler(HandlerConfiguration handlerConfig,
java.io.InputStream in,
java.io.OutputStream out)
Instantiates a Flash Access handler for authentication requests and responses.
public AuthenticationHandler(HandlerConfiguration handlerConfig,
java.io.InputStream in,
java.io.OutputStream out)
Instantiates a Flash Access handler for authentication requests and responses.
The handler reads an authentication request and
sends an authentication response when the close() method is called.
handlerConfig must contain the server's credentials, which are used for decrypting requests, signing authentication tokens, and signing responses.