Examples of HibernateUserImpl


Examples of org.jboss.portal.identity.db.HibernateUserImpl

      if (propertyName == null)
      {
         throw new IllegalArgumentException("Property name need to have value");
      }

      HibernateUserImpl dbUser = processUser(user);

      PropertyInfo pi = getProfileInfo().getPropertyInfo(propertyName);

      if (pi == null)
      {
         throw new IdentityException("Cannot find profile information about property: " + propertyName);
      }

      return dbUser.getProfileMap().get(propertyName);
   }
View Full Code Here

Examples of org.jboss.portal.identity.db.HibernateUserImpl

      if (propertyName == null)
      {
         throw new IllegalArgumentException("Property name need to have value");
      }

      HibernateUserImpl dbUser = processUser(user);


      PropertyInfo pi = getProfileInfo().getPropertyInfo(propertyName);

      if (pi == null)
      {
         throw new IdentityException("Cannot find profile information about property: " + propertyName);
      }
      else if (!pi.getAccessMode().equals(PropertyInfo.ACCESS_MODE_READ_WRITE))
      {
         throw new IdentityException("Property is not allowed for write access: " + propertyName);
      }

      if (propertyValue != null && !pi.getType().equals(propertyValue.getClass().getName()))
      {
         throw new IdentityException("Wrong property type. Must be: " + pi.getType() + "; and found: " + propertyValue.getClass().getName());
      }

      //if value is null reset property

      if (propertyValue != null)
      {
         dbUser.getProfileMap().put(propertyName, propertyValue);
      }
      else
      {
         dbUser.getProfileMap().remove(propertyName);
      }
      fireUserProfileChangedEvent(user.getId(), user.getUserName(), propertyName, propertyValue);
   }
View Full Code Here

Examples of org.jboss.portal.identity.db.HibernateUserImpl

      if (user == null)
      {
         throw new IllegalArgumentException("User cannot be null");
      }

      HibernateUserImpl dbUser = processUser(user);



      //make a copy
      Map props = new HashMap();
      Map profile = dbUser.getProfileMap();
      Set keys = profile.keySet();
      for (Iterator iterator = keys.iterator(); iterator.hasNext();)
      {
         String key = (String)iterator.next();
         props.put(key, profile.get(key));
View Full Code Here

Examples of org.jboss.portal.identity.db.HibernateUserImpl

      //if not Hibernate user try to obtain it using userName
      Session session = getCurrentSession();
      Query query = session.createQuery("from HibernateUserImpl where userName=:userName");
      query.setParameter("userName", user.getUserName());
      query.setCacheable(true);
      HibernateUserImpl hu = (HibernateUserImpl)query.uniqueResult();

      if (hu != null )
      {
         return hu;
      }
      else if (!isSynchronizeNonExistingUsers())
      {
         throw new IdentityException("No user in DB - set synchronizeNonExistingUsers option to true");
      }
      else
      {
         try
         {
            hu = new HibernateUserImpl(user.getUserName());
            //user.updatePassword(user.getPassword());
            if (defaultSynchronizePassword != null)
            {
               hu.updatePassword(getDefaultSynchronizePassword());
            }
            //really dummy password generation
            //TODO: make something more sophisticated (risk of this part is documented)
            else if (randomSynchronizePassword)
            {
               Random r = new Random();
               StringBuffer password = new StringBuffer();
               for (int i = 0; i < 10; i++)
               {
                  password.append(r.nextDouble());
               }
               hu.updatePassword(password.toString());
            }
            session = getCurrentSession();

            //so if we synchronize from LDAP lets make the user enabled
            if (isEnableSynchronizedUsers())
            {
               hu.setEnabled(true);
            }
            session.save(hu);

            return hu;
         }
View Full Code Here

Examples of org.jboss.portal.identity.db.HibernateUserImpl

      {
         throw new IllegalArgumentException("User is not a HibernateUserImpl user");
      }

      // We return an immutable set to avoid modifications
      HibernateUserImpl ui = (HibernateUserImpl)user;
      Set roles = ui.getRoles();
      Set copy = new HashSet();
      for (Iterator iterator = roles.iterator(); iterator.hasNext();)
      {
         HibernateRoleImpl role = (HibernateRoleImpl)iterator.next();
         copy.add(role);
View Full Code Here

Examples of org.jboss.portal.identity.db.HibernateUserImpl

      HibernateRoleImpl ri = (HibernateRoleImpl)role;
      Set users = ri.getUsers();
      Set copy = new HashSet();
      for (Iterator iterator = users.iterator(); iterator.hasNext();)
      {
         HibernateUserImpl user = (HibernateUserImpl)iterator.next();
         copy.add(user);
      }

      return Collections.unmodifiableSet(copy);
   }
View Full Code Here

Examples of org.jboss.portal.identity.db.HibernateUserImpl

            }
         }

         if (o instanceof HibernateUserImpl)
         {
            HibernateUserImpl user = (HibernateUserImpl)o;
            user.getRoles().add(role);
         }
         else
         {
            throw new IllegalArgumentException("Only HibernateUserImpl users can be accepted");
         }
View Full Code Here

Examples of org.jboss.portal.identity.db.HibernateUserImpl

            throw new IllegalArgumentException("Only HibernateRoleImpl roles can be accepted");
         }
      }

      // Assign new roles
      HibernateUserImpl ui = (HibernateUserImpl)user;
      ui.setRoles(copy);

      fireMembershipChangedEvent(user, roles);
   }
View Full Code Here

Examples of org.jboss.portal.identity.db.HibernateUserImpl

            Session session = getCurrentSession();
            HibernateRoleImpl role = (HibernateRoleImpl)session.load(HibernateRoleImpl.class, (Long)id);
            Iterator users = role.getUsers().iterator();
            while (users.hasNext())
            {
               HibernateUserImpl user = (HibernateUserImpl)users.next();
               user.getRoles().remove(role);
            }

            String name = role.getName();

            session.delete(role);
View Full Code Here

Examples of org.jboss.portal.identity.db.HibernateUserImpl

            throw new IllegalArgumentException("Only db roles can be accepted");
         }
      }

      // Assign new roles
      HibernateUserImpl ui = (HibernateUserImpl)user;
      ui.setRoles(copy);
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.