/** @return true if the passed-in user is currently authenticated */ protected boolean isAuthenticatedUser(UserEntity user) { if (user.getId() == null) { return false; } return user.getId() .equals( org.camunda.bpm.engine.impl.context.Context.getCommandContext() .getAuthenticatedUserId()); }
public List<User> findUsersWithoutGroupId(LdapUserQueryImpl query, String userBaseDn) { if (ldapConfiguration.isSortControlSupported()) { applyRequestControls(query); } NamingEnumeration<SearchResult> enumeration = null; try { String filter = getUserSearchFilter(query); enumeration = initialContext.search(userBaseDn, filter, ldapConfiguration.getSearchControls()); // perform client-side paging int resultCount = 0; List<User> userList = new ArrayList<User>(); while (enumeration.hasMoreElements() && userList.size() < query.getMaxResults()) { SearchResult result = enumeration.nextElement(); UserEntity user = transformUser(result); if (isAuthenticatedUser(user) || isAuthorized(READ, USER, user.getId())) { if (resultCount >= query.getFirstResult()) { userList.add(user); } resultCount++; } } return userList; } catch (NamingException e) { throw new IdentityProviderException("Could not query for users", e); } finally { try { if (enumeration != null) { enumeration.close(); } } catch (Exception e) { // ignore silently } } }