*/
logonStateMachine = new LogonStateAndCache(LogonStateAndCache.STATE_STARTED, request.getSession());
request.getSession().removeAttribute(Constants.AUTH_SESSION);
if(!Util.isNullOrTrimmedBlank(form.getUsername())) {
try {
User user = udb.getAccount(form.getUsername());
logonStateMachine.removeFromSpoofCache(user.getPrincipalName());
form.initUser();
try {
logonStateMachine.setUser(user);
}
catch(AccountLockedException ale) {
// Continue anyway and get the exception later
}
logonStateMachine.setState(LogonStateAndCache.STATE_DISPLAY_USERNAME_ENTERED);
}
catch(UserNotFoundException unfe) {
form.initUser();
// Spoof some authentication schemes
form.setHasMoreAuthenticationSchemes(true);
}
}
}
} else {
/*
* A username has been provided but it was unknown. The error message
* indicating this will not be displayed until the next stage is
* complete
*/
if (logonStateMachine.getState() == LogonStateAndCache.STATE_UNKNOWN_USERNAME) {
logonStateMachine.setState(LogonStateAndCache.STATE_UNKNOWN_USERNAME_PROMPT_FOR_PASSWORD);
}
else if (logonStateMachine.getState() == LogonStateAndCache.STATE_KNOWN_USERNAME_MULTIPLE_SCHEMES_SELECT){
/*
* The scheme to sign on with has changed, so we need to update the
* logon state machine.
*/
logonStateMachine.forceHighestPriorityScheme(request.getParameter("selectedAuthenticationScheme"),
request.getParameter("username"));
logonStateMachine.setState(LogonStateAndCache.STATE_KNOWN_USERNAME_MULTIPLE_SCHEMES);
} else if (logonStateMachine.getState() == LogonStateAndCache.STATE_KNOWN_USERNAME_NO_SCHEME_SPOOF_PASSWORD_ENTRY){
/*
* The scheme to sign on with has changed, so we need to update the
* logon state machine
*/
logonStateMachine.setSpoofedHighestPriorityScheme(request.getParameter("username"));
}
else if(logonStateMachine.getState() == LogonStateAndCache.STATE_DISPLAY_USERNAME_ENTRY){
/*
* The username has been collected, now process it.
*/
if(Util.isNullOrTrimmedBlank(form.getUsername())) {
/**
* Page refreshed, stay in same state
*/
logonStateMachine.setState(LogonStateAndCache.STATE_STARTED);
}
else {
logonStateMachine.setState(LogonStateAndCache.STATE_DISPLAY_USERNAME_ENTERED);
try {
User user = udb.getAccount(form.getUsername());
logonStateMachine.removeFromSpoofCache(user.getPrincipalName());
try {
logonStateMachine.setUser(user);
}
catch(AccountLockedException ale) {
// Continue anyway and get the exception later