Package org.picketlink.idm.api

Examples of org.picketlink.idm.api.AttributesManager


   }

   public void persistUserInfo(User user, IdentitySession session) throws Exception
   {

      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()));
      }
      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 (IdentityException e)
            {
               log.info("Cannot update password: " + user.getUserName() + "; ", e);

            }
         }
      }

      Attribute[] attrs = new Attribute[attributes.size()];
      attrs = (Attribute[])attributes.toArray(attrs);

      try
      {
         am.updateAttributes(user.getUserName(), attrs);
      }
      catch (IdentityException e)
      {
         log.info("Cannot update attributes for user: " + user.getUserName() + "; ", e);
View Full Code Here


   }

   public static void populateUser(User user, IdentitySession session) throws Exception
   {

      AttributesManager am = session.getAttributesManager();

      Map<String, Attribute> attrs = null;

      try
      {
         attrs = am.getAttributes(user.getUserName());
      }
      catch (IdentityException e)
      {

         log.info("Cannot obtain attributes for user: " + user.getUserName() + "; ", e);
View Full Code Here

    }

    public void persistUserInfo(User user, IdentitySession session) {
        orgService.flush();

        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 (IdentityException e) {
                    handleException("Cannot update password: " + user.getUserName() + "; ", e);

                }
            }
        }

        Attribute[] attrs = new Attribute[attributes.size()];
        attrs = (Attribute[]) attributes.toArray(attrs);

        try {
            am.updateAttributes(user.getUserName(), attrs);
        } catch (IdentityException e) {
            handleException("Cannot update attributes for user: " + user.getUserName() + "; ", e);

        }
View Full Code Here

    }

    public void populateUser(User user, IdentitySession session) {
        orgService.flush();

        AttributesManager am = session.getAttributesManager();

        Map<String, Attribute> attrs = null;

        try {
            attrs = am.getAttributes(new SimpleUser(user.getUserName()));
        } catch (IdentityException e) {

            handleException("Cannot obtain attributes for user: " + user.getUserName() + "; ", e);

        }
View Full Code Here

   }

   public void persistUserInfo(User user, IdentitySession session) throws Exception
   {

      AttributesManager am = session.getAttributesManager();

      ArrayList attributes = new ArrayList();

      if (user.getCreatedDate() != null)
      {
         attributes.add(new SimpleAttribute(USER_CREATED_DATE, dateFormat.format(user.getCreatedDate())));
      }
      if (user.getLastLoginTime() != null)
      {
         attributes.add(new SimpleAttribute(USER_LAST_LOGIN_TIME, dateFormat.format(user.getLastLoginTime())));
      }
      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()));
      }
      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
         {
            am.updatePassword(session.getPersistenceManager().findUser(user.getUserName()), user.getPassword());
         }
      }

      Attribute[] attrs = new Attribute[attributes.size()];
      attrs = (Attribute[])attributes.toArray(attrs);
      am.addAttributes(user.getUserName(), attrs);
   }
View Full Code Here

      if (session.getPersistenceManager().findUser(userName) == null)
      {
         return null;
      }

      AttributesManager am = session.getAttributesManager();

      Map<String, Attribute> attrs = am.getAttributes(userName);

      User user = new UserImpl(userName);

      if (attrs == null)
      {
View Full Code Here

    }

    public void persistUserInfo(User user, IdentitySession session) {
        orgService.flush();

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

                }
            }
        }

        Attribute[] attrs = new Attribute[attributes.size()];
        attrs = (Attribute[]) attributes.toArray(attrs);

        try {
            am.updateAttributes(user.getUserName(), attrs);
        } catch (Exception e) {
            handleException("Cannot update attributes for user: " + user.getUserName() + "; ", e);

        }
View Full Code Here

    }

    public void populateUser(User user, IdentitySession session) {
        orgService.flush();

        AttributesManager am = session.getAttributesManager();

        Map<String, Attribute> attrs = null;

        try {
            attrs = am.getAttributes(new SimpleUser(user.getUserName()));
        } catch (Exception e) {

            handleException("Cannot obtain attributes for user: " + user.getUserName() + "; ", e);

        }
View Full Code Here

        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) {
            handleException("Cannot update enabled status for user: " + userName + "; ", e);
        }

        if (getIntegrationCache() != null) {
View Full Code Here

    }

    public void persistUserInfo(User user, IdentitySession session, boolean isNew) {
        orgService.flush();

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

                }
            }
        }

        Attribute[] attrs = new Attribute[attributes.size()];
        attrs = (Attribute[]) attributes.toArray(attrs);

        try {
            am.updateAttributes(user.getUserName(), attrs);
        } catch (Exception e) {
            handleException("Cannot update attributes for user: " + user.getUserName() + "; ", e);

        }
View Full Code Here

TOP

Related Classes of org.picketlink.idm.api.AttributesManager

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.