Package com.adito.properties.impl.userattributes

Examples of com.adito.properties.impl.userattributes.UserAttributeKey


        Date lastPasswordChange = isPasswordChangeAllowed(attributes) ? getPasswordLastSetDate(attributes) : new Date();
        ActiveDirectoryUser user = new ActiveDirectoryUser(username, userPrincipalName, defaultDomain, email, fullName, dn, getEscapedDn(dn), lastPasswordChange, getRealm());

        String homeDirectory = getAttributeValue(attributes, User.USER_ATTR_HOME_DIRECTORY);
        if (homeDirectory.length() != 0) {
            Property.setProperty(new UserAttributeKey(user, User.USER_ATTR_HOME_DIRECTORY), homeDirectory, null);
        }

        String homeDrive = getAttributeValue(attributes, User.USER_ATTR_HOME_DRIVE);
        if (homeDrive.length() != 0) {
            Property.setProperty(new UserAttributeKey(user, User.USER_ATTR_HOME_DRIVE), homeDrive, null);
        }

        ActiveDirectoryGroup[] groups = getGroups(user, attributes);
        if (logger.isDebugEnabled()) {
            logger.debug("User belongs to " + groups.length + " groups");
View Full Code Here


        // Update the attributes
        for(Iterator i = account.getAttributeValueItems().iterator(); i.hasNext(); ) {
           AttributeValueItem v = (AttributeValueItem)i.next();
           if(v.getDefinition().getVisibility() != AttributeDefinition.USER_CONFIDENTIAL_ATTRIBUTE) {
               Property.setProperty(new UserAttributeKey(user, v.getDefinition().getName()), v.getDefinition().formatAttributeValue(v.getValue()), info);
           }
        }
        // XXX HACK to ensure user attributes in memory are the same as persisted
        for(Iterator j = LogonControllerFactory.getInstance().getActiveSessions().entrySet().iterator(); j.hasNext(); ) {
            Map.Entry e = (Map.Entry)j.next();
View Full Code Here

            && PublicKeyStore.getInstance().hasLoadedKey(user.getPrincipalName())) {
      for (PropertyDefinition def : userAttributes.getDefinitions()) {
        AttributeDefinition attrDef = (AttributeDefinition) def;
        if (attrDef.getVisibility() == AttributeDefinition.USER_CONFIDENTIAL_ATTRIBUTE) {
          String val = attrDef.getPropertyClass()
          .retrieveProperty(new UserAttributeKey(user, def.getName()));
          if(val == null) {
            val = def.getDefaultValue();
          }
          confidentialAttributes.setProperty(def.getName(), val);
        }
      }
    }

    try {

      char[] creds = LogonControllerFactory.getInstance()
              .getPasswordFromCredentials((AuthenticationScheme) request.getSession()
                      .getAttribute(Constants.AUTH_SESSION));

      if (creds == null) {
                HttpSession httpSession = getSessionInfo(request).getHttpSession();
                httpSession.setAttribute("newUser", user);
                // as the form will be reset, we need to store the current values to be used later
                httpSession.setAttribute(SetPasswordForm.SAVED_PASSWORD, setPasswordForm.getConfirmPassword());
                httpSession.setAttribute(SetPasswordForm.SAVED_FORCE_PASSWORD_CHANGE, setPasswordForm.getForceChangePasswordAtLogon());
                String forwardTo = Util.urlEncode(CoreUtil.addParameterToPath(request.getServletPath(), "action", "commit"));
                return new ActionForward("/promptForSessionPassword.do?forwardTo=" + forwardTo, false);
      }

      udb.setPassword(user.getPrincipalName(),
        setPasswordForm.getNewPassword(),
        setPasswordForm.getForceChangePasswordAtLogon(),
        LogonControllerFactory.getInstance().getUser(request),
        new String(creds));

      /* Only attempt to re-encrypt user attributes if users key is loaded */
      if ("automatic".equals(Property.getProperty(new SystemConfigKey("security.privateKeyMode")))) {
        if(PublicKeyStore.getInstance().hasLoadedKey(user.getPrincipalName())) {
          PublicKeyStore.getInstance().removeKeys(user.getPrincipalName());
          PublicKeyStore.getInstance().verifyPrivateKey(user.getPrincipalName(), setPasswordForm.getNewPassword().toCharArray());
          for(Iterator i = confidentialAttributes.keySet().iterator(); i.hasNext(); ) {
            String n = (String)i.next();
            AttributeDefinition attrDef = (AttributeDefinition) userAttributes.getDefinition(n);
            if (attrDef.getVisibility() == AttributeDefinition.USER_CONFIDENTIAL_ATTRIBUTE) {
              Property.setProperty(new UserAttributeKey(user, n),
                confidentialAttributes.getProperty(n),
                info);
            }
          }
        }
View Full Code Here

        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

        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));
      }

        CoreUtil.removePageInterceptListener(request.getSession(), "changePersonalAnswers");
        return mapping.findForward("success");
    }
View Full Code Here

     */
    @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);
            fail("This should have failed");
        } catch (Exception e) {
            // ignore
View Full Code Here

     */
    @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);
        deleteAccount(user);
View Full Code Here

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

        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);
            String answer = Property.getProperty(new UserAttributeKey(user, def.getName()));
            personalAnswers.add(new PersonalAnswer(id, answer==null ? "" : answer, def.getLabel()));
        }
       
        f.initialize(personalAnswers);
        if (request.getSession().getAttribute(Constants.REQ_ATTR_PERSONAL_ANSWERS_CHANGE_REASON_MESSAGE) != null) {
View Full Code Here

        // Where next?
        List profiles = (List)request.getSession().getAttribute(Constants.PROFILES);
        int selectProfileAtLogin = -1;
        try {
          selectProfileAtLogin = Property.getPropertyInt(new UserAttributeKey(scheme.getUser(),  User.USER_STARTUP_PROFILE));
        }
        catch(NumberFormatException nfe) {
        }
        if (selectProfileAtLogin == -1 && profiles != null && profiles.size() > 1) {
            // Prompt for the profile
View Full Code Here

TOP

Related Classes of com.adito.properties.impl.userattributes.UserAttributeKey

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.