Search in sources :

Example 1 with UMChangeUserPasswordModel

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));
}
Also used : UMChangeUserPasswordModel(com.sun.identity.console.user.model.UMChangeUserPasswordModel) CCPassword(com.sun.web.ui.view.html.CCPassword)

Example 2 with UMChangeUserPasswordModel

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();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) UMChangeUserPasswordModel(com.sun.identity.console.user.model.UMChangeUserPasswordModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Aggregations

UMChangeUserPasswordModel (com.sun.identity.console.user.model.UMChangeUserPasswordModel)2 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)1 CCPassword (com.sun.web.ui.view.html.CCPassword)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1