ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1464008 - in /webservices/wss4j/trunk: parent/ ws-security-common/ ws-security-common/src/main/java/org/apache/wss4j/common/cache/ ws-security-common/src/main/resources/ ws-security-dom/src/main/java/org/apache/wss4j/dom/cache/ ws-security...
Date Wed, 03 Apr 2013 13:46:38 GMT
Author: coheigea
Date: Wed Apr  3 13:46:37 2013
New Revision: 1464008

URL: http://svn.apache.org/r1464008
Log:
[WSS-348] - Move Caching stuff to ws-security-common + add EhCache caching functionality from
CXF

Added:
    webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/
    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/EHCacheReplayCacheFactory.java
    webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/MemoryReplayCache.java
      - copied, changed from r1463709, webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/cache/MemoryReplayCache.java
    webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/MemoryReplayCacheFactory.java
    webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/ReplayCache.java
      - copied, changed from r1463709, webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/cache/ReplayCache.java
    webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/ReplayCacheFactory.java
    webservices/wss4j/trunk/ws-security-common/src/main/resources/wss4j-ehcache.xml
Removed:
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/cache/MemoryReplayCache.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/cache/ReplayCache.java
Modified:
    webservices/wss4j/trunk/parent/pom.xml
    webservices/wss4j/trunk/ws-security-common/pom.xml
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/handler/RequestData.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/SignatureProcessor.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/UsernameTokenProcessor.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ReplayTest.java

Modified: webservices/wss4j/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/parent/pom.xml?rev=1464008&r1=1464007&r2=1464008&view=diff
==============================================================================
--- webservices/wss4j/trunk/parent/pom.xml (original)
+++ webservices/wss4j/trunk/parent/pom.xml Wed Apr  3 13:46:37 2013
@@ -36,6 +36,7 @@
     <url>http://ws.apache.org/wss4j/</url>
 
     <properties>
+        <ehcache.version>2.5.1</ehcache.version>
         <log4j.version>1.2.17</log4j.version>
         <neethi.version>3.0.2</neethi.version>
         <slf4j.version>1.7.5</slf4j.version>
@@ -134,6 +135,11 @@
                 <artifactId>xmlunit</artifactId>
                 <version>${xmlunit.version}</version>
             </dependency>
+            <dependency>
+                <groupId>net.sf.ehcache</groupId>
+                <artifactId>ehcache-core</artifactId>
+                <version>${ehcache.version}</version>
+            </dependency>
         </dependencies>
     </dependencyManagement>
 

Modified: webservices/wss4j/trunk/ws-security-common/pom.xml
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/pom.xml?rev=1464008&r1=1464007&r2=1464008&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/pom.xml (original)
+++ webservices/wss4j/trunk/ws-security-common/pom.xml Wed Apr  3 13:46:37 2013
@@ -274,6 +274,11 @@
             </exclusions>
         </dependency>
         <dependency>
+            <groupId>net.sf.ehcache</groupId>
+            <artifactId>ehcache-core</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <scope>test</scope>

Added: 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=1464008&view=auto
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/EHCacheManagerHolder.java
(added)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/EHCacheManagerHolder.java
Wed Apr  3 13:46:37 2013
@@ -0,0 +1,140 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.cache;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import net.sf.ehcache.CacheManager;
+import net.sf.ehcache.config.CacheConfiguration;
+import net.sf.ehcache.config.Configuration;
+import net.sf.ehcache.config.ConfigurationFactory;
+
+import org.apache.wss4j.common.util.Loader;
+
+/**
+ * We need to reference count the EHCacheManager things
+ */
+public final class EHCacheManagerHolder {
+    private static final org.slf4j.Logger LOG = 
+        org.slf4j.LoggerFactory.getLogger(EHCacheManagerHolder.class);
+    private static final ConcurrentHashMap<String, AtomicInteger> COUNTS 
+        = new ConcurrentHashMap<String, AtomicInteger>(8, 0.75f, 2);
+    
+    private EHCacheManagerHolder() {
+        //utility
+    }
+    
+    
+    public static CacheConfiguration getCacheConfiguration(String key,
+                                                           CacheManager cacheManager) {
+        CacheConfiguration cc = cacheManager.getConfiguration().getCacheConfigurations().get(key);
+        if (cc == null && key.contains("-")) {
+            cc = cacheManager.getConfiguration().getCacheConfigurations().get(
+                    key.substring(0, key.lastIndexOf('-') - 1));
+        }
+        if (cc == null) {
+            cc = cacheManager.getConfiguration().getDefaultCacheConfiguration();
+        }
+        if (cc == null) {
+            cc = new CacheConfiguration();
+        } else {
+            cc = (CacheConfiguration)cc.clone();
+        }
+        cc.setName(key);
+        return cc;
+    }
+    
+    public static CacheManager getCacheManager(URL configFileURL) {
+        CacheManager cacheManager = null;
+        if (configFileURL == null) {
+            //using the default
+            cacheManager = findDefaultCacheManager();
+        }
+        if (cacheManager == null) {
+            if (configFileURL == null) {
+                cacheManager = CacheManager.create();
+            } else {
+                cacheManager = CacheManager.create(configFileURL);
+            }
+        }
+        AtomicInteger a = COUNTS.get(cacheManager.getName());
+        if (a == null) {
+            COUNTS.putIfAbsent(cacheManager.getName(), new AtomicInteger());
+            a = COUNTS.get(cacheManager.getName());
+        }
+        a.incrementAndGet();
+        // if (a.incrementAndGet() == 1) {
+            //System.out.println("Create!! " + cacheManager.getName());
+        // }
+        return cacheManager;
+    }
+    
+    private static CacheManager findDefaultCacheManager() {
+
+        String defaultConfigFile = "wss4j-ehcache.xml";
+        URL configFileURL = null;
+        String busId = "";
+        try {
+            configFileURL = Loader.getResource(defaultConfigFile);
+            if (configFileURL == null) {
+                configFileURL = new URL(defaultConfigFile);
+            }
+        } catch (IOException e) {
+            // Do nothing
+            LOG.debug(e.getMessage());
+        }
+        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);
+            if ("java.io.tmpdir".equals(conf.getDiskStoreConfiguration().getOriginalPath()))
{
+                String path = conf.getDiskStoreConfiguration().getPath() + File.separator
+                    + busId;
+                conf.getDiskStoreConfiguration().setPath(path);
+            }
+            return CacheManager.create(conf);
+        } catch (Throwable t) {
+            return null;
+        }
+    }
+
+
+    public static void releaseCacheManger(CacheManager cacheManager) {
+        AtomicInteger a = COUNTS.get(cacheManager.getName());
+        if (a == null) {
+            return;
+        }
+        if (a.decrementAndGet() == 0) {
+            //System.out.println("Shutdown!! " + cacheManager.getName());
+            cacheManager.shutdown();
+        }
+    }
+    
+}

Added: 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=1464008&view=auto
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/EHCacheReplayCache.java
(added)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/EHCacheReplayCache.java
Wed Apr  3 13:46:37 2013
@@ -0,0 +1,132 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.cache;
+
+import java.io.Closeable;
+import java.net.URL;
+
+import net.sf.ehcache.Cache;
+import net.sf.ehcache.CacheManager;
+import net.sf.ehcache.Ehcache;
+import net.sf.ehcache.Element;
+import net.sf.ehcache.config.CacheConfiguration;
+
+/**
+ * An in-memory EHCache implementation of the ReplayCache interface. The default TTL is 60
minutes and the
+ * max TTL is 12 hours.
+ */
+public class EHCacheReplayCache implements ReplayCache, Closeable {
+    
+    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;
+    
+    public EHCacheReplayCache(String key, URL configFileURL) {
+        cacheManager = EHCacheManagerHolder.getCacheManager(configFileURL);
+        CacheConfiguration cc = EHCacheManagerHolder.getCacheConfiguration(key, cacheManager);
+
+        Ehcache newCache = new Cache(cc);
+        cache = cacheManager.addCacheIfAbsent(newCache);
+    }
+    
+    /**
+     * Set a new (default) TTL value in seconds
+     * @param newTtl a new (default) TTL value in seconds
+     */
+    public void setTTL(long newTtl) {
+        ttl = newTtl;
+    }
+    
+    /**
+     * Get the (default) TTL value in seconds
+     * @return the (default) TTL value in seconds
+     */
+    public long getTTL() {
+        return ttl;
+    }
+    
+    /**
+     * Add the given identifier to the cache. It will be cached for a default amount of time.
+     * @param identifier The identifier to be added
+     */
+    public void add(String identifier) {
+        add(identifier, ttl);
+    }
+    
+    /**
+     * Add the given identifier to the cache to be cached for the given time
+     * @param identifier The identifier to be added
+     * @param timeToLive The length of time to cache the Identifier in seconds
+     */
+    public void add(String identifier, long timeToLive) {
+        if (identifier == null || "".equals(identifier)) {
+            return;
+        }
+        
+        int parsedTTL = (int)timeToLive;
+        if (timeToLive != (long)parsedTTL || parsedTTL < 0 || parsedTTL > MAX_TTL)
{
+            // Default to configured value
+            parsedTTL = (int)ttl;
+            if (ttl != (long)parsedTTL) {
+                // Fall back to 60 minutes if the default TTL is set incorrectly
+                parsedTTL = 3600;
+            }
+        }
+        
+        cache.put(new Element(identifier, identifier, false, parsedTTL, parsedTTL));
+    }
+    
+    /**
+     * Return true if the given identifier is contained in the cache
+     * @param identifier The identifier to check
+     */
+    public boolean contains(String identifier) {
+        Element element = cache.get(identifier);
+        if (element != null) {
+            if (cache.isExpired(element)) {
+                cache.remove(identifier);
+                return false;
+            }
+            return true;
+        }
+        return false;
+    }
+
+    public synchronized void close() {
+        if (cacheManager != null) {
+            EHCacheManagerHolder.releaseCacheManger(cacheManager);
+            cacheManager = null;
+            cache = null;
+        }
+        
+    }
+
+    public void initComplete() {
+    }
+    public void preShutdown() {
+        close();
+    }
+    public void postShutdown() {
+        close();
+    }
+    
+}

Added: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/EHCacheReplayCacheFactory.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/EHCacheReplayCacheFactory.java?rev=1464008&view=auto
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/EHCacheReplayCacheFactory.java
(added)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/EHCacheReplayCacheFactory.java
Wed Apr  3 13:46:37 2013
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.cache;
+
+import java.net.URL;
+
+/**
+ * A factory to return an EHCacheReplayCache instance.
+ */
+public class EHCacheReplayCacheFactory extends ReplayCacheFactory {
+    
+    public ReplayCache newReplayCache(String key, Object configuration) {
+        URL configFileURL = getConfigFileURL(configuration);
+        return new EHCacheReplayCache(key, configFileURL);
+    }
+    
+}

Copied: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/MemoryReplayCache.java
(from r1463709, webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/cache/MemoryReplayCache.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/MemoryReplayCache.java?p2=webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/MemoryReplayCache.java&p1=webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/cache/MemoryReplayCache.java&r1=1463709&r2=1464008&rev=1464008&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/cache/MemoryReplayCache.java
(original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/MemoryReplayCache.java
Wed Apr  3 13:46:37 2013
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.wss4j.dom.cache;
+package org.apache.wss4j.common.cache;
 
 import java.util.ArrayList;
 import java.util.Collections;

Added: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/MemoryReplayCacheFactory.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/MemoryReplayCacheFactory.java?rev=1464008&view=auto
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/MemoryReplayCacheFactory.java
(added)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/MemoryReplayCacheFactory.java
Wed Apr  3 13:46:37 2013
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.cache;
+
+
+/**
+ * A factory to return a MemoryReplayCache instance.
+ */
+public class MemoryReplayCacheFactory extends ReplayCacheFactory {
+    
+    public ReplayCache newReplayCache(String key, Object configuration) {
+        return new MemoryReplayCache();
+    }
+    
+}

Copied: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/ReplayCache.java
(from r1463709, webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/cache/ReplayCache.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/ReplayCache.java?p2=webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/ReplayCache.java&p1=webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/cache/ReplayCache.java&r1=1463709&r2=1464008&rev=1464008&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/cache/ReplayCache.java
(original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/ReplayCache.java
Wed Apr  3 13:46:37 2013
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.wss4j.dom.cache;
+package org.apache.wss4j.common.cache;
 
 
 /**

Added: 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=1464008&view=auto
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/ReplayCacheFactory.java
(added)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/ReplayCacheFactory.java
Wed Apr  3 13:46:37 2013
@@ -0,0 +1,82 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.cache;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.apache.wss4j.common.util.Loader;
+
+/**
+ * An abstract factory to return a ReplayCache instance. It returns an EHCacheReplayCacheFactory
+ * if EH-Cache is available. Otherwise it returns a MemoryReplayCacheFactory.
+ */
+public abstract class ReplayCacheFactory {
+    
+    private static final org.slf4j.Logger LOG = 
+        org.slf4j.LoggerFactory.getLogger(ReplayCacheFactory.class);
+    private static boolean ehCacheInstalled;
+    
+    static {
+        try {
+            Class<?> cacheManagerClass = 
+                Loader.loadClass("net.sf.ehcache.CacheManager");
+            if (cacheManagerClass != null) {
+                ehCacheInstalled = true;
+            }
+        } catch (Exception e) {
+            //ignore
+            LOG.debug(e.getMessage());
+        }
+    }
+    
+    protected static synchronized boolean isEhCacheInstalled() {
+        return ehCacheInstalled;
+    }
+    
+    public static ReplayCacheFactory newInstance() {
+        if (isEhCacheInstalled()) {
+            return new EHCacheReplayCacheFactory();
+        }
+        
+        return new MemoryReplayCacheFactory();
+    }
+    
+    public abstract ReplayCache newReplayCache(String key, Object configuration);
+    
+    protected URL getConfigFileURL(Object o) {
+        if (o instanceof String) {
+            try {
+                URL url = Loader.getResource((String)o);
+                if (url == null) {
+                    url = new URL((String)o);
+                }
+                return url;
+            } catch (IOException e) {
+                // Do nothing
+                LOG.debug(e.getMessage());
+            }
+        } else if (o instanceof URL) {
+            return (URL)o;        
+        }
+        return null;
+    }
+    
+}

Added: webservices/wss4j/trunk/ws-security-common/src/main/resources/wss4j-ehcache.xml
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/resources/wss4j-ehcache.xml?rev=1464008&view=auto
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/resources/wss4j-ehcache.xml (added)
+++ webservices/wss4j/trunk/ws-security-common/src/main/resources/wss4j-ehcache.xml Wed Apr
 3 13:46:37 2013
@@ -0,0 +1,17 @@
+<ehcache xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="false" monitoring="autodetect"
dynamicConfig="true">
+
+    <diskStore path="java.io.tmpdir"/>
+
+    <defaultCache
+            maxEntriesLocalHeap="5000"
+            eternal="false"
+            timeToIdleSeconds="3600"
+            timeToLiveSeconds="3600"
+            overflowToDisk="true"
+            maxElementsOnDisk="10000000"
+            diskPersistent="false"
+            diskExpiryThreadIntervalSeconds="120"
+            memoryStoreEvictionPolicy="LRU"
+            />
+            
+</ehcache>

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=1464008&r1=1464007&r2=1464008&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
Wed Apr  3 13:46:37 2013
@@ -35,8 +35,8 @@ import org.apache.wss4j.dom.WSConstants;
 import org.apache.wss4j.dom.WSEncryptionPart;
 import org.apache.wss4j.dom.WSSConfig;
 import org.apache.wss4j.dom.bsp.BSPEnforcer;
-import org.apache.wss4j.dom.cache.ReplayCache;
 import org.apache.wss4j.common.bsp.BSPRule;
+import org.apache.wss4j.common.cache.ReplayCache;
 import org.apache.wss4j.common.crypto.AlgorithmSuite;
 import org.apache.wss4j.common.crypto.Crypto;
 import org.apache.wss4j.common.ext.WSSecurityException;

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/SignatureProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/SignatureProcessor.java?rev=1464008&r1=1464007&r2=1464008&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/SignatureProcessor.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/SignatureProcessor.java
Wed Apr  3 13:46:37 2013
@@ -59,6 +59,7 @@ import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
 import org.apache.wss4j.common.bsp.BSPRule;
+import org.apache.wss4j.common.cache.ReplayCache;
 import org.apache.wss4j.common.crypto.AlgorithmSuite;
 import org.apache.wss4j.common.crypto.AlgorithmSuiteValidator;
 import org.apache.wss4j.common.crypto.Crypto;
@@ -71,7 +72,6 @@ import org.apache.wss4j.dom.WSDocInfo;
 import org.apache.wss4j.dom.WSSecurityEngine;
 import org.apache.wss4j.dom.WSSecurityEngineResult;
 import org.apache.wss4j.dom.bsp.BSPEnforcer;
-import org.apache.wss4j.dom.cache.ReplayCache;
 import org.apache.wss4j.dom.handler.RequestData;
 import org.apache.wss4j.dom.message.CallbackLookup;
 import org.apache.wss4j.dom.message.DOMCallbackLookup;

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/UsernameTokenProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/UsernameTokenProcessor.java?rev=1464008&r1=1464007&r2=1464008&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/UsernameTokenProcessor.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/UsernameTokenProcessor.java
Wed Apr  3 13:46:37 2013
@@ -27,13 +27,13 @@ import org.apache.wss4j.common.principal
 import org.apache.wss4j.common.principal.WSUsernameTokenPrincipalImpl;
 import org.w3c.dom.Element;
 
+import org.apache.wss4j.common.cache.ReplayCache;
 import org.apache.wss4j.common.ext.WSSecurityException;
 import org.apache.wss4j.dom.WSConstants;
 import org.apache.wss4j.dom.WSDocInfo;
 import org.apache.wss4j.dom.WSSConfig;
 import org.apache.wss4j.dom.WSSecurityEngine;
 import org.apache.wss4j.dom.WSSecurityEngineResult;
-import org.apache.wss4j.dom.cache.ReplayCache;
 import org.apache.wss4j.dom.handler.RequestData;
 import org.apache.wss4j.dom.message.token.UsernameToken;
 import org.apache.wss4j.dom.validate.Credential;

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ReplayTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ReplayTest.java?rev=1464008&r1=1464007&r2=1464008&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ReplayTest.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ReplayTest.java
Wed Apr  3 13:46:37 2013
@@ -29,10 +29,10 @@ import org.apache.wss4j.dom.WSEncryption
 import org.apache.wss4j.dom.WSSConfig;
 import org.apache.wss4j.dom.WSSecurityEngine;
 import org.apache.wss4j.dom.WSSecurityEngineResult;
-import org.apache.wss4j.dom.cache.MemoryReplayCache;
 import org.apache.wss4j.dom.common.KeystoreCallbackHandler;
 import org.apache.wss4j.dom.common.SOAPUtil;
 import org.apache.wss4j.dom.common.UsernamePasswordCallbackHandler;
+import org.apache.wss4j.common.cache.MemoryReplayCache;
 import org.apache.wss4j.common.crypto.Crypto;
 import org.apache.wss4j.common.crypto.CryptoFactory;
 import org.apache.wss4j.common.ext.WSSecurityException;



Mime
View raw message