Package org.jboss.portal.identity

Examples of org.jboss.portal.identity.IdentityException


      {
         membershipModule = (MembershipModule)new InitialContext().lookup(membershipModuleJNDIName);
      }
      if (membershipModule == null)
      {
         throw new IdentityException("Cannot obtain MembershipModule using JNDI name:" + membershipModuleJNDIName);
      }
      return membershipModule;
   }
View Full Code Here


      {
         userProfileModule = (UserProfileModule)new InitialContext().lookup(userProfileModuleJNDIName);
      }
      if (userProfileModule == null)
      {
         throw new IdentityException("Cannot obtain UserProfileModule using JNDI name:" + userProfileModuleJNDIName);
      }
      return userProfileModule;
   }
View Full Code Here

            return new InitialLdapContext(env, null);
         }
      }
      catch (NamingException e)
      {
         throw new IdentityException("Unable to connect to LDAP: " + this, e);
         //return null;
      }

   }
View Full Code Here

   public void start() throws Exception
   {
      if (getConnectionJNDIName() == null)
      {
         throw new IdentityException("Cannot obtain ldap connection context JNDI name");
      }
      try
      {
         connectionContext = (LDAPConnectionContext)new InitialContext().lookup(getConnectionJNDIName());
      }
View Full Code Here

   protected LDAPConnectionContext getConnectionContext() throws IdentityException
   {
      if (connectionContext == null)
      {
         //this.connectionContext = (LDAPConnectionContext)getIdentityContext().getObject(IdentityContext.TYPE_CONNECTION_CONTEXT);
         throw new IdentityException("No LDAPConnectionContext available");
      }
      return connectionContext;
   }
View Full Code Here

      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

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

         {
            user = getUserModule().findUserById(user.getId());
         }
         catch(NoSuchUserException e)
         {
            throw new IdentityException("Illegal state - cached user doesn't exist in identity store: ", e);
         }
      }

      if (user instanceof HibernateUserImpl)
      {
         return (HibernateUserImpl)user;
      }
      else if (!isAcceptOtherImplementations())
      {
         throw new IllegalArgumentException("This UserProfileModule implementation support only HibenrateUserImpl objects - set acceptOtherImplementations option to true");
      }
      if (log.isDebugEnabled()) log.debug("Processing non HibernateUserImpl object: " + user.getClass());
      //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;
         }
         catch (HibernateException e)
         {
            String message = "Cannot create user " + user.getUserName();
            log.error(message, e);
            throw new IdentityException(message, e);
         }
      }


   }
View Full Code Here

      {
         //obtain main UserProfileModule
         UserProfileModule module = (UserProfileModule)getIdentityContext().getObject(IdentityContext.TYPE_USER_PROFILE_MODULE);
         if (module == this)
         {
            throw new IdentityException("ProfileInfo not accessible - check configuration");
         }
         else
         {
            setProfileInfo(module.getProfileInfo());
         }
View Full Code Here

         {
            this.userModule = (UserModule)getIdentityContext().getObject(IdentityContext.TYPE_USER_MODULE);
         }
         catch (ClassCastException e)
         {
            throw new IdentityException("Not supported object as part of the context - must be UserModule", e);
         }
      }
      return userModule;
   }
View Full Code Here

TOP

Related Classes of org.jboss.portal.identity.IdentityException

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.