Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
package fr.insee.sugoi.core.configuration;

import net.sf.ehcache.config.CacheConfiguration;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CachingConfigurer;
import org.springframework.cache.annotation.EnableCaching;
Expand All @@ -31,23 +33,21 @@
@EnableCaching
public class EhCacheConfig implements CachingConfigurer {

@Value("fr.insee.sugoi.realms.cache-ttl-seconds")
private int cacheTtlSeconds = 3600;

@Bean(destroyMethod = "shutdown")
public net.sf.ehcache.CacheManager ehCacheManager() {

CacheConfiguration cacheConfiguration = new CacheConfiguration();
cacheConfiguration.setName("Realms");
cacheConfiguration.setMemoryStoreEvictionPolicy("LRU");
cacheConfiguration.setMaxEntriesLocalHeap(1000);

CacheConfiguration cacheConfiguration1 = new CacheConfiguration();
cacheConfiguration1.setName("Realm");
cacheConfiguration1.setMemoryStoreEvictionPolicy("LRU");
cacheConfiguration1.setMaxEntriesLocalHeap(1000);
cacheConfiguration.setTimeToLiveSeconds(cacheTtlSeconds);

net.sf.ehcache.config.Configuration config = new net.sf.ehcache.config.Configuration();

config.addCache(cacheConfiguration);
config.addCache(cacheConfiguration1);

return net.sf.ehcache.CacheManager.newInstance(config);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,13 @@ public ProviderResponse deleteRealm(String realmName, ProviderRequest providerRe
List<UserStorage> userStorages =
load(realmName)
.orElseThrow(
() -> new RealmNotFoundException("The realm " + "test" + " doesn't exist "))
() -> new RealmNotFoundException("The realm " + realmName + " doesn't exist "))
.getUserStorages();
if (userStorages.size() > 1) {
for (UserStorage userStorage :
load(realmName)
.orElseThrow(
() -> new RealmNotFoundException("The realm " + "test" + " doesn't exist "))
() -> new RealmNotFoundException("The realm " + realmName + " doesn't exist "))
.getUserStorages()) {
ldapConnectionPool.delete(getUserStorageDn(userStorage.getName(), realmName));
}
Expand All @@ -335,6 +335,7 @@ public ProviderResponse deleteRealm(String realmName, ProviderRequest providerRe
}

private synchronized LDAPConnectionPool initLdapPoolConnection() {
//TODO use an authenticated connexion
try {
if (ldapConnectionPool == null
|| !ldapConnectionPool.getConnectionPoolName().equals(url + "-" + port)) {
Expand Down