Package com.adito.properties.impl.userattributes

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


    // Read in all of the confidential user attribute values

    /* BPS - Can only do this if the users key is currently loaded */

    Properties confidentialAttributes = new Properties();
    UserAttributes userAttributes = (UserAttributes) PropertyClassManager.getInstance().getPropertyClass(UserAttributes.NAME);
    if ("automatic".equals(Property.getProperty(new SystemConfigKey("security.privateKeyMode")))
            && 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


    /**
     * @throws Exception
     */
    @Test
    public void createUserAttributesDefinition() throws Exception {
        UserAttributes attribute = new UserAttributes();
        AttributeDefinition attributeDefinition = attribute.createAttributeDefinition(AttributeDefinition.TYPE_UNDEFINED, "AttributName", "typeMeta", -1, "categorylabel", "default value", AttributeDefinition.TYPE_UNDEFINED, 0, "", false, "Label", "Description", false, true, "");
        createAttributeDefinition(attribute, attributeDefinition);
        Assert.assertTrue("Should exist.", attribute.isDefinitionExists(attributeDefinition.getName()));
        deletAttributeDefinitionName(attribute, attributeDefinition.getName());
        Assert.assertFalse("Should not exist.", attribute.isDefinitionExists(attributeDefinition.getName()));
    }
View Full Code Here

    /**
     * @throws Exception
     */
    @Test
    public void createPolicyAttributesDefinition() throws Exception {
        UserAttributes attribute = new UserAttributes();
        AttributeDefinition attributeDefinition = attribute.createAttributeDefinition(AttributeDefinition.TYPE_UNDEFINED, "AttributName", "typeMeta", -1, "categorylabel", "default value", AttributeDefinition.TYPE_UNDEFINED, 0, "", false, "Label", "Description", false, true, "");
        createAttributeDefinition(attribute, attributeDefinition);
        Assert.assertTrue("Should exist.", attribute.isDefinitionExists(attributeDefinition.getName()));
        deletAttributeDefinitionName(attribute, attributeDefinition.getName());
        Assert.assertFalse("Should not exist.", attribute.isDefinitionExists(attributeDefinition.getName()));
    }
View Full Code Here

    /**
     * @throws Exception
     */
    @Test
    public void updateUserAttributeDefinitionName() throws Exception {
        UserAttributes attribute = new UserAttributes();
        AttributeDefinition attributeDefinition = attribute.createAttributeDefinition(AttributeDefinition.TYPE_UNDEFINED, "NewAttributName", "typeMeta", -1, "categorylabel", "default value", AttributeDefinition.TYPE_UNDEFINED, 0, "", false, "Label", "Description", false, true, "");
        createAttributeDefinition(attribute, attributeDefinition);
        Assert.assertTrue("Should exist.", attribute.isDefinitionExists(attributeDefinition.getName()));
        updateAttributeDefinition(attribute, attributeDefinition);
        deletAttributeDefinitionName(attribute, attributeDefinition.getName());
        Assert.assertFalse("Should not exist.", attribute.isDefinitionExists(attributeDefinition.getName()));
    }
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);
            fail("This should have failed");
        } catch (Exception e) {
            // ignore
View Full Code Here

    /**
     * @throws Exception
     */
    @Test
    public void deleteSystemUserAttributeDefinitionName() throws Exception {
        UserAttributes attribute = new UserAttributes();
        try {
            deletAttributeDefinitionName(attribute, "fathersFirstName");
            fail("This should have failed");
        } catch (Exception e) {
            // ignore
View Full Code Here

    /**
     * @throws Exception
     */
    @Test
    public void deleteNoExistingAttributeDefinition() throws Exception {
        UserAttributes attribute = new UserAttributes();
        try {
            deletAttributeDefinitionName(attribute, "none");
            fail("This should have failed");
        } catch (Exception e) {
            // ignore
View Full Code Here

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

                "false")));

            // Load the property classes
            PropertyClassManager.getInstance().registerPropertyClass(new ProfileProperties());
            PropertyClassManager.getInstance().registerPropertyClass(new SystemConfiguration());
            PropertyClassManager.getInstance().registerPropertyClass(new UserAttributes());
            PropertyClassManager.getInstance().registerPropertyClass(new PolicyAttributes());
            PropertyClassManager.getInstance().registerPropertyClass(new RealmProperties());
            PropertyClassManager.getInstance().registerPropertyClass(new ApplicationParameters());
            PropertyClassManager.getInstance().registerPropertyClass(new ResourceAttributes());
View Full Code Here

TOP

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

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.