loadAllLDAPObjects(LDAPQuery ldapQuery, LDAPStorageProvider ldapProvider) {
LDAPConfig ldapConfig = ldapProvider.getLdapIdentityStore().getConfig();
boolean pagination = ldapConfig.isPagination();
if (pagination) {
@@ -269,7 +270,7 @@ public class LDAPUtils {
* @param customFilter
* @throws FederationConfigValidationException
*/
- public static void validateCustomLdapFilter(String customFilter) throws FederationConfigValidationException {
+ public static void validateCustomLdapFilter(String customFilter) throws ComponentValidationException {
if (customFilter != null) {
customFilter = customFilter.trim();
@@ -278,7 +279,7 @@ public class LDAPUtils {
}
if (!customFilter.startsWith("(") || !customFilter.endsWith(")")) {
- throw new FederationConfigValidationException("ldapErrorInvalidCustomFilter");
+ throw new ComponentValidationException("ldapErrorInvalidCustomFilter");
}
}
}
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/ReadonlyLDAPUserModelDelegate.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/ReadonlyLDAPUserModelDelegate.java
similarity index 93%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/ReadonlyLDAPUserModelDelegate.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/ReadonlyLDAPUserModelDelegate.java
index 6a839b6698..18ed8e2d69 100755
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/ReadonlyLDAPUserModelDelegate.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/ReadonlyLDAPUserModelDelegate.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap;
+package org.keycloak.storage.ldap;
import org.keycloak.models.ModelReadOnlyException;
import org.keycloak.models.UserModel;
@@ -27,9 +27,9 @@ import org.keycloak.models.utils.UserModelDelegate;
*/
public class ReadonlyLDAPUserModelDelegate extends UserModelDelegate implements UserModel {
- protected LDAPFederationProvider provider;
+ protected LDAPStorageProvider provider;
- public ReadonlyLDAPUserModelDelegate(UserModel delegate, LDAPFederationProvider provider) {
+ public ReadonlyLDAPUserModelDelegate(UserModel delegate, LDAPStorageProvider provider) {
super(delegate);
this.provider = provider;
}
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/UnsyncedLDAPUserModelDelegate.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/UnsyncedLDAPUserModelDelegate.java
similarity index 91%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/UnsyncedLDAPUserModelDelegate.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/UnsyncedLDAPUserModelDelegate.java
index 4d116e4134..e26104c823 100755
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/UnsyncedLDAPUserModelDelegate.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/UnsyncedLDAPUserModelDelegate.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap;
+package org.keycloak.storage.ldap;
import org.jboss.logging.Logger;
import org.keycloak.models.UserModel;
@@ -28,9 +28,9 @@ import org.keycloak.models.utils.UserModelDelegate;
public class UnsyncedLDAPUserModelDelegate extends UserModelDelegate implements UserModel {
private static final Logger logger = Logger.getLogger(UnsyncedLDAPUserModelDelegate.class);
- protected LDAPFederationProvider provider;
+ protected LDAPStorageProvider provider;
- public UnsyncedLDAPUserModelDelegate(UserModel delegate, LDAPFederationProvider provider) {
+ public UnsyncedLDAPUserModelDelegate(UserModel delegate, LDAPStorageProvider provider) {
super(delegate);
this.provider = provider;
}
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/WritableLDAPUserModelDelegate.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/WritableLDAPUserModelDelegate.java
similarity index 86%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/WritableLDAPUserModelDelegate.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/WritableLDAPUserModelDelegate.java
index 7bc78014cf..6b87bb80c3 100755
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/WritableLDAPUserModelDelegate.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/WritableLDAPUserModelDelegate.java
@@ -15,12 +15,12 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap;
+package org.keycloak.storage.ldap;
import org.jboss.logging.Logger;
-import org.keycloak.federation.ldap.idm.model.LDAPObject;
import org.keycloak.models.UserModel;
import org.keycloak.models.utils.UserModelDelegate;
+import org.keycloak.storage.ldap.idm.model.LDAPObject;
/**
* @author Bill Burke
@@ -29,10 +29,10 @@ import org.keycloak.models.utils.UserModelDelegate;
public class WritableLDAPUserModelDelegate extends UserModelDelegate implements UserModel {
private static final Logger logger = Logger.getLogger(WritableLDAPUserModelDelegate.class);
- protected LDAPFederationProvider provider;
+ protected LDAPStorageProvider provider;
protected LDAPObject ldapObject;
- public WritableLDAPUserModelDelegate(UserModel delegate, LDAPFederationProvider provider, LDAPObject ldapObject) {
+ public WritableLDAPUserModelDelegate(UserModel delegate, LDAPStorageProvider provider, LDAPObject ldapObject) {
super(delegate);
this.provider = provider;
this.ldapObject = ldapObject;
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/model/LDAPDn.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/model/LDAPDn.java
similarity index 98%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/model/LDAPDn.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/model/LDAPDn.java
index bfbce5964a..e95e8adafd 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/model/LDAPDn.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/model/LDAPDn.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.idm.model;
+package org.keycloak.storage.ldap.idm.model;
import javax.naming.ldap.Rdn;
import java.util.Collection;
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/model/LDAPObject.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/model/LDAPObject.java
similarity index 99%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/model/LDAPObject.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/model/LDAPObject.java
index 0141a451f7..64ef65fd07 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/model/LDAPObject.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/model/LDAPObject.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.idm.model;
+package org.keycloak.storage.ldap.idm.model;
import org.jboss.logging.Logger;
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/Condition.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/Condition.java
similarity index 96%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/Condition.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/Condition.java
index a8d3f07182..152b0889ad 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/Condition.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/Condition.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.idm.query;
+package org.keycloak.storage.ldap.idm.query;
/**
* A {@link Condition} is used to specify how a specific query parameter
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/Sort.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/Sort.java
similarity index 95%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/Sort.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/Sort.java
index da982726c3..97e381d052 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/Sort.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/Sort.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.idm.query;
+package org.keycloak.storage.ldap.idm.query;
/**
* @author Pedro Igor
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/BetweenCondition.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/BetweenCondition.java
similarity index 92%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/BetweenCondition.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/BetweenCondition.java
index ba926e9310..dedc29d71b 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/BetweenCondition.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/BetweenCondition.java
@@ -15,9 +15,9 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.idm.query.internal;
+package org.keycloak.storage.ldap.idm.query.internal;
-import org.keycloak.federation.ldap.idm.store.ldap.LDAPUtil;
+import org.keycloak.storage.ldap.idm.store.ldap.LDAPUtil;
import java.util.Date;
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/CustomLDAPFilter.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/CustomLDAPFilter.java
similarity index 92%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/CustomLDAPFilter.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/CustomLDAPFilter.java
index 45b3b1d681..c65a4754cb 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/CustomLDAPFilter.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/CustomLDAPFilter.java
@@ -15,9 +15,9 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.idm.query.internal;
+package org.keycloak.storage.ldap.idm.query.internal;
-import org.keycloak.federation.ldap.idm.query.Condition;
+import org.keycloak.storage.ldap.idm.query.Condition;
/**
* @author Marek Posolda
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/EqualCondition.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/EqualCondition.java
similarity index 93%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/EqualCondition.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/EqualCondition.java
index 115e11f4da..e82fe376d2 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/EqualCondition.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/EqualCondition.java
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.idm.query.internal;
+package org.keycloak.storage.ldap.idm.query.internal;
-import org.keycloak.federation.ldap.idm.store.ldap.LDAPUtil;
import org.keycloak.models.LDAPConstants;
+import org.keycloak.storage.ldap.idm.store.ldap.LDAPUtil;
import java.util.Date;
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/GreaterThanCondition.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/GreaterThanCondition.java
similarity index 92%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/GreaterThanCondition.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/GreaterThanCondition.java
index 3ef6535719..32432e63ba 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/GreaterThanCondition.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/GreaterThanCondition.java
@@ -15,9 +15,9 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.idm.query.internal;
+package org.keycloak.storage.ldap.idm.query.internal;
-import org.keycloak.federation.ldap.idm.store.ldap.LDAPUtil;
+import org.keycloak.storage.ldap.idm.store.ldap.LDAPUtil;
import java.util.Date;
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/InCondition.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/InCondition.java
similarity index 95%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/InCondition.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/InCondition.java
index ebecd54cf6..8f5c26a0e5 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/InCondition.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/InCondition.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.idm.query.internal;
+package org.keycloak.storage.ldap.idm.query.internal;
import org.keycloak.models.LDAPConstants;
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/LDAPQuery.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/LDAPQuery.java
similarity index 83%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/LDAPQuery.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/LDAPQuery.java
index 5a57f84f3d..eb7ff1bb9a 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/LDAPQuery.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/LDAPQuery.java
@@ -15,16 +15,16 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.idm.query.internal;
+package org.keycloak.storage.ldap.idm.query.internal;
-import org.keycloak.federation.ldap.LDAPFederationProvider;
-import org.keycloak.federation.ldap.idm.model.LDAPObject;
-import org.keycloak.federation.ldap.idm.query.Condition;
-import org.keycloak.federation.ldap.idm.query.Sort;
-import org.keycloak.federation.ldap.mappers.LDAPFederationMapper;
+import org.keycloak.component.ComponentModel;
import org.keycloak.models.ModelDuplicateException;
import org.keycloak.models.ModelException;
-import org.keycloak.models.UserFederationMapperModel;
+import org.keycloak.storage.ldap.LDAPStorageProvider;
+import org.keycloak.storage.ldap.idm.model.LDAPObject;
+import org.keycloak.storage.ldap.idm.query.Condition;
+import org.keycloak.storage.ldap.idm.query.Sort;
+import org.keycloak.storage.ldap.mappers.LDAPStorageMapper;
import javax.naming.directory.SearchControls;
import java.util.ArrayList;
@@ -44,7 +44,7 @@ import static java.util.Collections.unmodifiableSet;
*/
public class LDAPQuery {
- private final LDAPFederationProvider ldapFedProvider;
+ private final LDAPStorageProvider ldapFedProvider;
private int offset;
private int limit;
@@ -60,11 +60,11 @@ public class LDAPQuery {
private final Set returningReadOnlyLdapAttributes = new LinkedHashSet();
private final Set objectClasses = new LinkedHashSet();
- private final List mappers = new ArrayList();
+ private final List mappers = new ArrayList<>();
private int searchScope = SearchControls.SUBTREE_SCOPE;
- public LDAPQuery(LDAPFederationProvider ldapProvider) {
+ public LDAPQuery(LDAPStorageProvider ldapProvider) {
this.ldapFedProvider = ldapProvider;
}
@@ -98,7 +98,7 @@ public class LDAPQuery {
return this;
}
- public LDAPQuery addMappers(Collection mappers) {
+ public LDAPQuery addMappers(Collection mappers) {
this.mappers.addAll(mappers);
return this;
}
@@ -128,7 +128,7 @@ public class LDAPQuery {
return unmodifiableSet(this.returningReadOnlyLdapAttributes);
}
- public List getMappers() {
+ public List getMappers() {
return mappers;
}
@@ -152,9 +152,9 @@ public class LDAPQuery {
public List getResultList() {
// Apply mappers now
- List sortedMappers = ldapFedProvider.sortMappersAsc(mappers);
- for (UserFederationMapperModel mapperModel : sortedMappers) {
- LDAPFederationMapper fedMapper = ldapFedProvider.getMapper(mapperModel);
+ List sortedMappers = ldapFedProvider.sortMappersAsc(mappers);
+ for (ComponentModel mapperModel : sortedMappers) {
+ LDAPStorageMapper fedMapper = ldapFedProvider.getMapper(mapperModel);
fedMapper.beforeLDAPQuery(mapperModel, this);
}
@@ -206,7 +206,7 @@ public class LDAPQuery {
return this.conditions;
}
- public LDAPFederationProvider getLdapProvider() {
+ public LDAPStorageProvider getLdapProvider() {
return ldapFedProvider;
}
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/LDAPQueryConditionsBuilder.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/LDAPQueryConditionsBuilder.java
similarity index 94%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/LDAPQueryConditionsBuilder.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/LDAPQueryConditionsBuilder.java
index 4be4ba41c5..715ec3da36 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/LDAPQueryConditionsBuilder.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/LDAPQueryConditionsBuilder.java
@@ -15,11 +15,11 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.idm.query.internal;
+package org.keycloak.storage.ldap.idm.query.internal;
-import org.keycloak.federation.ldap.idm.query.Condition;
-import org.keycloak.federation.ldap.idm.query.Sort;
import org.keycloak.models.ModelException;
+import org.keycloak.storage.ldap.idm.query.Condition;
+import org.keycloak.storage.ldap.idm.query.Sort;
/**
* @author Pedro Igor
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/LessThanCondition.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/LessThanCondition.java
similarity index 92%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/LessThanCondition.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/LessThanCondition.java
index e29b014125..a32fb27867 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/LessThanCondition.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/LessThanCondition.java
@@ -15,9 +15,9 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.idm.query.internal;
+package org.keycloak.storage.ldap.idm.query.internal;
-import org.keycloak.federation.ldap.idm.store.ldap.LDAPUtil;
+import org.keycloak.storage.ldap.idm.store.ldap.LDAPUtil;
import java.util.Date;
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/NamedParameterCondition.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/NamedParameterCondition.java
similarity index 92%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/NamedParameterCondition.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/NamedParameterCondition.java
index 50cb7723be..72a9a0cb81 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/NamedParameterCondition.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/NamedParameterCondition.java
@@ -15,9 +15,9 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.idm.query.internal;
+package org.keycloak.storage.ldap.idm.query.internal;
-import org.keycloak.federation.ldap.idm.query.Condition;
+import org.keycloak.storage.ldap.idm.query.Condition;
/**
* @author Marek Posolda
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/OrCondition.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/OrCondition.java
similarity index 93%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/OrCondition.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/OrCondition.java
index 7f0e93f211..f605f9a97a 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/query/internal/OrCondition.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/query/internal/OrCondition.java
@@ -15,9 +15,9 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.idm.query.internal;
+package org.keycloak.storage.ldap.idm.query.internal;
-import org.keycloak.federation.ldap.idm.query.Condition;
+import org.keycloak.storage.ldap.idm.query.Condition;
/**
* @author Marek Posolda
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/store/IdentityStore.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/store/IdentityStore.java
similarity index 91%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/store/IdentityStore.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/store/IdentityStore.java
index c14f4f03ad..4b2010b072 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/store/IdentityStore.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/store/IdentityStore.java
@@ -15,11 +15,11 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.idm.store;
+package org.keycloak.storage.ldap.idm.store;
-import org.keycloak.federation.ldap.LDAPConfig;
-import org.keycloak.federation.ldap.idm.model.LDAPObject;
-import org.keycloak.federation.ldap.idm.query.internal.LDAPQuery;
+import org.keycloak.storage.ldap.LDAPConfig;
+import org.keycloak.storage.ldap.idm.model.LDAPObject;
+import org.keycloak.storage.ldap.idm.query.internal.LDAPQuery;
import javax.naming.AuthenticationException;
import java.util.List;
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/store/ldap/LDAPIdentityStore.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/store/ldap/LDAPIdentityStore.java
similarity index 97%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/store/ldap/LDAPIdentityStore.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/store/ldap/LDAPIdentityStore.java
index 367fb04d57..6d0e2cc0b3 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/store/ldap/LDAPIdentityStore.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/store/ldap/LDAPIdentityStore.java
@@ -15,18 +15,18 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.idm.store.ldap;
+package org.keycloak.storage.ldap.idm.store.ldap;
import org.jboss.logging.Logger;
-import org.keycloak.federation.ldap.LDAPConfig;
-import org.keycloak.federation.ldap.idm.model.LDAPDn;
-import org.keycloak.federation.ldap.idm.model.LDAPObject;
-import org.keycloak.federation.ldap.idm.query.Condition;
-import org.keycloak.federation.ldap.idm.query.internal.EqualCondition;
-import org.keycloak.federation.ldap.idm.query.internal.LDAPQuery;
-import org.keycloak.federation.ldap.idm.store.IdentityStore;
import org.keycloak.models.LDAPConstants;
import org.keycloak.models.ModelException;
+import org.keycloak.storage.ldap.LDAPConfig;
+import org.keycloak.storage.ldap.idm.model.LDAPDn;
+import org.keycloak.storage.ldap.idm.model.LDAPObject;
+import org.keycloak.storage.ldap.idm.query.Condition;
+import org.keycloak.storage.ldap.idm.query.internal.EqualCondition;
+import org.keycloak.storage.ldap.idm.query.internal.LDAPQuery;
+import org.keycloak.storage.ldap.idm.store.IdentityStore;
import javax.naming.AuthenticationException;
import javax.naming.NamingEnumeration;
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/store/ldap/LDAPOperationManager.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/store/ldap/LDAPOperationManager.java
similarity index 99%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/store/ldap/LDAPOperationManager.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/store/ldap/LDAPOperationManager.java
index 02cd122b21..4fe40020e3 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/store/ldap/LDAPOperationManager.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/store/ldap/LDAPOperationManager.java
@@ -15,13 +15,13 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.idm.store.ldap;
+package org.keycloak.storage.ldap.idm.store.ldap;
import org.jboss.logging.Logger;
-import org.keycloak.federation.ldap.LDAPConfig;
-import org.keycloak.federation.ldap.idm.query.internal.LDAPQuery;
import org.keycloak.models.LDAPConstants;
import org.keycloak.models.ModelException;
+import org.keycloak.storage.ldap.LDAPConfig;
+import org.keycloak.storage.ldap.idm.query.internal.LDAPQuery;
import javax.naming.AuthenticationException;
import javax.naming.Binding;
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/store/ldap/LDAPUtil.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/store/ldap/LDAPUtil.java
similarity index 99%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/store/ldap/LDAPUtil.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/store/ldap/LDAPUtil.java
index a60d4eb988..2dc9d99ccb 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/idm/store/ldap/LDAPUtil.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/idm/store/ldap/LDAPUtil.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.idm.store.ldap;
+package org.keycloak.storage.ldap.idm.store.ldap;
import org.keycloak.models.ModelException;
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/kerberos/LDAPProviderKerberosConfig.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/kerberos/LDAPProviderKerberosConfig.java
similarity index 70%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/kerberos/LDAPProviderKerberosConfig.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/kerberos/LDAPProviderKerberosConfig.java
index 71e219871b..87bfcaf137 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/kerberos/LDAPProviderKerberosConfig.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/kerberos/LDAPProviderKerberosConfig.java
@@ -15,24 +15,25 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.kerberos;
+package org.keycloak.storage.ldap.kerberos;
import org.keycloak.common.constants.KerberosConstants;
+import org.keycloak.component.ComponentModel;
import org.keycloak.federation.kerberos.CommonKerberosConfig;
-import org.keycloak.models.UserFederationProviderModel;
+import org.keycloak.storage.ldap.LDAPStorageProvider;
/**
- * Configuration specific to {@link org.keycloak.federation.ldap.LDAPFederationProvider}
+ * Configuration specific to {@link LDAPStorageProvider}
*
* @author Marek Posolda
*/
public class LDAPProviderKerberosConfig extends CommonKerberosConfig {
- public LDAPProviderKerberosConfig(UserFederationProviderModel userFederationProvider) {
- super(userFederationProvider);
+ public LDAPProviderKerberosConfig(ComponentModel componentModel) {
+ super(componentModel);
}
public boolean isUseKerberosForPasswordAuthentication() {
- return Boolean.valueOf(getConfig().get(KerberosConstants.USE_KERBEROS_FOR_PASSWORD_AUTHENTICATION));
+ return Boolean.valueOf(componentModel.getConfig().getFirst(KerberosConstants.USE_KERBEROS_FOR_PASSWORD_AUTHENTICATION));
}
}
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/AbstractLDAPFederationMapper.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/AbstractLDAPStorageMapper.java
similarity index 50%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/AbstractLDAPFederationMapper.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/AbstractLDAPStorageMapper.java
index 8d203d6815..c6edd96ef6 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/AbstractLDAPFederationMapper.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/AbstractLDAPStorageMapper.java
@@ -15,19 +15,17 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.mappers;
+package org.keycloak.storage.ldap.mappers;
-import org.keycloak.federation.ldap.LDAPFederationProvider;
-import org.keycloak.federation.ldap.idm.model.LDAPObject;
-import org.keycloak.federation.ldap.idm.query.internal.LDAPQuery;
-import org.keycloak.mappers.UserFederationMapper;
+import org.keycloak.component.ComponentModel;
import org.keycloak.models.GroupModel;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.RealmModel;
-import org.keycloak.models.UserFederationMapperModel;
-import org.keycloak.models.UserFederationProvider;
-import org.keycloak.models.UserFederationSyncResult;
import org.keycloak.models.UserModel;
+import org.keycloak.storage.ldap.LDAPStorageProvider;
+import org.keycloak.storage.ldap.idm.model.LDAPObject;
+import org.keycloak.storage.ldap.idm.query.internal.LDAPQuery;
+import org.keycloak.storage.user.SynchronizationResult;
import javax.naming.AuthenticationException;
import java.util.Collections;
@@ -38,49 +36,49 @@ import java.util.List;
*
* @author Marek Posolda
*/
-public abstract class AbstractLDAPFederationMapper {
+public abstract class AbstractLDAPStorageMapper {
- protected final UserFederationMapperModel mapperModel;
- protected final LDAPFederationProvider ldapProvider;
+ protected final ComponentModel mapperModel;
+ protected final LDAPStorageProvider ldapProvider;
protected final RealmModel realm;
- public AbstractLDAPFederationMapper(UserFederationMapperModel mapperModel, LDAPFederationProvider ldapProvider, RealmModel realm) {
+ public AbstractLDAPStorageMapper(ComponentModel mapperModel, LDAPStorageProvider ldapProvider, RealmModel realm) {
this.mapperModel = mapperModel;
this.ldapProvider = ldapProvider;
this.realm = realm;
}
/**
- * @see UserFederationMapper#syncDataFromFederationProviderToKeycloak(UserFederationMapperModel, UserFederationProvider, KeycloakSession, RealmModel)
+ * @see LDAPStorageMapper#syncDataFromFederationProviderToKeycloak(ComponentModel, LDAPStorageProvider, KeycloakSession, RealmModel)
*/
- public UserFederationSyncResult syncDataFromFederationProviderToKeycloak() {
- return new UserFederationSyncResult();
+ public SynchronizationResult syncDataFromFederationProviderToKeycloak() {
+ return new SynchronizationResult();
}
/**
- * @see UserFederationMapper#syncDataFromKeycloakToFederationProvider(UserFederationMapperModel, UserFederationProvider, KeycloakSession, RealmModel)
+ * @see LDAPStorageMapper#syncDataFromKeycloakToFederationProvider(ComponentModel, LDAPStorageProvider, KeycloakSession, RealmModel)
*/
- public UserFederationSyncResult syncDataFromKeycloakToFederationProvider() {
- return new UserFederationSyncResult();
+ public SynchronizationResult syncDataFromKeycloakToFederationProvider() {
+ return new SynchronizationResult();
}
/**
- * @see LDAPFederationMapper#beforeLDAPQuery(UserFederationMapperModel, LDAPQuery)
+ * @see LDAPStorageMapper#beforeLDAPQuery(ComponentModel, LDAPQuery)
*/
public abstract void beforeLDAPQuery(LDAPQuery query);
/**
- * @see LDAPFederationMapper#proxy(UserFederationMapperModel, LDAPFederationProvider, LDAPObject, UserModel, RealmModel)
+ * @see LDAPStorageMapper#proxy(ComponentModel, LDAPStorageProvider, LDAPObject, UserModel, RealmModel)
*/
public abstract UserModel proxy(LDAPObject ldapUser, UserModel delegate);
/**
- * @see LDAPFederationMapper#onRegisterUserToLDAP(UserFederationMapperModel, LDAPFederationProvider, LDAPObject, UserModel, RealmModel)
+ * @see LDAPStorageMapper#onRegisterUserToLDAP(ComponentModel, LDAPStorageProvider, LDAPObject, UserModel, RealmModel)
*/
public abstract void onRegisterUserToLDAP(LDAPObject ldapUser, UserModel localUser);
/**
- * @see LDAPFederationMapper#onImportUserFromLDAP(UserFederationMapperModel, LDAPFederationProvider, LDAPObject, UserModel, RealmModel, boolean)
+ * @see LDAPStorageMapper#onImportUserFromLDAP(ComponentModel, LDAPStorageProvider, LDAPObject, UserModel, RealmModel, boolean)
*/
public abstract void onImportUserFromLDAP(LDAPObject ldapUser, UserModel user, boolean isCreate);
@@ -93,12 +91,12 @@ public abstract class AbstractLDAPFederationMapper {
}
- public static boolean parseBooleanParameter(UserFederationMapperModel mapperModel, String paramName) {
- String paramm = mapperModel.getConfig().get(paramName);
+ public static boolean parseBooleanParameter(ComponentModel mapperModel, String paramName) {
+ String paramm = mapperModel.getConfig().getFirst(paramName);
return Boolean.parseBoolean(paramm);
}
- public LDAPFederationProvider getLdapProvider() {
+ public LDAPStorageProvider getLdapProvider() {
return ldapProvider;
}
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/AbstractLDAPFederationMapperFactory.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/AbstractLDAPStorageMapperFactory.java
similarity index 63%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/AbstractLDAPFederationMapperFactory.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/AbstractLDAPStorageMapperFactory.java
index ccd4aa61dc..a6ba2d2651 100755
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/AbstractLDAPFederationMapperFactory.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/AbstractLDAPStorageMapperFactory.java
@@ -15,27 +15,26 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.mappers;
-
-import java.util.List;
+package org.keycloak.storage.ldap.mappers;
import org.keycloak.Config;
-import org.keycloak.federation.ldap.LDAPFederationProvider;
-import org.keycloak.federation.ldap.LDAPFederationProviderFactory;
-import org.keycloak.mappers.FederationConfigValidationException;
-import org.keycloak.mappers.UserFederationMapper;
-import org.keycloak.mappers.UserFederationMapperFactory;
+import org.keycloak.component.ComponentModel;
+import org.keycloak.component.ComponentValidationException;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.KeycloakSessionFactory;
import org.keycloak.models.RealmModel;
-import org.keycloak.models.UserFederationMapperModel;
import org.keycloak.provider.ProviderConfigProperty;
import org.keycloak.representations.idm.UserFederationMapperSyncConfigRepresentation;
+import org.keycloak.storage.ldap.LDAPStorageProvider;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
/**
* @author Marek Posolda
*/
-public abstract class AbstractLDAPFederationMapperFactory implements UserFederationMapperFactory {
+public abstract class AbstractLDAPStorageMapperFactory implements LDAPStorageMapperFactory {
// Used to map attributes from LDAP to UserModel attributes
public static final String ATTRIBUTE_MAPPER_CATEGORY = "Attribute Mapper";
@@ -52,25 +51,23 @@ public abstract class AbstractLDAPFederationMapperFactory implements UserFederat
}
@Override
- public UserFederationMapper create(KeycloakSession session) {
- return new LDAPFederationMapperBridge(this);
- }
+ public LDAPStorageMapper create(KeycloakSession session, ComponentModel model) {
+ return new LDAPStorageMapperBridge(this); }
// Used just by LDAPFederationMapperBridge.
- protected abstract AbstractLDAPFederationMapper createMapper(UserFederationMapperModel mapperModel, LDAPFederationProvider federationProvider, RealmModel realm);
-
- @Override
- public String getFederationProviderType() {
- return LDAPFederationProviderFactory.PROVIDER_NAME;
- }
+ protected abstract AbstractLDAPStorageMapper createMapper(ComponentModel mapperModel, LDAPStorageProvider federationProvider, RealmModel realm);
@Override
public void postInit(KeycloakSessionFactory factory) {
}
@Override
- public UserFederationMapperSyncConfigRepresentation getSyncConfig() {
- return new UserFederationMapperSyncConfigRepresentation(false, null, false, null);
+ public Map getTypeMetadata() {
+ Map metadata = new HashMap<>();
+ metadata.put("fedToKeycloakSyncSupported", false);
+ metadata.put("keycloakToFedSyncSupported", false);
+
+ return metadata;
}
@Override
@@ -87,10 +84,10 @@ public abstract class AbstractLDAPFederationMapperFactory implements UserFederat
return configProperty;
}
- protected void checkMandatoryConfigAttribute(String name, String displayName, UserFederationMapperModel mapperModel) throws FederationConfigValidationException {
- String attrConfigValue = mapperModel.getConfig().get(name);
+ protected void checkMandatoryConfigAttribute(String name, String displayName, ComponentModel mapperModel) throws ComponentValidationException {
+ String attrConfigValue = mapperModel.getConfig().getFirst(name);
if (attrConfigValue == null || attrConfigValue.trim().isEmpty()) {
- throw new FederationConfigValidationException("Missing configuration for '" + displayName + "'");
+ throw new ComponentValidationException("Missing configuration for '" + displayName + "'");
}
}
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/FullNameLDAPFederationMapper.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/FullNameLDAPStorageMapper.java
similarity index 89%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/FullNameLDAPFederationMapper.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/FullNameLDAPStorageMapper.java
index c2cabe412d..1806ecdf89 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/FullNameLDAPFederationMapper.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/FullNameLDAPStorageMapper.java
@@ -15,18 +15,18 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.mappers;
+package org.keycloak.storage.ldap.mappers;
-import org.keycloak.federation.ldap.LDAPFederationProvider;
-import org.keycloak.federation.ldap.idm.model.LDAPObject;
-import org.keycloak.federation.ldap.idm.query.Condition;
-import org.keycloak.federation.ldap.idm.query.internal.EqualCondition;
-import org.keycloak.federation.ldap.idm.query.internal.LDAPQuery;
+import org.keycloak.component.ComponentModel;
import org.keycloak.models.LDAPConstants;
import org.keycloak.models.RealmModel;
-import org.keycloak.models.UserFederationMapperModel;
-import org.keycloak.models.UserFederationProvider;
import org.keycloak.models.UserModel;
+import org.keycloak.storage.ldap.LDAPStorageProvider;
+import org.keycloak.storage.ldap.LDAPStorageProviderFactory;
+import org.keycloak.storage.ldap.idm.model.LDAPObject;
+import org.keycloak.storage.ldap.idm.query.Condition;
+import org.keycloak.storage.ldap.idm.query.internal.EqualCondition;
+import org.keycloak.storage.ldap.idm.query.internal.LDAPQuery;
import java.util.HashSet;
import java.util.Set;
@@ -36,14 +36,14 @@ import java.util.Set;
*
* @author Marek Posolda
*/
-public class FullNameLDAPFederationMapper extends AbstractLDAPFederationMapper {
+public class FullNameLDAPStorageMapper extends AbstractLDAPStorageMapper {
public static final String LDAP_FULL_NAME_ATTRIBUTE = "ldap.full.name.attribute";
public static final String READ_ONLY = "read.only";
public static final String WRITE_ONLY = "write.only";
- public FullNameLDAPFederationMapper(UserFederationMapperModel mapperModel, LDAPFederationProvider ldapProvider, RealmModel realm) {
+ public FullNameLDAPStorageMapper(ComponentModel mapperModel, LDAPStorageProvider ldapProvider, RealmModel realm) {
super(mapperModel, ldapProvider, realm);
}
@@ -84,7 +84,7 @@ public class FullNameLDAPFederationMapper extends AbstractLDAPFederationMapper {
@Override
public UserModel proxy(LDAPObject ldapUser, UserModel delegate) {
- if (ldapProvider.getEditMode() == UserFederationProvider.EditMode.WRITABLE && !isReadOnly()) {
+ if (ldapProvider.getEditMode() == LDAPStorageProviderFactory.EditMode.WRITABLE && !isReadOnly()) {
TxAwareLDAPUserModelDelegate txDelegate = new TxAwareLDAPUserModelDelegate(delegate, ldapProvider, ldapUser) {
@@ -169,7 +169,7 @@ public class FullNameLDAPFederationMapper extends AbstractLDAPFederationMapper {
}
protected String getLdapFullNameAttrName() {
- String ldapFullNameAttrName = mapperModel.getConfig().get(LDAP_FULL_NAME_ATTRIBUTE);
+ String ldapFullNameAttrName = mapperModel.getConfig().getFirst(LDAP_FULL_NAME_ATTRIBUTE);
return ldapFullNameAttrName == null ? LDAPConstants.CN : ldapFullNameAttrName;
}
diff --git a/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/FullNameLDAPStorageMapperFactory.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/FullNameLDAPStorageMapperFactory.java
new file mode 100755
index 0000000000..3cfa6c5204
--- /dev/null
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/FullNameLDAPStorageMapperFactory.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2016 Red Hat, Inc. and/or its affiliates
+ * and other contributors as indicated by the @author tags.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.keycloak.storage.ldap.mappers;
+
+import org.keycloak.component.ComponentModel;
+import org.keycloak.component.ComponentValidationException;
+import org.keycloak.models.KeycloakSession;
+import org.keycloak.models.LDAPConstants;
+import org.keycloak.models.RealmModel;
+import org.keycloak.models.UserFederationProvider;
+import org.keycloak.models.UserFederationProviderModel;
+import org.keycloak.provider.ProviderConfigProperty;
+import org.keycloak.provider.ProviderConfigurationBuilder;
+import org.keycloak.storage.ldap.LDAPConfig;
+import org.keycloak.storage.ldap.LDAPStorageProvider;
+import org.keycloak.storage.ldap.LDAPStorageProviderFactory;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Marek Posolda
+ */
+public class FullNameLDAPStorageMapperFactory extends AbstractLDAPStorageMapperFactory {
+
+ public static final String PROVIDER_ID = "full-name-ldap-mapper";
+
+ protected static final List configProperties;
+
+ static {
+ configProperties = getConfigProps(null);
+ }
+
+ private static List getConfigProps(ComponentModel parent) {
+ boolean readOnly = false;
+ if (parent != null) {
+ LDAPConfig config = new LDAPConfig(parent.getConfig());
+ readOnly = config.getEditMode() != LDAPStorageProviderFactory.EditMode.WRITABLE;
+ }
+
+
+ return ProviderConfigurationBuilder.create()
+ .property().name(FullNameLDAPStorageMapper.LDAP_FULL_NAME_ATTRIBUTE)
+ .label("LDAP Full Name Attribute")
+ .helpText("Name of LDAP attribute, which contains fullName of user. Usually it will be 'cn' ")
+ .type(ProviderConfigProperty.STRING_TYPE)
+ .defaultValue(LDAPConstants.CN)
+ .add()
+ .property().name(FullNameLDAPStorageMapper.READ_ONLY)
+ .label("Read Only")
+ .helpText("For Read-only is data imported from LDAP to Keycloak DB, but it's not saved back to LDAP when user is updated in Keycloak.")
+ .type(ProviderConfigProperty.BOOLEAN_TYPE)
+ .defaultValue(String.valueOf(readOnly))
+ .add()
+ .property().name(FullNameLDAPStorageMapper.WRITE_ONLY)
+ .label("Write Only")
+ .helpText("For Write-only is data propagated to LDAP when user is created or updated in Keycloak. But this mapper is not used to propagate data from LDAP back into Keycloak. " +
+ "This setting is useful if you configured separate firstName and lastName attribute mappers and you want to use those to read attribute from LDAP into Keycloak")
+ .type(ProviderConfigProperty.BOOLEAN_TYPE)
+ .defaultValue(String.valueOf(!readOnly))
+ .add()
+ .build();
+ }
+
+ @Override
+ public String getHelpText() {
+ return "Used to map full-name of user from single attribute in LDAP (usually 'cn' attribute) to firstName and lastName attributes of UserModel in Keycloak DB";
+ }
+
+ @Override
+ public List getConfigProperties() {
+ return configProperties;
+ }
+
+ @Override
+ public String getId() {
+ return PROVIDER_ID;
+ }
+
+ @Override
+ public void validateConfiguration(KeycloakSession session, RealmModel realm, ComponentModel config) throws ComponentValidationException {
+ checkMandatoryConfigAttribute(FullNameLDAPStorageMapper.LDAP_FULL_NAME_ATTRIBUTE, "LDAP Full Name Attribute", config);
+
+
+ boolean readOnly = AbstractLDAPStorageMapper.parseBooleanParameter(config, FullNameLDAPStorageMapper.READ_ONLY);
+ boolean writeOnly = AbstractLDAPStorageMapper.parseBooleanParameter(config, FullNameLDAPStorageMapper.WRITE_ONLY);
+
+ ComponentModel parent = realm.getComponent(config.getParentId());
+ if (parent == null) {
+ throw new ComponentValidationException("can't find parent component model");
+
+ }
+ LDAPConfig cfg = new LDAPConfig(parent.getConfig());
+ LDAPStorageProviderFactory.EditMode editMode = cfg.getEditMode();
+
+ if (writeOnly && cfg.getEditMode() != LDAPStorageProviderFactory.EditMode.WRITABLE) {
+ throw new ComponentValidationException("ldapErrorCantWriteOnlyForReadOnlyLdap");
+ }
+ if (writeOnly && readOnly) {
+ throw new ComponentValidationException("ldapErrorCantWriteOnlyAndReadOnly");
+ }
+ }
+
+ @Override
+ protected AbstractLDAPStorageMapper createMapper(ComponentModel mapperModel, LDAPStorageProvider federationProvider, RealmModel realm) {
+ return new FullNameLDAPStorageMapper(mapperModel, federationProvider, realm);
+ }
+}
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/HardcodedLDAPRoleMapper.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/HardcodedLDAPRoleStorageMapper.java
similarity index 85%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/HardcodedLDAPRoleMapper.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/HardcodedLDAPRoleStorageMapper.java
index 67e577eebe..ca79a1905e 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/HardcodedLDAPRoleMapper.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/HardcodedLDAPRoleStorageMapper.java
@@ -15,33 +15,33 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.mappers;
+package org.keycloak.storage.ldap.mappers;
import org.jboss.logging.Logger;
-import org.keycloak.federation.ldap.LDAPFederationProvider;
-import org.keycloak.federation.ldap.idm.model.LDAPObject;
-import org.keycloak.federation.ldap.idm.query.internal.LDAPQuery;
+import org.keycloak.component.ComponentModel;
import org.keycloak.models.ClientModel;
import org.keycloak.models.ModelException;
import org.keycloak.models.RealmModel;
import org.keycloak.models.RoleModel;
-import org.keycloak.models.UserFederationMapperModel;
import org.keycloak.models.UserModel;
import org.keycloak.models.utils.KeycloakModelUtils;
import org.keycloak.models.utils.UserModelDelegate;
+import org.keycloak.storage.ldap.LDAPStorageProvider;
+import org.keycloak.storage.ldap.idm.model.LDAPObject;
+import org.keycloak.storage.ldap.idm.query.internal.LDAPQuery;
import java.util.Set;
/**
* @author Marek Posolda
*/
-public class HardcodedLDAPRoleMapper extends AbstractLDAPFederationMapper {
+public class HardcodedLDAPRoleStorageMapper extends AbstractLDAPStorageMapper {
- private static final Logger logger = Logger.getLogger(HardcodedLDAPRoleMapper.class);
+ private static final Logger logger = Logger.getLogger(HardcodedLDAPRoleStorageMapper.class);
public static final String ROLE = "role";
- public HardcodedLDAPRoleMapper(UserFederationMapperModel mapperModel, LDAPFederationProvider ldapProvider, RealmModel realm) {
+ public HardcodedLDAPRoleStorageMapper(ComponentModel mapperModel, LDAPStorageProvider ldapProvider, RealmModel realm) {
super(mapperModel, ldapProvider, realm);
}
@@ -116,7 +116,7 @@ public class HardcodedLDAPRoleMapper extends AbstractLDAPFederationMapper {
}
private RoleModel getRole() {
- String roleName = mapperModel.getConfig().get(HardcodedLDAPRoleMapper.ROLE);
+ String roleName = mapperModel.getConfig().getFirst(HardcodedLDAPRoleStorageMapper.ROLE);
RoleModel role = KeycloakModelUtils.getRoleFromString(realm, roleName);
if (role == null) {
logger.warnf("Hardcoded role '%s' configured in mapper '%s' is not available anymore");
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/HardcodedLDAPRoleMapperFactory.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/HardcodedLDAPRoleStorageMapperFactory.java
similarity index 58%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/HardcodedLDAPRoleMapperFactory.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/HardcodedLDAPRoleStorageMapperFactory.java
index 2f1170d11c..c833504f20 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/HardcodedLDAPRoleMapperFactory.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/HardcodedLDAPRoleStorageMapperFactory.java
@@ -15,32 +15,30 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.mappers;
+package org.keycloak.storage.ldap.mappers;
-import org.keycloak.federation.ldap.LDAPFederationProvider;
-import org.keycloak.mappers.FederationConfigValidationException;
+import org.keycloak.component.ComponentModel;
+import org.keycloak.component.ComponentValidationException;
+import org.keycloak.models.KeycloakSession;
import org.keycloak.models.RealmModel;
import org.keycloak.models.RoleModel;
-import org.keycloak.models.UserFederationMapperModel;
-import org.keycloak.models.UserFederationProviderModel;
import org.keycloak.models.utils.KeycloakModelUtils;
import org.keycloak.provider.ProviderConfigProperty;
+import org.keycloak.storage.ldap.LDAPStorageProvider;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
/**
* @author Marek Posolda
*/
-public class HardcodedLDAPRoleMapperFactory extends AbstractLDAPFederationMapperFactory {
+public class HardcodedLDAPRoleStorageMapperFactory extends AbstractLDAPStorageMapperFactory {
public static final String PROVIDER_ID = "hardcoded-ldap-role-mapper";
protected static final List configProperties = new ArrayList();
static {
- ProviderConfigProperty roleAttr = createConfigProperty(HardcodedLDAPRoleMapper.ROLE, "Role",
+ ProviderConfigProperty roleAttr = createConfigProperty(HardcodedLDAPRoleStorageMapper.ROLE, "Role",
"Role to grant to user. Click 'Select Role' button to browse roles, or just type it in the textbox. To reference an application role the syntax is appname.approle, i.e. myapp.myrole",
ProviderConfigProperty.ROLE_TYPE, null);
configProperties.add(roleAttr);
@@ -51,45 +49,30 @@ public class HardcodedLDAPRoleMapperFactory extends AbstractLDAPFederationMapper
return "When user is imported from LDAP, he will be automatically added into this configured role.";
}
- @Override
- public String getDisplayCategory() {
- return ROLE_MAPPER_CATEGORY;
- }
-
- @Override
- public String getDisplayType() {
- return "Hardcoded Role";
- }
-
@Override
public List getConfigProperties() {
return configProperties;
}
- @Override
- public Map getDefaultConfig(UserFederationProviderModel providerModel) {
- return new HashMap<>();
- }
-
@Override
public String getId() {
return PROVIDER_ID;
}
@Override
- public void validateConfig(RealmModel realm, UserFederationProviderModel fedProviderModel, UserFederationMapperModel mapperModel) throws FederationConfigValidationException {
- String roleName = mapperModel.getConfig().get(HardcodedLDAPRoleMapper.ROLE);
+ public void validateConfiguration(KeycloakSession session, RealmModel realm, ComponentModel config) throws ComponentValidationException {
+ String roleName = config.getConfig().getFirst(HardcodedLDAPRoleStorageMapper.ROLE);
if (roleName == null) {
- throw new FederationConfigValidationException("Role can't be null");
+ throw new ComponentValidationException("Role can't be null");
}
RoleModel role = KeycloakModelUtils.getRoleFromString(realm, roleName);
if (role == null) {
- throw new FederationConfigValidationException("There is no role corresponding to configured value");
+ throw new ComponentValidationException("There is no role corresponding to configured value");
}
}
@Override
- protected AbstractLDAPFederationMapper createMapper(UserFederationMapperModel mapperModel, LDAPFederationProvider federationProvider, RealmModel realm) {
- return new HardcodedLDAPRoleMapper(mapperModel, federationProvider, realm);
+ protected AbstractLDAPStorageMapper createMapper(ComponentModel mapperModel, LDAPStorageProvider federationProvider, RealmModel realm) {
+ return new HardcodedLDAPRoleStorageMapper(mapperModel, federationProvider, realm);
}
}
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/LDAPMappersComparator.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/LDAPMappersComparator.java
similarity index 63%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/LDAPMappersComparator.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/LDAPMappersComparator.java
index 893cca765d..f659c2b3a9 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/LDAPMappersComparator.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/LDAPMappersComparator.java
@@ -15,11 +15,11 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.mappers;
+package org.keycloak.storage.ldap.mappers;
-import org.keycloak.federation.ldap.LDAPConfig;
-import org.keycloak.models.UserFederationMapperModel;
+import org.keycloak.component.ComponentModel;
import org.keycloak.models.UserModel;
+import org.keycloak.storage.ldap.LDAPConfig;
import java.util.ArrayList;
import java.util.Collection;
@@ -28,30 +28,30 @@ import java.util.Comparator;
import java.util.List;
/**
- * TODO: Possibly add "priority" to UserFederationMapper instead of hardcoding behaviour
+ * TODO: Possibly add "priority" instead of hardcoding behaviour
*
* @author Marek Posolda
*/
public class LDAPMappersComparator {
- public static List sortAsc(LDAPConfig ldapConfig, Collection mappers) {
- Comparator comparator = new ImportantFirstComparator(ldapConfig);
+ public static List sortAsc(LDAPConfig ldapConfig, Collection mappers) {
+ Comparator comparator = new ImportantFirstComparator(ldapConfig);
- List result = new ArrayList<>(mappers);
+ List result = new ArrayList<>(mappers);
Collections.sort(result, comparator);
return result;
}
- public static List sortDesc(LDAPConfig ldapConfig, Collection mappers) {
- Comparator comparator = new ImportantFirstComparator(ldapConfig).reversed();
+ public static List sortDesc(LDAPConfig ldapConfig, Collection mappers) {
+ Comparator comparator = new ImportantFirstComparator(ldapConfig).reversed();
- List result = new ArrayList<>(mappers);
+ List result = new ArrayList<>(mappers);
Collections.sort(result, comparator);
return result;
}
- private static class ImportantFirstComparator implements Comparator {
+ private static class ImportantFirstComparator implements Comparator {
private final LDAPConfig ldapConfig;
@@ -60,10 +60,10 @@ public class LDAPMappersComparator {
}
@Override
- public int compare(UserFederationMapperModel o1, UserFederationMapperModel o2) {
+ public int compare(ComponentModel o1, ComponentModel o2) {
// UserAttributeLDAPFederationMapper first
- boolean isO1AttrMapper = o1.getFederationMapperType().equals(UserAttributeLDAPFederationMapperFactory.PROVIDER_ID);
- boolean isO2AttrMapper = o2.getFederationMapperType().equals(UserAttributeLDAPFederationMapperFactory.PROVIDER_ID);
+ boolean isO1AttrMapper = o1.getProviderId().equals(UserAttributeLDAPStorageMapperFactory.PROVIDER_ID);
+ boolean isO2AttrMapper = o2.getProviderId().equals(UserAttributeLDAPStorageMapperFactory.PROVIDER_ID);
if (!isO1AttrMapper) {
if (isO2AttrMapper) {
return 1;
@@ -75,8 +75,8 @@ public class LDAPMappersComparator {
}
// Mapper for "username" attribute first
- String model1 = o1.getConfig().get(UserAttributeLDAPFederationMapper.USER_MODEL_ATTRIBUTE);
- String model2 = o2.getConfig().get(UserAttributeLDAPFederationMapper.USER_MODEL_ATTRIBUTE);
+ String model1 = o1.getConfig().getFirst(UserAttributeLDAPStorageMapper.USER_MODEL_ATTRIBUTE);
+ String model2 = o2.getConfig().getFirst(UserAttributeLDAPStorageMapper.USER_MODEL_ATTRIBUTE);
boolean isO1UsernameMapper = model1 != null && model1.equalsIgnoreCase(UserModel.USERNAME);
boolean isO2UsernameMapper = model2 != null && model2.equalsIgnoreCase(UserModel.USERNAME);
if (!isO1UsernameMapper) {
@@ -90,8 +90,8 @@ public class LDAPMappersComparator {
}
// The username mapper corresponding to the same like configured username for federationProvider is first
- String o1LdapAttr = o1.getConfig().get(UserAttributeLDAPFederationMapper.LDAP_ATTRIBUTE);
- String o2LdapAttr = o2.getConfig().get(UserAttributeLDAPFederationMapper.LDAP_ATTRIBUTE);
+ String o1LdapAttr = o1.getConfig().getFirst(UserAttributeLDAPStorageMapper.LDAP_ATTRIBUTE);
+ String o2LdapAttr = o2.getConfig().getFirst(UserAttributeLDAPStorageMapper.LDAP_ATTRIBUTE);
boolean isO1LdapAttr = o1LdapAttr != null && ldapConfig.getUsernameLdapAttribute().equalsIgnoreCase(o1LdapAttr);
boolean isO2LdapAttr = o2LdapAttr != null && ldapConfig.getUsernameLdapAttribute().equalsIgnoreCase(o2LdapAttr);
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/LDAPFederationMapper.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/LDAPStorageMapper.java
similarity index 50%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/LDAPFederationMapper.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/LDAPStorageMapper.java
index 52acbfb528..39831e1749 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/LDAPFederationMapper.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/LDAPStorageMapper.java
@@ -15,23 +15,54 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.mappers;
+package org.keycloak.storage.ldap.mappers;
-import org.keycloak.federation.ldap.LDAPFederationProvider;
-import org.keycloak.federation.ldap.idm.model.LDAPObject;
-import org.keycloak.federation.ldap.idm.query.internal.LDAPQuery;
-import org.keycloak.mappers.UserFederationMapper;
+import org.keycloak.component.ComponentModel;
+import org.keycloak.models.GroupModel;
+import org.keycloak.models.KeycloakSession;
import org.keycloak.models.RealmModel;
-import org.keycloak.models.UserFederationMapperModel;
import org.keycloak.models.UserModel;
+import org.keycloak.provider.Provider;
+import org.keycloak.storage.ldap.LDAPStorageProvider;
+import org.keycloak.storage.ldap.idm.model.LDAPObject;
+import org.keycloak.storage.ldap.idm.query.internal.LDAPQuery;
+import org.keycloak.storage.user.SynchronizationResult;
import javax.naming.AuthenticationException;
+import java.util.List;
/**
* @author Marek Posolda
*/
-public interface LDAPFederationMapper extends UserFederationMapper {
+public interface LDAPStorageMapper extends Provider {
+ /**
+ * Sync data from federated storage to Keycloak. It's useful just if mapper needs some data preloaded from federated storage (For example
+ * load roles from federated provider and sync them to Keycloak database)
+ *
+ * Applicable just if sync is supported
+ *
+ * @param mapperModel
+ * @param provider
+ * @param session
+ * @param realm
+ */
+ SynchronizationResult syncDataFromFederationProviderToKeycloak(ComponentModel mapperModel, LDAPStorageProvider provider, KeycloakSession session, RealmModel realm);
+
+ /**
+ * Sync data from Keycloak back to federated storage
+ *
+ * @param mapperModel
+ * @param provider
+ * @param session
+ * @param realm
+ */
+ SynchronizationResult syncDataFromKeycloakToFederationProvider(ComponentModel mapperModel, LDAPStorageProvider provider, KeycloakSession session, RealmModel realm);
+
+ /**
+ * Return empty list if doesn't support storing of groups
+ */
+ List getGroupMembers(ComponentModel mapperModel, LDAPStorageProvider provider, RealmModel realm, GroupModel group, int firstResult, int maxResults);
/**
* Called when importing user from LDAP to local keycloak DB.
@@ -43,7 +74,7 @@ public interface LDAPFederationMapper extends UserFederationMapper {
* @param realm
* @param isCreate true if we importing new user from LDAP. False if user already exists in Keycloak, but we are upgrading (syncing) it from LDAP
*/
- void onImportUserFromLDAP(UserFederationMapperModel mapperModel, LDAPFederationProvider ldapProvider, LDAPObject ldapUser, UserModel user, RealmModel realm, boolean isCreate);
+ void onImportUserFromLDAP(ComponentModel mapperModel, LDAPStorageProvider ldapProvider, LDAPObject ldapUser, UserModel user, RealmModel realm, boolean isCreate);
/**
@@ -55,7 +86,7 @@ public interface LDAPFederationMapper extends UserFederationMapper {
* @param localUser
* @param realm
*/
- void onRegisterUserToLDAP(UserFederationMapperModel mapperModel, LDAPFederationProvider ldapProvider, LDAPObject ldapUser, UserModel localUser, RealmModel realm);
+ void onRegisterUserToLDAP(ComponentModel mapperModel, LDAPStorageProvider ldapProvider, LDAPObject ldapUser, UserModel localUser, RealmModel realm);
/**
@@ -68,7 +99,7 @@ public interface LDAPFederationMapper extends UserFederationMapper {
* @param realm
* @return
*/
- UserModel proxy(UserFederationMapperModel mapperModel, LDAPFederationProvider ldapProvider, LDAPObject ldapUser, UserModel delegate, RealmModel realm);
+ UserModel proxy(ComponentModel mapperModel, LDAPStorageProvider ldapProvider, LDAPObject ldapUser, UserModel delegate, RealmModel realm);
/**
@@ -77,7 +108,7 @@ public interface LDAPFederationMapper extends UserFederationMapper {
* @param mapperModel
* @param query
*/
- void beforeLDAPQuery(UserFederationMapperModel mapperModel, LDAPQuery query);
+ void beforeLDAPQuery(ComponentModel mapperModel, LDAPQuery query);
/**
* Called when LDAP authentication of specified user fails. If any mapper returns true from this method, AuthenticationException won't be rethrown!
@@ -90,5 +121,5 @@ public interface LDAPFederationMapper extends UserFederationMapper {
* @param ldapException
* @return true if mapper processed the AuthenticationException and did some actions based on that. In that case, AuthenticationException won't be rethrown!
*/
- boolean onAuthenticationFailure(UserFederationMapperModel mapperModel, LDAPFederationProvider ldapProvider, LDAPObject ldapUser, UserModel user, AuthenticationException ldapException, RealmModel realm);
+ boolean onAuthenticationFailure(ComponentModel mapperModel, LDAPStorageProvider ldapProvider, LDAPObject ldapUser, UserModel user, AuthenticationException ldapException, RealmModel realm);
}
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/LDAPFederationMapperBridge.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/LDAPStorageMapperBridge.java
similarity index 50%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/LDAPFederationMapperBridge.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/LDAPStorageMapperBridge.java
index 1a3521af35..f3919cc76c 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/LDAPFederationMapperBridge.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/LDAPStorageMapperBridge.java
@@ -15,18 +15,17 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.mappers;
+package org.keycloak.storage.ldap.mappers;
-import org.keycloak.federation.ldap.LDAPFederationProvider;
-import org.keycloak.federation.ldap.idm.model.LDAPObject;
-import org.keycloak.federation.ldap.idm.query.internal.LDAPQuery;
+import org.keycloak.component.ComponentModel;
import org.keycloak.models.GroupModel;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.RealmModel;
-import org.keycloak.models.UserFederationMapperModel;
-import org.keycloak.models.UserFederationProvider;
-import org.keycloak.models.UserFederationSyncResult;
import org.keycloak.models.UserModel;
+import org.keycloak.storage.ldap.LDAPStorageProvider;
+import org.keycloak.storage.ldap.idm.model.LDAPObject;
+import org.keycloak.storage.ldap.idm.query.internal.LDAPQuery;
+import org.keycloak.storage.user.SynchronizationResult;
import javax.naming.AuthenticationException;
import java.util.List;
@@ -36,59 +35,59 @@ import java.util.List;
*
* @author Marek Posolda
*/
-public class LDAPFederationMapperBridge implements LDAPFederationMapper {
+public class LDAPStorageMapperBridge implements LDAPStorageMapper {
- private final AbstractLDAPFederationMapperFactory factory;
+ private final AbstractLDAPStorageMapperFactory factory;
- public LDAPFederationMapperBridge(AbstractLDAPFederationMapperFactory factory) {
+ public LDAPStorageMapperBridge(AbstractLDAPStorageMapperFactory factory) {
this.factory = factory;
}
// Sync groups from LDAP to Keycloak DB
@Override
- public UserFederationSyncResult syncDataFromFederationProviderToKeycloak(UserFederationMapperModel mapperModel, UserFederationProvider federationProvider, KeycloakSession session, RealmModel realm) {
+ public SynchronizationResult syncDataFromFederationProviderToKeycloak(ComponentModel mapperModel, LDAPStorageProvider federationProvider, KeycloakSession session, RealmModel realm) {
return getDelegate(mapperModel, federationProvider, realm).syncDataFromFederationProviderToKeycloak();
}
@Override
- public UserFederationSyncResult syncDataFromKeycloakToFederationProvider(UserFederationMapperModel mapperModel, UserFederationProvider federationProvider, KeycloakSession session, RealmModel realm) {
+ public SynchronizationResult syncDataFromKeycloakToFederationProvider(ComponentModel mapperModel, LDAPStorageProvider federationProvider, KeycloakSession session, RealmModel realm) {
return getDelegate(mapperModel, federationProvider, realm).syncDataFromKeycloakToFederationProvider();
}
@Override
- public void onImportUserFromLDAP(UserFederationMapperModel mapperModel, LDAPFederationProvider ldapProvider, LDAPObject ldapUser, UserModel user, RealmModel realm, boolean isCreate) {
+ public void onImportUserFromLDAP(ComponentModel mapperModel, LDAPStorageProvider ldapProvider, LDAPObject ldapUser, UserModel user, RealmModel realm, boolean isCreate) {
getDelegate(mapperModel, ldapProvider, realm).onImportUserFromLDAP(ldapUser, user, isCreate);
}
@Override
- public void onRegisterUserToLDAP(UserFederationMapperModel mapperModel, LDAPFederationProvider ldapProvider, LDAPObject ldapUser, UserModel localUser, RealmModel realm) {
+ public void onRegisterUserToLDAP(ComponentModel mapperModel, LDAPStorageProvider ldapProvider, LDAPObject ldapUser, UserModel localUser, RealmModel realm) {
getDelegate(mapperModel, ldapProvider, realm).onRegisterUserToLDAP(ldapUser, localUser);
}
@Override
- public UserModel proxy(UserFederationMapperModel mapperModel, LDAPFederationProvider ldapProvider, LDAPObject ldapUser, UserModel delegate, RealmModel realm) {
+ public UserModel proxy(ComponentModel mapperModel, LDAPStorageProvider ldapProvider, LDAPObject ldapUser, UserModel delegate, RealmModel realm) {
return getDelegate(mapperModel, ldapProvider, realm).proxy(ldapUser, delegate);
}
@Override
- public void beforeLDAPQuery(UserFederationMapperModel mapperModel, LDAPQuery query) {
+ public void beforeLDAPQuery(ComponentModel mapperModel, LDAPQuery query) {
// Improve if needed
getDelegate(mapperModel, query.getLdapProvider(), null).beforeLDAPQuery(query);
}
@Override
- public List getGroupMembers(UserFederationMapperModel mapperModel, UserFederationProvider ldapProvider, RealmModel realm, GroupModel group, int firstResult, int maxResults) {
+ public List getGroupMembers(ComponentModel mapperModel, LDAPStorageProvider ldapProvider, RealmModel realm, GroupModel group, int firstResult, int maxResults) {
return getDelegate(mapperModel, ldapProvider, realm).getGroupMembers(group, firstResult, maxResults);
}
@Override
- public boolean onAuthenticationFailure(UserFederationMapperModel mapperModel, LDAPFederationProvider ldapProvider, LDAPObject ldapUser, UserModel user, AuthenticationException ldapException, RealmModel realm) {
+ public boolean onAuthenticationFailure(ComponentModel mapperModel, LDAPStorageProvider ldapProvider, LDAPObject ldapUser, UserModel user, AuthenticationException ldapException, RealmModel realm) {
return getDelegate(mapperModel, ldapProvider, realm).onAuthenticationFailure(ldapUser, user, ldapException);
}
- private AbstractLDAPFederationMapper getDelegate(UserFederationMapperModel mapperModel, UserFederationProvider federationProvider, RealmModel realm) {
- LDAPFederationProvider ldapProvider = (LDAPFederationProvider) federationProvider;
+ private AbstractLDAPStorageMapper getDelegate(ComponentModel mapperModel, LDAPStorageProvider federationProvider, RealmModel realm) {
+ LDAPStorageProvider ldapProvider = (LDAPStorageProvider) federationProvider;
return factory.createMapper(mapperModel, ldapProvider, realm);
}
diff --git a/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/LDAPStorageMapperFactory.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/LDAPStorageMapperFactory.java
new file mode 100644
index 0000000000..d5e8318ed3
--- /dev/null
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/LDAPStorageMapperFactory.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2016 Red Hat, Inc. and/or its affiliates
+ * and other contributors as indicated by the @author tags.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.keycloak.storage.ldap.mappers;
+
+import org.keycloak.Config;
+import org.keycloak.component.ComponentFactory;
+import org.keycloak.component.ComponentModel;
+import org.keycloak.component.ComponentValidationException;
+import org.keycloak.component.SubComponentFactory;
+import org.keycloak.models.KeycloakSession;
+import org.keycloak.models.KeycloakSessionFactory;
+import org.keycloak.models.RealmModel;
+import org.keycloak.provider.ProviderConfigProperty;
+import org.keycloak.representations.idm.UserFederationMapperSyncConfigRepresentation;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author Bill Burke
+ * @version $Revision: 1 $
+ */
+public interface LDAPStorageMapperFactory extends SubComponentFactory {
+ /**
+ * called per Keycloak transaction.
+ *
+ * @param session
+ * @param model
+ * @return
+ */
+ T create(KeycloakSession session, ComponentModel model);
+
+ /**
+ * This is the name of the provider and will be showed in the admin console as an option.
+ *
+ * @return
+ */
+ @Override
+ String getId();
+
+ @Override
+ default void init(Config.Scope config) {
+
+ }
+
+ @Override
+ default void postInit(KeycloakSessionFactory factory) {
+
+ }
+
+ @Override
+ default void close() {
+
+ }
+
+ @Override
+ default String getHelpText() {
+ return "";
+ }
+
+ @Override
+ default List getConfigProperties() {
+ return Collections.EMPTY_LIST;
+ }
+
+ @Override
+ default void validateConfiguration(KeycloakSession session, RealmModel realm, ComponentModel config) throws ComponentValidationException {
+
+ }
+
+ /**
+ * Called when UserStorageProviderModel is created. This allows you to do initialization of any additional configuration
+ * you need to add. For example, you may be introspecting a database or ldap schema to automatically create mappings.
+ *
+ * @param session
+ * @param realm
+ * @param model
+ */
+ @Override
+ default void onCreate(KeycloakSession session, RealmModel realm, ComponentModel model) {
+
+ }
+}
diff --git a/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/LDAPStorageMapperSpi.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/LDAPStorageMapperSpi.java
new file mode 100644
index 0000000000..c7b8185dbf
--- /dev/null
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/LDAPStorageMapperSpi.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2016 Red Hat, Inc. and/or its affiliates
+ * and other contributors as indicated by the @author tags.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.keycloak.storage.ldap.mappers;
+
+import org.keycloak.credential.CredentialProvider;
+import org.keycloak.credential.CredentialProviderFactory;
+import org.keycloak.provider.Provider;
+import org.keycloak.provider.ProviderFactory;
+import org.keycloak.provider.Spi;
+
+/**
+ * @author Kunal Kerkar
+ */
+public class LDAPStorageMapperSpi implements Spi {
+
+ @Override
+ public boolean isInternal() {
+ return false;
+ }
+
+ @Override
+ public String getName() {
+ return "ldap-mapper";
+ }
+
+ @Override
+ public Class extends Provider> getProviderClass() {
+ return LDAPStorageMapper.class;
+ }
+
+ @Override
+ public Class extends ProviderFactory> getProviderFactoryClass() {
+ return LDAPStorageMapperFactory.class;
+ }
+}
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/PasswordUpdated.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/PasswordUpdated.java
similarity index 90%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/PasswordUpdated.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/PasswordUpdated.java
index 1ec5ad8e3c..c4d7b5eef8 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/PasswordUpdated.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/PasswordUpdated.java
@@ -14,11 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.keycloak.federation.ldap.mappers;
+package org.keycloak.storage.ldap.mappers;
import org.keycloak.credential.CredentialInput;
-import org.keycloak.federation.ldap.idm.model.LDAPObject;
import org.keycloak.models.UserModel;
+import org.keycloak.storage.ldap.idm.model.LDAPObject;
/**
* @author Bill Burke
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/TxAwareLDAPUserModelDelegate.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/TxAwareLDAPUserModelDelegate.java
similarity index 94%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/TxAwareLDAPUserModelDelegate.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/TxAwareLDAPUserModelDelegate.java
index 9126a668b8..4fc5cafb25 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/TxAwareLDAPUserModelDelegate.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/TxAwareLDAPUserModelDelegate.java
@@ -15,14 +15,14 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.mappers;
+package org.keycloak.storage.ldap.mappers;
import org.jboss.logging.Logger;
-import org.keycloak.federation.ldap.LDAPFederationProvider;
-import org.keycloak.federation.ldap.idm.model.LDAPObject;
import org.keycloak.models.KeycloakTransaction;
import org.keycloak.models.UserModel;
import org.keycloak.models.utils.UserModelDelegate;
+import org.keycloak.storage.ldap.LDAPStorageProvider;
+import org.keycloak.storage.ldap.idm.model.LDAPObject;
/**
* @author Marek Posolda
@@ -31,11 +31,11 @@ public abstract class TxAwareLDAPUserModelDelegate extends UserModelDelegate {
public static final Logger logger = Logger.getLogger(TxAwareLDAPUserModelDelegate.class);
- protected LDAPFederationProvider provider;
+ protected LDAPStorageProvider provider;
protected LDAPObject ldapUser;
private final LDAPTransaction transaction;
- public TxAwareLDAPUserModelDelegate(UserModel delegate, LDAPFederationProvider provider, LDAPObject ldapUser) {
+ public TxAwareLDAPUserModelDelegate(UserModel delegate, LDAPStorageProvider provider, LDAPObject ldapUser) {
super(delegate);
this.provider = provider;
this.ldapUser = ldapUser;
diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/UserAttributeLDAPFederationMapper.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/UserAttributeLDAPStorageMapper.java
similarity index 90%
rename from federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/UserAttributeLDAPFederationMapper.java
rename to federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/UserAttributeLDAPStorageMapper.java
index bc1041595e..cd41c5af43 100644
--- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/UserAttributeLDAPFederationMapper.java
+++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/mappers/UserAttributeLDAPStorageMapper.java
@@ -15,25 +15,25 @@
* limitations under the License.
*/
-package org.keycloak.federation.ldap.mappers;
+package org.keycloak.storage.ldap.mappers;
import org.jboss.logging.Logger;
-import org.keycloak.federation.ldap.LDAPFederationProvider;
-import org.keycloak.federation.ldap.idm.model.LDAPObject;
-import org.keycloak.federation.ldap.idm.query.Condition;
-import org.keycloak.federation.ldap.idm.query.internal.LDAPQuery;
+import org.keycloak.component.ComponentModel;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.LDAPConstants;
import org.keycloak.models.ModelDuplicateException;
import org.keycloak.models.RealmModel;
-import org.keycloak.models.UserFederationMapperModel;
-import org.keycloak.models.UserFederationProvider;
import org.keycloak.models.UserModel;
import org.keycloak.models.utils.KeycloakModelUtils;
import org.keycloak.models.utils.UserModelDelegate;
import org.keycloak.models.utils.reflection.Property;
import org.keycloak.models.utils.reflection.PropertyCriteria;
import org.keycloak.models.utils.reflection.PropertyQueries;
+import org.keycloak.storage.ldap.LDAPStorageProvider;
+import org.keycloak.storage.ldap.LDAPStorageProviderFactory;
+import org.keycloak.storage.ldap.idm.model.LDAPObject;
+import org.keycloak.storage.ldap.idm.query.Condition;
+import org.keycloak.storage.ldap.idm.query.internal.LDAPQuery;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -48,9 +48,9 @@ import java.util.Set;
/**
* @author Marek Posolda
*/
-public class UserAttributeLDAPFederationMapper extends AbstractLDAPFederationMapper {
+public class UserAttributeLDAPStorageMapper extends AbstractLDAPStorageMapper {
- private static final Logger logger = Logger.getLogger(UserAttributeLDAPFederationMapper.class);
+ private static final Logger logger = Logger.getLogger(UserAttributeLDAPStorageMapper.class);
private static final Map> userModelProperties;
@@ -81,14 +81,14 @@ public class UserAttributeLDAPFederationMapper extends AbstractLDAPFederationMap
public static final String ALWAYS_READ_VALUE_FROM_LDAP = "always.read.value.from.ldap";
public static final String IS_MANDATORY_IN_LDAP = "is.mandatory.in.ldap";
- public UserAttributeLDAPFederationMapper(UserFederationMapperModel mapperModel, LDAPFederationProvider ldapProvider, RealmModel realm) {
+ public UserAttributeLDAPStorageMapper(ComponentModel mapperModel, LDAPStorageProvider ldapProvider, RealmModel realm) {
super(mapperModel, ldapProvider, realm);
}
@Override
public void onImportUserFromLDAP(LDAPObject ldapUser, UserModel user, boolean isCreate) {
- String userModelAttrName = mapperModel.getConfig().get(USER_MODEL_ATTRIBUTE);
- String ldapAttrName = mapperModel.getConfig().get(LDAP_ATTRIBUTE);
+ String userModelAttrName = mapperModel.getConfig().getFirst(USER_MODEL_ATTRIBUTE);
+ String ldapAttrName = mapperModel.getConfig().getFirst(LDAP_ATTRIBUTE);
Property