Author: coheigea
Date: Wed May 29 13:57:52 2013
New Revision: 1487489

URL: http://svn.apache.org/r1487489
Log:
Add the ability to explicitly disable caching

Modified:
    
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/ConfigurationConstants.java
    
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ConfigurationConverter.java
    
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ext/WSSSecurityProperties.java

Modified: 
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/ConfigurationConstants.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/ConfigurationConstants.java?rev=1487489&r1=1487488&r2=1487489&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/ConfigurationConstants.java
 (original)
+++ 
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/ConfigurationConstants.java
 Wed May 29 13:57:52 2013
@@ -484,6 +484,17 @@ public final class ConfigurationConstant
      */
     public static final String INCLUDE_SIGNATURE_TOKEN = 
"includeSignatureToken";
     
+    /**
+     * Whether to cache UsernameToken nonces. The default value is "true".
+     */
+    public static final String ENABLE_NONCE_CACHE = "enableNonceCache";
+    
+    /**
+     * Whether to cache Timestamp Created Strings (these are only cached in 
conjunction with a message 
+     * Signature). The default value is "true".
+     */
+    public static final String ENABLE_TIMESTAMP_CACHE = 
"ws-security.enable.timestamp.cache";
+    
     //
     // (Non-boolean) Configuration parameters for the actions/processors
     //

Modified: 
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ConfigurationConverter.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ConfigurationConverter.java?rev=1487489&r1=1487488&r2=1487489&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ConfigurationConverter.java
 (original)
+++ 
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ConfigurationConverter.java
 Wed May 29 13:57:52 2013
@@ -407,6 +407,14 @@ public final class ConfigurationConverte
         boolean includeSignatureToken = 
             
decodeBooleanConfigValue(ConfigurationConstants.INCLUDE_SIGNATURE_TOKEN, false, 
config);
         properties.setIncludeSignatureToken(includeSignatureToken);
+        
+        boolean enableTimestampCache = 
+            
decodeBooleanConfigValue(ConfigurationConstants.ENABLE_TIMESTAMP_CACHE, true, 
config);
+        properties.setEnableTimestampReplayCache(enableTimestampCache);
+        
+        boolean enableNonceCache = 
+            
decodeBooleanConfigValue(ConfigurationConstants.ENABLE_NONCE_CACHE, true, 
config);
+        properties.setEnableNonceReplayCache(enableNonceCache);
     }
     
     private static void parseNonBooleanProperties(

Modified: 
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ext/WSSSecurityProperties.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ext/WSSSecurityProperties.java?rev=1487489&r1=1487488&r2=1487489&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ext/WSSSecurityProperties.java
 (original)
+++ 
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ext/WSSSecurityProperties.java
 Wed May 29 13:57:52 2013
@@ -102,6 +102,8 @@ public class WSSSecurityProperties exten
     private boolean enableRevocation = false;
     private ReplayCache timestampReplayCache;
     private ReplayCache nonceReplayCache;
+    private boolean enableTimestampReplayCache = true;
+    private boolean enableNonceReplayCache = true;
     private boolean validateSamlSubjectConfirmation = true;
 
     public WSSSecurityProperties() {
@@ -146,6 +148,8 @@ public class WSSSecurityProperties exten
         this.enableRevocation = wssSecurityProperties.enableRevocation;
         this.timestampReplayCache = wssSecurityProperties.timestampReplayCache;
         this.nonceReplayCache = wssSecurityProperties.nonceReplayCache;
+        this.enableTimestampReplayCache = 
wssSecurityProperties.enableTimestampReplayCache;
+        this.enableNonceReplayCache = 
wssSecurityProperties.enableNonceReplayCache;
         this.allowRSA15KeyTransportAlgorithm = 
wssSecurityProperties.allowRSA15KeyTransportAlgorithm;
         this.derivedKeyIterations = wssSecurityProperties.derivedKeyIterations;
         this.useDerivedKeyForMAC = wssSecurityProperties.useDerivedKeyForMAC;
@@ -706,7 +710,7 @@ public class WSSSecurityProperties exten
      * @throws WSSecurityException 
      */
     public ReplayCache getTimestampReplayCache() throws WSSecurityException {
-        if (timestampReplayCache == null) {
+        if (enableTimestampReplayCache && timestampReplayCache == null) {
             timestampReplayCache = createCache("wss4j-timestamp-cache-");
         }
         
@@ -733,7 +737,7 @@ public class WSSSecurityProperties exten
      * @throws WSSecurityException 
      */
     public ReplayCache getNonceReplayCache() throws WSSecurityException {
-        if (nonceReplayCache == null) {
+        if (enableNonceReplayCache && nonceReplayCache == null) {
             nonceReplayCache = createCache("wss4j-nonce-cache-");
         }
         
@@ -819,5 +823,21 @@ public class WSSSecurityProperties exten
     public void setIncludeSignatureToken(boolean includeSignatureToken) {
         this.includeSignatureToken = includeSignatureToken;
     }
+
+    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;
+    }
     
 }


Reply via email to