// check if we have a pre authenticated login from a previous login module
PreAuthenticatedLogin preAuthLogin = getSharedPreAuthLogin();
if (preAuthLogin != null) {
userId = preAuthLogin.getUserId();
Authentication authentication = new UserAuthentication(userId, getUserManager());
success = authentication.authenticate(UserAuthentication.PRE_AUTHENTICATED);
} else {
userId = getUserId();
Authentication authentication = new UserAuthentication(userId, getUserManager());
success = authentication.authenticate(credentials);
}
if (success) {
principals = getPrincipals(userId);