Package org.picketlink.idm

Examples of org.picketlink.idm.IdentityManager


            return false;
        }
    }

    public static User getUser(PartitionManager partitionManager, String username) {
        IdentityManager idmManager = getIdentityManager(partitionManager);
        return BasicModel.getUser(idmManager, username);
    }
View Full Code Here


            throw new IdentityManagementException("Error - multiple users found with same email");
        }
    }

    public static boolean removeUser(PartitionManager partitionManager, String username) {
        IdentityManager idmManager = getIdentityManager(partitionManager);
        User picketlinkUser = BasicModel.getUser(idmManager, username);
        if (picketlinkUser == null) {
            return false;
        }
        idmManager.remove(picketlinkUser);
        return true;
    }
View Full Code Here

        idmManager.remove(picketlinkUser);
        return true;
    }

    public static void removeAllUsers(PartitionManager partitionManager) {
        IdentityManager idmManager = getIdentityManager(partitionManager);
        List<User> users = idmManager.createIdentityQuery(User.class).getResultList();

        for (User user : users) {
            idmManager.remove(user);
        }
    }
View Full Code Here

            idmManager.remove(user);
        }
    }

    public static List<User> getAllUsers(PartitionManager partitionManager) {
        IdentityManager idmManager = getIdentityManager(partitionManager);
        return idmManager.createIdentityQuery(User.class).getResultList();
    }
View Full Code Here

        }
        return searchResults;
    }

    protected Map<String, User> searchPicketlink(Map<String, String> attributes, int maxResults) {
        IdentityManager identityManager = getIdentityManager();
        Map<String, User> results = new HashMap<String, User>();
        if (attributes.containsKey(USERNAME)) {
            User user = BasicModel.getUser(identityManager, attributes.get(USERNAME));
            if (user != null) {
                results.put(user.getLoginName(), user);
            }
        }

        if (attributes.containsKey(EMAIL)) {
            User user = queryByEmail(identityManager, attributes.get(EMAIL));
            if (user != null) {
                results.put(user.getLoginName(), user);
            }
        }

        if (attributes.containsKey(FIRST_NAME) || attributes.containsKey(LAST_NAME)) {
            IdentityQuery<User> query = identityManager.createIdentityQuery(User.class);
            if (attributes.containsKey(FIRST_NAME)) {
                query.setParameter(User.FIRST_NAME, attributes.get(FIRST_NAME));
            }
            if (attributes.containsKey(LAST_NAME)) {
                query.setParameter(User.LAST_NAME, attributes.get(LAST_NAME));
View Full Code Here

    }


    @Override
    public UserModel getUserByEmail(RealmModel realm, String email) {
        IdentityManager identityManager = getIdentityManager();

        try {
            User picketlinkUser = queryByEmail(identityManager, email);
            if (picketlinkUser == null) {
                return null;
View Full Code Here

  /**
   * <p>Loads some users during the first construction.</p>
   */
  @PostConstruct
  public void create() {
    final IdentityManager identityManager = partitionManager.createIdentityManager();
    final RelationshipManager relationshipManager = partitionManager.createRelationshipManager();

    User john = new User("john");

    john.setEmail("john@doe.com");
    john.setFirstName("John");
    john.setLastName("Doe");

    User hacker = new User("hacker");

    hacker.setEmail("hacker@illegal.ru");
    hacker.setFirstName("Hacker");
    hacker.setLastName("anonymous");
   
    identityManager.add(john);
    identityManager.add(hacker);
    final Password defaultPassword = new Password("123");
    identityManager.updateCredential(john, defaultPassword);
    identityManager.updateCredential(hacker, defaultPassword);

    Role roleDeveloper = new Role("simple");
    Role roleAdmin = new Role("admin");

    identityManager.add(roleDeveloper);
    identityManager.add(roleAdmin);

    relationshipManager.add(new Grant(john, roleDeveloper));
    relationshipManager.add(new Grant(john, roleAdmin));
  }
View Full Code Here

TOP

Related Classes of org.picketlink.idm.IdentityManager

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.