// Change the password
udb.changePassword(user.getPrincipalName(), f.getOldPassword(), f.getNewPassword(), false);
PublicKeyStore publicKeyStore = PublicKeyStore.getInstance();
if ("automatic".equals(Property.getProperty(new SystemConfigKey("security.privateKeyMode")))) {
if (publicKeyStore.isPassphraseValid(user.getPrincipalName(), f.getOldPassword())) {
publicKeyStore.changePrivateKeyPassphrase(user.getPrincipalName(), f.getOldPassword(), f.getNewPassword());
publicKeyStore.removeCachedKeys(user.getPrincipalName());
publicKeyStore.verifyPrivateKey(user.getPrincipalName(), f.getNewPassword().toCharArray());
// Write back all of the confidential user attribute values
for (PropertyDefinition def : userAttributes.getDefinitions()) {
AttributeDefinition attrDef = (AttributeDefinition) def;
if (attrDef.getVisibility() == AttributeDefinition.USER_CONFIDENTIAL_ATTRIBUTE) {
Property.setProperty(new UserAttributeKey(info.getUser(), def.getName()), confidentialAttributes
.getProperty(def.getName()), info);
}
}
} else {
// if the keystore is out of sync, the only option is to remove the key
// this can happen if the password is changed natively
publicKeyStore.removeKeys(user.getPrincipalName());
CoreUtil.removePageInterceptListener(request.getSession(), "updatePrivateKeyPassphrase");
BundleActionMessage message = new BundleActionMessage("security", "resetPrivateKey.required.message");
GlobalWarningManager.getInstance().addToSession(new GlobalWarning(request.getSession(), message));
}
}
else {
publicKeyStore.removeCachedKeys(user.getPrincipalName());
}
CoreServlet.getServlet().fireCoreEvent(new CoreEvent(this,
CoreEventConstants.CHANGE_PASSWORD,
null,
info,