Map Store Removal: Rename Legacy* classes (#26273)
Closes #24105 Signed-off-by: Martin Kanis <mkanis@redhat.com>
This commit is contained in:
parent
5bf2d4b6ec
commit
84603a9363
71 changed files with 209 additions and 245 deletions
14
.github/workflows/ci.yml
vendored
14
.github/workflows/ci.yml
vendored
|
@ -251,8 +251,8 @@ jobs:
|
||||||
with:
|
with:
|
||||||
job-id: jdk-integration-tests-${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.version }}
|
job-id: jdk-integration-tests-${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.version }}
|
||||||
|
|
||||||
legacy-store-integration-tests:
|
store-integration-tests:
|
||||||
name: Legacy Store IT
|
name: Store IT
|
||||||
needs: [build, conditional]
|
needs: [build, conditional]
|
||||||
if: needs.conditional.outputs.ci-store == 'true'
|
if: needs.conditional.outputs.ci-store == 'true'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -283,13 +283,13 @@ jobs:
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ github.token }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
with:
|
with:
|
||||||
job-name: Legacy Store IT
|
job-name: Store IT
|
||||||
|
|
||||||
- name: Surefire reports
|
- name: Surefire reports
|
||||||
if: always()
|
if: always()
|
||||||
uses: ./.github/actions/archive-surefire-reports
|
uses: ./.github/actions/archive-surefire-reports
|
||||||
with:
|
with:
|
||||||
job-id: legacy-store-integration-tests-${{ matrix.db }}
|
job-id: store-integration-tests-${{ matrix.db }}
|
||||||
|
|
||||||
store-model-tests:
|
store-model-tests:
|
||||||
name: Store Model Tests
|
name: Store Model Tests
|
||||||
|
@ -325,7 +325,7 @@ jobs:
|
||||||
job-id: store-model-tests
|
job-id: store-model-tests
|
||||||
|
|
||||||
clustering-integration-tests:
|
clustering-integration-tests:
|
||||||
name: Legacy Clustering IT
|
name: Clustering IT
|
||||||
needs: build
|
needs: build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 35
|
timeout-minutes: 35
|
||||||
|
@ -351,7 +351,7 @@ jobs:
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ github.token }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
with:
|
with:
|
||||||
job-name: Legacy Clustering IT
|
job-name: Clustering IT
|
||||||
|
|
||||||
- name: Surefire reports
|
- name: Surefire reports
|
||||||
if: always()
|
if: always()
|
||||||
|
@ -650,7 +650,7 @@ jobs:
|
||||||
- quarkus-unit-tests
|
- quarkus-unit-tests
|
||||||
- quarkus-integration-tests
|
- quarkus-integration-tests
|
||||||
- jdk-integration-tests
|
- jdk-integration-tests
|
||||||
- legacy-store-integration-tests
|
- store-integration-tests
|
||||||
- store-model-tests
|
- store-model-tests
|
||||||
- clustering-integration-tests
|
- clustering-integration-tests
|
||||||
- fips-unit-tests
|
- fips-unit-tests
|
||||||
|
|
|
@ -224,3 +224,11 @@ PUT /admin/realms/{realm}/users/{id}/execute-actions-email
|
||||||
= Removal of the deprecated mode for SAML encryption
|
= Removal of the deprecated mode for SAML encryption
|
||||||
|
|
||||||
The compatibility mode for SAML encryption introduced in version 21 is now removed. The system property `keycloak.saml.deprecated.encryption` is not managed anymore by the server. The clients which still used the old signing key for encryption should update it from the new IDP configuration metadata.
|
The compatibility mode for SAML encryption introduced in version 21 is now removed. The system property `keycloak.saml.deprecated.encryption` is not managed anymore by the server. The clients which still used the old signing key for encryption should update it from the new IDP configuration metadata.
|
||||||
|
|
||||||
|
= Renaming JPA provider configuration options for migration
|
||||||
|
|
||||||
|
After removal of the Map Store the following configuration options were renamed:
|
||||||
|
|
||||||
|
* `spi-connections-jpa-legacy-initialize-empty` to `spi-connections-jpa-quarkus-initialize-empty`
|
||||||
|
* `spi-connections-jpa-legacy-migration-export` to `spi-connections-jpa-quarkus-migration-export`
|
||||||
|
* `spi-connections-jpa-legacy-migration-strategy` to `spi-connections-jpa-quarkus-migration-strategy`
|
||||||
|
|
|
@ -31,7 +31,7 @@ default `connections-jpa` provider:
|
||||||
|
|
||||||
[source,bash]
|
[source,bash]
|
||||||
----
|
----
|
||||||
kc.[sh|bat] start --spi-connections-jpa-legacy-migration-strategy=manual
|
kc.[sh|bat] start --spi-connections-jpa-quarkus-migration-strategy=manual
|
||||||
----
|
----
|
||||||
|
|
||||||
When you start the server with this configuration it checks if the database needs to be migrated.
|
When you start the server with this configuration it checks if the database needs to be migrated.
|
||||||
|
@ -42,7 +42,7 @@ default `connections-jpa` provider:
|
||||||
|
|
||||||
[source,bash]
|
[source,bash]
|
||||||
----
|
----
|
||||||
kc.[sh|bat] start --spi-connections-jpa-legacy-migration-export=<path>/<file.sql>
|
kc.[sh|bat] start --spi-connections-jpa-quarkus-migration-export=<path>/<file.sql>
|
||||||
----
|
----
|
||||||
|
|
||||||
For further details on how to apply this file to the database, see the documentation for the relational database you're using.
|
For further details on how to apply this file to the database, see the documentation for the relational database you're using.
|
||||||
|
|
|
@ -247,16 +247,16 @@ The maximum timeout for this lock is 900 seconds. If a node waits on this lock f
|
||||||
To setup the JPA migrationStrategy (manual/update/validate) you should setup JPA provider as follows:
|
To setup the JPA migrationStrategy (manual/update/validate) you should setup JPA provider as follows:
|
||||||
|
|
||||||
.Setting the `migration-strategy` for the `quarkus` provider of the `connections-jpa` SPI
|
.Setting the `migration-strategy` for the `quarkus` provider of the `connections-jpa` SPI
|
||||||
<@kc.start parameters="--spi-connections-jpa-legacy-migration-strategy=manual"/>
|
<@kc.start parameters="--spi-connections-jpa-quarkus-migration-strategy=manual"/>
|
||||||
|
|
||||||
If you want to get a SQL file for DB initialization, too, you have to add this additional SPI initializeEmpty (true/false):
|
If you want to get a SQL file for DB initialization, too, you have to add this additional SPI initializeEmpty (true/false):
|
||||||
|
|
||||||
.Setting the `initialize-empty` for the `quarkus` provider of the `connections-jpa` SPI
|
.Setting the `initialize-empty` for the `quarkus` provider of the `connections-jpa` SPI
|
||||||
<@kc.start parameters="--spi-connections-jpa-legacy-initialize-empty=false"/>
|
<@kc.start parameters="--spi-connections-jpa-quarkus-initialize-empty=false"/>
|
||||||
|
|
||||||
In the same way the migrationExport to point to a specific file and location:
|
In the same way the migrationExport to point to a specific file and location:
|
||||||
|
|
||||||
.Setting the `migration-export` for the `quarkus` provider of the `connections-jpa` SPI
|
.Setting the `migration-export` for the `quarkus` provider of the `connections-jpa` SPI
|
||||||
<@kc.start parameters="--spi-connections-jpa-legacy-migration-export=<path>/<file.sql>"/>
|
<@kc.start parameters="--spi-connections-jpa-quarkus-migration-export=<path>/<file.sql>"/>
|
||||||
|
|
||||||
</@tmpl.guide>
|
</@tmpl.guide>
|
||||||
|
|
|
@ -24,7 +24,7 @@ import org.keycloak.credential.CredentialAuthentication;
|
||||||
import org.keycloak.credential.CredentialInput;
|
import org.keycloak.credential.CredentialInput;
|
||||||
import org.keycloak.credential.CredentialInputUpdater;
|
import org.keycloak.credential.CredentialInputUpdater;
|
||||||
import org.keycloak.credential.CredentialInputValidator;
|
import org.keycloak.credential.CredentialInputValidator;
|
||||||
import org.keycloak.credential.LegacyUserCredentialManager;
|
import org.keycloak.credential.UserCredentialManager;
|
||||||
import org.keycloak.federation.kerberos.impl.KerberosUsernamePasswordAuthenticator;
|
import org.keycloak.federation.kerberos.impl.KerberosUsernamePasswordAuthenticator;
|
||||||
import org.keycloak.federation.kerberos.impl.SPNEGOAuthenticator;
|
import org.keycloak.federation.kerberos.impl.SPNEGOAuthenticator;
|
||||||
import org.keycloak.models.CredentialValidationOutput;
|
import org.keycloak.models.CredentialValidationOutput;
|
||||||
|
@ -168,7 +168,7 @@ public class KerberosFederationProvider implements UserStorageProvider,
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid(RealmModel realm, UserModel user, CredentialInput input) {
|
public boolean isValid(RealmModel realm, UserModel user, CredentialInput input) {
|
||||||
if (!(input instanceof UserCredentialModel)) return false;
|
if (!(input instanceof UserCredentialModel)) return false;
|
||||||
if (input.getType().equals(PasswordCredentialModel.TYPE) && !((LegacyUserCredentialManager) user.credentialManager()).isConfiguredLocally(PasswordCredentialModel.TYPE)) {
|
if (input.getType().equals(PasswordCredentialModel.TYPE) && !((UserCredentialManager) user.credentialManager()).isConfiguredLocally(PasswordCredentialModel.TYPE)) {
|
||||||
return validPassword(user.getFirstAttribute(KERBEROS_PRINCIPAL), input.getChallengeResponse());
|
return validPassword(user.getFirstAttribute(KERBEROS_PRINCIPAL), input.getChallengeResponse());
|
||||||
} else {
|
} else {
|
||||||
return false; // invalid cred type
|
return false; // invalid cred type
|
||||||
|
|
|
@ -45,7 +45,7 @@ import org.keycloak.credential.CredentialAuthentication;
|
||||||
import org.keycloak.credential.CredentialInput;
|
import org.keycloak.credential.CredentialInput;
|
||||||
import org.keycloak.credential.CredentialInputUpdater;
|
import org.keycloak.credential.CredentialInputUpdater;
|
||||||
import org.keycloak.credential.CredentialInputValidator;
|
import org.keycloak.credential.CredentialInputValidator;
|
||||||
import org.keycloak.credential.LegacyUserCredentialManager;
|
import org.keycloak.credential.UserCredentialManager;
|
||||||
import org.keycloak.federation.kerberos.KerberosPrincipal;
|
import org.keycloak.federation.kerberos.KerberosPrincipal;
|
||||||
import org.keycloak.federation.kerberos.impl.KerberosUsernamePasswordAuthenticator;
|
import org.keycloak.federation.kerberos.impl.KerberosUsernamePasswordAuthenticator;
|
||||||
import org.keycloak.federation.kerberos.impl.SPNEGOAuthenticator;
|
import org.keycloak.federation.kerberos.impl.SPNEGOAuthenticator;
|
||||||
|
@ -68,7 +68,7 @@ import org.keycloak.policy.PasswordPolicyManagerProvider;
|
||||||
import org.keycloak.policy.PolicyError;
|
import org.keycloak.policy.PolicyError;
|
||||||
import org.keycloak.models.cache.UserCache;
|
import org.keycloak.models.cache.UserCache;
|
||||||
import org.keycloak.storage.DatastoreProvider;
|
import org.keycloak.storage.DatastoreProvider;
|
||||||
import org.keycloak.storage.LegacyStoreManagers;
|
import org.keycloak.storage.StoreManagers;
|
||||||
import org.keycloak.storage.ReadOnlyException;
|
import org.keycloak.storage.ReadOnlyException;
|
||||||
import org.keycloak.storage.StorageId;
|
import org.keycloak.storage.StorageId;
|
||||||
import org.keycloak.storage.UserStoragePrivateUtil;
|
import org.keycloak.storage.UserStoragePrivateUtil;
|
||||||
|
@ -205,7 +205,7 @@ public class LDAPStorageProvider implements UserStorageProvider,
|
||||||
|
|
||||||
// We need to avoid having CachedUserModel as cache is upper-layer then LDAP. Hence having CachedUserModel here may cause StackOverflowError
|
// We need to avoid having CachedUserModel as cache is upper-layer then LDAP. Hence having CachedUserModel here may cause StackOverflowError
|
||||||
if (local instanceof CachedUserModel) {
|
if (local instanceof CachedUserModel) {
|
||||||
LegacyStoreManagers datastoreProvider = (LegacyStoreManagers) session.getProvider(DatastoreProvider.class);
|
StoreManagers datastoreProvider = (StoreManagers) session.getProvider(DatastoreProvider.class);
|
||||||
local = datastoreProvider.userStorageManager().getUserById(realm, local.getId());
|
local = datastoreProvider.userStorageManager().getUserById(realm, local.getId());
|
||||||
|
|
||||||
existing = userManager.getManagedProxiedUser(local.getId());
|
existing = userManager.getManagedProxiedUser(local.getId());
|
||||||
|
@ -841,7 +841,7 @@ public class LDAPStorageProvider implements UserStorageProvider,
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid(RealmModel realm, UserModel user, CredentialInput input) {
|
public boolean isValid(RealmModel realm, UserModel user, CredentialInput input) {
|
||||||
if (!(input instanceof UserCredentialModel)) return false;
|
if (!(input instanceof UserCredentialModel)) return false;
|
||||||
if (input.getType().equals(PasswordCredentialModel.TYPE) && !((LegacyUserCredentialManager) user.credentialManager()).isConfiguredLocally(PasswordCredentialModel.TYPE)) {
|
if (input.getType().equals(PasswordCredentialModel.TYPE) && !((UserCredentialManager) user.credentialManager()).isConfiguredLocally(PasswordCredentialModel.TYPE)) {
|
||||||
return validPassword(realm, user, input.getChallengeResponse());
|
return validPassword(realm, user, input.getChallengeResponse());
|
||||||
} else {
|
} else {
|
||||||
return false; // invalid cred type
|
return false; // invalid cred type
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.keycloak.models.cache.infinispan.entities.*;
|
||||||
import org.keycloak.models.cache.infinispan.events.*;
|
import org.keycloak.models.cache.infinispan.events.*;
|
||||||
import org.keycloak.models.utils.KeycloakModelUtils;
|
import org.keycloak.models.utils.KeycloakModelUtils;
|
||||||
import org.keycloak.storage.DatastoreProvider;
|
import org.keycloak.storage.DatastoreProvider;
|
||||||
import org.keycloak.storage.LegacyStoreManagers;
|
import org.keycloak.storage.StoreManagers;
|
||||||
import org.keycloak.storage.StorageId;
|
import org.keycloak.storage.StorageId;
|
||||||
import org.keycloak.storage.client.ClientStorageProviderModel;
|
import org.keycloak.storage.client.ClientStorageProviderModel;
|
||||||
|
|
||||||
|
@ -121,13 +121,13 @@ public class RealmCacheSession implements CacheRealmProvider {
|
||||||
|
|
||||||
protected boolean clearAll;
|
protected boolean clearAll;
|
||||||
protected final long startupRevision;
|
protected final long startupRevision;
|
||||||
private final LegacyStoreManagers datastoreProvider;
|
private final StoreManagers datastoreProvider;
|
||||||
|
|
||||||
public RealmCacheSession(RealmCacheManager cache, KeycloakSession session) {
|
public RealmCacheSession(RealmCacheManager cache, KeycloakSession session) {
|
||||||
this.cache = cache;
|
this.cache = cache;
|
||||||
this.session = session;
|
this.session = session;
|
||||||
this.startupRevision = cache.getCurrentCounter();
|
this.startupRevision = cache.getCurrentCounter();
|
||||||
this.datastoreProvider = (LegacyStoreManagers) session.getProvider(DatastoreProvider.class);
|
this.datastoreProvider = (StoreManagers) session.getProvider(DatastoreProvider.class);
|
||||||
session.getTransactionManager().enlistPrepare(getPrepareTransaction());
|
session.getTransactionManager().enlistPrepare(getPrepareTransaction());
|
||||||
session.getTransactionManager().enlistAfterCompletion(getAfterTransaction());
|
session.getTransactionManager().enlistAfterCompletion(getAfterTransaction());
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.keycloak.models.cache.infinispan;
|
||||||
|
|
||||||
import org.keycloak.credential.CredentialInput;
|
import org.keycloak.credential.CredentialInput;
|
||||||
import org.keycloak.credential.CredentialModel;
|
import org.keycloak.credential.CredentialModel;
|
||||||
import org.keycloak.credential.LegacyUserCredentialManager;
|
import org.keycloak.credential.UserCredentialManager;
|
||||||
import org.keycloak.models.KeycloakSession;
|
import org.keycloak.models.KeycloakSession;
|
||||||
import org.keycloak.models.RealmModel;
|
import org.keycloak.models.RealmModel;
|
||||||
import org.keycloak.models.UserModel;
|
import org.keycloak.models.UserModel;
|
||||||
|
@ -27,7 +27,7 @@ import org.keycloak.models.UserModel;
|
||||||
/**
|
/**
|
||||||
* @author Alexander Schwartz
|
* @author Alexander Schwartz
|
||||||
*/
|
*/
|
||||||
public abstract class SubjectCredentialManagerCacheAdapter extends LegacyUserCredentialManager {
|
public abstract class SubjectCredentialManagerCacheAdapter extends UserCredentialManager {
|
||||||
|
|
||||||
public SubjectCredentialManagerCacheAdapter(KeycloakSession session, RealmModel realm, UserModel user) {
|
public SubjectCredentialManagerCacheAdapter(KeycloakSession session, RealmModel realm, UserModel user) {
|
||||||
super(session, realm, user);
|
super(session, realm, user);
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
package org.keycloak.models.cache.infinispan;
|
package org.keycloak.models.cache.infinispan;
|
||||||
|
|
||||||
import org.keycloak.credential.CredentialModel;
|
import org.keycloak.credential.CredentialModel;
|
||||||
import org.keycloak.credential.LegacyUserCredentialManager;
|
|
||||||
import org.keycloak.models.ClientModel;
|
import org.keycloak.models.ClientModel;
|
||||||
import org.keycloak.models.GroupModel;
|
import org.keycloak.models.GroupModel;
|
||||||
import org.keycloak.models.KeycloakSession;
|
import org.keycloak.models.KeycloakSession;
|
||||||
|
|
|
@ -56,7 +56,7 @@ import org.keycloak.models.utils.KeycloakModelUtils;
|
||||||
import org.keycloak.models.utils.ReadOnlyUserModelDelegate;
|
import org.keycloak.models.utils.ReadOnlyUserModelDelegate;
|
||||||
import org.keycloak.storage.CacheableStorageProviderModel;
|
import org.keycloak.storage.CacheableStorageProviderModel;
|
||||||
import org.keycloak.storage.DatastoreProvider;
|
import org.keycloak.storage.DatastoreProvider;
|
||||||
import org.keycloak.storage.LegacyStoreManagers;
|
import org.keycloak.storage.StoreManagers;
|
||||||
import org.keycloak.storage.OnCreateComponent;
|
import org.keycloak.storage.OnCreateComponent;
|
||||||
import org.keycloak.storage.OnUpdateComponent;
|
import org.keycloak.storage.OnUpdateComponent;
|
||||||
import org.keycloak.storage.StorageId;
|
import org.keycloak.storage.StorageId;
|
||||||
|
@ -94,13 +94,13 @@ public class UserCacheSession implements UserCache, OnCreateComponent, OnUpdateC
|
||||||
protected Set<String> realmInvalidations = new HashSet<>();
|
protected Set<String> realmInvalidations = new HashSet<>();
|
||||||
protected Set<InvalidationEvent> invalidationEvents = new HashSet<>(); // Events to be sent across cluster
|
protected Set<InvalidationEvent> invalidationEvents = new HashSet<>(); // Events to be sent across cluster
|
||||||
protected Map<String, UserModel> managedUsers = new HashMap<>();
|
protected Map<String, UserModel> managedUsers = new HashMap<>();
|
||||||
private LegacyStoreManagers datastoreProvider;
|
private StoreManagers datastoreProvider;
|
||||||
|
|
||||||
public UserCacheSession(UserCacheManager cache, KeycloakSession session) {
|
public UserCacheSession(UserCacheManager cache, KeycloakSession session) {
|
||||||
this.cache = cache;
|
this.cache = cache;
|
||||||
this.session = session;
|
this.session = session;
|
||||||
this.startupRevision = cache.getCurrentCounter();
|
this.startupRevision = cache.getCurrentCounter();
|
||||||
this.datastoreProvider = (LegacyStoreManagers) session.getProvider(DatastoreProvider.class);
|
this.datastoreProvider = (StoreManagers) session.getProvider(DatastoreProvider.class);
|
||||||
session.getTransactionManager().enlistAfterCompletion(getTransaction());
|
session.getTransactionManager().enlistAfterCompletion(getTransaction());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ import static org.keycloak.utils.StreamsUtil.closing;
|
||||||
* @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 RealmAdapter implements LegacyRealmModel, JpaModel<RealmEntity> {
|
public class RealmAdapter implements StorageProviderRealmModel, JpaModel<RealmEntity> {
|
||||||
protected static final Logger logger = Logger.getLogger(RealmAdapter.class);
|
protected static final Logger logger = Logger.getLogger(RealmAdapter.class);
|
||||||
protected RealmEntity realm;
|
protected RealmEntity realm;
|
||||||
protected EntityManager em;
|
protected EntityManager em;
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.keycloak.models.jpa;
|
||||||
|
|
||||||
import org.keycloak.common.util.MultivaluedHashMap;
|
import org.keycloak.common.util.MultivaluedHashMap;
|
||||||
import org.keycloak.common.util.ObjectUtil;
|
import org.keycloak.common.util.ObjectUtil;
|
||||||
import org.keycloak.credential.LegacyUserCredentialManager;
|
import org.keycloak.credential.UserCredentialManager;
|
||||||
import org.keycloak.models.ClientModel;
|
import org.keycloak.models.ClientModel;
|
||||||
import org.keycloak.models.GroupModel;
|
import org.keycloak.models.GroupModel;
|
||||||
import org.keycloak.models.KeycloakSession;
|
import org.keycloak.models.KeycloakSession;
|
||||||
|
@ -519,7 +519,7 @@ public class UserAdapter implements UserModel, JpaModel<UserEntity> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SubjectCredentialManager credentialManager() {
|
public SubjectCredentialManager credentialManager() {
|
||||||
return new LegacyUserCredentialManager(session, realm, this);
|
return new UserCredentialManager(session, realm, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import org.keycloak.models.KeycloakSession;
|
||||||
import org.keycloak.models.RealmModel;
|
import org.keycloak.models.RealmModel;
|
||||||
import org.keycloak.representations.idm.RealmRepresentation;
|
import org.keycloak.representations.idm.RealmRepresentation;
|
||||||
import org.keycloak.storage.DatastoreProvider;
|
import org.keycloak.storage.DatastoreProvider;
|
||||||
import org.keycloak.storage.datastore.LegacyDatastoreProvider;
|
import org.keycloak.storage.datastore.DefaultDatastoreProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
||||||
|
@ -30,11 +30,11 @@ import org.keycloak.storage.datastore.LegacyDatastoreProvider;
|
||||||
public class MigrationModelManager {
|
public class MigrationModelManager {
|
||||||
|
|
||||||
public static void migrate(KeycloakSession session) {
|
public static void migrate(KeycloakSession session) {
|
||||||
((LegacyDatastoreProvider) session.getProvider(DatastoreProvider.class)).getMigrationManager().migrate();
|
((DefaultDatastoreProvider) session.getProvider(DatastoreProvider.class)).getMigrationManager().migrate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void migrateImport(KeycloakSession session, RealmModel realm, RealmRepresentation rep, boolean skipUserDependent) {
|
public static void migrateImport(KeycloakSession session, RealmModel realm, RealmRepresentation rep, boolean skipUserDependent) {
|
||||||
((LegacyDatastoreProvider) session.getProvider(DatastoreProvider.class)).getMigrationManager().migrate(realm, rep, skipUserDependent);
|
((DefaultDatastoreProvider) session.getProvider(DatastoreProvider.class)).getMigrationManager().migrate(realm, rep, skipUserDependent);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.keycloak.component.ComponentFactory;
|
||||||
import org.keycloak.migration.ModelVersion;
|
import org.keycloak.migration.ModelVersion;
|
||||||
import org.keycloak.models.KeycloakSession;
|
import org.keycloak.models.KeycloakSession;
|
||||||
import org.keycloak.models.LDAPConstants;
|
import org.keycloak.models.LDAPConstants;
|
||||||
import org.keycloak.models.LegacyRealmModel;
|
import org.keycloak.models.StorageProviderRealmModel;
|
||||||
import org.keycloak.models.RealmModel;
|
import org.keycloak.models.RealmModel;
|
||||||
import org.keycloak.provider.ProviderFactory;
|
import org.keycloak.provider.ProviderFactory;
|
||||||
import org.keycloak.representations.idm.RealmRepresentation;
|
import org.keycloak.representations.idm.RealmRepresentation;
|
||||||
|
@ -53,7 +53,7 @@ public class MigrateTo1_3_0 implements Migration {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void migrateLDAPProviders(KeycloakSession session, RealmModel realm) {
|
private void migrateLDAPProviders(KeycloakSession session, RealmModel realm) {
|
||||||
((LegacyRealmModel) realm).getUserStorageProvidersStream().forEachOrdered(fedProvider -> {
|
((StorageProviderRealmModel) realm).getUserStorageProvidersStream().forEachOrdered(fedProvider -> {
|
||||||
if (fedProvider.getProviderId().equals(LDAPConstants.LDAP_PROVIDER)) {
|
if (fedProvider.getProviderId().equals(LDAPConstants.LDAP_PROVIDER)) {
|
||||||
fedProvider = new UserStorageProviderModel(fedProvider); // copy don't want to muck with cache
|
fedProvider = new UserStorageProviderModel(fedProvider); // copy don't want to muck with cache
|
||||||
MultivaluedHashMap<String, String> config = fedProvider.getConfig();
|
MultivaluedHashMap<String, String> config = fedProvider.getConfig();
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.keycloak.migration.ModelVersion;
|
||||||
import org.keycloak.models.ImpersonationConstants;
|
import org.keycloak.models.ImpersonationConstants;
|
||||||
import org.keycloak.models.KeycloakSession;
|
import org.keycloak.models.KeycloakSession;
|
||||||
import org.keycloak.models.LDAPConstants;
|
import org.keycloak.models.LDAPConstants;
|
||||||
import org.keycloak.models.LegacyRealmModel;
|
import org.keycloak.models.StorageProviderRealmModel;
|
||||||
import org.keycloak.models.RealmModel;
|
import org.keycloak.models.RealmModel;
|
||||||
import org.keycloak.models.UserModel;
|
import org.keycloak.models.UserModel;
|
||||||
import org.keycloak.models.cache.UserCache;
|
import org.keycloak.models.cache.UserCache;
|
||||||
|
@ -72,7 +72,7 @@ public class MigrateTo1_4_0 implements Migration {
|
||||||
|
|
||||||
private void migrateLDAPMappers(KeycloakSession session, RealmModel realm) {
|
private void migrateLDAPMappers(KeycloakSession session, RealmModel realm) {
|
||||||
List<String> mandatoryInLdap = Arrays.asList("username", "username-cn", "first name", "last name");
|
List<String> mandatoryInLdap = Arrays.asList("username", "username-cn", "first name", "last name");
|
||||||
((LegacyRealmModel) realm).getUserStorageProvidersStream()
|
((StorageProviderRealmModel) realm).getUserStorageProvidersStream()
|
||||||
.filter(providerModel -> Objects.equals(providerModel.getProviderId(), LDAPConstants.LDAP_PROVIDER))
|
.filter(providerModel -> Objects.equals(providerModel.getProviderId(), LDAPConstants.LDAP_PROVIDER))
|
||||||
.forEachOrdered(providerModel -> realm.getComponentsStream(providerModel.getId())
|
.forEachOrdered(providerModel -> realm.getComponentsStream(providerModel.getId())
|
||||||
.filter(mapper -> mandatoryInLdap.contains(mapper.getName()))
|
.filter(mapper -> mandatoryInLdap.contains(mapper.getName()))
|
||||||
|
|
|
@ -21,7 +21,7 @@ import org.keycloak.component.ComponentModel;
|
||||||
import org.keycloak.migration.ModelVersion;
|
import org.keycloak.migration.ModelVersion;
|
||||||
import org.keycloak.models.KeycloakSession;
|
import org.keycloak.models.KeycloakSession;
|
||||||
import org.keycloak.models.LDAPConstants;
|
import org.keycloak.models.LDAPConstants;
|
||||||
import org.keycloak.models.LegacyRealmModel;
|
import org.keycloak.models.StorageProviderRealmModel;
|
||||||
import org.keycloak.models.RealmModel;
|
import org.keycloak.models.RealmModel;
|
||||||
import org.keycloak.models.utils.KeycloakModelUtils;
|
import org.keycloak.models.utils.KeycloakModelUtils;
|
||||||
import org.keycloak.representations.idm.RealmRepresentation;
|
import org.keycloak.representations.idm.RealmRepresentation;
|
||||||
|
@ -51,7 +51,7 @@ public class MigrateTo1_8_0 implements Migration {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void migrateRealm(RealmModel realm) {
|
protected void migrateRealm(RealmModel realm) {
|
||||||
((LegacyRealmModel) realm).getUserStorageProvidersStream()
|
((StorageProviderRealmModel) realm).getUserStorageProvidersStream()
|
||||||
.filter(fedProvider -> Objects.equals(fedProvider.getProviderId(), LDAPConstants.LDAP_PROVIDER))
|
.filter(fedProvider -> Objects.equals(fedProvider.getProviderId(), LDAPConstants.LDAP_PROVIDER))
|
||||||
.filter(this::isActiveDirectory)
|
.filter(this::isActiveDirectory)
|
||||||
.filter(fedProvider -> Objects.isNull(getMapperByName(realm, fedProvider, "MSAD account controls")))
|
.filter(fedProvider -> Objects.isNull(getMapperByName(realm, fedProvider, "MSAD account controls")))
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
package org.keycloak.models.cache;
|
package org.keycloak.models.cache;
|
||||||
|
|
||||||
import org.keycloak.models.KeycloakSession;
|
import org.keycloak.models.KeycloakSession;
|
||||||
import org.keycloak.models.LegacyRealmModel;
|
import org.keycloak.models.StorageProviderRealmModel;
|
||||||
import org.keycloak.models.RealmModel;
|
import org.keycloak.models.RealmModel;
|
||||||
import org.keycloak.provider.ProviderEvent;
|
import org.keycloak.provider.ProviderEvent;
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
* @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 interface CachedRealmModel extends LegacyRealmModel {
|
public interface CachedRealmModel extends StorageProviderRealmModel {
|
||||||
|
|
||||||
interface RealmCachedEvent extends ProviderEvent {
|
interface RealmCachedEvent extends ProviderEvent {
|
||||||
CachedRealmModel getRealm();
|
CachedRealmModel getRealm();
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.keycloak.component.ComponentModel;
|
||||||
import org.keycloak.models.ClientModel;
|
import org.keycloak.models.ClientModel;
|
||||||
import org.keycloak.models.ClientProvider;
|
import org.keycloak.models.ClientProvider;
|
||||||
import org.keycloak.models.KeycloakSession;
|
import org.keycloak.models.KeycloakSession;
|
||||||
import org.keycloak.models.LegacyRealmModel;
|
import org.keycloak.models.StorageProviderRealmModel;
|
||||||
import org.keycloak.models.ModelException;
|
import org.keycloak.models.ModelException;
|
||||||
import org.keycloak.models.RealmModel;
|
import org.keycloak.models.RealmModel;
|
||||||
import org.keycloak.storage.client.ClientLookupProvider;
|
import org.keycloak.storage.client.ClientLookupProvider;
|
||||||
|
@ -79,7 +79,7 @@ public class ClientStorageManager implements ClientProvider {
|
||||||
|
|
||||||
|
|
||||||
private static <T> Stream<ClientStorageProviderModel> getStorageProviders(RealmModel realm, KeycloakSession session, Class<T> type) {
|
private static <T> Stream<ClientStorageProviderModel> getStorageProviders(RealmModel realm, KeycloakSession session, Class<T> type) {
|
||||||
return ((LegacyRealmModel) realm).getClientStorageProvidersStream()
|
return ((StorageProviderRealmModel) realm).getClientStorageProvidersStream()
|
||||||
.filter(model -> {
|
.filter(model -> {
|
||||||
ClientStorageProviderFactory factory = getClientStorageProviderFactory(model, session);
|
ClientStorageProviderFactory factory = getClientStorageProviderFactory(model, session);
|
||||||
if (factory == null) {
|
if (factory == null) {
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.keycloak.common.util.reflections.Types;
|
||||||
import org.keycloak.component.ComponentModel;
|
import org.keycloak.component.ComponentModel;
|
||||||
import org.keycloak.models.ClientModel;
|
import org.keycloak.models.ClientModel;
|
||||||
import org.keycloak.models.KeycloakSession;
|
import org.keycloak.models.KeycloakSession;
|
||||||
import org.keycloak.models.LegacyRealmModel;
|
import org.keycloak.models.StorageProviderRealmModel;
|
||||||
import org.keycloak.models.ModelException;
|
import org.keycloak.models.ModelException;
|
||||||
import org.keycloak.models.RealmModel;
|
import org.keycloak.models.RealmModel;
|
||||||
import org.keycloak.models.RoleModel;
|
import org.keycloak.models.RoleModel;
|
||||||
|
@ -73,7 +73,7 @@ public class RoleStorageManager implements RoleProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> Stream<RoleStorageProviderModel> getStorageProviders(RealmModel realm, KeycloakSession session, Class<T> type) {
|
public static <T> Stream<RoleStorageProviderModel> getStorageProviders(RealmModel realm, KeycloakSession session, Class<T> type) {
|
||||||
return ((LegacyRealmModel) realm).getRoleStorageProvidersStream()
|
return ((StorageProviderRealmModel) realm).getRoleStorageProvidersStream()
|
||||||
.filter(model -> {
|
.filter(model -> {
|
||||||
RoleStorageProviderFactory factory = getRoleStorageProviderFactory(model, session);
|
RoleStorageProviderFactory factory = getRoleStorageProviderFactory(model, session);
|
||||||
if (factory == null) {
|
if (factory == null) {
|
||||||
|
|
|
@ -60,7 +60,7 @@ import org.keycloak.models.cache.UserCache;
|
||||||
import org.keycloak.models.utils.ComponentUtil;
|
import org.keycloak.models.utils.ComponentUtil;
|
||||||
import org.keycloak.models.utils.ReadOnlyUserModelDelegate;
|
import org.keycloak.models.utils.ReadOnlyUserModelDelegate;
|
||||||
import org.keycloak.storage.client.ClientStorageProvider;
|
import org.keycloak.storage.client.ClientStorageProvider;
|
||||||
import org.keycloak.storage.datastore.LegacyDatastoreProvider;
|
import org.keycloak.storage.datastore.DefaultDatastoreProvider;
|
||||||
import org.keycloak.storage.federated.UserFederatedStorageProvider;
|
import org.keycloak.storage.federated.UserFederatedStorageProvider;
|
||||||
import org.keycloak.storage.managers.UserStorageSyncManager;
|
import org.keycloak.storage.managers.UserStorageSyncManager;
|
||||||
import org.keycloak.storage.user.ImportedUserValidation;
|
import org.keycloak.storage.user.ImportedUserValidation;
|
||||||
|
@ -89,7 +89,7 @@ public class UserStorageManager extends AbstractStorageManager<UserStorageProvid
|
||||||
}
|
}
|
||||||
|
|
||||||
protected UserProvider localStorage() {
|
protected UserProvider localStorage() {
|
||||||
return ((LegacyDatastoreProvider) session.getProvider(DatastoreProvider.class)).userLocalStorage();
|
return ((DefaultDatastoreProvider) session.getProvider(DatastoreProvider.class)).userLocalStorage();
|
||||||
}
|
}
|
||||||
|
|
||||||
private UserFederatedStorageProvider getFederatedStorage() {
|
private UserFederatedStorageProvider getFederatedStorage() {
|
||||||
|
|
|
@ -19,13 +19,13 @@ package org.keycloak.storage;
|
||||||
|
|
||||||
import org.keycloak.models.KeycloakSession;
|
import org.keycloak.models.KeycloakSession;
|
||||||
import org.keycloak.models.UserProvider;
|
import org.keycloak.models.UserProvider;
|
||||||
import org.keycloak.storage.datastore.LegacyDatastoreProvider;
|
import org.keycloak.storage.datastore.DefaultDatastoreProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Alexander Schwartz
|
* @author Alexander Schwartz
|
||||||
*/
|
*/
|
||||||
public class UserStoragePrivateUtil {
|
public class UserStoragePrivateUtil {
|
||||||
public static UserProvider userLocalStorage(KeycloakSession session) {
|
public static UserProvider userLocalStorage(KeycloakSession session) {
|
||||||
return ((LegacyDatastoreProvider) session.getProvider(DatastoreProvider.class)).userLocalStorage();
|
return ((DefaultDatastoreProvider) session.getProvider(DatastoreProvider.class)).userLocalStorage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.keycloak.storage.adapter;
|
package org.keycloak.storage.adapter;
|
||||||
|
|
||||||
import org.keycloak.credential.LegacyUserCredentialManager;
|
import org.keycloak.credential.UserCredentialManager;
|
||||||
import org.keycloak.models.KeycloakSession;
|
import org.keycloak.models.KeycloakSession;
|
||||||
import org.keycloak.models.RealmModel;
|
import org.keycloak.models.RealmModel;
|
||||||
import org.keycloak.models.SubjectCredentialManager;
|
import org.keycloak.models.SubjectCredentialManager;
|
||||||
|
@ -33,6 +33,6 @@ public class InMemoryUserAdapter extends AbstractInMemoryUserAdapter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SubjectCredentialManager credentialManager() {
|
public SubjectCredentialManager credentialManager() {
|
||||||
return new LegacyUserCredentialManager(session, realm, this);
|
return new UserCredentialManager(session, realm, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,14 +35,14 @@ import org.keycloak.storage.ClientStorageManager;
|
||||||
import org.keycloak.storage.DatastoreProvider;
|
import org.keycloak.storage.DatastoreProvider;
|
||||||
import org.keycloak.storage.ExportImportManager;
|
import org.keycloak.storage.ExportImportManager;
|
||||||
import org.keycloak.storage.GroupStorageManager;
|
import org.keycloak.storage.GroupStorageManager;
|
||||||
import org.keycloak.storage.LegacyStoreManagers;
|
import org.keycloak.storage.StoreManagers;
|
||||||
import org.keycloak.storage.MigrationManager;
|
import org.keycloak.storage.MigrationManager;
|
||||||
import org.keycloak.storage.RoleStorageManager;
|
import org.keycloak.storage.RoleStorageManager;
|
||||||
import org.keycloak.storage.UserStorageManager;
|
import org.keycloak.storage.UserStorageManager;
|
||||||
import org.keycloak.storage.federated.UserFederatedStorageProvider;
|
import org.keycloak.storage.federated.UserFederatedStorageProvider;
|
||||||
|
|
||||||
public class LegacyDatastoreProvider implements DatastoreProvider, LegacyStoreManagers {
|
public class DefaultDatastoreProvider implements DatastoreProvider, StoreManagers {
|
||||||
private final LegacyDatastoreProviderFactory factory;
|
private final DefaultDatastoreProviderFactory factory;
|
||||||
private final KeycloakSession session;
|
private final KeycloakSession session;
|
||||||
|
|
||||||
private AuthenticationSessionProvider authenticationSessionProvider;
|
private AuthenticationSessionProvider authenticationSessionProvider;
|
||||||
|
@ -63,7 +63,7 @@ public class LegacyDatastoreProvider implements DatastoreProvider, LegacyStoreMa
|
||||||
private UserProvider userStorageManager;
|
private UserProvider userStorageManager;
|
||||||
private UserFederatedStorageProvider userFederatedStorageProvider;
|
private UserFederatedStorageProvider userFederatedStorageProvider;
|
||||||
|
|
||||||
public LegacyDatastoreProvider(LegacyDatastoreProviderFactory factory, KeycloakSession session) {
|
public DefaultDatastoreProvider(DefaultDatastoreProviderFactory factory, KeycloakSession session) {
|
||||||
this.factory = factory;
|
this.factory = factory;
|
||||||
this.session = session;
|
this.session = session;
|
||||||
}
|
}
|
||||||
|
@ -260,11 +260,11 @@ public class LegacyDatastoreProvider implements DatastoreProvider, LegacyStoreMa
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ExportImportManager getExportImportManager() {
|
public ExportImportManager getExportImportManager() {
|
||||||
return new LegacyExportImportManager(session);
|
return new DefaultExportImportManager(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MigrationManager getMigrationManager() {
|
public MigrationManager getMigrationManager() {
|
||||||
return new LegacyMigrationManager(session);
|
return new DefaultMigrationManager(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -32,12 +32,12 @@ import org.keycloak.services.scheduled.ClearExpiredUserSessions;
|
||||||
import org.keycloak.services.scheduled.ClusterAwareScheduledTaskRunner;
|
import org.keycloak.services.scheduled.ClusterAwareScheduledTaskRunner;
|
||||||
import org.keycloak.storage.DatastoreProvider;
|
import org.keycloak.storage.DatastoreProvider;
|
||||||
import org.keycloak.storage.DatastoreProviderFactory;
|
import org.keycloak.storage.DatastoreProviderFactory;
|
||||||
import org.keycloak.storage.LegacyStoreMigrateRepresentationEvent;
|
import org.keycloak.storage.StoreMigrateRepresentationEvent;
|
||||||
import org.keycloak.storage.LegacyStoreSyncEvent;
|
import org.keycloak.storage.StoreSyncEvent;
|
||||||
import org.keycloak.storage.managers.UserStorageSyncManager;
|
import org.keycloak.storage.managers.UserStorageSyncManager;
|
||||||
import org.keycloak.timer.TimerProvider;
|
import org.keycloak.timer.TimerProvider;
|
||||||
|
|
||||||
public class LegacyDatastoreProviderFactory implements DatastoreProviderFactory, ProviderEventListener {
|
public class DefaultDatastoreProviderFactory implements DatastoreProviderFactory, ProviderEventListener {
|
||||||
|
|
||||||
private static final String PROVIDER_ID = "legacy";
|
private static final String PROVIDER_ID = "legacy";
|
||||||
private long clientStorageProviderTimeout;
|
private long clientStorageProviderTimeout;
|
||||||
|
@ -46,7 +46,7 @@ public class LegacyDatastoreProviderFactory implements DatastoreProviderFactory,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DatastoreProvider create(KeycloakSession session) {
|
public DatastoreProvider create(KeycloakSession session) {
|
||||||
return new LegacyDatastoreProvider(this, session);
|
return new DefaultDatastoreProvider(this, session);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -85,11 +85,11 @@ public class LegacyDatastoreProviderFactory implements DatastoreProviderFactory,
|
||||||
public void onEvent(ProviderEvent event) {
|
public void onEvent(ProviderEvent event) {
|
||||||
if (event instanceof PostMigrationEvent) {
|
if (event instanceof PostMigrationEvent) {
|
||||||
setupScheduledTasks(((PostMigrationEvent) event).getFactory());
|
setupScheduledTasks(((PostMigrationEvent) event).getFactory());
|
||||||
} else if (event instanceof LegacyStoreSyncEvent) {
|
} else if (event instanceof StoreSyncEvent) {
|
||||||
LegacyStoreSyncEvent ev = (LegacyStoreSyncEvent) event;
|
StoreSyncEvent ev = (StoreSyncEvent) event;
|
||||||
UserStorageSyncManager.notifyToRefreshPeriodicSyncAll(ev.getSession(), ev.getRealm(), ev.getRemoved());
|
UserStorageSyncManager.notifyToRefreshPeriodicSyncAll(ev.getSession(), ev.getRealm(), ev.getRemoved());
|
||||||
} else if (event instanceof LegacyStoreMigrateRepresentationEvent) {
|
} else if (event instanceof StoreMigrateRepresentationEvent) {
|
||||||
LegacyStoreMigrateRepresentationEvent ev = (LegacyStoreMigrateRepresentationEvent) event;
|
StoreMigrateRepresentationEvent ev = (StoreMigrateRepresentationEvent) event;
|
||||||
MigrationModelManager.migrateImport(ev.getSession(), ev.getRealm(), ev.getRep(), ev.isSkipUserDependent());
|
MigrationModelManager.migrateImport(ev.getSession(), ev.getRealm(), ev.getRep(), ev.isSkipUserDependent());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -98,7 +98,6 @@ import org.keycloak.storage.UserStorageProviderModel;
|
||||||
import org.keycloak.storage.UserStorageUtil;
|
import org.keycloak.storage.UserStorageUtil;
|
||||||
import org.keycloak.storage.federated.UserFederatedStorageProvider;
|
import org.keycloak.storage.federated.UserFederatedStorageProvider;
|
||||||
import org.keycloak.util.JsonSerialization;
|
import org.keycloak.util.JsonSerialization;
|
||||||
import org.keycloak.utils.ReservedCharValidator;
|
|
||||||
import org.keycloak.utils.StringUtil;
|
import org.keycloak.utils.StringUtil;
|
||||||
import org.keycloak.validation.ValidationUtil;
|
import org.keycloak.validation.ValidationUtil;
|
||||||
|
|
||||||
|
@ -126,16 +125,15 @@ import static org.keycloak.models.utils.RepresentationToModel.importRoles;
|
||||||
import static org.keycloak.models.utils.StripSecretsUtils.stripForExport;
|
import static org.keycloak.models.utils.StripSecretsUtils.stripForExport;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This wraps the functionality about export/import for legacy storage. This will be handled differently for the new map storage,
|
* This wraps the functionality about export/import for the storage.
|
||||||
* therefore, it has been extracted.
|
|
||||||
*
|
*
|
||||||
* @author Alexander Schwartz
|
* @author Alexander Schwartz
|
||||||
*/
|
*/
|
||||||
public class LegacyExportImportManager implements ExportImportManager {
|
public class DefaultExportImportManager implements ExportImportManager {
|
||||||
private final KeycloakSession session;
|
private final KeycloakSession session;
|
||||||
private static final Logger logger = Logger.getLogger(LegacyExportImportManager.class);
|
private static final Logger logger = Logger.getLogger(DefaultExportImportManager.class);
|
||||||
|
|
||||||
public LegacyExportImportManager(KeycloakSession session) {
|
public DefaultExportImportManager(KeycloakSession session) {
|
||||||
this.session = session;
|
this.session = session;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,13 +70,12 @@ import java.util.Map;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This wraps the functionality for migrations of the legacy storage. This will be handled differently for the new map storage,
|
* This wraps the functionality for migrations of the storage.
|
||||||
* therefore, it has been extracted.
|
|
||||||
*
|
*
|
||||||
* @author Alexander Schwartz
|
* @author Alexander Schwartz
|
||||||
*/
|
*/
|
||||||
public class LegacyMigrationManager implements MigrationManager {
|
public class DefaultMigrationManager implements MigrationManager {
|
||||||
private static final Logger logger = Logger.getLogger(LegacyMigrationManager.class);
|
private static final Logger logger = Logger.getLogger(DefaultMigrationManager.class);
|
||||||
|
|
||||||
private static final Migration[] migrations = {
|
private static final Migration[] migrations = {
|
||||||
new MigrateTo1_2_0(),
|
new MigrateTo1_2_0(),
|
||||||
|
@ -119,7 +118,7 @@ public class LegacyMigrationManager implements MigrationManager {
|
||||||
|
|
||||||
private final KeycloakSession session;
|
private final KeycloakSession session;
|
||||||
|
|
||||||
public LegacyMigrationManager(KeycloakSession session) {
|
public DefaultMigrationManager(KeycloakSession session) {
|
||||||
this.session = session;
|
this.session = session;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ import org.keycloak.component.ComponentModel;
|
||||||
import org.keycloak.models.KeycloakSession;
|
import org.keycloak.models.KeycloakSession;
|
||||||
import org.keycloak.models.KeycloakSessionFactory;
|
import org.keycloak.models.KeycloakSessionFactory;
|
||||||
import org.keycloak.models.KeycloakSessionTask;
|
import org.keycloak.models.KeycloakSessionTask;
|
||||||
import org.keycloak.models.LegacyRealmModel;
|
import org.keycloak.models.StorageProviderRealmModel;
|
||||||
import org.keycloak.models.RealmModel;
|
import org.keycloak.models.RealmModel;
|
||||||
import org.keycloak.models.utils.KeycloakModelUtils;
|
import org.keycloak.models.utils.KeycloakModelUtils;
|
||||||
import org.keycloak.storage.UserStorageProvider;
|
import org.keycloak.storage.UserStorageProvider;
|
||||||
|
@ -62,7 +62,7 @@ public class UserStorageSyncManager {
|
||||||
public void run(KeycloakSession session) {
|
public void run(KeycloakSession session) {
|
||||||
Stream<RealmModel> realms = session.realms().getRealmsWithProviderTypeStream(UserStorageProvider.class);
|
Stream<RealmModel> realms = session.realms().getRealmsWithProviderTypeStream(UserStorageProvider.class);
|
||||||
realms.forEach(realm -> {
|
realms.forEach(realm -> {
|
||||||
Stream<UserStorageProviderModel> providers = ((LegacyRealmModel) realm).getUserStorageProvidersStream();
|
Stream<UserStorageProviderModel> providers = ((StorageProviderRealmModel) realm).getUserStorageProvidersStream();
|
||||||
providers.forEachOrdered(provider -> {
|
providers.forEachOrdered(provider -> {
|
||||||
UserStorageProviderFactory factory = (UserStorageProviderFactory) session.getKeycloakSessionFactory().getProviderFactory(UserStorageProvider.class, provider.getProviderId());
|
UserStorageProviderFactory factory = (UserStorageProviderFactory) session.getKeycloakSessionFactory().getProviderFactory(UserStorageProvider.class, provider.getProviderId());
|
||||||
if (factory instanceof ImportSynchronization && provider.isImportEnabled()) {
|
if (factory instanceof ImportSynchronization && provider.isImportEnabled()) {
|
||||||
|
@ -174,7 +174,7 @@ public class UserStorageSyncManager {
|
||||||
|
|
||||||
|
|
||||||
public static void notifyToRefreshPeriodicSyncAll(KeycloakSession session, RealmModel realm, boolean removed) {
|
public static void notifyToRefreshPeriodicSyncAll(KeycloakSession session, RealmModel realm, boolean removed) {
|
||||||
((LegacyRealmModel) realm).getUserStorageProvidersStream().forEachOrdered(fedProvider ->
|
((StorageProviderRealmModel) realm).getUserStorageProvidersStream().forEachOrdered(fedProvider ->
|
||||||
notifyToRefreshPeriodicSync(session, realm, fedProvider, removed));
|
notifyToRefreshPeriodicSync(session, realm, fedProvider, removed));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ public class UserStorageSyncManager {
|
||||||
@Override
|
@Override
|
||||||
public void run(KeycloakSession session) {
|
public void run(KeycloakSession session) {
|
||||||
RealmModel persistentRealm = session.realms().getRealm(realmId);
|
RealmModel persistentRealm = session.realms().getRealm(realmId);
|
||||||
((LegacyRealmModel) persistentRealm).getUserStorageProvidersStream()
|
((StorageProviderRealmModel) persistentRealm).getUserStorageProvidersStream()
|
||||||
.filter(persistentFedProvider -> Objects.equals(provider.getId(), persistentFedProvider.getId()))
|
.filter(persistentFedProvider -> Objects.equals(provider.getId(), persistentFedProvider.getId()))
|
||||||
.forEachOrdered(persistentFedProvider -> {
|
.forEachOrdered(persistentFedProvider -> {
|
||||||
// Update persistent provider in DB
|
// Update persistent provider in DB
|
||||||
|
|
|
@ -15,4 +15,4 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
org.keycloak.storage.datastore.LegacyDatastoreProviderFactory
|
org.keycloak.storage.datastore.DefaultDatastoreProviderFactory
|
|
@ -17,17 +17,16 @@
|
||||||
|
|
||||||
package org.keycloak.models.datastore;
|
package org.keycloak.models.datastore;
|
||||||
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.keycloak.migration.ModelVersion;
|
import org.keycloak.migration.ModelVersion;
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.keycloak.storage.datastore.LegacyMigrationManager.RHSSO_VERSION_7_0_KEYCLOAK_VERSION;
|
import static org.keycloak.storage.datastore.DefaultMigrationManager.RHSSO_VERSION_7_0_KEYCLOAK_VERSION;
|
||||||
import static org.keycloak.storage.datastore.LegacyMigrationManager.RHSSO_VERSION_7_1_KEYCLOAK_VERSION;
|
import static org.keycloak.storage.datastore.DefaultMigrationManager.RHSSO_VERSION_7_1_KEYCLOAK_VERSION;
|
||||||
import static org.keycloak.storage.datastore.LegacyMigrationManager.RHSSO_VERSION_7_2_KEYCLOAK_VERSION;
|
import static org.keycloak.storage.datastore.DefaultMigrationManager.RHSSO_VERSION_7_2_KEYCLOAK_VERSION;
|
||||||
import static org.keycloak.storage.datastore.LegacyMigrationManager.RHSSO_VERSION_7_3_KEYCLOAK_VERSION;
|
import static org.keycloak.storage.datastore.DefaultMigrationManager.RHSSO_VERSION_7_3_KEYCLOAK_VERSION;
|
||||||
import static org.keycloak.storage.datastore.LegacyMigrationManager.RHSSO_VERSION_7_4_KEYCLOAK_VERSION;
|
import static org.keycloak.storage.datastore.DefaultMigrationManager.RHSSO_VERSION_7_4_KEYCLOAK_VERSION;
|
||||||
import static org.keycloak.storage.datastore.LegacyMigrationManager.convertRHSSOVersionToKeycloakVersion;
|
import static org.keycloak.storage.datastore.DefaultMigrationManager.convertRHSSOVersionToKeycloakVersion;
|
||||||
import static org.hamcrest.CoreMatchers.equalTo;
|
import static org.hamcrest.CoreMatchers.equalTo;
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
import static org.hamcrest.CoreMatchers.nullValue;
|
import static org.hamcrest.CoreMatchers.nullValue;
|
||||||
|
@ -36,7 +35,7 @@ import static org.hamcrest.CoreMatchers.nullValue;
|
||||||
* @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 LegacyMigrationManagerTest {
|
public class MigrationManagerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRHSSOVersionToKeycloakVersionConversion() {
|
public void testRHSSOVersionToKeycloakVersionConversion() {
|
|
@ -32,7 +32,7 @@ import org.keycloak.models.utils.RepresentationToModel;
|
||||||
import org.keycloak.representations.idm.RealmRepresentation;
|
import org.keycloak.representations.idm.RealmRepresentation;
|
||||||
import org.keycloak.representations.idm.UserRepresentation;
|
import org.keycloak.representations.idm.UserRepresentation;
|
||||||
import org.keycloak.services.managers.RealmManager;
|
import org.keycloak.services.managers.RealmManager;
|
||||||
import org.keycloak.storage.datastore.LegacyExportImportManager;
|
import org.keycloak.storage.datastore.DefaultExportImportManager;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -266,7 +266,7 @@ public class ImportUtils {
|
||||||
private static void importFederatedUsers(KeycloakSession session, RealmProvider model, String realmName, List<UserRepresentation> userReps) {
|
private static void importFederatedUsers(KeycloakSession session, RealmProvider model, String realmName, List<UserRepresentation> userReps) {
|
||||||
RealmModel realm = model.getRealmByName(realmName);
|
RealmModel realm = model.getRealmByName(realmName);
|
||||||
for (UserRepresentation user : userReps) {
|
for (UserRepresentation user : userReps) {
|
||||||
LegacyExportImportManager.importFederatedUser(session, realm, user);
|
DefaultExportImportManager.importFederatedUser(session, realm, user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ import org.keycloak.models.SubjectCredentialManager;
|
||||||
import org.keycloak.models.UserModel;
|
import org.keycloak.models.UserModel;
|
||||||
import org.keycloak.storage.AbstractStorageManager;
|
import org.keycloak.storage.AbstractStorageManager;
|
||||||
import org.keycloak.storage.DatastoreProvider;
|
import org.keycloak.storage.DatastoreProvider;
|
||||||
import org.keycloak.storage.LegacyStoreManagers;
|
import org.keycloak.storage.StoreManagers;
|
||||||
import org.keycloak.storage.StorageId;
|
import org.keycloak.storage.StorageId;
|
||||||
import org.keycloak.storage.UserStorageProvider;
|
import org.keycloak.storage.UserStorageProvider;
|
||||||
import org.keycloak.storage.UserStorageProviderFactory;
|
import org.keycloak.storage.UserStorageProviderFactory;
|
||||||
|
@ -36,17 +36,17 @@ import java.util.Objects;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handling credentials for a given user for the legacy store.
|
* Handling credentials for a given user for the store.
|
||||||
*
|
*
|
||||||
* @author Alexander Schwartz
|
* @author Alexander Schwartz
|
||||||
*/
|
*/
|
||||||
public class LegacyUserCredentialManager extends AbstractStorageManager<UserStorageProvider, UserStorageProviderModel> implements SubjectCredentialManager {
|
public class UserCredentialManager extends AbstractStorageManager<UserStorageProvider, UserStorageProviderModel> implements SubjectCredentialManager {
|
||||||
|
|
||||||
private final UserModel user;
|
private final UserModel user;
|
||||||
private final KeycloakSession session;
|
private final KeycloakSession session;
|
||||||
private final RealmModel realm;
|
private final RealmModel realm;
|
||||||
|
|
||||||
public LegacyUserCredentialManager(KeycloakSession session, RealmModel realm, UserModel user) {
|
public UserCredentialManager(KeycloakSession session, RealmModel realm, UserModel user) {
|
||||||
super(session, UserStorageProviderFactory.class, UserStorageProvider.class, UserStorageProviderModel::new, "user");
|
super(session, UserStorageProviderFactory.class, UserStorageProvider.class, UserStorageProviderModel::new, "user");
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.session = session;
|
this.session = session;
|
||||||
|
@ -269,7 +269,7 @@ public class LegacyUserCredentialManager extends AbstractStorageManager<UserStor
|
||||||
}
|
}
|
||||||
|
|
||||||
private UserCredentialStore getStoreForUser(UserModel user) {
|
private UserCredentialStore getStoreForUser(UserModel user) {
|
||||||
LegacyStoreManagers p = (LegacyStoreManagers) session.getProvider(DatastoreProvider.class);
|
StoreManagers p = (StoreManagers) session.getProvider(DatastoreProvider.class);
|
||||||
if (StorageId.isLocalStorage(user.getId())) {
|
if (StorageId.isLocalStorage(user.getId())) {
|
||||||
return (UserCredentialStore) p.userLocalStorage();
|
return (UserCredentialStore) p.userLocalStorage();
|
||||||
} else {
|
} else {
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
package org.keycloak.models;
|
package org.keycloak.models;
|
||||||
|
|
||||||
import org.keycloak.models.RealmModel;
|
|
||||||
import org.keycloak.storage.UserStorageProvider;
|
import org.keycloak.storage.UserStorageProvider;
|
||||||
import org.keycloak.storage.UserStorageProviderModel;
|
import org.keycloak.storage.UserStorageProviderModel;
|
||||||
import org.keycloak.storage.client.ClientStorageProvider;
|
import org.keycloak.storage.client.ClientStorageProvider;
|
||||||
|
@ -32,7 +31,7 @@ import java.util.stream.Stream;
|
||||||
/**
|
/**
|
||||||
* @author Alexander Schwartz
|
* @author Alexander Schwartz
|
||||||
*/
|
*/
|
||||||
public interface LegacyRealmModel extends RealmModel {
|
public interface StorageProviderRealmModel extends RealmModel {
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link #getClientStorageProvidersStream() getClientStorageProvidersStream} instead.
|
* @deprecated Use {@link #getClientStorageProvidersStream() getClientStorageProvidersStream} instead.
|
||||||
*/
|
*/
|
|
@ -24,7 +24,7 @@ import org.keycloak.models.RoleProvider;
|
||||||
import org.keycloak.models.UserProvider;
|
import org.keycloak.models.UserProvider;
|
||||||
import org.keycloak.storage.federated.UserFederatedStorageProvider;
|
import org.keycloak.storage.federated.UserFederatedStorageProvider;
|
||||||
|
|
||||||
public interface LegacyStoreManagers {
|
public interface StoreManagers {
|
||||||
|
|
||||||
ClientProvider clientStorageManager();
|
ClientProvider clientStorageManager();
|
||||||
|
|
|
@ -18,7 +18,7 @@ package org.keycloak.storage.adapter;
|
||||||
|
|
||||||
import org.keycloak.common.util.MultivaluedHashMap;
|
import org.keycloak.common.util.MultivaluedHashMap;
|
||||||
import org.keycloak.component.ComponentModel;
|
import org.keycloak.component.ComponentModel;
|
||||||
import org.keycloak.credential.LegacyUserCredentialManager;
|
import org.keycloak.credential.UserCredentialManager;
|
||||||
import org.keycloak.models.ClientModel;
|
import org.keycloak.models.ClientModel;
|
||||||
import org.keycloak.models.GroupModel;
|
import org.keycloak.models.GroupModel;
|
||||||
import org.keycloak.models.KeycloakSession;
|
import org.keycloak.models.KeycloakSession;
|
||||||
|
@ -400,7 +400,7 @@ public abstract class AbstractUserAdapterFederatedStorage extends UserModelDefau
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SubjectCredentialManager credentialManager() {
|
public SubjectCredentialManager credentialManager() {
|
||||||
return new LegacyUserCredentialManager(session, realm, this);
|
return new UserCredentialManager(session, realm, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -154,7 +154,7 @@ import static org.keycloak.quarkus.runtime.configuration.Configuration.getProper
|
||||||
import static org.keycloak.quarkus.runtime.configuration.MicroProfileConfigProvider.NS_KEYCLOAK_PREFIX;
|
import static org.keycloak.quarkus.runtime.configuration.MicroProfileConfigProvider.NS_KEYCLOAK_PREFIX;
|
||||||
import static org.keycloak.quarkus.runtime.configuration.MicroProfileConfigProvider.NS_QUARKUS;
|
import static org.keycloak.quarkus.runtime.configuration.MicroProfileConfigProvider.NS_QUARKUS;
|
||||||
import static org.keycloak.quarkus.runtime.configuration.QuarkusPropertiesConfigSource.QUARKUS_PROPERTY_ENABLED;
|
import static org.keycloak.quarkus.runtime.configuration.QuarkusPropertiesConfigSource.QUARKUS_PROPERTY_ENABLED;
|
||||||
import static org.keycloak.quarkus.runtime.storage.legacy.database.LegacyJpaConnectionProviderFactory.QUERY_PROPERTY_PREFIX;
|
import static org.keycloak.quarkus.runtime.storage.legacy.database.QuarkusJpaConnectionProviderFactory.QUERY_PROPERTY_PREFIX;
|
||||||
import static org.keycloak.representations.provider.ScriptProviderDescriptor.AUTHENTICATORS;
|
import static org.keycloak.representations.provider.ScriptProviderDescriptor.AUTHENTICATORS;
|
||||||
import static org.keycloak.representations.provider.ScriptProviderDescriptor.MAPPERS;
|
import static org.keycloak.representations.provider.ScriptProviderDescriptor.MAPPERS;
|
||||||
import static org.keycloak.representations.provider.ScriptProviderDescriptor.POLICIES;
|
import static org.keycloak.representations.provider.ScriptProviderDescriptor.POLICIES;
|
||||||
|
|
|
@ -60,10 +60,10 @@ import org.keycloak.quarkus.runtime.storage.database.jpa.AbstractJpaConnectionPr
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
|
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
|
||||||
*/
|
*/
|
||||||
public class LegacyJpaConnectionProviderFactory extends AbstractJpaConnectionProviderFactory implements ServerInfoAwareProviderFactory {
|
public class QuarkusJpaConnectionProviderFactory extends AbstractJpaConnectionProviderFactory implements ServerInfoAwareProviderFactory {
|
||||||
|
|
||||||
public static final String QUERY_PROPERTY_PREFIX = "kc.query.";
|
public static final String QUERY_PROPERTY_PREFIX = "kc.query.";
|
||||||
private static final Logger logger = Logger.getLogger(LegacyJpaConnectionProviderFactory.class);
|
private static final Logger logger = Logger.getLogger(QuarkusJpaConnectionProviderFactory.class);
|
||||||
private static final String SQL_GET_LATEST_VERSION = "SELECT ID, VERSION FROM %sMIGRATION_MODEL ORDER BY UPDATE_TIME DESC";
|
private static final String SQL_GET_LATEST_VERSION = "SELECT ID, VERSION FROM %sMIGRATION_MODEL ORDER BY UPDATE_TIME DESC";
|
||||||
|
|
||||||
enum MigrationStrategy {
|
enum MigrationStrategy {
|
||||||
|
@ -80,7 +80,7 @@ public class LegacyJpaConnectionProviderFactory extends AbstractJpaConnectionPro
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return "legacy";
|
return "quarkus";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addSpecificNamedQueries(KeycloakSession session) {
|
private void addSpecificNamedQueries(KeycloakSession session) {
|
|
@ -23,7 +23,7 @@ import org.keycloak.connections.infinispan.DefaultInfinispanConnectionProviderFa
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:psilva@redhat.com">Pedro Igor</a>
|
* @author <a href="mailto:psilva@redhat.com">Pedro Igor</a>
|
||||||
*/
|
*/
|
||||||
public class LegacyInfinispanConnectionFactory extends DefaultInfinispanConnectionProviderFactory {
|
public class QuarkusInfinispanConnectionFactory extends DefaultInfinispanConnectionProviderFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected EmbeddedCacheManager initContainerManaged(EmbeddedCacheManager cacheManager) {
|
protected EmbeddedCacheManager initContainerManaged(EmbeddedCacheManager cacheManager) {
|
|
@ -17,4 +17,4 @@
|
||||||
# */
|
# */
|
||||||
#
|
#
|
||||||
|
|
||||||
org.keycloak.quarkus.runtime.storage.legacy.infinispan.LegacyInfinispanConnectionFactory
|
org.keycloak.quarkus.runtime.storage.legacy.infinispan.QuarkusInfinispanConnectionFactory
|
|
@ -15,4 +15,4 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
org.keycloak.quarkus.runtime.storage.legacy.database.LegacyJpaConnectionProviderFactory
|
org.keycloak.quarkus.runtime.storage.legacy.database.QuarkusJpaConnectionProviderFactory
|
||||||
|
|
|
@ -21,7 +21,7 @@ import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.keycloak.it.TestProvider;
|
import org.keycloak.it.TestProvider;
|
||||||
|
|
||||||
public class CustomLegacyJpaEntityProvider implements TestProvider {
|
public class CustomJpaEntityProvider implements TestProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class[] getClasses() {
|
public Class[] getClasses() {
|
|
@ -20,9 +20,8 @@ package com.acme.provider.legacy.jpa.user;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.keycloak.it.TestProvider;
|
import org.keycloak.it.TestProvider;
|
||||||
import com.acme.provider.legacy.jpa.entity.Realm;
|
|
||||||
|
|
||||||
public class CustomLegacyUserProvider implements TestProvider {
|
public class CustomUserProvider implements TestProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class[] getClasses() {
|
public Class[] getClasses() {
|
|
@ -30,7 +30,7 @@ import org.junit.jupiter.api.condition.OS;
|
||||||
import org.keycloak.it.junit5.extension.BeforeStartDistribution;
|
import org.keycloak.it.junit5.extension.BeforeStartDistribution;
|
||||||
import org.keycloak.it.junit5.extension.CLIResult;
|
import org.keycloak.it.junit5.extension.CLIResult;
|
||||||
import org.keycloak.it.junit5.extension.DistributionTest;
|
import org.keycloak.it.junit5.extension.DistributionTest;
|
||||||
import org.keycloak.it.junit5.extension.LegacyStore;
|
import org.keycloak.it.junit5.extension.Storage;
|
||||||
import org.keycloak.it.junit5.extension.RawDistOnly;
|
import org.keycloak.it.junit5.extension.RawDistOnly;
|
||||||
import org.keycloak.it.utils.KeycloakDistribution;
|
import org.keycloak.it.utils.KeycloakDistribution;
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ import io.quarkus.test.junit.main.LaunchResult;
|
||||||
|
|
||||||
@DistributionTest(reInstall = DistributionTest.ReInstall.BEFORE_TEST)
|
@DistributionTest(reInstall = DistributionTest.ReInstall.BEFORE_TEST)
|
||||||
@RawDistOnly(reason = "Not possible to mount files using docker.")
|
@RawDistOnly(reason = "Not possible to mount files using docker.")
|
||||||
@LegacyStore(defaultLocalCache = false)
|
@Storage(defaultLocalCache = false)
|
||||||
public class ClusterConfigDistTest {
|
public class ClusterConfigDistTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -20,21 +20,19 @@ package org.keycloak.it.cli.dist;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.keycloak.it.junit5.extension.CLIResult;
|
import org.keycloak.it.junit5.extension.CLIResult;
|
||||||
import org.keycloak.it.junit5.extension.DistributionTest;
|
import org.keycloak.it.junit5.extension.DistributionTest;
|
||||||
import org.keycloak.it.junit5.extension.LegacyStore;
|
|
||||||
import org.keycloak.it.junit5.extension.RawDistOnly;
|
import org.keycloak.it.junit5.extension.RawDistOnly;
|
||||||
import org.keycloak.it.junit5.extension.TestProvider;
|
import org.keycloak.it.junit5.extension.TestProvider;
|
||||||
import com.acme.provider.legacy.jpa.entity.CustomLegacyJpaEntityProvider;
|
import com.acme.provider.legacy.jpa.entity.CustomJpaEntityProvider;
|
||||||
|
|
||||||
import io.quarkus.test.junit.main.Launch;
|
import io.quarkus.test.junit.main.Launch;
|
||||||
import io.quarkus.test.junit.main.LaunchResult;
|
import io.quarkus.test.junit.main.LaunchResult;
|
||||||
|
|
||||||
@DistributionTest
|
@DistributionTest
|
||||||
@RawDistOnly(reason = "Containers are immutable")
|
@RawDistOnly(reason = "Containers are immutable")
|
||||||
@LegacyStore
|
public class CustomJpaEntityProviderDistTest {
|
||||||
public class CustomLegacyJpaEntityProviderDistTest {
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestProvider(CustomLegacyJpaEntityProvider.class)
|
@TestProvider(CustomJpaEntityProvider.class)
|
||||||
@Launch({ "start-dev", "--log-level=org.hibernate.jpa.internal.util.LogHelper:debug" })
|
@Launch({ "start-dev", "--log-level=org.hibernate.jpa.internal.util.LogHelper:debug" })
|
||||||
void testUserManagedEntityNotAddedToDefaultPU(LaunchResult result) {
|
void testUserManagedEntityNotAddedToDefaultPU(LaunchResult result) {
|
||||||
CLIResult cliResult = (CLIResult) result;
|
CLIResult cliResult = (CLIResult) result;
|
|
@ -20,21 +20,19 @@ package org.keycloak.it.cli.dist;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.keycloak.it.junit5.extension.CLIResult;
|
import org.keycloak.it.junit5.extension.CLIResult;
|
||||||
import org.keycloak.it.junit5.extension.DistributionTest;
|
import org.keycloak.it.junit5.extension.DistributionTest;
|
||||||
import org.keycloak.it.junit5.extension.LegacyStore;
|
|
||||||
import org.keycloak.it.junit5.extension.RawDistOnly;
|
import org.keycloak.it.junit5.extension.RawDistOnly;
|
||||||
import org.keycloak.it.junit5.extension.TestProvider;
|
import org.keycloak.it.junit5.extension.TestProvider;
|
||||||
import com.acme.provider.legacy.jpa.user.CustomLegacyUserProvider;
|
import com.acme.provider.legacy.jpa.user.CustomUserProvider;
|
||||||
|
|
||||||
import io.quarkus.test.junit.main.Launch;
|
import io.quarkus.test.junit.main.Launch;
|
||||||
import io.quarkus.test.junit.main.LaunchResult;
|
import io.quarkus.test.junit.main.LaunchResult;
|
||||||
|
|
||||||
@DistributionTest
|
@DistributionTest
|
||||||
@RawDistOnly(reason = "Containers are immutable")
|
@RawDistOnly(reason = "Containers are immutable")
|
||||||
@LegacyStore
|
public class CustomUserProviderDistTest {
|
||||||
public class CustomLegacyUserProviderDistTest {
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestProvider(CustomLegacyUserProvider.class)
|
@TestProvider(CustomUserProvider.class)
|
||||||
@Launch({ "start-dev", "--spi-user-provider=custom_jpa", "--spi-user-jpa-enabled=false" })
|
@Launch({ "start-dev", "--spi-user-provider=custom_jpa", "--spi-user-jpa-enabled=false" })
|
||||||
void testUserManagedEntityNotAddedToDefaultPU(LaunchResult result) {
|
void testUserManagedEntityNotAddedToDefaultPU(LaunchResult result) {
|
||||||
CLIResult cliResult = (CLIResult) result;
|
CLIResult cliResult = (CLIResult) result;
|
|
@ -10,7 +10,6 @@ import org.junit.jupiter.api.condition.EnabledOnOs;
|
||||||
import org.junit.jupiter.api.condition.OS;
|
import org.junit.jupiter.api.condition.OS;
|
||||||
import org.keycloak.it.junit5.extension.CLIResult;
|
import org.keycloak.it.junit5.extension.CLIResult;
|
||||||
import org.keycloak.it.junit5.extension.DistributionTest;
|
import org.keycloak.it.junit5.extension.DistributionTest;
|
||||||
import org.keycloak.it.junit5.extension.LegacyStore;
|
|
||||||
import org.keycloak.it.junit5.extension.RawDistOnly;
|
import org.keycloak.it.junit5.extension.RawDistOnly;
|
||||||
import org.keycloak.it.utils.KeycloakDistribution;
|
import org.keycloak.it.utils.KeycloakDistribution;
|
||||||
import org.keycloak.quarkus.runtime.cli.command.Build;
|
import org.keycloak.quarkus.runtime.cli.command.Build;
|
||||||
|
@ -25,7 +24,6 @@ import static org.keycloak.quarkus.runtime.cli.command.AbstractStartCommand.OPTI
|
||||||
@DistributionTest
|
@DistributionTest
|
||||||
@RawDistOnly(reason = "Containers are immutable")
|
@RawDistOnly(reason = "Containers are immutable")
|
||||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||||
@LegacyStore
|
|
||||||
public class FeaturesDistTest {
|
public class FeaturesDistTest {
|
||||||
|
|
||||||
private static final String PREVIEW_FEATURES_EXPECTED_LOG = "Preview features enabled: admin-fine-grained-authz:v1, client-secret-rotation:v1, dpop:v1, multi-site:v1, recovery-codes:v1, scripts:v1, token-exchange:v1, update-email:v1";
|
private static final String PREVIEW_FEATURES_EXPECTED_LOG = "Preview features enabled: admin-fine-grained-authz:v1, client-secret-rotation:v1, dpop:v1, multi-site:v1, recovery-codes:v1, scripts:v1, token-exchange:v1, update-email:v1";
|
||||||
|
|
|
@ -29,14 +29,12 @@ import java.util.function.Consumer;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.keycloak.it.junit5.extension.BeforeStartDistribution;
|
import org.keycloak.it.junit5.extension.BeforeStartDistribution;
|
||||||
import org.keycloak.it.junit5.extension.DistributionTest;
|
import org.keycloak.it.junit5.extension.DistributionTest;
|
||||||
import org.keycloak.it.junit5.extension.LegacyStore;
|
|
||||||
import org.keycloak.it.junit5.extension.RawDistOnly;
|
import org.keycloak.it.junit5.extension.RawDistOnly;
|
||||||
import org.keycloak.it.utils.KeycloakDistribution;
|
import org.keycloak.it.utils.KeycloakDistribution;
|
||||||
|
|
||||||
import io.quarkus.test.junit.main.Launch;
|
import io.quarkus.test.junit.main.Launch;
|
||||||
|
|
||||||
@DistributionTest(keepAlive =true)
|
@DistributionTest(keepAlive =true)
|
||||||
@LegacyStore
|
|
||||||
public class MetricsDistTest {
|
public class MetricsDistTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -37,7 +37,6 @@ import org.keycloak.it.junit5.extension.BeforeStartDistribution;
|
||||||
import org.keycloak.it.junit5.extension.CLIResult;
|
import org.keycloak.it.junit5.extension.CLIResult;
|
||||||
import org.keycloak.it.junit5.extension.DistributionTest;
|
import org.keycloak.it.junit5.extension.DistributionTest;
|
||||||
import org.keycloak.it.junit5.extension.KeepServerAlive;
|
import org.keycloak.it.junit5.extension.KeepServerAlive;
|
||||||
import org.keycloak.it.junit5.extension.LegacyStore;
|
|
||||||
import org.keycloak.it.junit5.extension.RawDistOnly;
|
import org.keycloak.it.junit5.extension.RawDistOnly;
|
||||||
import org.keycloak.it.utils.KeycloakDistribution;
|
import org.keycloak.it.utils.KeycloakDistribution;
|
||||||
|
|
||||||
|
@ -47,7 +46,6 @@ import io.quarkus.test.junit.main.LaunchResult;
|
||||||
@DistributionTest(reInstall = DistributionTest.ReInstall.NEVER)
|
@DistributionTest(reInstall = DistributionTest.ReInstall.NEVER)
|
||||||
@RawDistOnly(reason = "Containers are immutable")
|
@RawDistOnly(reason = "Containers are immutable")
|
||||||
@TestMethodOrder(OrderAnnotation.class)
|
@TestMethodOrder(OrderAnnotation.class)
|
||||||
@LegacyStore
|
|
||||||
public class QuarkusPropertiesDistTest {
|
public class QuarkusPropertiesDistTest {
|
||||||
|
|
||||||
private static final String QUARKUS_BUILDTIME_HIBERNATE_METRICS_KEY = "quarkus.datasource.metrics.enabled";
|
private static final String QUARKUS_BUILDTIME_HIBERNATE_METRICS_KEY = "quarkus.datasource.metrics.enabled";
|
||||||
|
|
|
@ -22,13 +22,11 @@ import io.quarkus.test.junit.main.LaunchResult;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.keycloak.it.junit5.extension.CLIResult;
|
import org.keycloak.it.junit5.extension.CLIResult;
|
||||||
import org.keycloak.it.junit5.extension.DistributionTest;
|
import org.keycloak.it.junit5.extension.DistributionTest;
|
||||||
import org.keycloak.it.junit5.extension.LegacyStore;
|
|
||||||
import org.keycloak.it.junit5.extension.WithDatabase;
|
import org.keycloak.it.junit5.extension.WithDatabase;
|
||||||
import org.keycloak.it.junit5.extension.WithEnvVars;
|
import org.keycloak.it.junit5.extension.WithEnvVars;
|
||||||
|
|
||||||
@DistributionTest
|
@DistributionTest
|
||||||
@WithDatabase(alias = "postgres")
|
@WithDatabase(alias = "postgres")
|
||||||
@LegacyStore
|
|
||||||
public class DatabaseOptionsDistTest {
|
public class DatabaseOptionsDistTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -17,15 +17,12 @@
|
||||||
|
|
||||||
package org.keycloak.it.storage.database.dist;
|
package org.keycloak.it.storage.database.dist;
|
||||||
|
|
||||||
import org.keycloak.it.junit5.extension.CLITest;
|
|
||||||
import org.keycloak.it.junit5.extension.DistributionTest;
|
import org.keycloak.it.junit5.extension.DistributionTest;
|
||||||
import org.keycloak.it.junit5.extension.LegacyStore;
|
|
||||||
import org.keycloak.it.junit5.extension.WithDatabase;
|
import org.keycloak.it.junit5.extension.WithDatabase;
|
||||||
import org.keycloak.it.storage.database.MariaDBTest;
|
import org.keycloak.it.storage.database.MariaDBTest;
|
||||||
|
|
||||||
@DistributionTest(removeBuildOptionsAfterBuild = true)
|
@DistributionTest(removeBuildOptionsAfterBuild = true)
|
||||||
@WithDatabase(alias = "mariadb")
|
@WithDatabase(alias = "mariadb")
|
||||||
@LegacyStore
|
|
||||||
public class MariaDBDistTest extends MariaDBTest {
|
public class MariaDBDistTest extends MariaDBTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
package org.keycloak.it.storage.database.dist;
|
package org.keycloak.it.storage.database.dist;
|
||||||
|
|
||||||
import org.keycloak.it.junit5.extension.DistributionTest;
|
import org.keycloak.it.junit5.extension.DistributionTest;
|
||||||
import org.keycloak.it.junit5.extension.LegacyStore;
|
|
||||||
import org.keycloak.it.junit5.extension.WithDatabase;
|
import org.keycloak.it.junit5.extension.WithDatabase;
|
||||||
import org.keycloak.it.storage.database.MySQLTest;
|
import org.keycloak.it.storage.database.MySQLTest;
|
||||||
|
|
||||||
@DistributionTest(removeBuildOptionsAfterBuild = true)
|
@DistributionTest(removeBuildOptionsAfterBuild = true)
|
||||||
@WithDatabase(alias = "mysql")
|
@WithDatabase(alias = "mysql")
|
||||||
@LegacyStore
|
|
||||||
public class MySQLDistTest extends MySQLTest {
|
public class MySQLDistTest extends MySQLTest {
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.keycloak.it.junit5.extension.CLIResult;
|
import org.keycloak.it.junit5.extension.CLIResult;
|
||||||
import org.keycloak.it.junit5.extension.DistributionTest;
|
import org.keycloak.it.junit5.extension.DistributionTest;
|
||||||
import org.keycloak.it.junit5.extension.LegacyStore;
|
|
||||||
import org.keycloak.it.junit5.extension.WithDatabase;
|
import org.keycloak.it.junit5.extension.WithDatabase;
|
||||||
import org.keycloak.it.storage.database.PostgreSQLTest;
|
import org.keycloak.it.storage.database.PostgreSQLTest;
|
||||||
|
|
||||||
|
@ -32,7 +31,6 @@ import io.quarkus.test.junit.main.LaunchResult;
|
||||||
|
|
||||||
@DistributionTest(removeBuildOptionsAfterBuild = true)
|
@DistributionTest(removeBuildOptionsAfterBuild = true)
|
||||||
@WithDatabase(alias = "postgres")
|
@WithDatabase(alias = "postgres")
|
||||||
@LegacyStore
|
|
||||||
public class PostgreSQLDistTest extends PostgreSQLTest {
|
public class PostgreSQLDistTest extends PostgreSQLTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -5,12 +5,10 @@ import io.quarkus.test.junit.main.LaunchResult;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.keycloak.it.junit5.extension.CLIResult;
|
import org.keycloak.it.junit5.extension.CLIResult;
|
||||||
import org.keycloak.it.junit5.extension.DistributionTest;
|
import org.keycloak.it.junit5.extension.DistributionTest;
|
||||||
import org.keycloak.it.junit5.extension.LegacyStore;
|
|
||||||
import org.keycloak.it.junit5.extension.WithDatabase;
|
import org.keycloak.it.junit5.extension.WithDatabase;
|
||||||
|
|
||||||
@DistributionTest
|
@DistributionTest
|
||||||
@WithDatabase(alias = "mssql")
|
@WithDatabase(alias = "mssql")
|
||||||
@LegacyStore
|
|
||||||
public class TransactionConfigurationDistTest {
|
public class TransactionConfigurationDistTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -22,7 +22,6 @@ import io.quarkus.runtime.configuration.QuarkusConfigFactory;
|
||||||
import io.quarkus.test.junit.QuarkusMainTestExtension;
|
import io.quarkus.test.junit.QuarkusMainTestExtension;
|
||||||
import io.quarkus.test.junit.main.Launch;
|
import io.quarkus.test.junit.main.Launch;
|
||||||
import io.quarkus.test.junit.main.LaunchResult;
|
import io.quarkus.test.junit.main.LaunchResult;
|
||||||
|
|
||||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||||
import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
|
import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
|
||||||
import org.junit.jupiter.api.extension.ExtensionContext.Store;
|
import org.junit.jupiter.api.extension.ExtensionContext.Store;
|
||||||
|
@ -46,7 +45,6 @@ import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
@ -101,7 +99,7 @@ public class CLITestExtension extends QuarkusMainTestExtension {
|
||||||
onKeepServerAlive(context.getRequiredTestMethod().getAnnotation(KeepServerAlive.class));
|
onKeepServerAlive(context.getRequiredTestMethod().getAnnotation(KeepServerAlive.class));
|
||||||
|
|
||||||
if (dist == null) {
|
if (dist == null) {
|
||||||
dist = createDistribution(distConfig, getLegacyStoreConfig(context), getDatabaseConfig(context));
|
dist = createDistribution(distConfig, getStoreConfig(context), getDatabaseConfig(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
copyTestProvider(context.getRequiredTestClass().getAnnotation(TestProvider.class));
|
copyTestProvider(context.getRequiredTestClass().getAnnotation(TestProvider.class));
|
||||||
|
@ -125,8 +123,8 @@ public class CLITestExtension extends QuarkusMainTestExtension {
|
||||||
return context.getStore(Namespace.create(context.getRequiredTestClass(), context.getRequiredTestMethod()));
|
return context.getStore(Namespace.create(context.getRequiredTestClass(), context.getRequiredTestMethod()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static LegacyStore getLegacyStoreConfig(ExtensionContext context) {
|
private static Storage getStoreConfig(ExtensionContext context) {
|
||||||
return context.getTestClass().get().getDeclaredAnnotation(LegacyStore.class);
|
return context.getTestClass().get().getDeclaredAnnotation(Storage.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyTestProvider(TestProvider provider) {
|
private void copyTestProvider(TestProvider provider) {
|
||||||
|
@ -227,7 +225,7 @@ public class CLITestExtension extends QuarkusMainTestExtension {
|
||||||
|
|
||||||
if (distConfig != null) {
|
if (distConfig != null) {
|
||||||
if (BEFORE_ALL.equals(distConfig.reInstall())) {
|
if (BEFORE_ALL.equals(distConfig.reInstall())) {
|
||||||
dist = createDistribution(distConfig, getLegacyStoreConfig(context), getDatabaseConfig(context));
|
dist = createDistribution(distConfig, getStoreConfig(context), getDatabaseConfig(context));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
forceTestLaunchMode();
|
forceTestLaunchMode();
|
||||||
|
@ -245,8 +243,8 @@ public class CLITestExtension extends QuarkusMainTestExtension {
|
||||||
super.afterAll(context);
|
super.afterAll(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
private KeycloakDistribution createDistribution(DistributionTest config, LegacyStore legacyStoreConfig, WithDatabase databaseConfig) {
|
private KeycloakDistribution createDistribution(DistributionTest config, Storage storeConfig, WithDatabase databaseConfig) {
|
||||||
return new KeycloakDistributionDecorator(legacyStoreConfig, databaseConfig, config, DistributionType.getCurrent().orElse(RAW).newInstance(config));
|
return new KeycloakDistributionDecorator(storeConfig, databaseConfig, config, DistributionType.getCurrent().orElse(RAW).newInstance(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -24,14 +24,14 @@ import org.keycloak.it.utils.KeycloakDistribution;
|
||||||
|
|
||||||
public class KeycloakDistributionDecorator implements KeycloakDistribution {
|
public class KeycloakDistributionDecorator implements KeycloakDistribution {
|
||||||
|
|
||||||
private LegacyStore legacyStoreConfig;
|
private Storage storageConfig;
|
||||||
private WithDatabase databaseConfig;
|
private WithDatabase databaseConfig;
|
||||||
private DistributionTest config;
|
private DistributionTest config;
|
||||||
private KeycloakDistribution delegate;
|
private KeycloakDistribution delegate;
|
||||||
|
|
||||||
public KeycloakDistributionDecorator(LegacyStore legacyStoreConfig, WithDatabase databaseConfig, DistributionTest config,
|
public KeycloakDistributionDecorator(Storage storageConfig, WithDatabase databaseConfig, DistributionTest config,
|
||||||
KeycloakDistribution delegate) {
|
KeycloakDistribution delegate) {
|
||||||
this.legacyStoreConfig = legacyStoreConfig;
|
this.storageConfig = storageConfig;
|
||||||
this.databaseConfig = databaseConfig;
|
this.databaseConfig = databaseConfig;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
|
@ -43,7 +43,7 @@ public class KeycloakDistributionDecorator implements KeycloakDistribution {
|
||||||
|
|
||||||
args.addAll(List.of(config.defaultOptions()));
|
args.addAll(List.of(config.defaultOptions()));
|
||||||
|
|
||||||
return delegate.run(new ServerOptions(legacyStoreConfig, databaseConfig, args));
|
return delegate.run(new ServerOptions(storageConfig, databaseConfig, args));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -39,12 +39,12 @@ final class ServerOptions extends ArrayList<String> {
|
||||||
.or("-h"::equals)
|
.or("-h"::equals)
|
||||||
.or(ShowConfig.NAME::equals);
|
.or(ShowConfig.NAME::equals);
|
||||||
|
|
||||||
ServerOptions(LegacyStore legacyStoreConfig, WithDatabase withDatabase, List<String> rawOptions) {
|
ServerOptions(Storage storageConfig, WithDatabase withDatabase, List<String> rawOptions) {
|
||||||
if (rawOptions.isEmpty()) {
|
if (rawOptions.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Map.Entry<String, Predicate<String>> entry : getDefaultOptions(legacyStoreConfig, withDatabase).entrySet()) {
|
for (Map.Entry<String, Predicate<String>> entry : getDefaultOptions(storageConfig, withDatabase).entrySet()) {
|
||||||
if (contains(entry.getKey())) {
|
if (contains(entry.getKey())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -57,28 +57,19 @@ final class ServerOptions extends ArrayList<String> {
|
||||||
addAll(0, rawOptions);
|
addAll(0, rawOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Predicate<String>> getDefaultOptions(LegacyStore legacyStoreConfig, WithDatabase withDatabase) {
|
private Map<String, Predicate<String>> getDefaultOptions(Storage storageConfig, WithDatabase withDatabase) {
|
||||||
Map<String, Predicate<String>> defaultOptions = new HashMap<>();
|
Map<String, Predicate<String>> defaultOptions = new HashMap<>();
|
||||||
|
|
||||||
defaultOptions.put("--cache=local", ignoreCacheLocal(legacyStoreConfig));
|
defaultOptions.put("--cache=local", ignoreCacheLocal(storageConfig));
|
||||||
|
|
||||||
return defaultOptions;
|
return defaultOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Predicate<String> ignoreCacheLocal(LegacyStore legacyStoreConfig) {
|
private Predicate<String> ignoreCacheLocal(Storage storageConfig) {
|
||||||
return new Predicate<String>() {
|
return new Predicate<String>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean test(String arg) {
|
public boolean test(String arg) {
|
||||||
return arg.contains("--cache") || legacyStoreConfig == null || !legacyStoreConfig.defaultLocalCache();
|
return arg.contains("--cache") || storageConfig == null || !storageConfig.defaultLocalCache();
|
||||||
}
|
|
||||||
}.or(IGNORED_ARGUMENTS);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Predicate<String> ignoreStorageChm(LegacyStore legacyStoreConfig, WithDatabase withDatabase) {
|
|
||||||
return new Predicate<String>() {
|
|
||||||
@Override
|
|
||||||
public boolean test(String arg) {
|
|
||||||
return arg.contains("--storage") || legacyStoreConfig != null || withDatabase != null;
|
|
||||||
}
|
}
|
||||||
}.or(IGNORED_ARGUMENTS);
|
}.or(IGNORED_ARGUMENTS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,12 +24,12 @@ import java.lang.annotation.Target;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use this annotation to enable the legacy store when running a test.
|
* Use this annotation to change the default storage configuration when running a test.
|
||||||
*/
|
*/
|
||||||
@Target(ElementType.TYPE)
|
@Target(ElementType.TYPE)
|
||||||
@ExtendWith({ CLITestExtension.class })
|
@ExtendWith({ CLITestExtension.class })
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface LegacyStore {
|
public @interface Storage {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If {@code true}, the cache is set to local by default.
|
* If {@code true}, the cache is set to local by default.
|
|
@ -28,7 +28,7 @@ import org.keycloak.representations.idm.UserRepresentation;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage importing and updating of realms for the legacy store.
|
* Manage importing and updating of realms for the store.
|
||||||
*
|
*
|
||||||
* @author Alexander Schwartz
|
* @author Alexander Schwartz
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -22,19 +22,18 @@ import org.keycloak.provider.ProviderEvent;
|
||||||
import org.keycloak.representations.idm.RealmRepresentation;
|
import org.keycloak.representations.idm.RealmRepresentation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event for notifying legacy store, so it can do migrations on the representation as needed.
|
* Event for notifying the store, so it can do migrations on the representation as needed.
|
||||||
*
|
*
|
||||||
* CAUTION: This event is exceptional as it performs any necessary modificaton of the representation.
|
* CAUTION: This event is exceptional as it performs any necessary modificaton of the representation.
|
||||||
* This will be removed once the legacy store has been removed.
|
|
||||||
*/
|
*/
|
||||||
public class LegacyStoreMigrateRepresentationEvent implements ProviderEvent {
|
public class StoreMigrateRepresentationEvent implements ProviderEvent {
|
||||||
|
|
||||||
private final KeycloakSession session;
|
private final KeycloakSession session;
|
||||||
private final RealmModel realm;
|
private final RealmModel realm;
|
||||||
private final RealmRepresentation rep;
|
private final RealmRepresentation rep;
|
||||||
private final boolean skipUserDependent;
|
private final boolean skipUserDependent;
|
||||||
|
|
||||||
public LegacyStoreMigrateRepresentationEvent(KeycloakSession session, RealmModel realm, RealmRepresentation rep, boolean skipUserDependent) {
|
public StoreMigrateRepresentationEvent(KeycloakSession session, RealmModel realm, RealmRepresentation rep, boolean skipUserDependent) {
|
||||||
this.session = session;
|
this.session = session;
|
||||||
this.realm = realm;
|
this.realm = realm;
|
||||||
this.rep = rep;
|
this.rep = rep;
|
||||||
|
@ -42,7 +41,7 @@ public class LegacyStoreMigrateRepresentationEvent implements ProviderEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void fire(KeycloakSession session, RealmModel realm, RealmRepresentation rep, boolean skipUserDependent) {
|
public static void fire(KeycloakSession session, RealmModel realm, RealmRepresentation rep, boolean skipUserDependent) {
|
||||||
session.getKeycloakSessionFactory().publish(new LegacyStoreMigrateRepresentationEvent(session, realm, rep, skipUserDependent));
|
session.getKeycloakSessionFactory().publish(new StoreMigrateRepresentationEvent(session, realm, rep, skipUserDependent));
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeycloakSession getSession() {
|
public KeycloakSession getSession() {
|
|
@ -21,23 +21,23 @@ import org.keycloak.models.RealmModel;
|
||||||
import org.keycloak.provider.ProviderEvent;
|
import org.keycloak.provider.ProviderEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event for notifying legacy store about the need to reconfigure user providers
|
* Event for notifying the store about the need to reconfigure user providers
|
||||||
* sychronization.
|
* synchronization.
|
||||||
*/
|
*/
|
||||||
public class LegacyStoreSyncEvent implements ProviderEvent {
|
public class StoreSyncEvent implements ProviderEvent {
|
||||||
|
|
||||||
private final KeycloakSession session;
|
private final KeycloakSession session;
|
||||||
private final RealmModel realm;
|
private final RealmModel realm;
|
||||||
private final boolean removed;
|
private final boolean removed;
|
||||||
|
|
||||||
public LegacyStoreSyncEvent(KeycloakSession session, RealmModel realm, boolean removed) {
|
public StoreSyncEvent(KeycloakSession session, RealmModel realm, boolean removed) {
|
||||||
this.session = session;
|
this.session = session;
|
||||||
this.realm = realm;
|
this.realm = realm;
|
||||||
this.removed = removed;
|
this.removed = removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void fire(KeycloakSession session, RealmModel realm, boolean removed) {
|
public static void fire(KeycloakSession session, RealmModel realm, boolean removed) {
|
||||||
session.getKeycloakSessionFactory().publish(new LegacyStoreSyncEvent(session, realm, removed));
|
session.getKeycloakSessionFactory().publish(new StoreSyncEvent(session, realm, removed));
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeycloakSession getSession() {
|
public KeycloakSession getSession() {
|
|
@ -53,8 +53,8 @@ import org.keycloak.representations.idm.RealmEventsConfigRepresentation;
|
||||||
import org.keycloak.representations.idm.RealmRepresentation;
|
import org.keycloak.representations.idm.RealmRepresentation;
|
||||||
import org.keycloak.representations.idm.RoleRepresentation;
|
import org.keycloak.representations.idm.RoleRepresentation;
|
||||||
import org.keycloak.sessions.AuthenticationSessionProvider;
|
import org.keycloak.sessions.AuthenticationSessionProvider;
|
||||||
import org.keycloak.storage.LegacyStoreMigrateRepresentationEvent;
|
import org.keycloak.storage.StoreMigrateRepresentationEvent;
|
||||||
import org.keycloak.storage.LegacyStoreSyncEvent;
|
import org.keycloak.storage.StoreSyncEvent;
|
||||||
import org.keycloak.services.clientregistration.policy.DefaultClientRegistrationPolicies;
|
import org.keycloak.services.clientregistration.policy.DefaultClientRegistrationPolicies;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -280,7 +280,7 @@ public class RealmManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh periodic sync tasks for configured storageProviders
|
// Refresh periodic sync tasks for configured storageProviders
|
||||||
LegacyStoreSyncEvent.fire(session, realm, true);
|
StoreSyncEvent.fire(session, realm, true);
|
||||||
}
|
}
|
||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
|
@ -607,13 +607,13 @@ public class RealmManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh periodic sync tasks for configured storageProviders
|
// Refresh periodic sync tasks for configured storageProviders
|
||||||
LegacyStoreSyncEvent.fire(session, realm, false);
|
StoreSyncEvent.fire(session, realm, false);
|
||||||
|
|
||||||
setupAuthorizationServices(realm);
|
setupAuthorizationServices(realm);
|
||||||
setupClientRegistrations(realm);
|
setupClientRegistrations(realm);
|
||||||
|
|
||||||
if (rep.getKeycloakVersion() != null) {
|
if (rep.getKeycloakVersion() != null) {
|
||||||
LegacyStoreMigrateRepresentationEvent.fire(session, realm, rep, skipUserDependent);
|
StoreMigrateRepresentationEvent.fire(session, realm, rep, skipUserDependent);
|
||||||
}
|
}
|
||||||
|
|
||||||
session.clientPolicy().updateRealmModelFromRepresentation(realm, rep);
|
session.clientPolicy().updateRealmModelFromRepresentation(realm, rep);
|
||||||
|
|
|
@ -27,7 +27,6 @@ import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
@ -117,8 +116,7 @@ import org.keycloak.services.resources.admin.permissions.AdminPermissionManageme
|
||||||
import org.keycloak.services.resources.admin.permissions.AdminPermissions;
|
import org.keycloak.services.resources.admin.permissions.AdminPermissions;
|
||||||
import org.keycloak.storage.DatastoreProvider;
|
import org.keycloak.storage.DatastoreProvider;
|
||||||
import org.keycloak.storage.ExportImportManager;
|
import org.keycloak.storage.ExportImportManager;
|
||||||
import org.keycloak.storage.LegacyStoreSyncEvent;
|
import org.keycloak.storage.StoreSyncEvent;
|
||||||
import org.keycloak.userprofile.DeclarativeUserProfileProvider;
|
|
||||||
import org.keycloak.utils.ProfileHelper;
|
import org.keycloak.utils.ProfileHelper;
|
||||||
import org.keycloak.utils.ReservedCharValidator;
|
import org.keycloak.utils.ReservedCharValidator;
|
||||||
|
|
||||||
|
@ -447,7 +445,7 @@ public class RealmAdminResource {
|
||||||
RepresentationToModel.updateRealm(rep, realm, session);
|
RepresentationToModel.updateRealm(rep, realm, session);
|
||||||
|
|
||||||
// Refresh periodic sync tasks for configured federationProviders
|
// Refresh periodic sync tasks for configured federationProviders
|
||||||
LegacyStoreSyncEvent.fire(session, realm, false);
|
StoreSyncEvent.fire(session, realm, false);
|
||||||
|
|
||||||
// This populates the map in DefaultKeycloakContext to be used when treating the event
|
// This populates the map in DefaultKeycloakContext to be used when treating the event
|
||||||
session.getContext().getUri();
|
session.getContext().getUri();
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.keycloak.testsuite.federation;
|
||||||
import org.keycloak.component.ComponentModel;
|
import org.keycloak.component.ComponentModel;
|
||||||
import org.keycloak.credential.CredentialInput;
|
import org.keycloak.credential.CredentialInput;
|
||||||
import org.keycloak.credential.CredentialInputValidator;
|
import org.keycloak.credential.CredentialInputValidator;
|
||||||
import org.keycloak.credential.LegacyUserCredentialManager;
|
import org.keycloak.credential.UserCredentialManager;
|
||||||
import org.keycloak.models.GroupModel;
|
import org.keycloak.models.GroupModel;
|
||||||
import org.keycloak.models.KeycloakSession;
|
import org.keycloak.models.KeycloakSession;
|
||||||
import org.keycloak.models.RealmModel;
|
import org.keycloak.models.RealmModel;
|
||||||
|
@ -144,7 +144,7 @@ public class UserPropertyFileStorage implements UserLookupProvider, UserStorageP
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SubjectCredentialManager credentialManager() {
|
public SubjectCredentialManager credentialManager() {
|
||||||
return new LegacyUserCredentialManager(session, realm, this);
|
return new UserCredentialManager(session, realm, this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.keycloak.component.ComponentModel;
|
||||||
import org.keycloak.models.GroupModel;
|
import org.keycloak.models.GroupModel;
|
||||||
import org.keycloak.models.KeycloakSessionFactory;
|
import org.keycloak.models.KeycloakSessionFactory;
|
||||||
import org.keycloak.models.LDAPConstants;
|
import org.keycloak.models.LDAPConstants;
|
||||||
import org.keycloak.models.LegacyRealmModel;
|
import org.keycloak.models.StorageProviderRealmModel;
|
||||||
import org.keycloak.models.RealmModel;
|
import org.keycloak.models.RealmModel;
|
||||||
import org.keycloak.models.UserModel;
|
import org.keycloak.models.UserModel;
|
||||||
import org.keycloak.models.UserProvider;
|
import org.keycloak.models.UserProvider;
|
||||||
|
@ -151,7 +151,7 @@ public class LDAPSyncTest extends AbstractLDAPTest {
|
||||||
|
|
||||||
// Assert lastSync time updated
|
// Assert lastSync time updated
|
||||||
Assert.assertTrue(ctx.getLdapModel().getLastSync() > 0);
|
Assert.assertTrue(ctx.getLdapModel().getLastSync() > 0);
|
||||||
((LegacyRealmModel) testRealm).getUserStorageProvidersStream().forEachOrdered(persistentFedModel -> {
|
((StorageProviderRealmModel) testRealm).getUserStorageProvidersStream().forEachOrdered(persistentFedModel -> {
|
||||||
if (LDAPStorageProviderFactory.PROVIDER_NAME.equals(persistentFedModel.getProviderId())) {
|
if (LDAPStorageProviderFactory.PROVIDER_NAME.equals(persistentFedModel.getProviderId())) {
|
||||||
Assert.assertTrue(persistentFedModel.getLastSync() > 0);
|
Assert.assertTrue(persistentFedModel.getLastSync() > 0);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.keycloak.events.Details;
|
||||||
import org.keycloak.models.ClientModel;
|
import org.keycloak.models.ClientModel;
|
||||||
import org.keycloak.models.Constants;
|
import org.keycloak.models.Constants;
|
||||||
import org.keycloak.models.KeycloakSession;
|
import org.keycloak.models.KeycloakSession;
|
||||||
import org.keycloak.models.LegacyRealmModel;
|
import org.keycloak.models.StorageProviderRealmModel;
|
||||||
import org.keycloak.models.RealmModel;
|
import org.keycloak.models.RealmModel;
|
||||||
import org.keycloak.models.cache.infinispan.ClientAdapter;
|
import org.keycloak.models.cache.infinispan.ClientAdapter;
|
||||||
import org.keycloak.representations.AccessToken;
|
import org.keycloak.representations.AccessToken;
|
||||||
|
@ -328,7 +328,7 @@ public class ClientStorageTest extends AbstractTestRealmKeycloakTest {
|
||||||
|
|
||||||
testingClient.server().run(session -> {
|
testingClient.server().run(session -> {
|
||||||
RealmModel realm = session.realms().getRealmByName("test");
|
RealmModel realm = session.realms().getRealmByName("test");
|
||||||
ClientStorageProviderModel model = ((LegacyRealmModel) realm).getClientStorageProvidersStream().findFirst().get();
|
ClientStorageProviderModel model = ((StorageProviderRealmModel) realm).getClientStorageProvidersStream().findFirst().get();
|
||||||
Calendar eviction = Calendar.getInstance();
|
Calendar eviction = Calendar.getInstance();
|
||||||
eviction.add(Calendar.HOUR, 1);
|
eviction.add(Calendar.HOUR, 1);
|
||||||
model.setCachePolicy(CacheableStorageProviderModel.CachePolicy.EVICT_DAILY);
|
model.setCachePolicy(CacheableStorageProviderModel.CachePolicy.EVICT_DAILY);
|
||||||
|
@ -352,7 +352,7 @@ public class ClientStorageTest extends AbstractTestRealmKeycloakTest {
|
||||||
|
|
||||||
testingClient.server().run(session -> {
|
testingClient.server().run(session -> {
|
||||||
RealmModel realm = session.realms().getRealmByName("test");
|
RealmModel realm = session.realms().getRealmByName("test");
|
||||||
ClientStorageProviderModel model = ((LegacyRealmModel) realm).getClientStorageProvidersStream().findAny().get();
|
ClientStorageProviderModel model = ((StorageProviderRealmModel) realm).getClientStorageProvidersStream().findAny().get();
|
||||||
Calendar eviction = Calendar.getInstance();
|
Calendar eviction = Calendar.getInstance();
|
||||||
eviction.add(Calendar.HOUR, 4 * 24);
|
eviction.add(Calendar.HOUR, 4 * 24);
|
||||||
model.setCachePolicy(CacheableStorageProviderModel.CachePolicy.EVICT_WEEKLY);
|
model.setCachePolicy(CacheableStorageProviderModel.CachePolicy.EVICT_WEEKLY);
|
||||||
|
@ -379,7 +379,7 @@ public class ClientStorageTest extends AbstractTestRealmKeycloakTest {
|
||||||
|
|
||||||
testingClient.server().run(session -> {
|
testingClient.server().run(session -> {
|
||||||
RealmModel realm = session.realms().getRealmByName("test");
|
RealmModel realm = session.realms().getRealmByName("test");
|
||||||
ClientStorageProviderModel model = ((LegacyRealmModel) realm).getClientStorageProvidersStream().findFirst().get();
|
ClientStorageProviderModel model = ((StorageProviderRealmModel) realm).getClientStorageProvidersStream().findFirst().get();
|
||||||
model.setCachePolicy(CacheableStorageProviderModel.CachePolicy.MAX_LIFESPAN);
|
model.setCachePolicy(CacheableStorageProviderModel.CachePolicy.MAX_LIFESPAN);
|
||||||
model.setMaxLifespan(1 * 60 * 60 * 1000);
|
model.setMaxLifespan(1 * 60 * 60 * 1000);
|
||||||
realm.updateComponent(model);
|
realm.updateComponent(model);
|
||||||
|
@ -427,7 +427,7 @@ public class ClientStorageTest extends AbstractTestRealmKeycloakTest {
|
||||||
|
|
||||||
testingClient.server().run(session -> {
|
testingClient.server().run(session -> {
|
||||||
RealmModel realm = session.realms().getRealmByName("test");
|
RealmModel realm = session.realms().getRealmByName("test");
|
||||||
ClientStorageProviderModel model = ((LegacyRealmModel) realm).getClientStorageProvidersStream().findFirst().get();
|
ClientStorageProviderModel model = ((StorageProviderRealmModel) realm).getClientStorageProvidersStream().findFirst().get();
|
||||||
model.setCachePolicy(CacheableStorageProviderModel.CachePolicy.NO_CACHE);
|
model.setCachePolicy(CacheableStorageProviderModel.CachePolicy.NO_CACHE);
|
||||||
realm.updateComponent(model);
|
realm.updateComponent(model);
|
||||||
});
|
});
|
||||||
|
@ -447,7 +447,7 @@ public class ClientStorageTest extends AbstractTestRealmKeycloakTest {
|
||||||
private void setDefaultCachePolicy() {
|
private void setDefaultCachePolicy() {
|
||||||
testingClient.server().run(session -> {
|
testingClient.server().run(session -> {
|
||||||
RealmModel realm = session.realms().getRealmByName("test");
|
RealmModel realm = session.realms().getRealmByName("test");
|
||||||
ClientStorageProviderModel model = ((LegacyRealmModel) realm).getClientStorageProvidersStream().findFirst().get();
|
ClientStorageProviderModel model = ((StorageProviderRealmModel) realm).getClientStorageProvidersStream().findFirst().get();
|
||||||
model.setCachePolicy(CacheableStorageProviderModel.CachePolicy.DEFAULT);
|
model.setCachePolicy(CacheableStorageProviderModel.CachePolicy.DEFAULT);
|
||||||
realm.updateComponent(model);
|
realm.updateComponent(model);
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@ import org.jboss.logging.Logger;
|
||||||
import org.keycloak.common.util.reflections.Types;
|
import org.keycloak.common.util.reflections.Types;
|
||||||
import org.keycloak.component.ComponentModel;
|
import org.keycloak.component.ComponentModel;
|
||||||
import org.keycloak.models.KeycloakSession;
|
import org.keycloak.models.KeycloakSession;
|
||||||
import org.keycloak.models.LegacyRealmModel;
|
import org.keycloak.models.StorageProviderRealmModel;
|
||||||
import org.keycloak.models.ModelException;
|
import org.keycloak.models.ModelException;
|
||||||
import org.keycloak.models.RealmModel;
|
import org.keycloak.models.RealmModel;
|
||||||
import org.keycloak.storage.UserStorageProvider;
|
import org.keycloak.storage.UserStorageProvider;
|
||||||
|
@ -47,7 +47,7 @@ public class UserStorageProvidersTestUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> Stream<UserStorageProviderModel> getStorageProviders(RealmModel realm, KeycloakSession session, Class<T> type) {
|
public static <T> Stream<UserStorageProviderModel> getStorageProviders(RealmModel realm, KeycloakSession session, Class<T> type) {
|
||||||
return ((LegacyRealmModel) realm).getUserStorageProvidersStream()
|
return ((StorageProviderRealmModel) realm).getUserStorageProvidersStream()
|
||||||
.filter(model -> {
|
.filter(model -> {
|
||||||
UserStorageProviderFactory factory = getUserStorageProviderFactory(model, session);
|
UserStorageProviderFactory factory = getUserStorageProviderFactory(model, session);
|
||||||
if (factory == null) {
|
if (factory == null) {
|
||||||
|
|
|
@ -6,8 +6,7 @@ initialized only with those providers that are explicitly enabled
|
||||||
in a used profile via `keycloak.model.parameters` system property.
|
in a used profile via `keycloak.model.parameters` system property.
|
||||||
|
|
||||||
This allows writing tests and running those in different
|
This allows writing tests and running those in different
|
||||||
configurations quickly, e.g. once with legacy JPA storage,
|
configurations quickly.
|
||||||
second time with purely new Hot Rod implementation.
|
|
||||||
|
|
||||||
The valid parameters are names of classes in `org.keycloak.testsuite.model.parameters`
|
The valid parameters are names of classes in `org.keycloak.testsuite.model.parameters`
|
||||||
package, and it is possible to combine those by providing multiple class names
|
package, and it is possible to combine those by providing multiple class names
|
||||||
|
|
|
@ -197,104 +197,104 @@
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
<profile>
|
<profile>
|
||||||
<id>legacy-jpa</id>
|
<id>jpa</id>
|
||||||
<properties>
|
<properties>
|
||||||
<keycloak.model.parameters>LegacyJpa</keycloak.model.parameters>
|
<keycloak.model.parameters>Jpa</keycloak.model.parameters>
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
<profile>
|
<profile>
|
||||||
<id>legacy-jpa+infinispan</id>
|
<id>jpa+infinispan</id>
|
||||||
<properties>
|
<properties>
|
||||||
<keycloak.model.parameters>Infinispan,LegacyJpa</keycloak.model.parameters>
|
<keycloak.model.parameters>Infinispan,Jpa</keycloak.model.parameters>
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
<profile>
|
<profile>
|
||||||
<id>legacy-jpa+infinispan+client-storage</id>
|
<id>jpa+infinispan+client-storage</id>
|
||||||
<properties>
|
<properties>
|
||||||
<keycloak.model.parameters>LegacyJpa,Infinispan,HardcodedClientStorage</keycloak.model.parameters>
|
<keycloak.model.parameters>Jpa,Infinispan,HardcodedClientStorage</keycloak.model.parameters>
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
<profile>
|
<profile>
|
||||||
<id>legacy-jpa+cross-dc-infinispan</id>
|
<id>jpa+cross-dc-infinispan</id>
|
||||||
<properties>
|
<properties>
|
||||||
<keycloak.model.parameters>CrossDCInfinispan,LegacyJpa</keycloak.model.parameters>
|
<keycloak.model.parameters>CrossDCInfinispan,Jpa</keycloak.model.parameters>
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
<profile>
|
<profile>
|
||||||
<id>legacy-jpa+cross-dc-infinispan-offline-sessions-preloading</id>
|
<id>jpa+cross-dc-infinispan-offline-sessions-preloading</id>
|
||||||
<properties>
|
<properties>
|
||||||
<keycloak.model.parameters>CrossDCInfinispan,LegacyJpa</keycloak.model.parameters>
|
<keycloak.model.parameters>CrossDCInfinispan,Jpa</keycloak.model.parameters>
|
||||||
<keycloak.profile.feature.offline_session_preloading>enabled</keycloak.profile.feature.offline_session_preloading>
|
<keycloak.profile.feature.offline_session_preloading>enabled</keycloak.profile.feature.offline_session_preloading>
|
||||||
<keycloak.userSessions.infinispan.preloadOfflineSessionsFromDatabase>true</keycloak.userSessions.infinispan.preloadOfflineSessionsFromDatabase>
|
<keycloak.userSessions.infinispan.preloadOfflineSessionsFromDatabase>true</keycloak.userSessions.infinispan.preloadOfflineSessionsFromDatabase>
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
<profile>
|
<profile>
|
||||||
<id>legacy-jpa+infinispan-offline-sessions-preloading</id>
|
<id>jpa+infinispan-offline-sessions-preloading</id>
|
||||||
<properties>
|
<properties>
|
||||||
<keycloak.model.parameters>Infinispan,LegacyJpa</keycloak.model.parameters>
|
<keycloak.model.parameters>Infinispan,Jpa</keycloak.model.parameters>
|
||||||
<keycloak.profile.feature.offline_session_preloading>enabled</keycloak.profile.feature.offline_session_preloading>
|
<keycloak.profile.feature.offline_session_preloading>enabled</keycloak.profile.feature.offline_session_preloading>
|
||||||
<keycloak.userSessions.infinispan.preloadOfflineSessionsFromDatabase>true</keycloak.userSessions.infinispan.preloadOfflineSessionsFromDatabase>
|
<keycloak.userSessions.infinispan.preloadOfflineSessionsFromDatabase>true</keycloak.userSessions.infinispan.preloadOfflineSessionsFromDatabase>
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
<profile>
|
<profile>
|
||||||
<id>legacy-jpa-federation+infinispan</id>
|
<id>jpa-federation+infinispan</id>
|
||||||
<properties>
|
<properties>
|
||||||
<keycloak.model.parameters>Infinispan,LegacyJpaFederation,TestsuiteUserMapStorage</keycloak.model.parameters>
|
<keycloak.model.parameters>Infinispan,JpaFederation,TestsuiteUserMapStorage</keycloak.model.parameters>
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
<profile>
|
<profile>
|
||||||
<id>legacy-jpa-federation-backward+infinispan</id>
|
<id>jpa-federation-backward+infinispan</id>
|
||||||
<properties>
|
<properties>
|
||||||
<keycloak.model.parameters>Infinispan,LegacyJpaFederation,BackwardsCompatibilityUserStorage</keycloak.model.parameters>
|
<keycloak.model.parameters>Infinispan,JpaFederation,BackwardsCompatibilityUserStorage</keycloak.model.parameters>
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
<profile>
|
<profile>
|
||||||
<id>legacy-jpa-federation</id>
|
<id>jpa-federation</id>
|
||||||
<properties>
|
<properties>
|
||||||
<keycloak.model.parameters>LegacyJpaFederation,TestsuiteUserMapStorage</keycloak.model.parameters>
|
<keycloak.model.parameters>JpaFederation,TestsuiteUserMapStorage</keycloak.model.parameters>
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
<profile>
|
<profile>
|
||||||
<id>legacy-jpa-federation-backward</id>
|
<id>jpa-federation-backward</id>
|
||||||
<properties>
|
<properties>
|
||||||
<keycloak.model.parameters>LegacyJpaFederation,BackwardsCompatibilityUserStorage</keycloak.model.parameters>
|
<keycloak.model.parameters>JpaFederation,BackwardsCompatibilityUserStorage</keycloak.model.parameters>
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
<profile>
|
<profile>
|
||||||
<id>legacy-jpa-federation-file-storage</id>
|
<id>jpa-federation-file-storage</id>
|
||||||
<properties>
|
<properties>
|
||||||
<keycloak.model.parameters>LegacyJpaFederation,TestsuiteUserFileStorage</keycloak.model.parameters>
|
<keycloak.model.parameters>JpaFederation,TestsuiteUserFileStorage</keycloak.model.parameters>
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
<profile>
|
<profile>
|
||||||
<id>legacy-jpa-federation-file-storage+infinispan</id>
|
<id>jpa-federation-file-storage+infinispan</id>
|
||||||
<properties>
|
<properties>
|
||||||
<keycloak.model.parameters>LegacyJpaFederation,TestsuiteUserFileStorage,Infinispan</keycloak.model.parameters>
|
<keycloak.model.parameters>JpaFederation,TestsuiteUserFileStorage,Infinispan</keycloak.model.parameters>
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
<profile>
|
<profile>
|
||||||
<id>legacy-jpa-federation+ldap</id>
|
<id>jpa-federation+ldap</id>
|
||||||
<properties>
|
<properties>
|
||||||
<keycloak.model.parameters>LegacyJpaFederation,LdapUserStorage</keycloak.model.parameters>
|
<keycloak.model.parameters>JpaFederation,LdapUserStorage</keycloak.model.parameters>
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
<profile>
|
<profile>
|
||||||
<id>legacy-jpa-federation+ldap+infinispan</id>
|
<id>jpa-federation+ldap+infinispan</id>
|
||||||
<properties>
|
<properties>
|
||||||
<keycloak.model.parameters>LegacyJpaFederation,LdapUserStorage,Infinispan</keycloak.model.parameters>
|
<keycloak.model.parameters>JpaFederation,LdapUserStorage,Infinispan</keycloak.model.parameters>
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class TimeOffsetTest extends KeycloakModelTest {
|
||||||
|
|
||||||
setTimeOffset(5);
|
setTimeOffset(5);
|
||||||
|
|
||||||
// legacy store requires explicit expiration of expired events
|
// store requires explicit expiration of expired events
|
||||||
ProviderFactory<EventStoreProvider> providerFactory = session.getKeycloakSessionFactory().getProviderFactory(EventStoreProvider.class);
|
ProviderFactory<EventStoreProvider> providerFactory = session.getKeycloakSessionFactory().getProviderFactory(EventStoreProvider.class);
|
||||||
if ("jpa".equals(providerFactory.getId())) {
|
if ("jpa".equals(providerFactory.getId())) {
|
||||||
provider.clearExpiredEvents();
|
provider.clearExpiredEvents();
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
package org.keycloak.testsuite.model.parameters;
|
package org.keycloak.testsuite.model.parameters;
|
||||||
|
|
||||||
import org.keycloak.authorization.jpa.store.JPAAuthorizationStoreFactory;
|
import org.keycloak.authorization.jpa.store.JPAAuthorizationStoreFactory;
|
||||||
import org.keycloak.broker.provider.IdentityProvider;
|
|
||||||
import org.keycloak.broker.provider.IdentityProviderFactory;
|
import org.keycloak.broker.provider.IdentityProviderFactory;
|
||||||
import org.keycloak.broker.provider.IdentityProviderSpi;
|
import org.keycloak.broker.provider.IdentityProviderSpi;
|
||||||
import org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory;
|
import org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory;
|
||||||
|
@ -43,7 +42,7 @@ import org.keycloak.models.jpa.JpaUserProviderFactory;
|
||||||
import org.keycloak.provider.ProviderFactory;
|
import org.keycloak.provider.ProviderFactory;
|
||||||
import org.keycloak.provider.Spi;
|
import org.keycloak.provider.Spi;
|
||||||
import org.keycloak.storage.DatastoreSpi;
|
import org.keycloak.storage.DatastoreSpi;
|
||||||
import org.keycloak.storage.datastore.LegacyDatastoreProviderFactory;
|
import org.keycloak.storage.datastore.DefaultDatastoreProviderFactory;
|
||||||
import org.keycloak.testsuite.model.Config;
|
import org.keycloak.testsuite.model.Config;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -54,7 +53,7 @@ import org.keycloak.protocol.LoginProtocolSpi;
|
||||||
*
|
*
|
||||||
* @author hmlnarik
|
* @author hmlnarik
|
||||||
*/
|
*/
|
||||||
public class LegacyJpa extends KeycloakModelParameters {
|
public class Jpa extends KeycloakModelParameters {
|
||||||
|
|
||||||
static final Set<Class<? extends Spi>> ALLOWED_SPIS = ImmutableSet.<Class<? extends Spi>>builder()
|
static final Set<Class<? extends Spi>> ALLOWED_SPIS = ImmutableSet.<Class<? extends Spi>>builder()
|
||||||
// jpa-specific
|
// jpa-specific
|
||||||
|
@ -78,7 +77,7 @@ public class LegacyJpa extends KeycloakModelParameters {
|
||||||
|
|
||||||
static final Set<Class<? extends ProviderFactory>> ALLOWED_FACTORIES = ImmutableSet.<Class<? extends ProviderFactory>>builder()
|
static final Set<Class<? extends ProviderFactory>> ALLOWED_FACTORIES = ImmutableSet.<Class<? extends ProviderFactory>>builder()
|
||||||
// jpa-specific
|
// jpa-specific
|
||||||
.add(LegacyDatastoreProviderFactory.class)
|
.add(DefaultDatastoreProviderFactory.class)
|
||||||
|
|
||||||
.add(DefaultJpaConnectionProviderFactory.class)
|
.add(DefaultJpaConnectionProviderFactory.class)
|
||||||
.add(JPAAuthorizationStoreFactory.class)
|
.add(JPAAuthorizationStoreFactory.class)
|
||||||
|
@ -103,7 +102,7 @@ public class LegacyJpa extends KeycloakModelParameters {
|
||||||
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public LegacyJpa() {
|
public Jpa() {
|
||||||
super(ALLOWED_SPIS, ALLOWED_FACTORIES);
|
super(ALLOWED_SPIS, ALLOWED_FACTORIES);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,12 +37,12 @@ import org.keycloak.testsuite.model.Config;
|
||||||
*
|
*
|
||||||
* @author hmlnarik
|
* @author hmlnarik
|
||||||
*/
|
*/
|
||||||
public class LegacyJpaFederation extends KeycloakModelParameters {
|
public class JpaFederation extends KeycloakModelParameters {
|
||||||
|
|
||||||
private final AtomicInteger counter = new AtomicInteger();
|
private final AtomicInteger counter = new AtomicInteger();
|
||||||
|
|
||||||
static final Set<Class<? extends Spi>> ALLOWED_SPIS = ImmutableSet.<Class<? extends Spi>>builder()
|
static final Set<Class<? extends Spi>> ALLOWED_SPIS = ImmutableSet.<Class<? extends Spi>>builder()
|
||||||
.addAll(LegacyJpa.ALLOWED_SPIS)
|
.addAll(Jpa.ALLOWED_SPIS)
|
||||||
.add(UserStorageProviderSpi.class)
|
.add(UserStorageProviderSpi.class)
|
||||||
.add(UserFederatedStorageProviderSpi.class)
|
.add(UserFederatedStorageProviderSpi.class)
|
||||||
.add(ClientScopeStorageProviderSpi.class)
|
.add(ClientScopeStorageProviderSpi.class)
|
||||||
|
@ -50,12 +50,12 @@ public class LegacyJpaFederation extends KeycloakModelParameters {
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
static final Set<Class<? extends ProviderFactory>> ALLOWED_FACTORIES = ImmutableSet.<Class<? extends ProviderFactory>>builder()
|
static final Set<Class<? extends ProviderFactory>> ALLOWED_FACTORIES = ImmutableSet.<Class<? extends ProviderFactory>>builder()
|
||||||
.addAll(LegacyJpa.ALLOWED_FACTORIES)
|
.addAll(Jpa.ALLOWED_FACTORIES)
|
||||||
.add(JpaUserFederatedStorageProviderFactory.class)
|
.add(JpaUserFederatedStorageProviderFactory.class)
|
||||||
.add(ClientScopeStorageProviderFactory.class)
|
.add(ClientScopeStorageProviderFactory.class)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public LegacyJpaFederation() {
|
public JpaFederation() {
|
||||||
super(ALLOWED_SPIS, ALLOWED_FACTORIES);
|
super(ALLOWED_SPIS, ALLOWED_FACTORIES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,6 +74,6 @@ public class LegacyJpaFederation extends KeycloakModelParameters {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateConfig(Config cf) {
|
public void updateConfig(Config cf) {
|
||||||
LegacyJpa.updateConfigForJpa(cf);
|
Jpa.updateConfigForJpa(cf);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -19,7 +19,7 @@ package org.keycloak.testsuite.util.cli;
|
||||||
|
|
||||||
import org.keycloak.common.util.MultivaluedHashMap;
|
import org.keycloak.common.util.MultivaluedHashMap;
|
||||||
import org.keycloak.models.KeycloakSession;
|
import org.keycloak.models.KeycloakSession;
|
||||||
import org.keycloak.models.LegacyRealmModel;
|
import org.keycloak.models.StorageProviderRealmModel;
|
||||||
import org.keycloak.models.RealmModel;
|
import org.keycloak.models.RealmModel;
|
||||||
import org.keycloak.storage.managers.UserStorageSyncManager;
|
import org.keycloak.storage.managers.UserStorageSyncManager;
|
||||||
import org.keycloak.storage.UserStorageProviderModel;
|
import org.keycloak.storage.UserStorageProviderModel;
|
||||||
|
@ -71,7 +71,7 @@ public class SyncDummyFederationProviderCommand extends AbstractCommand {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ((LegacyRealmModel) realm).getUserStorageProvidersStream()
|
return ((StorageProviderRealmModel) realm).getUserStorageProvidersStream()
|
||||||
.filter(fedProvider -> Objects.equals(fedProvider.getName(), displayName))
|
.filter(fedProvider -> Objects.equals(fedProvider.getName(), displayName))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|
Loading…
Reference in a new issue