[java-identity-provider COMMIT] in /trunk: idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/r...

noreply at shibboleth.net noreply at shibboleth.net
Thu Jan 5 11:56:09 EST 2017


Author: rdw
Date: Thu Jan  5 11:56:09 2017
New Revision: 8594

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=8594&view=rev
Log:
IDP-1093 New attributes to control TTL policy

https://issues.shibboleth.net/jira/browse/IDP-1093

expireAfterWrite="Duration" or expireAfterAccess="Duration"

Added:
    trunk/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/ResultCacheExpireAfterAccess.xml   (with props)
    trunk/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/ResultCacheExpireAfterWrite.xml   (with props)
    trunk/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/ResultCacheExpireBoth.xml   (with props)
Modified:
    trunk/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/dc/impl/CacheConfigParser.java
    trunk/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/dc/CacheConfigParserTest.java
    trunk/idp-schema/src/main/resources/schema/shibboleth-attribute-resolver.xsd

Modified: trunk/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/dc/impl/CacheConfigParser.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/dc/impl/CacheConfigParser.java?rev=8594&r1=8593&r2=8594&view=diff
==============================================================================
--- trunk/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/dc/impl/CacheConfigParser.java	(original)
+++ trunk/idp-attribute-resolver-spring/src/main/java/net/shibboleth/idp/attribute/resolver/spring/dc/impl/CacheConfigParser.java	Thu Jan  5 11:56:09 2017
@@ -60,6 +60,14 @@
     /** ResultCacheBean name - resolver:. */
     @Nonnull public static final QName RESULT_CACHE_BEAN_RESOLVER =
             new QName(AttributeResolverNamespaceHandler.NAMESPACE, "ResultCacheBean");
+
+    /** Documented maximumCachedElements maximum (500).  Unfortunately it has to be here since
+     * we do not own the implemented class */
+    private static final long DEFAULT_CACHE_ENTRIES = 500;
+
+    /** Documented cache lifetime (4 hours).  Unfortunately it has to be here since
+     * we do not own the implemented class */
+    private static final long DEFAULT_TTL_MS = 4 * 60 * 60 * 1000;
     
     /** Class logger. */
     @Nonnull private final Logger log = LoggerFactory.getLogger(CacheConfigParser.class);
@@ -101,29 +109,98 @@
         }
         
         final Element cacheElement = cacheElements.get(0);
-        
-        final BeanDefinitionBuilder cache =
-                BeanDefinitionBuilder.rootBeanDefinition(CacheConfigParser.class, "buildCache");
-        cache.addConstructorArgValue(AttributeSupport.getAttributeValue(cacheElement, new QName("elementTimeToLive")));
+        final String elementTimeToLive = AttributeSupport.getAttributeValue(cacheElement, new QName("elementTimeToLive"));
+        if (null != elementTimeToLive) {
+            log.warn("ResultCache: Attribute 'elementTimeToLive' is deprecated, consider using 'expireAfterAccess'");
+        }
+        final String expireAfterWrite = AttributeSupport.getAttributeValue(cacheElement, new QName("expireAfterWrite"));
+        final String expireAfterAccess = AttributeSupport.getAttributeValue(cacheElement, new QName("expireAfterAccess"));
+
+        if (null != expireAfterAccess && null != expireAfterWrite) {
+            log.warn("ResultCache:  Attribute 'expireAfterAccess' is mututally exclusive with 'expireAfterWrite'");
+        }
+        
+        final BeanDefinitionBuilder cache;
+        if (expireAfterAccess != null) {
+            cache = BeanDefinitionBuilder.rootBeanDefinition(CacheConfigParser.class, "buildCacheAccess");            
+            cache.addConstructorArgValue(expireAfterAccess);
+        } else if (elementTimeToLive != null) {
+            cache = BeanDefinitionBuilder.rootBeanDefinition(CacheConfigParser.class, "buildCacheAccess");            
+            cache.addConstructorArgValue(elementTimeToLive);
+        } else if (expireAfterWrite != null) {
+            cache = BeanDefinitionBuilder.rootBeanDefinition(CacheConfigParser.class, "buildCacheWrite");            
+            cache.addConstructorArgValue(expireAfterWrite);            
+        } else {
+            cache = BeanDefinitionBuilder.rootBeanDefinition(CacheConfigParser.class, "buildCacheWrite");            
+            cache.addConstructorArgValue(null);                        
+        }
         cache.addConstructorArgValue(
                 AttributeSupport.getAttributeValue(cacheElement, new QName("maximumCachedElements")));
         return cache.getBeanDefinition();
     }
-
+    
+    /** Helper function to return size provided with a suitable default/
+     * @param maximumSize long string
+     * @return the input as a long, or DEFAULT_CACHE_ENTRIES
+     */

[... 171 lines stripped ...]


More information about the commits mailing list