You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ff...@apache.org on 2021/08/26 18:13:07 UTC
[cxf] branch 3.4.x-fixes updated: [CXF-8566] cxf-ws-rt-security &
ehcache: OSGi classloading
This is an automated email from the ASF dual-hosted git repository.
ffang pushed a commit to branch 3.4.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/3.4.x-fixes by this push:
new ec9e894 [CXF-8566] cxf-ws-rt-security & ehcache: OSGi classloading
ec9e894 is described below
commit ec9e894b86e06577e7797bad603c850822e9ddf3
Author: Julien Greffe <36...@users.noreply.github.com>
AuthorDate: Thu Aug 26 17:32:02 2021 +0200
[CXF-8566] cxf-ws-rt-security & ehcache: OSGi classloading
(cherry picked from commit 47db1b5843e92493b9619887588d41edb19acb84)
---
.../apache/cxf/ws/security/tokenstore/EHCacheTokenStore.java | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/EHCacheTokenStore.java b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/EHCacheTokenStore.java
index 66d77bd..cf43d28 100644
--- a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/EHCacheTokenStore.java
+++ b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/EHCacheTokenStore.java
@@ -22,7 +22,9 @@ package org.apache.cxf.ws.security.tokenstore;
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.CacheManager;
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 class EHCacheTokenStore implements TokenStore, Closeable, BusLifeCycleLis
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);