Search in sources :

Example 11 with ClientStorageProviderModel

use of org.keycloak.storage.client.ClientStorageProviderModel in project keycloak by keycloak.

the class ClientStorageTest method testDailyEviction.

@Test
public void testDailyEviction() {
    testIsCached();
    testingClient.server().run(session -> {
        RealmModel realm = session.realms().getRealmByName("test");
        ClientStorageProviderModel model = realm.getClientStorageProvidersStream().findFirst().get();
        Calendar eviction = Calendar.getInstance();
        eviction.add(Calendar.HOUR, 1);
        model.setCachePolicy(CacheableStorageProviderModel.CachePolicy.EVICT_DAILY);
        model.setEvictionHour(eviction.get(HOUR_OF_DAY));
        model.setEvictionMinute(eviction.get(MINUTE));
        realm.updateComponent(model);
    });
    testIsCached();
    // 2 hours in future
    setTimeOffset(2 * 60 * 60);
    testNotCached();
    testIsCached();
    setDefaultCachePolicy();
    testIsCached();
}
Also used : RealmModel(org.keycloak.models.RealmModel) Calendar(java.util.Calendar) ClientStorageProviderModel(org.keycloak.storage.client.ClientStorageProviderModel) Test(org.junit.Test) AbstractTestRealmKeycloakTest(org.keycloak.testsuite.AbstractTestRealmKeycloakTest)

Example 12 with ClientStorageProviderModel

use of org.keycloak.storage.client.ClientStorageProviderModel in project keycloak by keycloak.

the class HardcodedClientStorage method getParameters.

@Override
public <T> Stream<T> getParameters(Class<T> clazz) {
    if (ClientStorageProviderModel.class.isAssignableFrom(clazz)) {
        ClientStorageProviderModel clientStorage = new ClientStorageProviderModel();
        clientStorage.setName(HardcodedClientStorageProviderFactory.PROVIDER_ID + ":" + counter.getAndIncrement());
        clientStorage.setProviderId(HardcodedClientStorageProviderFactory.PROVIDER_ID);
        return Stream.of((T) clientStorage);
    } else {
        return super.getParameters(clazz);
    }
}
Also used : ClientStorageProviderModel(org.keycloak.storage.client.ClientStorageProviderModel)

Aggregations

ClientStorageProviderModel (org.keycloak.storage.client.ClientStorageProviderModel)12 RealmModel (org.keycloak.models.RealmModel)7 Test (org.junit.Test)4 AbstractTestRealmKeycloakTest (org.keycloak.testsuite.AbstractTestRealmKeycloakTest)4 ComponentModel (org.keycloak.component.ComponentModel)3 ModelException (org.keycloak.models.ModelException)3 Calendar (java.util.Calendar)2 ClientModel (org.keycloak.models.ClientModel)2 ClientScopeModel (org.keycloak.models.ClientScopeModel)2 KeycloakSession (org.keycloak.models.KeycloakSession)2 UserConsentModel (org.keycloak.models.UserConsentModel)2 UserModel (org.keycloak.models.UserModel)2 RealmManager (org.keycloak.services.managers.RealmManager)2 StorageId (org.keycloak.storage.StorageId)2 IClient (com.openshift.restclient.IClient)1 UserStorageProviderModel (org.keycloak.storage.UserStorageProviderModel)1 ClientStorageProvider (org.keycloak.storage.client.ClientStorageProvider)1 ClientStorageProviderFactory (org.keycloak.storage.client.ClientStorageProviderFactory)1