You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2013/08/16 12:31:55 UTC
svn commit: r1514644 - in /webservices/wss4j/trunk:
ws-security-common/src/main/java/org/apache/wss4j/common/cache/
ws-security-dom/src/main/java/org/apache/wss4j/dom/handler/
Author: coheigea
Date: Fri Aug 16 10:31:55 2013
New Revision: 1514644
URL: http://svn.apache.org/r1514644
Log:
Fixed some caching issues with CXF
Modified:
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/EHCacheManagerHolder.java
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/EHCacheReplayCache.java
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/ReplayCacheFactory.java
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/handler/RequestData.java
Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/EHCacheManagerHolder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/EHCacheManagerHolder.java?rev=1514644&r1=1514643&r2=1514644&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/EHCacheManagerHolder.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/EHCacheManagerHolder.java Fri Aug 16 10:31:55 2013
@@ -90,17 +90,17 @@ public final class EHCacheManagerHolder
return cc;
}
- public static CacheManager getCacheManager(URL configFileURL) {
+ public static CacheManager getCacheManager(String confName, URL configFileURL) {
CacheManager cacheManager = null;
if (configFileURL == null) {
//using the default
- cacheManager = findDefaultCacheManager();
+ cacheManager = findDefaultCacheManager(confName);
}
if (cacheManager == null) {
if (configFileURL == null) {
cacheManager = createCacheManager();
} else {
- cacheManager = createCacheManager(configFileURL);
+ cacheManager = findDefaultCacheManager(confName, configFileURL);
}
}
AtomicInteger a = COUNTS.get(cacheManager.getName());
@@ -115,11 +115,10 @@ public final class EHCacheManagerHolder
return cacheManager;
}
- private static CacheManager findDefaultCacheManager() {
+ private static CacheManager findDefaultCacheManager(String confName) {
String defaultConfigFile = "wss4j-ehcache.xml";
URL configFileURL = null;
- String busId = "";
try {
configFileURL = Loader.getResource(defaultConfigFile);
if (configFileURL == null) {
@@ -129,19 +128,16 @@ public final class EHCacheManagerHolder
// Do nothing
LOG.debug(e.getMessage());
}
+ return findDefaultCacheManager(confName, configFileURL);
+ }
+
+ private static CacheManager findDefaultCacheManager(String confName, URL configFileURL) {
try {
Configuration conf = ConfigurationFactory.parseConfiguration(configFileURL);
- /*
- String perBus = (String)bus.getProperty("ws-security.cachemanager.per.bus");
- if (perBus == null) {
- perBus = "true";
- }
- if (Boolean.parseBoolean(perBus)) {
- */
- conf.setName(busId);
+ conf.setName(confName);
if ("java.io.tmpdir".equals(conf.getDiskStoreConfiguration().getOriginalPath())) {
String path = conf.getDiskStoreConfiguration().getPath() + File.separator
- + busId;
+ + confName;
conf.getDiskStoreConfiguration().setPath(path);
}
return createCacheManager(conf);
Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/EHCacheReplayCache.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/EHCacheReplayCache.java?rev=1514644&r1=1514643&r2=1514644&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/EHCacheReplayCache.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/EHCacheReplayCache.java Fri Aug 16 10:31:55 2013
@@ -36,12 +36,17 @@ public class EHCacheReplayCache implemen
public static final long DEFAULT_TTL = 3600L;
public static final long MAX_TTL = DEFAULT_TTL * 12L;
- private Ehcache cache;
- private CacheManager cacheManager;
- private long ttl = DEFAULT_TTL;
+ protected Ehcache cache;
+ protected CacheManager cacheManager;
+ protected long ttl = DEFAULT_TTL;
public EHCacheReplayCache(String key, URL configFileURL) {
- cacheManager = EHCacheManagerHolder.getCacheManager(configFileURL);
+ this(key, EHCacheManagerHolder.getCacheManager("", configFileURL));
+ }
+
+ public EHCacheReplayCache(String key, CacheManager cacheManager) {
+ this.cacheManager = cacheManager;
+
CacheConfiguration cc = EHCacheManagerHolder.getCacheConfiguration(key, cacheManager);
Ehcache newCache = new Cache(cc);
@@ -95,7 +100,7 @@ public class EHCacheReplayCache implemen
}
}
- cache.put(new Element(identifier, identifier, false, parsedTTL, parsedTTL));
+ cache.put(new Element(identifier, identifier, parsedTTL, parsedTTL));
}
/**
Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/ReplayCacheFactory.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/ReplayCacheFactory.java?rev=1514644&r1=1514643&r2=1514644&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/ReplayCacheFactory.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/ReplayCacheFactory.java Fri Aug 16 10:31:55 2013
@@ -46,7 +46,7 @@ public abstract class ReplayCacheFactory
}
}
- protected static synchronized boolean isEhCacheInstalled() {
+ public static synchronized boolean isEhCacheInstalled() {
return ehCacheInstalled;
}
Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/handler/RequestData.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/handler/RequestData.java?rev=1514644&r1=1514643&r2=1514644&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/handler/RequestData.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/handler/RequestData.java Fri Aug 16 10:31:55 2013
@@ -102,6 +102,8 @@ public class RequestData {
private boolean addUsernameTokenCreated;
private Certificate[] tlsCerts;
private boolean includeSignatureToken;
+ private boolean enableTimestampReplayCache = true;
+ private boolean enableNonceReplayCache = true;
public void clear() {
soapConstants = null;
@@ -136,12 +138,30 @@ public class RequestData {
setAddUsernameTokenCreated(false);
setTlsCerts(null);
includeSignatureToken = false;
+ enableTimestampReplayCache = true;
+ enableNonceReplayCache = true;
}
public String getSignatureC14nAlgorithm() {
return signatureC14nAlgorithm;
}
+ public boolean isEnableTimestampReplayCache() {
+ return enableTimestampReplayCache;
+ }
+
+ public void setEnableTimestampReplayCache(boolean enableTimestampReplayCache) {
+ this.enableTimestampReplayCache = enableTimestampReplayCache;
+ }
+
+ public boolean isEnableNonceReplayCache() {
+ return enableNonceReplayCache;
+ }
+
+ public void setEnableNonceReplayCache(boolean enableNonceReplayCache) {
+ this.enableNonceReplayCache = enableNonceReplayCache;
+ }
+
public void setSignatureC14nAlgorithm(String signatureC14nAlgorithm) {
this.signatureC14nAlgorithm = signatureC14nAlgorithm;
}
@@ -499,7 +519,7 @@ public class RequestData {
* @throws WSSecurityException
*/
public ReplayCache getTimestampReplayCache() throws WSSecurityException {
- if (timestampReplayCache == null) {
+ if (enableTimestampReplayCache && timestampReplayCache == null) {
timestampReplayCache = createCache("wss4j-timestamp-cache-");
}
@@ -524,7 +544,7 @@ public class RequestData {
* @throws WSSecurityException
*/
public ReplayCache getNonceReplayCache() throws WSSecurityException {
- if (nonceReplayCache == null) {
+ if (enableNonceReplayCache && nonceReplayCache == null) {
nonceReplayCache = createCache("wss4j-nonce-cache-");
}