From b72a7db6fea433d280442a71eb9e696c77071583 Mon Sep 17 00:00:00 2001 From: Bill Burke Date: Thu, 31 Jul 2014 10:51:04 -0400 Subject: [PATCH 1/2] federation display name --- ...derationProviderFactoryRepresentation.java | 46 +++++++++++ .../UserFederationProviderRepresentation.java | 9 +++ .../base/resources/js/controllers/users.js | 76 ++++++++++++++++++- .../resources/partials/federated-ldap.html | 12 +++ .../resources/partials/user-federation.html | 2 +- .../java/org/keycloak/models/RealmModel.java | 2 +- .../models/UserFederationProviderModel.java | 13 +++- .../UserFederationProviderEntity.java | 9 +++ .../models/utils/ModelToRepresentation.java | 1 + .../models/utils/RepresentationToModel.java | 2 +- .../keycloak/models/cache/RealmAdapter.java | 4 +- .../org/keycloak/models/jpa/RealmAdapter.java | 24 +++++- .../UserFederationProviderEntity.java | 9 +++ .../mongo/keycloak/adapters/RealmAdapter.java | 17 ++++- .../admin/UserFederationResource.java | 14 +++- .../FederationProvidersIntegrationTest.java | 2 +- 16 files changed, 222 insertions(+), 20 deletions(-) create mode 100755 core/src/main/java/org/keycloak/representations/idm/UserFederationProviderFactoryRepresentation.java diff --git a/core/src/main/java/org/keycloak/representations/idm/UserFederationProviderFactoryRepresentation.java b/core/src/main/java/org/keycloak/representations/idm/UserFederationProviderFactoryRepresentation.java new file mode 100755 index 0000000000..359c37c789 --- /dev/null +++ b/core/src/main/java/org/keycloak/representations/idm/UserFederationProviderFactoryRepresentation.java @@ -0,0 +1,46 @@ +package org.keycloak.representations.idm; + +import java.util.List; +import java.util.Map; + +/** + * @author Bill Burke + */ +public class UserFederationProviderFactoryRepresentation { + + private String id; + private List options; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public List getOptions() { + return options; + } + + public void setOptions(List options) { + this.options = options; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + UserFederationProviderFactoryRepresentation that = (UserFederationProviderFactoryRepresentation) o; + + if (!id.equals(that.id)) return false; + + return true; + } + + @Override + public int hashCode() { + return id.hashCode(); + } +} diff --git a/core/src/main/java/org/keycloak/representations/idm/UserFederationProviderRepresentation.java b/core/src/main/java/org/keycloak/representations/idm/UserFederationProviderRepresentation.java index 76541f9810..19f1d0c6cf 100755 --- a/core/src/main/java/org/keycloak/representations/idm/UserFederationProviderRepresentation.java +++ b/core/src/main/java/org/keycloak/representations/idm/UserFederationProviderRepresentation.java @@ -8,6 +8,7 @@ import java.util.Map; public class UserFederationProviderRepresentation { private String id; + private String displayName; private String providerName; private Map config; private int priority; @@ -20,6 +21,14 @@ public class UserFederationProviderRepresentation { this.id = id; } + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + public String getProviderName() { return providerName; } diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/users.js b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/users.js index 73b476f41b..034d52b326 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/users.js +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/users.js @@ -346,14 +346,82 @@ module.controller('UserFederationCtrl', function($scope, $location, realm, UserF }); -module.controller('GenericUserFederationCtrl', function($scope, realm, provider, UserFederationProviders, UserFederationInstances, Notifications, Dialog) { +module.controller('GenericUserFederationCtrl', function($scope, $location, Notifications, Dialog, realm, provider, providerFactory, UserFederationInstances) { console.log('GenericUserFederationCtrl'); - console.log("provider: " + provider.providerName); + $scope.provider = angular.copy(provider); + $scope.create = !provider.providerName; + + if ($scope.create) { + $scope.provider.providerName = providerFactory.id; + $scope.provider.config = {}; + $scope.provider.priority = 0; + } + + $scope.realm = realm; + + + $scope.changed = false; + + $scope.$watch('provider', function() { + if (!angular.equals($scope.provider, provider)) { + $scope.changed = true; + } + + }, true); + + $scope.save = function() { + $scope.changed = false; + if ($scope.create) { + UserFederationInstances.save({realm: realm.realm}, $scope.provider, function () { + $scope.changed = false; + $location.url("/realms/" + realm.realm + "/user-federation"); + Notifications.success("The provider has been created."); + }); + } else { + UserFederationInstances.update({realm: realm.realm, + provider: provider.id + }, + $scope.provider, function () { + $scope.changed = false; + $location.url("/realms/" + realm.realm + "/user-federation"); + Notifications.success("The provider has been updated."); + }); + + } + }; + + $scope.reset = function() { + $scope.provider = angular.copy(provider); + if ($scope.create) { + $scope.provider.providerName = providerFactory.id; + $scope.provider.config = {}; + $scope.provider.priority = 0; + } + $scope.changed = false; + }; + + $scope.cancel = function() { + $location.url("/realms/" + realm.realm + "/user-federation"); + }; + + $scope.remove = function() { + Dialog.confirmDelete($scope.provider.id, 'provider', function() { + $scope.provider.$remove({ + realm : realm.realm, + provider : $scope.provider.id + }, function() { + $location.url("/realms/" + realm.realm + "/user-federation"); + Notifications.success("The provider has been deleted."); + }); + }); + }; + }); + module.controller('LDAPCtrl', function($scope, $location, Notifications, Dialog, realm, provider, UserFederationInstances, RealmLDAPConnectionTester) { console.log('LDAPCtrl'); @@ -363,6 +431,7 @@ module.controller('LDAPCtrl', function($scope, $location, Notifications, Dialog, if ($scope.create) { $scope.provider.providerName = "ldap"; $scope.provider.config = {}; + $scope.provider.priority = 0; } $scope.ldapVendors = [ @@ -382,7 +451,7 @@ module.controller('LDAPCtrl', function($scope, $location, Notifications, Dialog, $scope.lastVendor = $scope.provider.config.vendor; - $scope.$watch('realm', function() { + $scope.$watch('provider', function() { if (!angular.equals($scope.provider, provider)) { $scope.changed = true; } @@ -427,6 +496,7 @@ module.controller('LDAPCtrl', function($scope, $location, Notifications, Dialog, if ($scope.create) { $scope.provider.providerName = "ldap"; $scope.provider.config = {}; + $scope.provider.priority = 0; } $scope.changed = false; $scope.lastVendor = $scope.provider.config.vendor; diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/federated-ldap.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/federated-ldap.html index c4f1d7bd54..edcf14173c 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/federated-ldap.html +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/federated-ldap.html @@ -15,6 +15,18 @@
Required Settings +
+ +
+ +
+
+
+ +
+ +
+
diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-federation.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-federation.html index d56ec17e42..352f526b64 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-federation.html +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-federation.html @@ -34,7 +34,7 @@ - {{instance.id}} + {{instance.displayName}} {{instance.providerName|capitalize}} {{instance.priority}} 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 aee3119ec1..36b14b7e13 100755 --- a/model/api/src/main/java/org/keycloak/models/RealmModel.java +++ b/model/api/src/main/java/org/keycloak/models/RealmModel.java @@ -167,7 +167,7 @@ public interface RealmModel extends RoleContainerModel { List getUserFederationProviders(); - UserFederationProviderModel addUserFederationProvider(String providerName, Map config, int priority); + UserFederationProviderModel addUserFederationProvider(String providerName, Map config, int priority, String displayName); void updateUserFederationProvider(UserFederationProviderModel provider); void removeUserFederationProvider(UserFederationProviderModel provider); void setUserFederationProviders(List providers); diff --git a/model/api/src/main/java/org/keycloak/models/UserFederationProviderModel.java b/model/api/src/main/java/org/keycloak/models/UserFederationProviderModel.java index a682c5499d..2542b9084b 100755 --- a/model/api/src/main/java/org/keycloak/models/UserFederationProviderModel.java +++ b/model/api/src/main/java/org/keycloak/models/UserFederationProviderModel.java @@ -13,15 +13,18 @@ public class UserFederationProviderModel { private String providerName; private Map config = new HashMap(); private int priority; + private String displayName; public UserFederationProviderModel() {}; - public UserFederationProviderModel(String id, String providerName, Map config, int priority) { + public UserFederationProviderModel(String id, String providerName, Map config, int priority, String displayName) { this.id = id; this.providerName = providerName; if (config != null) { this.config.putAll(config); } + this.priority = priority; + this.displayName = displayName; } public String getId() { @@ -51,4 +54,12 @@ public class UserFederationProviderModel { public void setPriority(int priority) { this.priority = priority; } + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } } diff --git a/model/api/src/main/java/org/keycloak/models/entities/UserFederationProviderEntity.java b/model/api/src/main/java/org/keycloak/models/entities/UserFederationProviderEntity.java index 5e39d9dbb6..6d3916e7e7 100755 --- a/model/api/src/main/java/org/keycloak/models/entities/UserFederationProviderEntity.java +++ b/model/api/src/main/java/org/keycloak/models/entities/UserFederationProviderEntity.java @@ -11,6 +11,7 @@ public class UserFederationProviderEntity { protected String providerName; protected Map config; protected int priority; + protected String displayName; public String getId() { @@ -44,4 +45,12 @@ public class UserFederationProviderEntity { public void setPriority(int priority) { this.priority = priority; } + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } } 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 714ee8dfa5..21765a347c 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 @@ -276,6 +276,7 @@ public class ModelToRepresentation { rep.setConfig(model.getConfig()); rep.setProviderName(model.getProviderName()); rep.setPriority(model.getPriority()); + rep.setDisplayName(model.getDisplayName()); 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 06c66307bd..4df881c67b 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 @@ -320,7 +320,7 @@ public class RepresentationToModel { for (UserFederationProviderRepresentation representation : providers) { UserFederationProviderModel model = new UserFederationProviderModel(representation.getId(), representation.getProviderName(), - representation.getConfig(), representation.getPriority()); + representation.getConfig(), representation.getPriority(), representation.getDisplayName()); result.add(model); } return result; 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 b0281dc5e0..6639208f57 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 @@ -618,9 +618,9 @@ public class RealmAdapter implements RealmModel { } @Override - public UserFederationProviderModel addUserFederationProvider(String providerName, Map config, int priority) { + public UserFederationProviderModel addUserFederationProvider(String providerName, Map config, int priority, String displayName) { getDelegateForUpdate(); - return updated.addUserFederationProvider(providerName, config, priority); + return updated.addUserFederationProvider(providerName, config, priority, displayName); } @Override 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 ee94cf16fa..bc57ef16f8 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 @@ -746,14 +746,14 @@ public class RealmAdapter implements RealmModel { }); List result = new ArrayList(); for (UserFederationProviderEntity entity : copy) { - result.add(new UserFederationProviderModel(entity.getId(), entity.getProviderName(), entity.getConfig(), entity.getPriority())); + result.add(new UserFederationProviderModel(entity.getId(), entity.getProviderName(), entity.getConfig(), entity.getPriority(), entity.getDisplayName())); } return result; } @Override - public UserFederationProviderModel addUserFederationProvider(String providerName, Map config, int priority) { + public UserFederationProviderModel addUserFederationProvider(String providerName, Map config, int priority, String displayName) { String id = KeycloakModelUtils.generateId(); UserFederationProviderEntity entity = new UserFederationProviderEntity(); entity.setId(id); @@ -761,10 +761,14 @@ public class RealmAdapter implements RealmModel { entity.setProviderName(providerName); entity.setConfig(config); entity.setPriority(priority); + if (displayName == null) { + displayName = id; + } + entity.setDisplayName(displayName); em.persist(entity); realm.getUserFederationProviders().add(entity); em.flush(); - return new UserFederationProviderModel(entity.getId(), providerName, config, priority); + return new UserFederationProviderModel(entity.getId(), providerName, config, priority, displayName); } @Override @@ -785,6 +789,10 @@ public class RealmAdapter implements RealmModel { while (it.hasNext()) { UserFederationProviderEntity entity = it.next(); if (entity.getId().equals(model.getId())) { + String displayName = model.getDisplayName(); + if (displayName != null) { + entity.setDisplayName(model.getDisplayName()); + } entity.setConfig(model.getConfig()); entity.setPriority(model.getPriority()); entity.setProviderName(model.getProviderName()); @@ -807,6 +815,10 @@ public class RealmAdapter implements RealmModel { entity.setPriority(model.getPriority()); entity.setProviderName(model.getProviderName()); entity.setPriority(model.getPriority()); + String displayName = model.getDisplayName(); + if (displayName != null) { + entity.setDisplayName(model.getDisplayName()); + } found = true; break; } @@ -829,7 +841,7 @@ public class RealmAdapter implements RealmModel { if (!found) add.add(model); } - for (UserFederationProviderModel model : providers) { + for (UserFederationProviderModel model : add) { UserFederationProviderEntity entity = new UserFederationProviderEntity(); if (model.getId() != null) entity.setId(model.getId()); else entity.setId(KeycloakModelUtils.generateId()); @@ -837,6 +849,10 @@ public class RealmAdapter implements RealmModel { entity.setPriority(model.getPriority()); entity.setProviderName(model.getProviderName()); entity.setPriority(model.getPriority()); + String displayName = model.getDisplayName(); + if (displayName == null) { + entity.setDisplayName(entity.getId()); + } em.persist(entity); realm.getUserFederationProviders().add(entity); diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserFederationProviderEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserFederationProviderEntity.java index d4a40c2c2f..42863bf29f 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserFederationProviderEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/UserFederationProviderEntity.java @@ -41,6 +41,9 @@ public class UserFederationProviderEntity { @CollectionTable(name="USER_FEDERATION_CONFIG") private Map config; + @Column(name="DISPLAY_NAME") + private String displayName; + public String getId() { return id; } @@ -81,5 +84,11 @@ public class UserFederationProviderEntity { this.config = config; } + public String getDisplayName() { + return displayName; + } + public void setDisplayName(String displayName) { + this.displayName = displayName; + } } 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 351ea6b5fe..f42365e6ac 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 @@ -795,16 +795,19 @@ public class RealmAdapter extends AbstractMongoAdapter impleme } @Override - public UserFederationProviderModel addUserFederationProvider(String providerName, Map config, int priority) { + public UserFederationProviderModel addUserFederationProvider(String providerName, Map config, int priority, String displayName) { UserFederationProviderEntity entity = new UserFederationProviderEntity(); entity.setId(KeycloakModelUtils.generateId()); entity.setPriority(priority); entity.setProviderName(providerName); entity.setConfig(config); + if (displayName == null) { + displayName = entity.getId(); + } realm.getUserFederationProviders().add(entity); updateRealm(); - return new UserFederationProviderModel(entity.getId(), providerName, config, priority); + return new UserFederationProviderModel(entity.getId(), providerName, config, priority, displayName); } @Override @@ -828,6 +831,10 @@ public class RealmAdapter extends AbstractMongoAdapter impleme entity.setProviderName(model.getProviderName()); entity.setConfig(model.getConfig()); entity.setPriority(model.getPriority()); + String displayName = model.getDisplayName(); + if (displayName != null) { + entity.setDisplayName(model.getDisplayName()); + } } } updateRealm(); @@ -851,7 +858,7 @@ public class RealmAdapter extends AbstractMongoAdapter impleme }); List result = new LinkedList(); for (UserFederationProviderEntity entity : copy) { - result.add(new UserFederationProviderModel(entity.getId(), entity.getProviderName(), entity.getConfig(), entity.getPriority())); + result.add(new UserFederationProviderModel(entity.getId(), entity.getProviderName(), entity.getConfig(), entity.getPriority(), entity.getDisplayName())); } return result; @@ -867,6 +874,10 @@ public class RealmAdapter extends AbstractMongoAdapter impleme entity.setProviderName(model.getProviderName()); entity.setConfig(model.getConfig()); entity.setPriority(model.getPriority()); + String displayName = model.getDisplayName(); + if (displayName == null) { + entity.setDisplayName(entity.getId()); + } entities.add(entity); } diff --git a/services/src/main/java/org/keycloak/services/resources/admin/UserFederationResource.java b/services/src/main/java/org/keycloak/services/resources/admin/UserFederationResource.java index 4ceef1c122..7e7a0b27ac 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/UserFederationResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/UserFederationResource.java @@ -121,7 +121,11 @@ public class UserFederationResource { public Response createProvider(UserFederationProviderRepresentation rep) { logger.info("createProvider"); auth.requireManage(); - UserFederationProviderModel model = realm.addUserFederationProvider(rep.getProviderName(), rep.getConfig(), rep.getPriority()); + String displayName = rep.getDisplayName(); + if (displayName != null && displayName.trim().equals("")) { + displayName = null; + } + UserFederationProviderModel model = realm.addUserFederationProvider(rep.getProviderName(), rep.getConfig(), rep.getPriority(), displayName); return Response.created(uriInfo.getAbsolutePathBuilder().path(model.getId()).build()).build(); } @@ -137,7 +141,11 @@ public class UserFederationResource { public void updateProvider(@PathParam("id") String id, UserFederationProviderRepresentation rep) { logger.info("updateProvider"); auth.requireManage(); - UserFederationProviderModel model = new UserFederationProviderModel(id, rep.getProviderName(), rep.getConfig(), rep.getPriority()); + String displayName = rep.getDisplayName(); + if (displayName != null && displayName.trim().equals("")) { + displayName = null; + } + UserFederationProviderModel model = new UserFederationProviderModel(id, rep.getProviderName(), rep.getConfig(), rep.getPriority(), displayName); realm.updateUserFederationProvider(model); } @@ -170,7 +178,7 @@ public class UserFederationResource { public void deleteProvider(@PathParam("id") String id) { logger.info("deleteProvider"); auth.requireManage(); - UserFederationProviderModel model = new UserFederationProviderModel(id, null, null, -1); + UserFederationProviderModel model = new UserFederationProviderModel(id, null, null, -1, null); realm.removeUserFederationProvider(model); } 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 ba162623ba..0dbb9474f6 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 @@ -64,7 +64,7 @@ public class FederationProvidersIntegrationTest { - appRealm.addUserFederationProvider(LDAPFederationProviderFactory.PROVIDER_NAME, ldapConfig, 0); + appRealm.addUserFederationProvider(LDAPFederationProviderFactory.PROVIDER_NAME, ldapConfig, 0, null); // Configure LDAP ldapRule.getEmbeddedServer().setupLdapInRealm(appRealm); From 94c06f3f5d44b907f0f563da95747f89ae60fa07 Mon Sep 17 00:00:00 2001 From: Bill Burke Date: Thu, 31 Jul 2014 13:13:48 -0400 Subject: [PATCH 2/2] fed ui --- .../ldap/LDAPFederationProviderFactory.java | 8 ++ .../theme/admin/base/resources/js/app.js | 30 ++++- .../base/resources/js/controllers/users.js | 109 ++++++++++-------- .../theme/admin/base/resources/js/loaders.js | 9 ++ .../theme/admin/base/resources/js/services.js | 9 +- .../resources/partials/federated-generic.html | 42 +++++++ .../resources/partials/federated-ldap.html | 26 +++-- .../base/resources/partials/user-detail.html | 6 + .../resources/partials/user-federation.html | 2 +- .../models/UserFederationProviderFactory.java | 3 + .../models/utils/ModelToRepresentation.java | 1 + .../admin/UserFederationResource.java | 49 ++++++-- .../DummyUserFederationProvider.java | 88 ++++++++++++++ .../DummyUserFederationProviderFactory.java | 48 ++++++++ ...cloak.models.UserFederationProviderFactory | 1 + 15 files changed, 351 insertions(+), 80 deletions(-) create mode 100755 testsuite/integration/src/main/java/org/keycloak/testutils/DummyUserFederationProvider.java create mode 100755 testsuite/integration/src/main/java/org/keycloak/testutils/DummyUserFederationProviderFactory.java create mode 100755 testsuite/integration/src/main/resources/META-INF/services/org.keycloak.models.UserFederationProviderFactory diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/LDAPFederationProviderFactory.java b/federation/ldap/src/main/java/org/keycloak/federation/ldap/LDAPFederationProviderFactory.java index b656d7ac26..155c2a0d66 100755 --- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/LDAPFederationProviderFactory.java +++ b/federation/ldap/src/main/java/org/keycloak/federation/ldap/LDAPFederationProviderFactory.java @@ -7,6 +7,9 @@ import org.keycloak.models.UserFederationProviderModel; import org.keycloak.models.KeycloakSession; import org.picketlink.idm.PartitionManager; +import java.util.Collections; +import java.util.List; + /** * @author Bill Burke * @version $Revision: 1 $ @@ -40,4 +43,9 @@ public class LDAPFederationProviderFactory implements UserFederationProviderFact public String getId() { return PROVIDER_NAME; } + + @Override + public List getConfigurationOptions() { + return Collections.emptyList(); + } } diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/app.js b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/app.js index 937bad7df3..94970f4dda 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/app.js +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/app.js @@ -711,13 +711,13 @@ module.config([ '$routeProvider', function($routeProvider) { }, controller : 'UserFederationCtrl' }) - .when('/realms/:realm/user-federation/providers/ldap/:provider', { + .when('/realms/:realm/user-federation/providers/ldap/:instance', { templateUrl : 'partials/federated-ldap.html', resolve : { realm : function(RealmLoader) { return RealmLoader(); }, - provider : function(UserFederationInstanceLoader) { + instance : function(UserFederationInstanceLoader) { return UserFederationInstanceLoader(); } }, @@ -729,22 +729,40 @@ module.config([ '$routeProvider', function($routeProvider) { realm : function(RealmLoader) { return RealmLoader(); }, - provider : function() { + instance : function() { return {}; } }, controller : 'LDAPCtrl' }) .when('/create/user-federation/:realm/providers/:provider', { - templateUrl : 'partials/federated-ldap.html', + templateUrl : 'partials/federated-generic.html', resolve : { realm : function(RealmLoader) { return RealmLoader(); }, - provider : function() { + instance : function() { return { - providerName: "@provider" + }; + }, + providerFactory : function(UserFederationFactoryLoader) { + return UserFederationFactoryLoader(); + } + }, + controller : 'GenericUserFederationCtrl' + }) + .when('/realms/:realm/user-federation/providers/:provider/:instance', { + templateUrl : 'partials/federated-generic.html', + resolve : { + realm : function(RealmLoader) { + return RealmLoader(); + }, + instance : function(UserFederationInstanceLoader) { + return UserFederationInstanceLoader(); + }, + providerFactory : function(UserFederationFactoryLoader) { + return UserFederationFactoryLoader(); } }, controller : 'GenericUserFederationCtrl' diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/users.js b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/users.js index 034d52b326..0161019b13 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/users.js +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/users.js @@ -176,13 +176,23 @@ module.controller('UserListCtrl', function($scope, realm, User) { -module.controller('UserDetailCtrl', function($scope, realm, user, User, $location, Dialog, Notifications) { +module.controller('UserDetailCtrl', function($scope, realm, user, User, UserFederationInstances, $location, Dialog, Notifications) { $scope.realm = realm; $scope.user = angular.copy(user); $scope.create = !user.username; if ($scope.create) { $scope.user.enabled = true; + } else { + if(user.federationLink) { + console.log("federationLink is not null"); + UserFederationInstances.get({realm : realm.realm, instance: user.federationLink}, function(link) { + $scope.federationLinkName = link.displayName; + $scope.federationLink = "#/realms/" + realm.realm + "/user-federation/providers/" + link.providerName + "/" + link.id; + }) + } else { + console.log("federationLink is null"); + } } $scope.changed = false; // $scope.create; @@ -338,24 +348,27 @@ module.controller('UserFederationCtrl', function($scope, $location, realm, UserF $scope.providers = UserFederationProviders.query({realm: realm.realm}); $scope.addProvider = function(provider) { - console.log('Add provider: ' + provider.name); - $location.url("/create/user-federation/" + realm.realm + "/providers/" + provider.name); + console.log('Add provider: ' + provider.id); + $location.url("/create/user-federation/" + realm.realm + "/providers/" + provider.id); }; $scope.instances = UserFederationInstances.query({realm: realm.realm}); }); -module.controller('GenericUserFederationCtrl', function($scope, $location, Notifications, Dialog, realm, provider, providerFactory, UserFederationInstances) { +module.controller('GenericUserFederationCtrl', function($scope, $location, Notifications, Dialog, realm, instance, providerFactory, UserFederationInstances) { console.log('GenericUserFederationCtrl'); - $scope.provider = angular.copy(provider); - $scope.create = !provider.providerName; + $scope.instance = angular.copy(instance); + $scope.create = !instance.providerName; + $scope.providerFactory = providerFactory; + + console.log("providerFactory: " + providerFactory.id); if ($scope.create) { - $scope.provider.providerName = providerFactory.id; - $scope.provider.config = {}; - $scope.provider.priority = 0; + $scope.instance.providerName = providerFactory.id; + $scope.instance.config = {}; + $scope.instance.priority = 0; } $scope.realm = realm; @@ -363,8 +376,8 @@ module.controller('GenericUserFederationCtrl', function($scope, $location, Notif $scope.changed = false; - $scope.$watch('provider', function() { - if (!angular.equals($scope.provider, provider)) { + $scope.$watch('instance', function() { + if (!angular.equals($scope.instance, instance)) { $scope.changed = true; } @@ -373,16 +386,16 @@ module.controller('GenericUserFederationCtrl', function($scope, $location, Notif $scope.save = function() { $scope.changed = false; if ($scope.create) { - UserFederationInstances.save({realm: realm.realm}, $scope.provider, function () { + UserFederationInstances.save({realm: realm.realm}, $scope.instance, function () { $scope.changed = false; $location.url("/realms/" + realm.realm + "/user-federation"); Notifications.success("The provider has been created."); }); } else { UserFederationInstances.update({realm: realm.realm, - provider: provider.id + instance: instance.id }, - $scope.provider, function () { + $scope.instance, function () { $scope.changed = false; $location.url("/realms/" + realm.realm + "/user-federation"); Notifications.success("The provider has been updated."); @@ -392,11 +405,11 @@ module.controller('GenericUserFederationCtrl', function($scope, $location, Notif }; $scope.reset = function() { - $scope.provider = angular.copy(provider); + $scope.instance = angular.copy(instance); if ($scope.create) { - $scope.provider.providerName = providerFactory.id; - $scope.provider.config = {}; - $scope.provider.priority = 0; + $scope.instance.providerName = providerFactory.id; + $scope.instance.config = {}; + $scope.instance.priority = 0; } $scope.changed = false; }; @@ -406,10 +419,10 @@ module.controller('GenericUserFederationCtrl', function($scope, $location, Notif }; $scope.remove = function() { - Dialog.confirmDelete($scope.provider.id, 'provider', function() { - $scope.provider.$remove({ + Dialog.confirmDelete($scope.instance.id, 'provider', function() { + $scope.instance.$remove({ realm : realm.realm, - provider : $scope.provider.id + instance : $scope.instance.id }, function() { $location.url("/realms/" + realm.realm + "/user-federation"); Notifications.success("The provider has been deleted."); @@ -422,16 +435,16 @@ module.controller('GenericUserFederationCtrl', function($scope, $location, Notif -module.controller('LDAPCtrl', function($scope, $location, Notifications, Dialog, realm, provider, UserFederationInstances, RealmLDAPConnectionTester) { +module.controller('LDAPCtrl', function($scope, $location, Notifications, Dialog, realm, instance, UserFederationInstances, RealmLDAPConnectionTester) { console.log('LDAPCtrl'); - $scope.provider = angular.copy(provider); - $scope.create = !provider.providerName; + $scope.instance = angular.copy(instance); + $scope.create = !instance.providerName; if ($scope.create) { - $scope.provider.providerName = "ldap"; - $scope.provider.config = {}; - $scope.provider.priority = 0; + $scope.instance.providerName = "ldap"; + $scope.instance.config = {}; + $scope.instance.priority = 0; } $scope.ldapVendors = [ @@ -449,23 +462,23 @@ module.controller('LDAPCtrl', function($scope, $location, Notifications, Dialog, $scope.changed = false; - $scope.lastVendor = $scope.provider.config.vendor; + $scope.lastVendor = $scope.instance.config.vendor; - $scope.$watch('provider', function() { - if (!angular.equals($scope.provider, provider)) { + $scope.$watch('instance', function() { + if (!angular.equals($scope.instance, instance)) { $scope.changed = true; } - if (!angular.equals($scope.provider.config.vendor, $scope.lastVendor)) { + if (!angular.equals($scope.instance.config.vendor, $scope.lastVendor)) { console.log("LDAP vendor changed"); - $scope.lastVendor = $scope.provider.config.vendor; + $scope.lastVendor = $scope.instance.config.vendor; if ($scope.lastVendor === "ad") { - $scope.provider.config.usernameLDAPAttribute = "cn"; - $scope.provider.config.userObjectClasses = "person, organizationalPerson"; + $scope.instance.config.usernameLDAPAttribute = "cn"; + $scope.instance.config.userObjectClasses = "person, organizationalPerson"; } else { - $scope.provider.config.usernameLDAPAttribute = "uid"; - $scope.provider.config.userObjectClasses = "inetOrgPerson, organizationalPerson"; + $scope.instance.config.usernameLDAPAttribute = "uid"; + $scope.instance.config.userObjectClasses = "inetOrgPerson, organizationalPerson"; } } }, true); @@ -473,16 +486,16 @@ module.controller('LDAPCtrl', function($scope, $location, Notifications, Dialog, $scope.save = function() { $scope.changed = false; if ($scope.create) { - UserFederationInstances.save({realm: realm.realm}, $scope.provider, function () { + UserFederationInstances.save({realm: realm.realm}, $scope.instance, function () { $scope.changed = false; $location.url("/realms/" + realm.realm + "/user-federation"); Notifications.success("The provider has been created."); }); } else { UserFederationInstances.update({realm: realm.realm, - provider: provider.id + instance: instance.id }, - $scope.provider, function () { + $scope.instance, function () { $scope.changed = false; $location.url("/realms/" + realm.realm + "/user-federation"); Notifications.success("The provider has been updated."); @@ -492,14 +505,14 @@ module.controller('LDAPCtrl', function($scope, $location, Notifications, Dialog, }; $scope.reset = function() { - $scope.provider = angular.copy(provider); + $scope.instance = angular.copy(instance); if ($scope.create) { - $scope.provider.providerName = "ldap"; - $scope.provider.config = {}; - $scope.provider.priority = 0; + $scope.instance.providerName = "ldap"; + $scope.instance.config = {}; + $scope.instance.priority = 0; } $scope.changed = false; - $scope.lastVendor = $scope.provider.config.vendor; + $scope.lastVendor = $scope.instance.config.vendor; }; $scope.cancel = function() { @@ -507,10 +520,10 @@ module.controller('LDAPCtrl', function($scope, $location, Notifications, Dialog, }; $scope.remove = function() { - Dialog.confirmDelete($scope.provider.id, 'provider', function() { - $scope.provider.$remove({ + Dialog.confirmDelete($scope.instance.id, 'provider', function() { + $scope.instance.$remove({ realm : realm.realm, - provider : $scope.provider.id + instance : $scope.instance.id }, function() { $location.url("/realms/" + realm.realm + "/user-federation"); Notifications.success("The provider has been deleted."); @@ -531,7 +544,7 @@ module.controller('LDAPCtrl', function($scope, $location, Notifications, Dialog, $scope.testConnection = function() { console.log('LDAPCtrl: testConnection'); - RealmLDAPConnectionTester.get(initConnectionTest("testConnection", $scope.provider.config), function() { + RealmLDAPConnectionTester.get(initConnectionTest("testConnection", $scope.instance.config), function() { Notifications.success("LDAP connection successful."); }, function() { Notifications.error("Error when trying to connect to LDAP. See server.log for details."); diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/loaders.js b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/loaders.js index f18f1c2c42..987d8c765c 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/loaders.js +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/loaders.js @@ -90,6 +90,15 @@ module.factory('UserLoader', function(Loader, User, $route, $q) { module.factory('UserFederationInstanceLoader', function(Loader, UserFederationInstances, $route, $q) { return Loader.get(UserFederationInstances, function() { + return { + realm : $route.current.params.realm, + instance: $route.current.params.instance + } + }); +}); + +module.factory('UserFederationFactoryLoader', function(Loader, UserFederationProviders, $route, $q) { + return Loader.get(UserFederationProviders, function() { return { realm : $route.current.params.realm, provider: $route.current.params.provider diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/services.js b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/services.js index 6ea04fde83..e8af6643ec 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/services.js +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/services.js @@ -200,9 +200,9 @@ module.factory('User', function($resource) { }); module.factory('UserFederationInstances', function($resource) { - return $resource(authUrl + '/admin/realms/:realm/user-federation/instances/:provider', { + return $resource(authUrl + '/admin/realms/:realm/user-federation/instances/:instance', { realm : '@realm', - provider : '@provider' + instance : '@instance' }, { update : { method : 'PUT' @@ -211,8 +211,9 @@ module.factory('UserFederationInstances', function($resource) { }); module.factory('UserFederationProviders', function($resource) { - return $resource(authUrl + '/admin/realms/:realm/user-federation/providers', { - realm : '@realm' + return $resource(authUrl + '/admin/realms/:realm/user-federation/providers/:provider', { + realm : '@realm', + provider : "@provider" }); }); diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/federated-generic.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/federated-generic.html index 775f8f86f4..0bb813bb0e 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/federated-generic.html +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/federated-generic.html @@ -11,6 +11,48 @@

{{realm.realm}} Provider Settings

* Required fields

+
+
+ Required Settings +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ + +
+ +
+
+ +
+ +
+ + +
+ +
+ + + +
+
\ No newline at end of file diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/federated-ldap.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/federated-ldap.html index edcf14173c..9916be562e 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/federated-ldap.html +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/federated-ldap.html @@ -15,16 +15,22 @@
Required Settings +
+ +
+ +
+
- +
- +
@@ -32,7 +38,7 @@
@@ -43,7 +49,7 @@
@@ -52,13 +58,13 @@
- +
- +
Test connection @@ -67,25 +73,25 @@
- +
- +
- +
- +
Test authentication diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-detail.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-detail.html index 6238039326..d99c518d49 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-detail.html +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-detail.html @@ -75,6 +75,12 @@
+
+ + +
diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-federation.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-federation.html index 352f526b64..aad2d4b6e0 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-federation.html +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/user-federation.html @@ -18,7 +18,7 @@
diff --git a/model/api/src/main/java/org/keycloak/models/UserFederationProviderFactory.java b/model/api/src/main/java/org/keycloak/models/UserFederationProviderFactory.java index b723f3dd74..7b3c38835a 100755 --- a/model/api/src/main/java/org/keycloak/models/UserFederationProviderFactory.java +++ b/model/api/src/main/java/org/keycloak/models/UserFederationProviderFactory.java @@ -2,10 +2,13 @@ package org.keycloak.models; import org.keycloak.provider.ProviderFactory; +import java.util.List; + /** * @author Bill Burke * @version $Revision: 1 $ */ public interface UserFederationProviderFactory extends ProviderFactory { UserFederationProvider getInstance(KeycloakSession session, UserFederationProviderModel model); + List getConfigurationOptions(); } 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 21765a347c..ec0c8442ba 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 @@ -51,6 +51,7 @@ public class ModelToRepresentation { rep.setEnabled(user.isEnabled()); rep.setEmailVerified(user.isEmailVerified()); rep.setTotp(user.isTotp()); + rep.setFederationLink(user.getFederationLink()); List reqActions = new ArrayList(); for (UserModel.RequiredAction ra : user.getRequiredActions()){ diff --git a/services/src/main/java/org/keycloak/services/resources/admin/UserFederationResource.java b/services/src/main/java/org/keycloak/services/resources/admin/UserFederationResource.java index 7e7a0b27ac..e947b1ed6b 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/UserFederationResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/UserFederationResource.java @@ -16,8 +16,10 @@ import org.keycloak.models.RoleModel; import org.keycloak.models.SocialLinkModel; import org.keycloak.models.UserCredentialModel; import org.keycloak.models.UserFederationProvider; +import org.keycloak.models.UserFederationProviderFactory; import org.keycloak.models.UserFederationProviderModel; import org.keycloak.models.UserModel; +import org.keycloak.models.UserProviderFactory; import org.keycloak.models.UserSessionModel; import org.keycloak.models.utils.ModelToRepresentation; import org.keycloak.models.utils.RepresentationToModel; @@ -28,6 +30,7 @@ import org.keycloak.representations.idm.CredentialRepresentation; import org.keycloak.representations.idm.MappingsRepresentation; import org.keycloak.representations.idm.RoleRepresentation; import org.keycloak.representations.idm.SocialLinkRepresentation; +import org.keycloak.representations.idm.UserFederationProviderFactoryRepresentation; import org.keycloak.representations.idm.UserFederationProviderRepresentation; import org.keycloak.representations.idm.UserRepresentation; import org.keycloak.representations.idm.UserSessionRepresentation; @@ -96,19 +99,43 @@ public class UserFederationResource { @GET @Path("providers") @Produces("application/json") - public List> getProviders() { + public List getProviders() { logger.info("get provider list"); auth.requireView(); - List> providers = new LinkedList>(); + List providers = new LinkedList(); for (ProviderFactory factory : session.getKeycloakSessionFactory().getProviderFactories(UserFederationProvider.class)) { - Map provider = new HashMap(); - provider.put("name", factory.getId()); - providers.add(provider); + UserFederationProviderFactoryRepresentation rep = new UserFederationProviderFactoryRepresentation(); + rep.setId(factory.getId()); + rep.setOptions(((UserFederationProviderFactory)factory).getConfigurationOptions()); + providers.add(rep); } logger.info("provider list.size() " + providers.size()); return providers; } + /** + * Get List of available provider factories + * + * @return + */ + @GET + @Path("providers/{id}") + @Produces("application/json") + public UserFederationProviderFactoryRepresentation getProvider(@PathParam("id") String id) { + logger.info("get provider list"); + auth.requireView(); + for (ProviderFactory factory : session.getKeycloakSessionFactory().getProviderFactories(UserFederationProvider.class)) { + if (!factory.getId().equals(id)) { + continue; + } + UserFederationProviderFactoryRepresentation rep = new UserFederationProviderFactoryRepresentation(); + rep.setId(factory.getId()); + rep.setOptions(((UserFederationProviderFactory)factory).getConfigurationOptions()); + return rep; + } + throw new NotFoundException("Could not find provider"); + } + /** * Create a provider * @@ -118,7 +145,7 @@ public class UserFederationResource { @POST @Path("instances") @Consumes("application/json") - public Response createProvider(UserFederationProviderRepresentation rep) { + public Response createProviderInstance(UserFederationProviderRepresentation rep) { logger.info("createProvider"); auth.requireManage(); String displayName = rep.getDisplayName(); @@ -138,7 +165,7 @@ public class UserFederationResource { @PUT @Path("instances/{id}") @Consumes("application/json") - public void updateProvider(@PathParam("id") String id, UserFederationProviderRepresentation rep) { + public void updateProviderInstance(@PathParam("id") String id, UserFederationProviderRepresentation rep) { logger.info("updateProvider"); auth.requireManage(); String displayName = rep.getDisplayName(); @@ -157,7 +184,7 @@ public class UserFederationResource { @GET @Path("instances/{id}") @Consumes("application/json") - public UserFederationProviderRepresentation getProvider(@PathParam("id") String id) { + public UserFederationProviderRepresentation getProviderInstance(@PathParam("id") String id) { logger.info("getProvider"); auth.requireView(); for (UserFederationProviderModel model : realm.getUserFederationProviders()) { @@ -175,7 +202,7 @@ public class UserFederationResource { */ @DELETE @Path("instances/{id}") - public void deleteProvider(@PathParam("id") String id) { + public void deleteProviderInstance(@PathParam("id") String id) { logger.info("deleteProvider"); auth.requireManage(); UserFederationProviderModel model = new UserFederationProviderModel(id, null, null, -1, null); @@ -192,8 +219,8 @@ public class UserFederationResource { @GET @Path("instances") @Produces("application/json") - public List getUserFederationProviders() { - logger.info("getUserFederationProviders"); + public List getUserFederationInstances() { + logger.info("getUserFederationInstances"); auth.requireManage(); List reps = new LinkedList(); for (UserFederationProviderModel model : realm.getUserFederationProviders()) { diff --git a/testsuite/integration/src/main/java/org/keycloak/testutils/DummyUserFederationProvider.java b/testsuite/integration/src/main/java/org/keycloak/testutils/DummyUserFederationProvider.java new file mode 100755 index 0000000000..5d2c36b738 --- /dev/null +++ b/testsuite/integration/src/main/java/org/keycloak/testutils/DummyUserFederationProvider.java @@ -0,0 +1,88 @@ +package org.keycloak.testutils; + +import org.keycloak.models.RealmModel; +import org.keycloak.models.RoleModel; +import org.keycloak.models.UserCredentialModel; +import org.keycloak.models.UserFederationProvider; +import org.keycloak.models.UserModel; + +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * @author Bill Burke + * @version $Revision: 1 $ + */ +public class DummyUserFederationProvider implements UserFederationProvider { + @Override + public UserModel proxy(UserModel local) { + return local; + } + + @Override + public boolean isRegistrationSupported() { + return false; + } + + @Override + public UserModel register(RealmModel realm, UserModel user) { + return user; + } + + @Override + public boolean removeUser(RealmModel realm, UserModel user) { + return true; + } + + @Override + public UserModel getUserByUsername(RealmModel realm, String username) { + return null; + } + + @Override + public UserModel getUserByEmail(RealmModel realm, String email) { + return null; + } + + @Override + public List searchByAttributes(Map attributes, RealmModel realm) { + return Collections.emptyList(); + } + + @Override + public void preRemove(RealmModel realm) { + + } + + @Override + public void preRemove(RealmModel realm, RoleModel role) { + + } + + @Override + public boolean isValid(UserModel local) { + return false; + } + + @Override + public Set getSupportedCredentialTypes() { + return Collections.emptySet(); + } + + @Override + public boolean validCredentials(RealmModel realm, UserModel user, List input) { + return false; + } + + @Override + public boolean validCredentials(RealmModel realm, UserModel user, UserCredentialModel... input) { + return false; + } + + @Override + public void close() { + + } +} diff --git a/testsuite/integration/src/main/java/org/keycloak/testutils/DummyUserFederationProviderFactory.java b/testsuite/integration/src/main/java/org/keycloak/testutils/DummyUserFederationProviderFactory.java new file mode 100755 index 0000000000..2314a67482 --- /dev/null +++ b/testsuite/integration/src/main/java/org/keycloak/testutils/DummyUserFederationProviderFactory.java @@ -0,0 +1,48 @@ +package org.keycloak.testutils; + +import org.keycloak.Config; +import org.keycloak.models.KeycloakSession; +import org.keycloak.models.UserFederationProvider; +import org.keycloak.models.UserFederationProviderFactory; +import org.keycloak.models.UserFederationProviderModel; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Bill Burke + * @version $Revision: 1 $ + */ +public class DummyUserFederationProviderFactory implements UserFederationProviderFactory { + @Override + public UserFederationProvider getInstance(KeycloakSession session, UserFederationProviderModel model) { + return new DummyUserFederationProvider(); + } + + @Override + public List getConfigurationOptions() { + List list = new ArrayList(); + list.add("important.config"); + return list; + } + + @Override + public UserFederationProvider create(KeycloakSession session) { + return new DummyUserFederationProvider(); + } + + @Override + public void init(Config.Scope config) { + + } + + @Override + public void close() { + + } + + @Override + public String getId() { + return "dummy"; + } +} diff --git a/testsuite/integration/src/main/resources/META-INF/services/org.keycloak.models.UserFederationProviderFactory b/testsuite/integration/src/main/resources/META-INF/services/org.keycloak.models.UserFederationProviderFactory new file mode 100755 index 0000000000..82b852c8e0 --- /dev/null +++ b/testsuite/integration/src/main/resources/META-INF/services/org.keycloak.models.UserFederationProviderFactory @@ -0,0 +1 @@ +org.keycloak.testutils.DummyUserFederationProviderFactory \ No newline at end of file