* @return forward
* @throws Exception
*/
public ActionForward commit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
PromptForSessionPasswordForm pfspf = (PromptForSessionPasswordForm) form;
AuthenticationScheme scheme = (AuthenticationScheme) getSessionInfo(request).getHttpSession().getAttribute(Constants.AUTH_SESSION);
try {
SessionInfo session = getSessionInfo(request);
UserDatabase udb = UserDatabaseManager.getInstance().getUserDatabase(session.getUser().getRealm());
String username = session.getUser().getPrincipalName();
if (!udb.checkPassword(username, pfspf.getPassword())) {
throw new Exception("Incorrect password.");
}
scheme.addCredentials(new PasswordCredentials(username, pfspf.getPassword().toCharArray()));
request.setAttribute(Constants.REQ_ATTR_FORWARD_TO, ((PromptForSessionPasswordForm)form).getForwardTo());
request.setAttribute(Constants.REQ_ATTR_TARGET, ((PromptForSessionPasswordForm)form).getTarget());
request.setAttribute(Constants.REQ_ATTR_FOLDER, ((PromptForSessionPasswordForm)form).getFolder());
return mapping.findForward("redirect");
} catch (InvalidLoginCredentialsException e) {