Disable the JpaUserFederatedStorageProvider when map storage is enabled
Closes #12895
This commit is contained in:
parent
d91a5eb99f
commit
29a501552e
4 changed files with 22 additions and 6 deletions
|
@ -17,9 +17,11 @@
|
||||||
package org.keycloak.storage.jpa;
|
package org.keycloak.storage.jpa;
|
||||||
|
|
||||||
import org.keycloak.Config;
|
import org.keycloak.Config;
|
||||||
|
import org.keycloak.common.Profile;
|
||||||
import org.keycloak.connections.jpa.JpaConnectionProvider;
|
import org.keycloak.connections.jpa.JpaConnectionProvider;
|
||||||
import org.keycloak.models.KeycloakSession;
|
import org.keycloak.models.KeycloakSession;
|
||||||
import org.keycloak.models.KeycloakSessionFactory;
|
import org.keycloak.models.KeycloakSessionFactory;
|
||||||
|
import org.keycloak.provider.EnvironmentDependentProviderFactory;
|
||||||
import org.keycloak.storage.federated.UserFederatedStorageProvider;
|
import org.keycloak.storage.federated.UserFederatedStorageProvider;
|
||||||
import org.keycloak.storage.federated.UserFederatedStorageProviderFactory;
|
import org.keycloak.storage.federated.UserFederatedStorageProviderFactory;
|
||||||
|
|
||||||
|
@ -29,7 +31,7 @@ import javax.persistence.EntityManager;
|
||||||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
||||||
* @version $Revision: 1 $
|
* @version $Revision: 1 $
|
||||||
*/
|
*/
|
||||||
public class JpaUserFederatedStorageProviderFactory implements UserFederatedStorageProviderFactory {
|
public class JpaUserFederatedStorageProviderFactory implements UserFederatedStorageProviderFactory, EnvironmentDependentProviderFactory {
|
||||||
@Override
|
@Override
|
||||||
public UserFederatedStorageProvider create(KeycloakSession session) {
|
public UserFederatedStorageProvider create(KeycloakSession session) {
|
||||||
EntityManager em = session.getProvider(JpaConnectionProvider.class).getEntityManager();
|
EntityManager em = session.getProvider(JpaConnectionProvider.class).getEntityManager();
|
||||||
|
@ -55,4 +57,10 @@ public class JpaUserFederatedStorageProviderFactory implements UserFederatedStor
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return "jpa";
|
return "jpa";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSupported() {
|
||||||
|
return !Profile.isFeatureEnabled(Profile.Feature.MAP_STORAGE);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,11 @@ public abstract class MultipleStepsExportProvider implements ExportProvider {
|
||||||
// Count total number of users
|
// Count total number of users
|
||||||
if (!exportUsersIntoRealmFile) {
|
if (!exportUsersIntoRealmFile) {
|
||||||
usersHolder.totalCount = session.users().getUsersCount(realm, true);
|
usersHolder.totalCount = session.users().getUsersCount(realm, true);
|
||||||
federatedUsersHolder.totalCount = UserStorageUtil.userFederatedStorage(session).getStoredUsersCount(realm);
|
if (UserStorageUtil.userFederatedStorage(session) != null) {
|
||||||
|
federatedUsersHolder.totalCount = UserStorageUtil.userFederatedStorage(session).getStoredUsersCount(realm);
|
||||||
|
} else {
|
||||||
|
federatedUsersHolder.totalCount = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -235,10 +235,13 @@ public class ExportUtils {
|
||||||
rep.setUsers(users);
|
rep.setUsers(users);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<UserRepresentation> federatedUsers = userFederatedStorage(session).getStoredUsersStream(realm, 0, -1)
|
UserFederatedStorageProvider userFederatedStorageProvider = userFederatedStorage(session);
|
||||||
.map(user -> exportFederatedUser(session, realm, user, options)).collect(Collectors.toList());
|
if (userFederatedStorageProvider != null) {
|
||||||
if (federatedUsers.size() > 0) {
|
List<UserRepresentation> federatedUsers = userFederatedStorage(session).getStoredUsersStream(realm, 0, -1)
|
||||||
rep.setFederatedUsers(federatedUsers);
|
.map(user -> exportFederatedUser(session, realm, user, options)).collect(Collectors.toList());
|
||||||
|
if (federatedUsers.size() > 0) {
|
||||||
|
rep.setFederatedUsers(federatedUsers);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (options.isClientsIncluded() && options.isOnlyServiceAccountsIncluded()) {
|
} else if (options.isClientsIncluded() && options.isOnlyServiceAccountsIncluded()) {
|
||||||
|
|
|
@ -855,6 +855,7 @@
|
||||||
<keycloak.userCache.enabled>false</keycloak.userCache.enabled>
|
<keycloak.userCache.enabled>false</keycloak.userCache.enabled>
|
||||||
<keycloak.publicKeyCache.enabled>false</keycloak.publicKeyCache.enabled>
|
<keycloak.publicKeyCache.enabled>false</keycloak.publicKeyCache.enabled>
|
||||||
<keycloak.userSessionPersister.provider></keycloak.userSessionPersister.provider>
|
<keycloak.userSessionPersister.provider></keycloak.userSessionPersister.provider>
|
||||||
|
<keycloak.userFederatedStorage.provider></keycloak.userFederatedStorage.provider>
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
Loading…
Reference in a new issue