Package org.picketlink.idm.impl.api

Examples of org.picketlink.idm.impl.api.SimpleAttribute


            String attrValue = entry.getValue();
            // Treat empty strings as null (needed for compatibility with Oracle as Oracle always treats empty strings as null)
            if ("".equals(attrValue)) {
                attrValue = null;
            }
            attrs.add(new SimpleAttribute(entry.getKey(), attrValue));
        }

        Attribute[] attrArray = new Attribute[attrs.size()];
        attrArray = attrs.toArray(attrArray);
View Full Code Here


        }
        ((UserImpl) foundUser).setEnabled(enabled);
        if (broadcast)
            preSetEnabled(foundUser);

        Attribute[] attrs = new Attribute[] { new SimpleAttribute(USER_ENABLED, String.valueOf(enabled)) };

        AttributesManager am = session.getAttributesManager();
        try {
            am.updateAttributes(userName, attrs);
        } catch (Exception e) {
View Full Code Here

        AttributesManager am = session.getAttributesManager();

        ArrayList attributes = new ArrayList();

        if (user.getCreatedDate() != null) {
            attributes.add(new SimpleAttribute(USER_CREATED_DATE, "" + user.getCreatedDate().getTime()));
        }
        if (user.getLastLoginTime() != null) {
            attributes.add(new SimpleAttribute(USER_LAST_LOGIN_TIME, "" + user.getLastLoginTime().getTime()));
        }
        if (user.getEmail() != null) {
            attributes.add(new SimpleAttribute(USER_EMAIL, user.getEmail()));
        }
        if (user.getFirstName() != null) {
            attributes.add(new SimpleAttribute(USER_FIRST_NAME, user.getFirstName()));
        }
        if (user.getLastName() != null) {
            attributes.add(new SimpleAttribute(USER_LAST_NAME, user.getLastName()));
        }

        // TODO: GTNPORTAL-2358 Change once displayName will be available as part of Organization API
        if (user instanceof UserImpl) {
            UserImpl userImpl = (UserImpl) user;
            if (userImpl.getDisplayName() != null) {
                attributes.add(new SimpleAttribute(USER_DISPLAY_NAME, ((UserImpl) user).getDisplayName()));
            } else {
                removeDisplayNameIfNeeded(am, user);
            }

            if (isNew) {
                attributes.add(new SimpleAttribute(USER_ENABLED, Boolean.TRUE.toString()));
            }
        } else {
            log.warn("User is of class " + user.getClass() + " which is not instanceof " + UserImpl.class);
        }

        if (user.getOrganizationId() != null) {
            attributes.add(new SimpleAttribute(USER_ORGANIZATION_ID, user.getOrganizationId()));
        }
        if (user.getPassword() != null) {
            if (orgService.getConfiguration().isPasswordAsAttribute()) {
                attributes.add(new SimpleAttribute(USER_PASSWORD, user.getPassword()));
            } else {
                try {
                    am.updatePassword(session.getPersistenceManager().findUser(user.getUserName()), user.getPassword());
                } catch (Exception e) {
                    handleException("Cannot update password: " + user.getUserName() + "; ", e);
View Full Code Here

            List<IdentityObjectAttribute> attribs = new ArrayList<IdentityObjectAttribute>();
            for (String key : attributes.keySet())
            {
               for (String value : attributes.get(key))
               {
                  attribs.add(new SimpleAttribute(key, value));
               }
            }
           
            updateAttributes(ctx, obj, attribs.toArray(new IdentityObjectAttribute[attribs.size()]));
         }
View Full Code Here

      if (attributeProperty != null)
      {
         // TODO implement attribute search for attributes scattered across the model
        
        
         return new SimpleAttribute(name);
      }
      else
      {
         // If there is no attributeClass set, we have nowhere else to look - return an empty attribute
         if (attributeClass == null) return new SimpleAttribute(name);
        
         Property<?> attributeIdentityProp = modelProperties.get(PROPERTY_ATTRIBUTE_IDENTITY);
         Property<?> attributeNameProp = modelProperties.get(PROPERTY_ATTRIBUTE_NAME);
         Property<?> attributeValueProp = modelProperties.get(PROPERTY_ATTRIBUTE_VALUE);
        
         CriteriaBuilder builder = em.getCriteriaBuilder();
         CriteriaQuery<?> criteria = builder.createQuery(attributeClass);
         Root<?> root = criteria.from(attributeClass);
        
         List<Predicate> predicates = new ArrayList<Predicate>();
         predicates.add(builder.equal(root.get(attributeIdentityProp.getName()),
               lookupIdentity(identity, em)));
         predicates.add(builder.equal(root.get(attributeNameProp.getName()),
               name));
        
         criteria.where(predicates.toArray(new Predicate[predicates.size()]));
        
         List<?> results = em.createQuery(criteria).getResultList();
        
         if (results.size() == 0)
         {
            // No results found, return an empty attribute value
            return new SimpleAttribute(name);           
         }
         else if (results.size() == 1)
         {
            return new SimpleAttribute(name, attributeValueProp.getValue(results.get(0)));
         }
         else
         {
            Collection<Object> values = new ArrayList<Object>();
            for (Object result : results)
            {
               values.add(attributeValueProp.getValue(result));              
            }
           
            return new SimpleAttribute(name, values.toArray());
         }
      }
   }
View Full Code Here

               IdentityObjectAttribute attr = attributes.get(name);
               attr.addValue(value);
            }
            else
            {
               attributes.put(name, new SimpleAttribute(name, value));
            }
         }
      }
     
      return attributes;
View Full Code Here

            identitySession.getRoleManager().createRole(role.getRoleType(), user, role.getGroup());
         }
      }
     
      identitySession.getAttributesManager().updateAttributes(user,
            new Attribute[] {new SimpleAttribute(ATTRIBUTE_NAME_USER_ENABLED, enabled)});

      conversation.end();
      return "success";
   }
View Full Code Here

                identitySession.getRoleManager().createRole(role.getRoleType(), user, role.getGroup());
            }
        }

        identitySession.getAttributesManager().updateAttributes(user,
                new Attribute[]{new SimpleAttribute(ATTRIBUTE_NAME_USER_ENABLED, enabled)});

        conversation.end();
        return "success";
    }
View Full Code Here

        AttributesManager am = session.getAttributesManager();

        ArrayList attributes = new ArrayList();

        if (user.getCreatedDate() != null) {
            attributes.add(new SimpleAttribute(USER_CREATED_DATE, "" + user.getCreatedDate().getTime()));
        }
        if (user.getLastLoginTime() != null) {
            attributes.add(new SimpleAttribute(USER_LAST_LOGIN_TIME, "" + user.getLastLoginTime().getTime()));
        }
        if (user.getEmail() != null) {
            attributes.add(new SimpleAttribute(USER_EMAIL, user.getEmail()));
        }
        if (user.getFirstName() != null) {
            attributes.add(new SimpleAttribute(USER_FIRST_NAME, user.getFirstName()));
        }
        if (user.getLastName() != null) {
            attributes.add(new SimpleAttribute(USER_LAST_NAME, user.getLastName()));
        }

        // TODO: GTNPORTAL-2358 Change once displayName will be available as part of Organization API
        if (user instanceof UserImpl) {
            UserImpl userImpl = (UserImpl) user;
            if (userImpl.getDisplayName() != null) {
                attributes.add(new SimpleAttribute(USER_DISPLAY_NAME, ((UserImpl) user).getDisplayName()));
            } else {
                removeDisplayNameIfNeeded(am, user);
            }
        } else {
            log.warn("User is of class " + user.getClass() + " which is not instanceof " + UserImpl.class);
        }

        if (user.getOrganizationId() != null) {
            attributes.add(new SimpleAttribute(USER_ORGANIZATION_ID, user.getOrganizationId()));
        }
        if (user.getPassword() != null) {
            if (orgService.getConfiguration().isPasswordAsAttribute()) {
                attributes.add(new SimpleAttribute(USER_PASSWORD, user.getPassword()));
            } else {
                try {
                    am.updatePassword(session.getPersistenceManager().findUser(user.getUserName()), user.getPassword());
                } catch (Exception e) {
                    handleException("Cannot update password: " + user.getUserName() + "; ", e);
View Full Code Here

            String attrValue = entry.getValue();
            // Treat empty strings as null (needed for compatibility with Oracle as Oracle always treats empty strings as null)
            if ("".equals(attrValue)) {
                attrValue = null;
            }
            attrs.add(new SimpleAttribute(entry.getKey(), attrValue));
        }

        Attribute[] attrArray = new Attribute[attrs.size()];
        attrArray = attrs.toArray(attrArray);
View Full Code Here

TOP

Related Classes of org.picketlink.idm.impl.api.SimpleAttribute

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.