Package com.adito.security

Examples of com.adito.security.User


     */
    public ActionForward confirmResetPrivateKey(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
        String[] accounts = request.getParameterValues("username");
        if (accounts != null && accounts.length == 1) {
            int resourceId = getSessionInfo(request).getUser().getRealm().getResourceId();
            User account = UserDatabaseManager.getInstance().getUserDatabase(resourceId).getAccount(accounts[0]);
            request.getSession().setAttribute(Constants.EDITING_ITEM, account);
            return mapping.findForward("confirmResetPrivateKey");
        }
        return list(mapping, form, request, response);
    }
View Full Code Here


     * @param response
     * @return forward
     * @throws Exception
     */
    public ActionForward resetPrivateKey(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
        User user = (User) request.getSession().getAttribute(Constants.EDITING_ITEM);
        PolicyUtil.checkPermission(PolicyConstants.ACCOUNTS_AND_GROUPS_RESOURCE_TYPE, PolicyConstants.PERM_CREATE_EDIT_AND_ASSIGN, request);
        PropertyClass propertyClass = PropertyClassManager.getInstance().getPropertyClass(UserAttributes.NAME);
        /* We must delete all confidential attribute values */
        for (PropertyDefinition propertyDefinition : propertyClass.getDefinitions()) {
            AttributeDefinition attributeDefinition = (AttributeDefinition) propertyDefinition;
            if (attributeDefinition.getVisibility() == AttributeDefinition.USER_CONFIDENTIAL_ATTRIBUTE) {
                Property.setProperty(new UserAttributeKey(user, attributeDefinition.getName()), (String) null, getSessionInfo(request));
            }
        }
        PublicKeyStore.getInstance().removeKeys(user.getPrincipalName());
        return list(mapping, form, request, response);
    }
View Full Code Here

    public ActionForward onExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
     
        PersonalAnswersForm f = (PersonalAnswersForm) form;
        User user = LogonControllerFactory.getInstance().getUser(request);
       
      PersonalAnswer answer;
      for(Iterator it = f.getPersonalAnswers().iterator(); it.hasNext();) {
        answer = (PersonalAnswer) it.next();
            Property.setProperty(new UserAttributeKey(user, answer.getId()), answer.getAnswer(), getSessionInfo(request));
View Full Code Here

    /**
     * @throws Exception
     */
    @Test
    public void updateSystemUserAttributeDefinitionName() throws Exception {
        User user = createAccount();
        UserAttributes attribute = new UserAttributes();
        UserAttributeKey attributeKey = new UserAttributeKey(user, "fathersFirstName");
        AttributeDefinition attributeDefinition = (AttributeDefinition)attribute.getDefinition(attributeKey.getName());
        try {
            updateAttributeDefinition(attribute, attributeDefinition);
View Full Code Here

     * @throws Exception
     */
    @Test
    public void storeAndRetrieveUserAttributeValue() throws Exception {
        String value = "new value";
        User user = createAccount();
        UserAttributeKey key = new UserAttributeKey(user, "newKey");
        propertyDatabase.storeAttributeValue(key, value);
        String retrievedValue = propertyDatabase.retrieveAttributeValue(key);
        Assert.assertEquals("Attribute value should be this one.", value, retrievedValue);
        propertyDatabase.storeAttributeValue(key, null);
View Full Code Here

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

    @Test
    public void attachDetachPolicyToUser() throws Exception {
        Realm realm = getUserService().getDefaultRealm();
        Policy policy = createPolicy(realm);
        int users = getUserService().getDefaultUserDatabase().listAllUsers(UserDatabase.WILDCARD_SEARCH, Integer.MAX_VALUE).length;
        User user = createAccount();
        assertEquals(
            getUserService().getDefaultUserDatabase().listAllUsers(UserDatabase.WILDCARD_SEARCH, Integer.MAX_VALUE).length,
            users + 1);
        getPolicyService().grantPolicyToPrincipal(policy, user);
        assertTrue("The policy should be granted", PolicyDatabaseFactory.getInstance().isPolicyGrantedToUser(policy, user));
View Full Code Here

     */
    @Test
    public void attachDetachPolicyToRole() throws Exception {
        Realm realm = getUserService().getDefaultRealm();
        Policy policy = createPolicy(realm);
        User user = createAccount();
        Role role = createRole("Group1");
        user = updateAccountRoles(user, Collections.singleton(role));
        getPolicyService().grantPolicyToPrincipal(policy, role);
        assertTrue("The policy should be granted", PolicyDatabaseFactory.getInstance().isPolicyGrantedToUser(policy, user));
        getPolicyService().revokePolicyFromPrincipal(policy, role);
View Full Code Here

            if (f.getReferer() == null) {
                f.setReferer(CoreUtil.getReferer(request));
            }
        }
        List<PersonalAnswer> personalAnswers = new ArrayList<PersonalAnswer>();
        User user = LogonControllerFactory.getInstance().getUser(request);
        AttributeDefinition def;
        for (int i = 0; i < PersonalQuestionsAuthenticationModule.SECURITY_QUESTIONS.length; i++) {
         
            String id = PersonalQuestionsAuthenticationModule.SECURITY_QUESTIONS[i];
            def = (AttributeDefinition)PropertyClassManager.getInstance().getPropertyClass(UserAttributes.NAME).getDefinition(id);
View Full Code Here

                }
            }
        }
       
        for (String principalName : selectedUsers) {
            User user = userDatabase.getAccount(principalName);
            Role[] updatedRoles = addRole(role, user.getRoles());
            userDatabase.updateAccount(user, user.getEmail(), user.getFullname(), updatedRoles);
        }
        return usersNotRemoved.toArray(new String[usersNotRemoved.size()]);
    }
View Full Code Here

TOP

Related Classes of com.adito.security.User

Copyright © 2018 www.massapicom. 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.