Package org.picketlink.idm.api

Examples of org.picketlink.idm.api.IdentitySession


      return new UserImpl(username);
   }

   public void createUser(User user, boolean broadcast) throws Exception
   {
      IdentitySession session = service_.getIdentitySession();
      if (broadcast)
      {
         preSave(user, true);
      }

      try
      {
         session.getPersistenceManager().createUser(user.getUserName());
      }
      catch (IdentityException e)
      {
         log.info("Identity operation error: ", e);
View Full Code Here


   }

   public void saveUser(User user, boolean broadcast) throws Exception
   {
      IdentitySession session = service_.getIdentitySession();
      if (broadcast)
      {
         preSave(user, false);
      }
View Full Code Here

      }
   }

   public User removeUser(String userName, boolean broadcast) throws Exception
   {
      IdentitySession session = service_.getIdentitySession();

      org.picketlink.idm.api.User foundUser = null;

      try
      {
         foundUser = session.getPersistenceManager().findUser(userName);
      }
      catch (IdentityException e)
      {
         log.info("Cannot obtain user: " + userName + "; ", e);

      }

      if (foundUser == null)
      {
         return null;
      }

      try
      {
         // Remove all memberships and profile first
         orgService.getMembershipHandler().removeMembershipByUser(userName, false);
         orgService.getUserProfileHandler().removeUserProfile(userName, false);
      }
      catch (Exception e)
      {
         log.info("Cannot cleanup user relationships: " + userName + "; ", e);

      }

      User exoUser = getPopulatedUser(userName, session);

      if (broadcast)
      {
         preDelete(exoUser);
      }

      try
      {
         session.getPersistenceManager().removeUser(foundUser, true);
      }
      catch (IdentityException e)
      {
         log.info("Cannot remove user: " + userName + "; ", e);
View Full Code Here

   }

   //
   public User findUserByName(String userName) throws Exception
   {
      IdentitySession session = service_.getIdentitySession();

      User user = getPopulatedUser(userName, session);

      return user;
   }
View Full Code Here

      }
      else
      {
         try
         {
            IdentitySession session = service_.getIdentitySession();
            org.picketlink.idm.api.User idmUser = session.getPersistenceManager().findUser(user.getUserName());

            authenticated = session.getAttributesManager().validatePassword(idmUser, password);
         }
         catch (Exception e)
         {
            log.info("Cannot authenticate user: " + username + "; ",  e);
View Full Code Here

      return new LazyPageList(new IDMUserListAccess(this, service_, qb, 20, false), 20);
   }

   public User findUserByEmail(String email) throws Exception
   {
      IdentitySession session = service_.getIdentitySession();


      org.picketlink.idm.api.User plUser = null;

      try
      {
         plUser = session.getAttributesManager().findUserByUniqueAttribute(USER_EMAIL, email);
      }
      catch (IdentityException e)
      {
         log.info("Cannot find user by email: " + email + "; ", e );
View Full Code Here

     *
     *
     * @param principal
     */
    protected void validateManagedUser(OpenIdPrincipal principal) {
        IdentitySession session = identitySession.get();
       
        try {           
            // Check that the user's identity exists
            if (session.getPersistenceManager().findUser(principal.getIdentifier()) == null) {
                // The user wasn't found, let's create them
               
                User user = session.getPersistenceManager().createUser(principal.getIdentifier());
               
                // TODO allow the OpenID -> IDM attribute mapping to be configured
               
                // Map fetched attributes to identity-managed attributes for new users
                for (String alias : principal.getAttributeValues().keySet()) {
                    session.getAttributesManager().addAttribute(user, alias, principal.getAttribute(alias));   
                }              
               
                // Load the user's roles and groups       
                try {           
                    Collection<RoleType> roleTypes = session.getRoleManager().findUserRoleTypes(user);

                    for (RoleType roleType : roleTypes) {
                        for (Role role : session.getRoleManager().findRoles(user, roleType)) {
                            identity.addRole(role.getRoleType().getName(),
                                    role.getGroup().getName(), role.getGroup().getGroupType());
                        }
                    }
                   
                    for (Group g : session.getRelationshipManager().findAssociatedGroups(user)) {
                        identity.addGroup(g.getName(), g.getGroupType());
                    }
                } catch (FeatureNotSupportedException ex) {
                    throw new AuthenticationException("Error loading user's roles and groups", ex);
                } catch (IdentityException ex) {
View Full Code Here

        beanManager.fireEvent(new DeferredAuthenticationEvent(true));
    }

    protected void validateManagedUser(OAuthUser principal) {
        IdentitySession session = identitySession.get();

        try {
            // Check that the user's identity exists
            if (session.getPersistenceManager().findUser(principal.getId()) == null) {
                // The user wasn't found, let's create them

                User user = session.getPersistenceManager().createUser(principal.getId());

                // TODO allow the OAuth -> IDM attribute mapping to be configured
                // e.g.
                // session.getAttributesManager().addAttribute(user, "fullName", principal.getUserProfile().getFullName());
                // session.getAttributesManager().addAttribute(user, "profileImageUrl",
                // principal.getUserProfile().getProfileImageUrl());

                // Load the user's roles and groups
                try {
                    Collection<RoleType> roleTypes = session.getRoleManager().findUserRoleTypes(user);

                    for (RoleType roleType : roleTypes) {
                        for (Role role : session.getRoleManager().findRoles(user, roleType)) {
                            identity.get().addRole(role.getRoleType().getName(), role.getGroup().getName(),
                                    role.getGroup().getGroupType());
                        }
                    }

                    for (Group g : session.getRelationshipManager().findAssociatedGroups(user)) {
                        identity.get().addGroup(g.getName(), g.getGroupType());
                    }
                } catch (FeatureNotSupportedException ex) {
                    throw new AuthenticationException("Error loading user's roles and groups", ex);
                } catch (IdentityException ex) {
View Full Code Here

        if (!entityManagerInstance.isUnsatisfied() && !entityManagerInstance.isAmbiguous()) {
            sessionOptions.put(SESSION_OPTION_ENTITY_MANAGER, entityManagerInstance.get());
            sessionOptions.put(SESSION_OPTION_IDENTITY_OBJECT_CREATED_EVENT, identityObjectCreatedEvent);
        }
           
        IdentitySession session = factory.createIdentitySession(getDefaultRealm(), sessionOptions);
        session.registerListener(this);
        return session;
    }
View Full Code Here

    public void createUser(User user, boolean broadcast) throws Exception {
        if (log.isTraceEnabled()) {
            Tools.logMethodIn(log, LogLevel.TRACE, "createUser", new Object[] { "user", user, "broadcast", broadcast });
        }

        IdentitySession session = service_.getIdentitySession();
        if (broadcast) {
            preSave(user, true);
        }

        try {
            orgService.flush();

            session.getPersistenceManager().createUser(user.getUserName());
        } catch (IdentityException e) {
            handleException("Identity operation error: ", e);

        }
View Full Code Here

TOP

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

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.