Examples of ChangePasswordForm


Examples of com.adito.security.forms.ChangePasswordForm

    }

    public ActionForward onExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {

        ChangePasswordForm f = (ChangePasswordForm) form;
        UserDatabase udb = UserDatabaseManager.getInstance().getUserDatabase(getSessionInfo(request).getUser().getRealm());
        if (!udb.supportsPasswordChange()) {
            throw new Exception("Changing of passwords is not supported by the underlying user database.");
        }
        User user = LogonControllerFactory.getInstance().getUser(request);

        SessionInfo info = this.getSessionInfo(request);

        // Read in all of the confidential user attribute values
        Properties confidentialAttributes = new Properties();
        UserAttributes userAttributes = (UserAttributes) PropertyClassManager.getInstance().getPropertyClass(UserAttributes.NAME);
        for (PropertyDefinition def : userAttributes.getDefinitions()) {
            AttributeDefinition attrDef = (AttributeDefinition) def;
            if (attrDef.getVisibility() == AttributeDefinition.USER_CONFIDENTIAL_ATTRIBUTE) {
                confidentialAttributes.setProperty(def.getName(), attrDef.getPropertyClass()
                                .retrieveProperty(new UserAttributeKey(info.getUser(), def.getName())));
            }
        }

        try {

            // 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) {
View Full Code Here

Examples of com.adito.security.forms.ChangePasswordForm

        });
    }

    public ActionForward onExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {       
        ChangePasswordForm f = (ChangePasswordForm) form;
        ActionMessages messages = new ActionMessages();
        if (request.getSession().getAttribute(Constants.PASSWORD_CHANGE_REASON_MESSAGE) != null) {
            messages.add(Globals.MESSAGE_KEY, (ActionMessage) request.getSession().getAttribute(
                Constants.PASSWORD_CHANGE_REASON_MESSAGE));
        }
        try {
            messages.add(Globals.MESSAGE_KEY, new ActionMessage("changePassword.message.passwordPolicy",
              Property
                            .getProperty(new RealmKey("security.password.pattern.description", getSessionInfo(request).getUser()
                                            .getRealm().getResourceId()))));
        } catch (Exception e) {
            log.error("Failed to get password policy text.", e);
        }
        f.setReferer(getReferer(request));
        f.init(getSessionInfo(request).getUser().getPrincipalName());
        saveMessages(request, messages);
        CoreUtil.addRequiredFieldMessage(this, request);
        return mapping.findForward("success");

    }
View Full Code Here

Examples of org.jmanage.webui.forms.ChangePasswordForm

                                 ActionForm actionForm,
                                 HttpServletRequest request,
                                 HttpServletResponse response)
            throws Exception {

        ChangePasswordForm changePasswordForm = (ChangePasswordForm)actionForm;
        ActionErrors errors = new ActionErrors();

        /*Make sure that entered password is valid*/
        if(!Crypto.hash(changePasswordForm.getOldPassword()).equals
                (context.getUser().getPassword())){
            errors.add(ActionErrors.GLOBAL_ERROR,
                    new ActionError(ErrorCodes.INVALID_OLD_PASSWORD));
            request.setAttribute(Globals.ERROR_KEY, errors);
            return mapping.getInputForward();
        }

        /*Make sure that both entered passwords match */
        if(!changePasswordForm.getNewPassword().equals
                (changePasswordForm.getConfirmPassword())){
            errors.add(ActionErrors.GLOBAL_ERROR,
                    new ActionError(ErrorCodes.PASSWORD_MISMATCH));
            request.setAttribute(Globals.ERROR_KEY, errors);
            return mapping.getInputForward();
        }

        /* TODO: there is some odd behavior with this code - rk*/
        if(context.getUser().getName().equals(AuthConstants.USER_ADMIN)){
            /* re-encrypt the key */
            EncryptedKey encryptedKey = KeyManager.readKey(changePasswordForm.getOldPassword().toCharArray());
            encryptedKey.setPassword(changePasswordForm.getNewPassword().toCharArray());
            /* write the encryptedKey to the key file */
            KeyManager.writeKey(encryptedKey);
        }

        String username = context.getUser().getUsername();
        String password = changePasswordForm.getNewPassword();
        UserManager.getInstance().updatePassword(username, password);

        return mapping.findForward(Forwards.SUCCESS);

    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.