Package org.jboss.portal.identity

Examples of org.jboss.portal.identity.IdentityException


   public User createUser(String userName, String password) throws IdentityException, IllegalArgumentException
   {

      if (userName == null)
      {
         throw new IdentityException("User name cannot be null");
      }
      /*if (realEmail == null)
      {
         throw new IdentityException("User email cannot be null");
      }*/
      if (password == null)
      {
         throw new IdentityException("User password cannot be null");
      }

      log.debug("Creating user: " + userName);


      LdapContext ldapContext = getConnectionContext().createInitialContext();

      try
      {
         //
         LdapContext ctx = (LdapContext)ldapContext.lookup(getContainerDN());

         //We store new entry using set of attributes. This should give more flexibility then
         //extending user object from ContextDir - configure what objectClass place there
         Attributes attrs = new BasicAttributes(true);

         //create attribute using provided configuration
         Map attributesToAdd = getAttributesToAdd();

         //attributes
         for (Iterator it1 = attributesToAdd.keySet().iterator(); it1.hasNext();)
         {
            String attributeName = (String)it1.next();
            log.debug("adding attribute: " + attributeName);
            Attribute attr = new BasicAttribute(attributeName);
            Set attributeValues = (Set)attributesToAdd.get(attributeName);

            //values
            for (Iterator it2 = attributeValues.iterator(); it2.hasNext();)
            {
               String attrValue = (String)it2.next();
               log.debug("adding attribute value: " + attrValue);
               attr.add(attrValue);
            }
            attrs.put(attr);
         }

         attrs.put(getPasswordAttributeId(), password);


         String validUserName = LDAPTools.encodeRfc2253Name(userName);

         String dn = getUidAttributeID().concat("=").concat(validUserName);

         log.debug("creating ldap entry for: " + dn + "; " + attrs);
         ctx.createSubcontext(dn, attrs);
      }
      catch (Exception e)
      {
         throw new IdentityException("Failed to create user", e);
      }
      finally
      {
         try
         {
            ldapContext.close();
         }
         catch (NamingException e)
         {
            throw new IdentityException("Failed to close LDAP connection", e);
         }
      }
      User u =  findUserByUserName(userName);


View Full Code Here


      String userName = ldapu.getUserName();

      if (ldapu == null)
      {
         throw new IdentityException("Cannot find user for removal");
      }

      if (ldapu.getDn() == null)
      {
         throw new IdentityException("Cannot obtain DN of user");
      }

      LdapContext ldapContext = getConnectionContext().createInitialContext();

      try
      {
         log.debug("removing entry: " + ldapu.getDn());
         ldapContext.unbind(ldapu.getDn());
      }
      catch (Exception e)
      {
         throw new IdentityException("Failed to remove user: ", e);
      }
      finally
      {
         try
         {
            ldapContext.close();
         }
         catch (NamingException e)
         {
            throw new IdentityException("Failed to close LDAP connection", e);
         }
      }


      //user was successfull removed so fire events
View Full Code Here

      //log.info("Current implementation of findUsersFilteredByUserName returns all users and is not \"offset\" and \"limit\" sensitive ");

      if (limit == 0)
      {
         throw new IdentityException("Search limit shouldn't be set to 0");
      }

      List uf = new LinkedList();
      Enumeration results = null;


      if (filter.length() == 0)
      {
         filter = "*";
      }
      else if (!(filter.length() == && filter.equals("*")))
      {
         filter = "*" + filter + "*";
      }

      try
      {
         //search all entries containing "uid" attribute
         String ldap_filter = "(".concat(getUidAttributeID()).concat("=").concat(filter).concat(")");
         log.debug("Search filter: " + filter);



         uf = searchUsers(ldap_filter, null);

         int size = uf.size();
         if (offset == 0 && size <= limit)
         {
            return processUsers(uf);
         }

         Collections.sort(uf, new UserEntryComparator());

         if (offset + limit <= size)
         {
            return processUsers(uf.subList(offset, offset + limit));
         }
         else if (offset >= size)
         {
            return new HashSet();
         }

         return processUsers(uf.subList(offset, size));
      }
      catch (NoSuchElementException e)
      {
         log.debug("No users found", e);
      }
      catch (Throwable e)
      {
         throw new IdentityException("User search failed.", e);
      }

      //won't happen
      return null;

View Full Code Here

      {
         log.debug("No users found", e);
      }
      catch (Exception e)
      {
         throw new IdentityException("User search failed.", e);
      }
      return 0;
   }
View Full Code Here

      {
         userModule = (UserModule)new InitialContext().lookup(userModuleJNDIName);
      }
      if (userModule == null)
      {
         throw new IdentityException("Cannot obtain UserModule using JNDI name:" + userModuleJNDIName);
      }

      return userModule;
   }
View Full Code Here

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

      {
         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

      {
         userModule = (UserModule)new InitialContext().lookup(userModuleJNDIName);
      }
      if (userModule == null)
      {
         throw new IdentityException("Cannot obtain UserModule using JNDI name:" + userModuleJNDIName);
      }

      return userModule;
   }
View Full Code Here

      {
         roleModule = (RoleModule)new InitialContext().lookup(roleModuleJNDIName);
      }
      if (roleModule == null)
      {
         throw new IdentityException("Cannot obtain RoleModule using JNDI name:" + roleModuleJNDIName);
      }
      return roleModule;
   }
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.