use of com.sun.identity.console.user.model.UMChangeUserPasswordModel in project OpenAM by OpenRock.
the class UMChangeUserPasswordViewBean method beginDisplay.
public void beginDisplay(DisplayEvent event) throws ModelControlException {
super.beginDisplay(event);
UMChangeUserPasswordModel model = (UMChangeUserPasswordModel) getModel();
String userId = (String) getPageSessionAttribute(EntityEditViewBean.UNIVERSAL_ID);
if (userId == null) {
userId = model.getUserName();
}
String loggedinUser = model.getUserName();
//is same as logged in user
if (model.isOldPasswordRequired() && LDAPUtils.rdnValueFromDn(userId).equalsIgnoreCase(LDAPUtils.rdnValueFromDn(loggedinUser))) {
oldapicall = false;
} else {
CCPassword pwdtag = (CCPassword) getChild(ATTR_OLD_PASSWORD);
pwdtag.setDisabled(true);
oldapicall = true;
}
String[] arg = { AMFormatUtils.getIdentityDisplayName(model, userId) };
ptModel.setPageTitleText(MessageFormat.format(model.getLocalizedString("page.title.user.change.password"), (Object[]) arg));
}
use of com.sun.identity.console.user.model.UMChangeUserPasswordModel in project OpenAM by OpenRock.
the class UMChangeUserPasswordViewBean method handleButton1Request.
/**
* Handles save password options request.
*
* @param event Request invocation event.
* @throws ModelControlException if action table model state cannot be
* restored.
*/
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
submitCycle = true;
HttpServletRequest req = event.getRequestContext().getRequest();
String formToken = req.getParameter(FORM_TOKEN);
if (formToken == null || formToken.isEmpty() || !formToken.equals(getFormToken())) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", "Invalid form token");
forwardTo();
return;
}
UMChangeUserPasswordModel model = (UMChangeUserPasswordModel) getModel();
String userId = (String) getPageSessionAttribute(EntityEditViewBean.UNIVERSAL_ID);
if (userId == null) {
userId = model.getUserName();
}
String pwd = (String) propertySheetModel.getValue(ATTR_PASSWORD);
String reenter = (String) propertySheetModel.getValue(REENTER_PASSWORD);
String oldPwd = (String) propertySheetModel.getValue(ATTR_OLD_PASSWORD);
pwd = pwd.trim();
reenter = reenter.trim();
if (pwd.length() == 0) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", "user.change.password.missing.password.message");
} else if (!pwd.equals(reenter)) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", "user.change.password.mismatch.password.message");
} else {
if (!oldapicall) {
if (oldPwd.length() == 0) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", "user.change.password.missing.old.password.message");
} else {
try {
//change password after validating old password
model.changePwd(userId, oldPwd, pwd);
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "user.change.password.modified.password.message");
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
}
}
} else {
try {
model.changePassword(userId, pwd);
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "user.change.password.modified.password.message");
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
}
}
}
forwardTo();
}
Aggregations