session.setNote(Constants.SESS_USERNAME_NOTE, username);
session.setNote(Constants.SESS_PASSWORD_NOTE, password);
request.setUserPrincipal(principal);
if (enableAudit) {
PicketLinkAuditEvent auditEvent = new PicketLinkAuditEvent(AuditLevel.INFO);
auditEvent.setType(PicketLinkAuditEventType.RESPONSE_FROM_IDP);
auditEvent.setSubjectName(username);
auditEvent.setWhoIsAuditing(getContextPath());
auditHelper.audit(auditEvent);
}
// Redirect the user to the originally requested URL
if (saveRestoreRequest) {
// Store the authenticated principal in the session.
session.setNote(Constants.FORM_PRINCIPAL_NOTE, principal);
// Redirect to the original URL. Note that this will trigger the
// authenticator again, but on resubmission we will look in the
// session notes to retrieve the authenticated principal and
// prevent reauthentication
String requestURI = savedRequestURL(session);
logger.trace("Redirecting back to original Request URI: " + requestURI);
if (requestURI == null) {
requestURI = getConfiguration().getServiceURL();
}
response.sendRedirect(response.encodeRedirectURL(requestURI));
return false;
}
register(request, response, principal, Constants.FORM_METHOD, username, password);
return true;
}
} catch (ProcessingException pe) {
Throwable t = pe.getCause();
if (t != null && t instanceof AssertionExpiredException) {
logger.error("Assertion has expired. Asking IDP for reissue");
if (enableAudit) {
PicketLinkAuditEvent auditEvent = new PicketLinkAuditEvent(AuditLevel.INFO);
auditEvent.setType(PicketLinkAuditEventType.EXPIRED_ASSERTION);
auditEvent.setAssertionID(((AssertionExpiredException) t).getId());
auditHelper.audit(auditEvent);
}
// Just issue a fresh request back to IDP
return generalUserRequest(request, response, loginConfig);
}