diff --git a/core/src/main/java/org/keycloak/representations/idm/RealmRepresentation.java b/core/src/main/java/org/keycloak/representations/idm/RealmRepresentation.java index 584e6392db..5f87feea96 100755 --- a/core/src/main/java/org/keycloak/representations/idm/RealmRepresentation.java +++ b/core/src/main/java/org/keycloak/representations/idm/RealmRepresentation.java @@ -1,7 +1,5 @@ package org.keycloak.representations.idm; -import org.keycloak.representations.FederationProviderRepresentation; - import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -58,7 +56,7 @@ public class RealmRepresentation { protected Map smtpServer; protected Map ldapServer; protected List authenticationProviders; - protected List federationProviders; + protected List userFederationProviders; protected String loginTheme; protected String accountTheme; protected String adminTheme; @@ -471,11 +469,11 @@ public class RealmRepresentation { this.auditListeners = auditListeners; } - public List getFederationProviders() { - return federationProviders; + public List getUserFederationProviders() { + return userFederationProviders; } - public void setFederationProviders(List federationProviders) { - this.federationProviders = federationProviders; + public void setUserFederationProviders(List userFederationProviders) { + this.userFederationProviders = userFederationProviders; } } diff --git a/core/src/main/java/org/keycloak/representations/FederationProviderRepresentation.java b/core/src/main/java/org/keycloak/representations/idm/UserFederationProviderRepresentation.java similarity index 83% rename from core/src/main/java/org/keycloak/representations/FederationProviderRepresentation.java rename to core/src/main/java/org/keycloak/representations/idm/UserFederationProviderRepresentation.java index e14f96e18b..90efd175ce 100755 --- a/core/src/main/java/org/keycloak/representations/FederationProviderRepresentation.java +++ b/core/src/main/java/org/keycloak/representations/idm/UserFederationProviderRepresentation.java @@ -1,11 +1,11 @@ -package org.keycloak.representations; +package org.keycloak.representations.idm; import java.util.Map; /** * @author Marek Posolda */ -public class FederationProviderRepresentation { +public class UserFederationProviderRepresentation { private String id; private String providerName; @@ -41,7 +41,7 @@ public class FederationProviderRepresentation { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - FederationProviderRepresentation that = (FederationProviderRepresentation) o; + UserFederationProviderRepresentation that = (UserFederationProviderRepresentation) o; if (!id.equals(that.id)) return false; 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 f99af8286a..49b84f3785 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 @@ -267,12 +267,12 @@ public class LDAPFederationProvider implements UserFederationProvider { @Override public void preRemove(RealmModel realm) { - //To change body of implemented methods use File | Settings | File Templates. + // complete Don't think we have to do anything } @Override public void preRemove(RealmModel realm, RoleModel role) { - //To change body of implemented methods use File | Settings | File Templates. + // complete I don't think we have to do anything here } public boolean validPassword(String username, String password) { diff --git a/model/api/src/main/java/org/keycloak/models/RealmModel.java b/model/api/src/main/java/org/keycloak/models/RealmModel.java index c1afcf53eb..1884dec9f2 100755 --- a/model/api/src/main/java/org/keycloak/models/RealmModel.java +++ b/model/api/src/main/java/org/keycloak/models/RealmModel.java @@ -165,9 +165,9 @@ public interface RealmModel extends RoleContainerModel { void setAuthenticationProviders(List authenticationProviders); - List getFederationProviders(); + List getUserFederationProviders(); - void setFederationProviders(List providers); + void setUserFederationProviders(List providers); String getLoginTheme(); 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 b94803b6ad..f67a821474 100755 --- a/model/api/src/main/java/org/keycloak/models/UserFederationManager.java +++ b/model/api/src/main/java/org/keycloak/models/UserFederationManager.java @@ -20,7 +20,7 @@ public class UserFederationManager implements UserProvider { @Override public UserModel addUser(RealmModel realm, String id, String username, boolean addDefaultRoles) { UserModel user = session.userStorage().addUser(realm, id, username, addDefaultRoles); - for (UserFederationProviderModel federation : realm.getFederationProviders()) { + for (UserFederationProviderModel federation : realm.getUserFederationProviders()) { UserFederationProvider fed = session.getProvider(UserFederationProvider.class, federation.getProviderName()); return fed.addUser(realm, user); } @@ -36,7 +36,7 @@ public class UserFederationManager implements UserProvider { @Override public UserModel addUser(RealmModel realm, String username) { UserModel user = session.userStorage().addUser(realm, username); - for (UserFederationProviderModel federation : realm.getFederationProviders()) { + for (UserFederationProviderModel federation : realm.getUserFederationProviders()) { UserFederationProvider fed = getFederationProvider(federation); return fed.addUser(realm, user); } @@ -45,7 +45,7 @@ public class UserFederationManager implements UserProvider { protected UserFederationProvider getFederationLink(RealmModel realm, UserModel user) { if (user.getFederationLink() == null) return null; - for (UserFederationProviderModel fed : realm.getFederationProviders()) { + for (UserFederationProviderModel fed : realm.getUserFederationProviders()) { if (fed.getId().equals(user.getFederationLink())) { return getFederationProvider(fed); } @@ -95,7 +95,7 @@ public class UserFederationManager implements UserProvider { } return user; } - for (UserFederationProviderModel federation : realm.getFederationProviders()) { + for (UserFederationProviderModel federation : realm.getUserFederationProviders()) { UserFederationProvider fed = getFederationProvider(federation); user = fed.getUserById(id, realm); if (user != null) return user; @@ -113,7 +113,7 @@ public class UserFederationManager implements UserProvider { } return user; } - for (UserFederationProviderModel federation : realm.getFederationProviders()) { + for (UserFederationProviderModel federation : realm.getUserFederationProviders()) { UserFederationProvider fed = getFederationProvider(federation); user = fed.getUserByUsername(username, realm); if (user != null) return user; @@ -131,7 +131,7 @@ public class UserFederationManager implements UserProvider { } return user; } - for (UserFederationProviderModel federation : realm.getFederationProviders()) { + for (UserFederationProviderModel federation : realm.getUserFederationProviders()) { UserFederationProvider fed = getFederationProvider(federation); user = fed.getUserByEmail(email, realm); if (user != null) return user; @@ -149,7 +149,7 @@ public class UserFederationManager implements UserProvider { } return user; } - for (UserFederationProviderModel federation : realm.getFederationProviders()) { + for (UserFederationProviderModel federation : realm.getUserFederationProviders()) { UserFederationProvider fed = getFederationProvider(federation); user = fed.getUserBySocialLink(socialLink, realm); if (user != null) return user; @@ -185,7 +185,7 @@ public class UserFederationManager implements UserProvider { results.addAll(users.values()); return results; } - List federationProviders = realm.getFederationProviders(); + List federationProviders = realm.getUserFederationProviders(); for (int i = federationProviders.size() - 1; i >= 0; i--) { UserFederationProviderModel federation = federationProviders.get(i); UserFederationProvider fed = getFederationProvider(federation); @@ -219,7 +219,7 @@ public class UserFederationManager implements UserProvider { results.addAll(users.values()); return results; } - List federationProviders = realm.getFederationProviders(); + List federationProviders = realm.getUserFederationProviders(); for (int i = federationProviders.size() - 1; i >= 0; i--) { UserFederationProviderModel federation = federationProviders.get(i); UserFederationProvider fed = getFederationProvider(federation); @@ -253,7 +253,7 @@ public class UserFederationManager implements UserProvider { results.addAll(users.values()); return results; } - List federationProviders = realm.getFederationProviders(); + List federationProviders = realm.getUserFederationProviders(); for (int i = federationProviders.size() - 1; i >= 0; i--) { UserFederationProviderModel federation = federationProviders.get(i); UserFederationProvider fed = getFederationProvider(federation); @@ -285,7 +285,7 @@ public class UserFederationManager implements UserProvider { @Override public void preRemove(RealmModel realm) { - for (UserFederationProviderModel federation : realm.getFederationProviders()) { + for (UserFederationProviderModel federation : realm.getUserFederationProviders()) { UserFederationProvider fed = getFederationProvider(federation); fed.preRemove(realm); } @@ -294,7 +294,7 @@ public class UserFederationManager implements UserProvider { @Override public void preRemove(RealmModel realm, RoleModel role) { - for (UserFederationProviderModel federation : realm.getFederationProviders()) { + for (UserFederationProviderModel federation : realm.getUserFederationProviders()) { UserFederationProvider fed = getFederationProvider(federation); fed.preRemove(realm, role); } diff --git a/model/api/src/main/java/org/keycloak/models/utils/ModelToRepresentation.java b/model/api/src/main/java/org/keycloak/models/utils/ModelToRepresentation.java index 2fc5893446..13e3a8965b 100755 --- a/model/api/src/main/java/org/keycloak/models/utils/ModelToRepresentation.java +++ b/model/api/src/main/java/org/keycloak/models/utils/ModelToRepresentation.java @@ -14,7 +14,7 @@ import org.keycloak.models.SocialLinkModel; import org.keycloak.models.UserCredentialModel; import org.keycloak.models.UserModel; import org.keycloak.models.UserSessionModel; -import org.keycloak.representations.FederationProviderRepresentation; +import org.keycloak.representations.idm.UserFederationProviderRepresentation; import org.keycloak.representations.idm.ApplicationRepresentation; import org.keycloak.representations.idm.AuthenticationProviderRepresentation; import org.keycloak.representations.idm.ClaimRepresentation; @@ -143,17 +143,17 @@ public class ModelToRepresentation { } rep.setAuthenticationProviders(authProviderReps); } - List fedProviderModels = realm.getFederationProviders(); + List fedProviderModels = realm.getUserFederationProviders(); if (fedProviderModels.size() > 0) { - List fedProviderReps = new ArrayList(); + List fedProviderReps = new ArrayList(); for (UserFederationProviderModel model : fedProviderModels) { - FederationProviderRepresentation fedProvRep = new FederationProviderRepresentation(); + UserFederationProviderRepresentation fedProvRep = new UserFederationProviderRepresentation(); fedProvRep.setId(model.getId()); fedProvRep.setProviderName(model.getProviderName()); fedProvRep.setConfig(model.getConfig()); fedProviderReps.add(fedProvRep); } - rep.setFederationProviders(fedProviderReps); + rep.setUserFederationProviders(fedProviderReps); } return rep; } diff --git a/model/api/src/main/java/org/keycloak/models/utils/RepresentationToModel.java b/model/api/src/main/java/org/keycloak/models/utils/RepresentationToModel.java index 51a5ce73c7..6b3ec2dca1 100755 --- a/model/api/src/main/java/org/keycloak/models/utils/RepresentationToModel.java +++ b/model/api/src/main/java/org/keycloak/models/utils/RepresentationToModel.java @@ -17,7 +17,7 @@ import org.keycloak.models.SocialLinkModel; import org.keycloak.models.UserCredentialModel; import org.keycloak.models.UserCredentialValueModel; import org.keycloak.models.UserModel; -import org.keycloak.representations.FederationProviderRepresentation; +import org.keycloak.representations.idm.UserFederationProviderRepresentation; import org.keycloak.representations.idm.ApplicationRepresentation; import org.keycloak.representations.idm.AuthenticationLinkRepresentation; import org.keycloak.representations.idm.AuthenticationProviderRepresentation; @@ -215,9 +215,9 @@ public class RepresentationToModel { newRealm.setAuthenticationProviders(authProviderModels); } - if (rep.getFederationProviders() != null) { - List providerModels = convertFederationProviders(rep.getFederationProviders()); - newRealm.setFederationProviders(providerModels); + if (rep.getUserFederationProviders() != null) { + List providerModels = convertFederationProviders(rep.getUserFederationProviders()); + newRealm.setUserFederationProviders(providerModels); } // create users and their role mappings and social mappings @@ -287,9 +287,9 @@ public class RepresentationToModel { realm.setAuthenticationProviders(authProviderModels); } - if (rep.getFederationProviders() != null) { - List providerModels = convertFederationProviders(rep.getFederationProviders()); - realm.setFederationProviders(providerModels); + if (rep.getUserFederationProviders() != null) { + List providerModels = convertFederationProviders(rep.getUserFederationProviders()); + realm.setUserFederationProviders(providerModels); } if ("GENERATE".equals(rep.getPublicKey())) { @@ -315,10 +315,10 @@ public class RepresentationToModel { return result; } - private static List convertFederationProviders(List providers) { + private static List convertFederationProviders(List providers) { List result = new ArrayList(); - for (FederationProviderRepresentation representation : providers) { + for (UserFederationProviderRepresentation representation : providers) { UserFederationProviderModel model = new UserFederationProviderModel(representation.getId(), representation.getProviderName(), representation.getConfig()); result.add(model); diff --git a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/RealmAdapter.java b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/RealmAdapter.java index d280a20131..4d9bf616e4 100755 --- a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/RealmAdapter.java +++ b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/RealmAdapter.java @@ -606,15 +606,15 @@ public class RealmAdapter implements RealmModel { } @Override - public List getFederationProviders() { - if (updated != null) return updated.getFederationProviders(); + public List getUserFederationProviders() { + if (updated != null) return updated.getUserFederationProviders(); return cached.getFederationProviders(); } @Override - public void setFederationProviders(List providers) { + public void setUserFederationProviders(List providers) { getDelegateForUpdate(); - updated.setFederationProviders(providers); + updated.setUserFederationProviders(providers); } @Override diff --git a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/entities/CachedRealm.java b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/entities/CachedRealm.java index 292b174764..c8748fe603 100755 --- a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/entities/CachedRealm.java +++ b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/entities/CachedRealm.java @@ -122,7 +122,7 @@ public class CachedRealm { requiredCredentials = model.getRequiredCredentials(); authenticationProviders = model.getAuthenticationProviders(); - federationProviders = model.getFederationProviders(); + federationProviders = model.getUserFederationProviders(); smtpConfig.putAll(model.getSmtpConfig()); socialConfig.putAll(model.getSocialConfig()); diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/RealmAdapter.java b/model/jpa/src/main/java/org/keycloak/models/jpa/RealmAdapter.java index 4312ce7814..e65e377521 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/RealmAdapter.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/RealmAdapter.java @@ -727,7 +727,7 @@ public class RealmAdapter implements RealmModel { } @Override - public List getFederationProviders() { + public List getUserFederationProviders() { List entities = realm.getFederationProviders(); List copy = new ArrayList(); for (FederationProviderEntity entity : entities) { @@ -751,7 +751,7 @@ public class RealmAdapter implements RealmModel { } @Override - public void setFederationProviders(List providers) { + public void setUserFederationProviders(List providers) { List newEntities = new ArrayList(); int counter = 1; for (UserFederationProviderModel model : providers) { diff --git a/model/mongo/src/main/java/org/keycloak/models/mongo/keycloak/adapters/RealmAdapter.java b/model/mongo/src/main/java/org/keycloak/models/mongo/keycloak/adapters/RealmAdapter.java index 003523599a..2e563f5296 100755 --- a/model/mongo/src/main/java/org/keycloak/models/mongo/keycloak/adapters/RealmAdapter.java +++ b/model/mongo/src/main/java/org/keycloak/models/mongo/keycloak/adapters/RealmAdapter.java @@ -791,7 +791,7 @@ public class RealmAdapter extends AbstractMongoAdapter impleme updateRealm(); } @Override - public List getFederationProviders() { + public List getUserFederationProviders() { List entities = realm.getFederationProviders(); List result = new ArrayList(); for (FederationProviderEntity entity : entities) { @@ -802,7 +802,7 @@ public class RealmAdapter extends AbstractMongoAdapter impleme } @Override - public void setFederationProviders(List providers) { + public void setUserFederationProviders(List providers) { List entities = new ArrayList(); for (UserFederationProviderModel model : providers) { FederationProviderEntity entity = new FederationProviderEntity(); diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/forms/FederationProvidersIntegrationTest.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/forms/FederationProvidersIntegrationTest.java index b1c3fd1674..353aae22e9 100755 --- a/testsuite/integration/src/test/java/org/keycloak/testsuite/forms/FederationProvidersIntegrationTest.java +++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/forms/FederationProvidersIntegrationTest.java @@ -62,7 +62,7 @@ public class FederationProvidersIntegrationTest { UserFederationProviderModel ldapProvider = new UserFederationProviderModel(null, LDAPFederationProviderFactory.PROVIDER_NAME, ldapConfig); - appRealm.setFederationProviders(Arrays.asList(ldapProvider)); + appRealm.setUserFederationProviders(Arrays.asList(ldapProvider)); // Configure LDAP ldapRule.getEmbeddedServer().setupLdapInRealm(appRealm);