From 64589bc807b3e735d11b7772cab4bc1233c95b00 Mon Sep 17 00:00:00 2001 From: Bill Burke Date: Thu, 31 Jul 2014 17:41:38 -0400 Subject: [PATCH] maxResults --- .../org/keycloak/federation/ldap/LDAPFederationProvider.java | 3 ++- .../main/java/org/keycloak/models/UserFederationManager.java | 2 +- .../main/java/org/keycloak/models/UserFederationProvider.java | 2 +- .../org/keycloak/testutils/DummyUserFederationProvider.java | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/LDAPFederationProvider.java b/federation/ldap/src/main/java/org/keycloak/federation/ldap/LDAPFederationProvider.java index 587cc39120..27a6dd2c82 100755 --- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/LDAPFederationProvider.java +++ b/federation/ldap/src/main/java/org/keycloak/federation/ldap/LDAPFederationProvider.java @@ -151,7 +151,7 @@ public class LDAPFederationProvider implements UserFederationProvider { } @Override - public List searchByAttributes(Map attributes, RealmModel realm) { + public List searchByAttributes(Map attributes, RealmModel realm, int maxResults) { IdentityManager identityManager = getIdentityManager(); List searchResults =new LinkedList(); try { @@ -170,6 +170,7 @@ public class LDAPFederationProvider implements UserFederationProvider { if (attributes.containsKey(LAST_NAME)) { query.setParameter(User.LAST_NAME, attributes.get(LAST_NAME)); } + query.setLimit(maxResults); List agents = query.getResultList(); for (User user : agents) { results.put(user.getLoginName(), user); diff --git a/model/api/src/main/java/org/keycloak/models/UserFederationManager.java b/model/api/src/main/java/org/keycloak/models/UserFederationManager.java index 0e887d3a53..aa197d2937 100755 --- a/model/api/src/main/java/org/keycloak/models/UserFederationManager.java +++ b/model/api/src/main/java/org/keycloak/models/UserFederationManager.java @@ -225,7 +225,7 @@ public class UserFederationManager implements UserProvider { void federationLoad(RealmModel realm, Map attributes) { for (UserFederationProviderModel federation : realm.getUserFederationProviders()) { UserFederationProvider fed = getFederationProvider(federation); - fed.searchByAttributes(attributes, realm); + fed.searchByAttributes(attributes, realm, 30); } } diff --git a/model/api/src/main/java/org/keycloak/models/UserFederationProvider.java b/model/api/src/main/java/org/keycloak/models/UserFederationProvider.java index c0923e4e69..d142464adc 100755 --- a/model/api/src/main/java/org/keycloak/models/UserFederationProvider.java +++ b/model/api/src/main/java/org/keycloak/models/UserFederationProvider.java @@ -89,7 +89,7 @@ public interface UserFederationProvider extends Provider { * @param realm * @return */ - List searchByAttributes(Map attributes, RealmModel realm); + List searchByAttributes(Map attributes, RealmModel realm, int maxResults); void preRemove(RealmModel realm); void preRemove(RealmModel realm, RoleModel role); diff --git a/testsuite/integration/src/main/java/org/keycloak/testutils/DummyUserFederationProvider.java b/testsuite/integration/src/main/java/org/keycloak/testutils/DummyUserFederationProvider.java index 2559b39792..b99a47d4f9 100755 --- a/testsuite/integration/src/main/java/org/keycloak/testutils/DummyUserFederationProvider.java +++ b/testsuite/integration/src/main/java/org/keycloak/testutils/DummyUserFederationProvider.java @@ -47,7 +47,7 @@ public class DummyUserFederationProvider implements UserFederationProvider { } @Override - public List searchByAttributes(Map attributes, RealmModel realm) { + public List searchByAttributes(Map attributes, RealmModel realm, int maxResults) { return Collections.emptyList(); }