// Create the authentication request from parameters.
AuthenticationToken token =
handleRequest(
request,
response,
new AuthenticationRequest(username, password));
// Add a cookie for the authentication token.
Cookie cookie =
new Cookie(PARAM_AUTHENTICATION_AUTH_TOKEN, token.getToken());
// Set the expiration on the cookie.