* @return forward
* @throws Exception
*/
public ActionForward commit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
PromptForPrivateKeyPassphraseForm f = (PromptForPrivateKeyPassphraseForm) form;
SessionInfo session = getSessionInfo(request);
UserDatabase udb = UserDatabaseManager.getInstance().getUserDatabase(session.getUser().getRealm());
if(!udb.checkPassword(session.getUser().getPrincipalName(),
f.getPassphrase())) {
// User has entered incorrect passphrase - go back
ActionErrors errs = new ActionErrors();
errs.add(Globals.ERROR_KEY, new ActionMessage("promptForPrivateKeyPassphrase.error.incorrectPassphrase"));
saveErrors(request.getSession(), errs);
return mapping.getInputForward();
}
// Now check to see if the password has been added to the authentication scheme
AuthenticationScheme scheme = (AuthenticationScheme) getSessionInfo(request).getHttpSession().getAttribute(Constants.AUTH_SESSION);
if(LogonControllerFactory.getInstance().getPasswordFromCredentials(scheme)==null) {
// No so lets add it
scheme.addCredentials(new PasswordCredentials(getSessionInfo(request).getUser().getPrincipalName(), f.getPassphrase().toCharArray()));
}
try {
PublicKeyStore.getInstance().verifyPrivateKey(getSessionInfo(request).getUser().getPrincipalName(), f.getPassphrase().toCharArray());
}
catch(UpdatePrivateKeyPassphraseException upkpe) {
// LDP - This code was incorrectly adding a bad logon warning. What we actually have to
// do is redirect back again to the UpdatePrivateKeyPassphraseIntercerptListener