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:09:58 UTC

[cxf] branch master 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 master
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/master by this push:
     new 47db1b5  [CXF-8566] cxf-ws-rt-security & ehcache: OSGi classloading
     new 45f92e8  Merge pull request #837 from jgreffe/bugfix/master/CXF-8566
47db1b5 is described below

commit 47db1b5843e92493b9619887588d41edb19acb84
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
---
 .../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 1ddac82..80b890f 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);