if (userPrincipal != null && request.getParameter("continueSession") != null) {
// ### If already authenticated before, continue this session
// Execute protocol to signal container registered authentication session be used.
callbacks = new Callback[] { new CallerPrincipalCallback(clientSubject, userPrincipal) };
} else if (request.getParameter("doLogin") != null) {
// ### If not authenticated before, do a new login if so requested
// For the test perform a login by directly "returning" the details of the authenticated user.
// Normally credentials would be checked and the details fetched from some repository
callbacks = new Callback[] {
// The name of the authenticated user
new CallerPrincipalCallback(clientSubject, "test"),
// the roles of the authenticated user
new GroupPrincipalCallback(clientSubject, new String[] { "architect" }) };
// Tell container to register an authentication session.
messageInfo.getMap().put("javax.servlet.http.registerSession", TRUE.toString());
} else {
// ### If no registered session and no login request "do nothing"
// The JASPIC protocol for "do nothing"
callbacks = new Callback[] { new CallerPrincipalCallback(clientSubject, (Principal) null) };
}
try {
// Communicate the details of the authenticated user to the container. In many