finish cache policy
This commit is contained in:
parent
68e853b4bd
commit
f8a78d5565
9 changed files with 83 additions and 3 deletions
|
@ -20,8 +20,12 @@ import org.keycloak.models.KeycloakSession;
|
|||
import org.keycloak.models.RealmModel;
|
||||
import org.keycloak.provider.ConfiguredProvider;
|
||||
import org.keycloak.provider.Provider;
|
||||
import org.keycloak.provider.ProviderConfigProperty;
|
||||
import org.keycloak.provider.ProviderFactory;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
||||
* @version $Revision: 1 $
|
||||
|
@ -41,4 +45,15 @@ public interface ComponentFactory<CreatedType, ProviderType extends Provider> ex
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* These are config properties that are common across all implementation of this component type
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
default
|
||||
List<ProviderConfigProperty> getCommonProviderConfigProperties() {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -53,11 +53,17 @@ public class ComponentUtil {
|
|||
|
||||
private static Map<String, ProviderConfigProperty> getComponentConfigProperties(KeycloakSession session, String providerType, String providerId) {
|
||||
try {
|
||||
List<ProviderConfigProperty> l = getComponentFactory(session, providerType, providerId).getConfigProperties();
|
||||
ComponentFactory componentFactory = getComponentFactory(session, providerType, providerId);
|
||||
List<ProviderConfigProperty> l = componentFactory.getConfigProperties();
|
||||
Map<String, ProviderConfigProperty> properties = new HashMap<>();
|
||||
for (ProviderConfigProperty p : l) {
|
||||
properties.put(p.getName(), p);
|
||||
}
|
||||
List<ProviderConfigProperty> common = componentFactory.getCommonProviderConfigProperties();
|
||||
for (ProviderConfigProperty p : common) {
|
||||
properties.put(p.getName(), p);
|
||||
}
|
||||
|
||||
return properties;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
|
|
|
@ -385,6 +385,10 @@ public class ModelToRepresentation {
|
|||
Map<String, String> attributes = realm.getAttributes();
|
||||
rep.setAttributes(attributes);
|
||||
|
||||
if (!internal) {
|
||||
rep = StripSecretsUtils.strip(rep);
|
||||
}
|
||||
|
||||
return rep;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ public class StripSecretsUtils {
|
|||
next.setValue(Collections.singletonList(ComponentRepresentation.SECRET_VALUE));
|
||||
}
|
||||
} else {
|
||||
itr.remove();
|
||||
}
|
||||
}
|
||||
return rep;
|
||||
|
|
|
@ -25,8 +25,10 @@ import org.keycloak.models.KeycloakSession;
|
|||
import org.keycloak.models.KeycloakSessionFactory;
|
||||
import org.keycloak.models.RealmModel;
|
||||
import org.keycloak.provider.ProviderConfigProperty;
|
||||
import org.keycloak.provider.ProviderConfigurationBuilder;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -95,4 +97,15 @@ public interface UserStorageProviderFactory<T extends UserStorageProvider> exten
|
|||
default void onCreate(KeycloakSession session, RealmModel realm, ComponentModel model) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* configuration properties that are common across all UserStorageProvider implementations
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
default
|
||||
List<ProviderConfigProperty> getCommonProviderConfigProperties() {
|
||||
return UserStorageProviderSpi.commonConfig();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,9 +18,14 @@
|
|||
package org.keycloak.storage;
|
||||
|
||||
import org.keycloak.provider.Provider;
|
||||
import org.keycloak.provider.ProviderConfigProperty;
|
||||
import org.keycloak.provider.ProviderConfigurationBuilder;
|
||||
import org.keycloak.provider.ProviderFactory;
|
||||
import org.keycloak.provider.Spi;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
|
||||
*/
|
||||
|
@ -46,4 +51,39 @@ public class UserStorageProviderSpi implements Spi {
|
|||
return UserStorageProviderFactory.class;
|
||||
}
|
||||
|
||||
private static final List<ProviderConfigProperty> commonConfig;
|
||||
|
||||
static {
|
||||
List<ProviderConfigProperty> config = ProviderConfigurationBuilder.create()
|
||||
.property()
|
||||
.name("priority").type(ProviderConfigProperty.STRING_TYPE).add()
|
||||
.property()
|
||||
.name("fullSyncPeriod").type(ProviderConfigProperty.STRING_TYPE).add()
|
||||
.property()
|
||||
.name("changedSyncPeriod").type(ProviderConfigProperty.STRING_TYPE).add()
|
||||
.property()
|
||||
.name("lastSync").type(ProviderConfigProperty.STRING_TYPE).add()
|
||||
.property()
|
||||
.name("importEnabled").type(ProviderConfigProperty.BOOLEAN_TYPE).add()
|
||||
.property()
|
||||
.name("cachePolicy").type(ProviderConfigProperty.STRING_TYPE).add()
|
||||
.property()
|
||||
.name("maxLifespan").type(ProviderConfigProperty.STRING_TYPE).add()
|
||||
.property()
|
||||
.name("evictionHour").type(ProviderConfigProperty.STRING_TYPE).add()
|
||||
.property()
|
||||
.name("evictionMinute").type(ProviderConfigProperty.STRING_TYPE).add()
|
||||
.property()
|
||||
.name("evictionDay").type(ProviderConfigProperty.STRING_TYPE).add()
|
||||
.property()
|
||||
.name("cacheInvalidBefore").type(ProviderConfigProperty.STRING_TYPE).add()
|
||||
.build();
|
||||
commonConfig = Collections.unmodifiableList(config);
|
||||
}
|
||||
|
||||
public static List<ProviderConfigProperty> commonConfig() {
|
||||
return commonConfig;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ public class UserStorageTest {
|
|||
|
||||
}
|
||||
|
||||
//@Test
|
||||
@Test
|
||||
public void testIDE() throws Exception {
|
||||
Thread.sleep(100000000);
|
||||
}
|
||||
|
|
|
@ -1188,7 +1188,7 @@ Thursday=Thursday
|
|||
Friday=Friday
|
||||
Saturday=Saturday
|
||||
|
||||
user-strage-cache=Cache Settings
|
||||
user-storage-cache-policy=Cache Settings
|
||||
userStorage.cachePolicy=Cache Policy
|
||||
userStorage.cachePolicy.option.DEFAULT=DEFAULT
|
||||
userStorage.cachePolicy.option.EVICT_WEEKLY=EVICT_WEEKLY
|
||||
|
|
|
@ -203,6 +203,7 @@
|
|||
<option value="59">59</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<kc-tooltip>{{:: 'userStorage.cachePolicy.evictionMinute.tooltip' | translate}}</kc-tooltip>
|
||||
</div>
|
||||
<div class="form-group clearfix" data-ng-show="instance.config['cachePolicy'][0] == 'MAX_LIFESPAN'">
|
||||
|
|
Loading…
Reference in a new issue