Skip to content
Permalink
Browse files
[CXF-8566] cxf-ws-rt-security & ehcache: OSGi classloading
  • Loading branch information
jgreffe committed Aug 26, 2021
1 parent cb71352 commit 47db1b5843e92493b9619887588d41edb19acb84
Showing 1 changed file with 9 additions and 2 deletions.
@@ -22,7 +22,9 @@
import java.io.Closeable;
import java.net.URL;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.apache.cxf.Bus;
@@ -34,6 +36,7 @@
import org.ehcache.Status;
import org.ehcache.config.builders.CacheConfigurationBuilder;
import org.ehcache.config.builders.CacheManagerBuilder;
import org.ehcache.core.util.ClassLoading;
import org.ehcache.xml.XmlConfiguration;

/**
@@ -54,14 +57,18 @@ public EHCacheTokenStore(String key, Bus b, URL configFileURL) throws TokenStore

this.key = key;
try {
XmlConfiguration xmlConfig = new XmlConfiguration(configFileURL);

// Exclude the endpoint info bit added in TokenStoreUtils when getting the template name
String template = key;
if (template.contains("-")) {
template = key.substring(0, key.lastIndexOf('-'));
}

// Set class loader cache of template object to SecurityToken classloader
Map<String, ClassLoader> cacheClassLoaders = new HashMap<>();
cacheClassLoaders.put(template, SecurityToken.class.getClassLoader());
XmlConfiguration xmlConfig = new XmlConfiguration(configFileURL, ClassLoading.getDefaultClassLoader(),
cacheClassLoaders);

CacheConfigurationBuilder<String, SecurityToken> configurationBuilder =
xmlConfig.newCacheConfigurationBuilderFromTemplate(template,
String.class, SecurityToken.class);

0 comments on commit 47db1b5

Please sign in to comment.