@Test public void testGetUser() { User slcoperator = ldapService.getUser("LocalNew", "slcoperator"); assertNotNull(slcoperator); assertTrue(slcoperator.getGroups().contains("SLC Operator")); assertTrue(slcoperator.getEmail().equals("slcoperator@slidev.org")); assertTrue(slcoperator.getUid().equals("slcoperator")); assertNotNull(slcoperator.getHomeDir()); assertNotNull(slcoperator.getGivenName()); assertNotNull(slcoperator.getSn()); assertNotNull(slcoperator.getFullName()); assertNull(slcoperator.getTenant()); assertNull(slcoperator.getEdorg()); assertNotNull(slcoperator.getCreateTime()); assertNotNull(slcoperator.getModifyTime()); }
@SuppressWarnings("rawtypes") @Override public User getUser(String realm, String uid) { AndFilter filter = new AndFilter(); filter.and(new EqualsFilter(OBJECTCLASS, userObjectClass)).and(new EqualsFilter(userSearchAttribute, uid)); DistinguishedName dn = new DistinguishedName("ou=" + realm); User user; try { List userList = ldapTemplate.search(dn, filter.toString(), SearchControls.SUBTREE_SCOPE, new String[] { "*", CREATE_TIMESTAMP, MODIFY_TIMESTAMP }, new UserContextMapper()); if (userList == null || userList.size() == 0) { throw new EmptyResultDataAccessException(1); } else if (userList.size() > 1) { throw new IncorrectResultSizeDataAccessException("User must be unique", 1); } user = (User) userList.get(0); user.setUid(uid); user.setGroups(getGroupNames(getUserGroups(realm, uid))); } catch (EmptyResultDataAccessException e) { return null; } return user; }
LdapServiceImpl implements LdapService { @SuppressWarnings("rawtypes") @Override public User getUser(String realm, String uid) { AndFilter filter = new AndFilter(); filter.and(new EqualsFilter(OBJECTCLASS, userObjectClass)).and(new EqualsFilter(userSearchAttribute, uid)); DistinguishedName dn = new DistinguishedName("ou=" + realm); User user; try { List userList = ldapTemplate.search(dn, filter.toString(), SearchControls.SUBTREE_SCOPE, new String[] { "*", CREATE_TIMESTAMP, MODIFY_TIMESTAMP }, new UserContextMapper()); if (userList == null || userList.size() == 0) { throw new EmptyResultDataAccessException(1); } else if (userList.size() > 1) { throw new IncorrectResultSizeDataAccessException("User must be unique", 1); } user = (User) userList.get(0); user.setUid(uid); user.setGroups(getGroupNames(getUserGroups(realm, uid))); } catch (EmptyResultDataAccessException e) { return null; } return user; } }
LdapServiceImpl implements LdapService { @SuppressWarnings("rawtypes") @Override public User getUser(String realm, String uid) { AndFilter filter = new AndFilter(); filter.and(new EqualsFilter(OBJECTCLASS, userObjectClass)).and(new EqualsFilter(userSearchAttribute, uid)); DistinguishedName dn = new DistinguishedName("ou=" + realm); User user; try { List userList = ldapTemplate.search(dn, filter.toString(), SearchControls.SUBTREE_SCOPE, new String[] { "*", CREATE_TIMESTAMP, MODIFY_TIMESTAMP }, new UserContextMapper()); if (userList == null || userList.size() == 0) { throw new EmptyResultDataAccessException(1); } else if (userList.size() > 1) { throw new IncorrectResultSizeDataAccessException("User must be unique", 1); } user = (User) userList.get(0); user.setUid(uid); user.setGroups(getGroupNames(getUserGroups(realm, uid))); } catch (EmptyResultDataAccessException e) { return null; } return user; }  }
LdapServiceImpl implements LdapService { @SuppressWarnings("rawtypes") @Override public User getUser(String realm, String uid) { AndFilter filter = new AndFilter(); filter.and(new EqualsFilter(OBJECTCLASS, userObjectClass)).and(new EqualsFilter(userSearchAttribute, uid)); DistinguishedName dn = new DistinguishedName("ou=" + realm); User user; try { List userList = ldapTemplate.search(dn, filter.toString(), SearchControls.SUBTREE_SCOPE, new String[] { "*", CREATE_TIMESTAMP, MODIFY_TIMESTAMP }, new UserContextMapper()); if (userList == null || userList.size() == 0) { throw new EmptyResultDataAccessException(1); } else if (userList.size() > 1) { throw new IncorrectResultSizeDataAccessException("User must be unique", 1); } user = (User) userList.get(0); user.setUid(uid); user.setGroups(getGroupNames(getUserGroups(realm, uid))); } catch (EmptyResultDataAccessException e) { return null; } return user; }  @SuppressWarnings("rawtypes") @Override User getUser(String realm, String uid); @SuppressWarnings("unchecked") @Override Collection<Group> getUserGroups(String realm, String uid); @Override void removeUser(String realm, String uid); @Override String createUser(String realm, User user); @Override boolean updateUser(String realm, User user); @Override Collection<User> findUsersByGroups(String realm, final Collection<String> allowedGroupNames,
                                              final Collection<String> disallowedGroupNames, String tenant, Collection<String> edorgs); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames, String tenant); @Override Collection<User> findUsersByAttributes(String realm, Collection<String> attributes); @Override Group getGroup(String realm, String groupName); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames, String tenant,
                                              Collection<String> edorgs); @Override boolean addUserToGroup(String realm, Group group, User user); @Override boolean removeUserFromGroup(String realm, Group group, User user); @Override boolean updateGroup(String realm, Group group); @Override void setLdapTemplate(LdapTemplate ldapTemplate); }
LdapServiceImpl implements LdapService { @SuppressWarnings("rawtypes") @Override public User getUser(String realm, String uid) { AndFilter filter = new AndFilter(); filter.and(new EqualsFilter(OBJECTCLASS, userObjectClass)).and(new EqualsFilter(userSearchAttribute, uid)); DistinguishedName dn = new DistinguishedName("ou=" + realm); User user; try { List userList = ldapTemplate.search(dn, filter.toString(), SearchControls.SUBTREE_SCOPE, new String[] { "*", CREATE_TIMESTAMP, MODIFY_TIMESTAMP }, new UserContextMapper()); if (userList == null || userList.size() == 0) { throw new EmptyResultDataAccessException(1); } else if (userList.size() > 1) { throw new IncorrectResultSizeDataAccessException("User must be unique", 1); } user = (User) userList.get(0); user.setUid(uid); user.setGroups(getGroupNames(getUserGroups(realm, uid))); } catch (EmptyResultDataAccessException e) { return null; } return user; }  @SuppressWarnings("rawtypes") @Override User getUser(String realm, String uid); @SuppressWarnings("unchecked") @Override Collection<Group> getUserGroups(String realm, String uid); @Override void removeUser(String realm, String uid); @Override String createUser(String realm, User user); @Override boolean updateUser(String realm, User user); @Override Collection<User> findUsersByGroups(String realm, final Collection<String> allowedGroupNames,
                                              final Collection<String> disallowedGroupNames, String tenant, Collection<String> edorgs); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames, String tenant); @Override Collection<User> findUsersByAttributes(String realm, Collection<String> attributes); @Override Group getGroup(String realm, String groupName); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames, String tenant,
                                              Collection<String> edorgs); @Override boolean addUserToGroup(String realm, Group group, User user); @Override boolean removeUserFromGroup(String realm, Group group, User user); @Override boolean updateGroup(String realm, Group group); @Override void setLdapTemplate(LdapTemplate ldapTemplate); static final String OBJECTCLASS; }