* @return forward
* @throws Exception
*/
public ActionForward commit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
UpdatePrivateKeyPassphraseForm f = (UpdatePrivateKeyPassphraseForm) form;
if (f.isResetPrivateKey()){
// user has opted to reset his key, this will mean all personal info will be lost.
PublicKeyStore.getInstance().removeKeys(getSessionInfo(request).getUser().getPrincipalName());
return cleanUpAndReturn(mapping, request, mapping.findForward("confirmReset"));
}
else{
/*
* Need to verify using the old password so the confidential
* user attributes can be decrypted
*/
try {
PublicKeyStore.getInstance().verifyPrivateKey(getSessionInfo(request).getUser().getPrincipalName(), f.getOldPassphrase().toCharArray());
} catch (UpdatePrivateKeyPassphraseException upkpe) {
// incorrect passphrase
ActionErrors errs = new ActionErrors();
errs.add(Globals.ERROR_KEY, new ActionMessage("updatePrivateKeyPassphrase.error.incorrectPassphrase"));
saveErrors(request.getSession(), errs);
return mapping.getInputForward();
}
/*
* Now change the passphrase
*/
PublicKeyStore.getInstance().changePrivateKeyPassphrase(
getSessionInfo(request).getUser().getPrincipalName(),
f.getOldPassphrase(),
new String(LogonControllerFactory.getInstance().getPasswordFromCredentials(
getSessionInfo(request).getCredentials())));
return cleanUpAndReturn(mapping, request, mapping.findForward("success"));
}
}