[java-identity-provider] branch master updated: OSJ-234: Reset next dynamic metadata refresh when entity is unchanged
Brent Putman
putmanb at georgetown.edu
Fri Aug 3 14:35:06 EDT 2018
This is an automated email from the git hooks/post-receive script.
putmanb pushed a commit to branch master
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=c9ba86335f66996c2956d3bae3abf3a0835ded34
The following commit(s) were added to refs/heads/master by this push:
new c9ba863 OSJ-234: Reset next dynamic metadata refresh when entity is unchanged
c9ba863 is described below
commit c9ba86335f66996c2956d3bae3abf3a0835ded34
Author: Brent Putman <putmanb at georgetown.edu>
AuthorDate: Fri Aug 3 14:34:59 2018 -0400
OSJ-234: Reset next dynamic metadata refresh when entity is unchanged
Add dynamic metadata resolver parser support for new
'negativeLookupCacheDuration' param.
Update/fix unit tests.
---
.../impl/AbstractDynamicMetadataProviderParser.java | 5 +++++
.../metadata/DynamicHTTPMetadataProviderParserTest.java | 2 ++
.../metadata/LocalDynamicMetadataProviderParserTest.java | 16 ++++++++++++++++
.../spring/relyingparty/metadata/dynamicBasicParams.xml | 1 +
.../metadata/localDynamicWithManagerAndGenerator.xml | 1 +
.../metadata/localDynamicWithSourceDirectory.xml | 1 +
.../src/main/resources/schema/shibboleth-metadata.xsd | 9 +++++++++
7 files changed, 35 insertions(+)
diff --git a/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/impl/AbstractDynamicMetadataProviderParser.java b/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/impl/AbstractDynamicMetadataProviderParser.java
index d53641e..beb8703 100644
--- a/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/impl/AbstractDynamicMetadataProviderParser.java
+++ b/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/impl/AbstractDynamicMetadataProviderParser.java
@@ -71,6 +71,11 @@ public abstract class AbstractDynamicMetadataProviderParser extends AbstractMeta
StringSupport.trimOrNull(element.getAttributeNS(null, "maxCacheDuration")));
}
+ if (element.hasAttributeNS(null, "negativeLookupCacheDuration")) {
+ builder.addPropertyValue("negativeLookupCacheDuration",
+ StringSupport.trimOrNull(element.getAttributeNS(null, "negativeLookupCacheDuration")));
+ }
+
if (element.hasAttributeNS(null, "maxIdleEntityData")) {
builder.addPropertyValue("maxIdleEntityData",
StringSupport.trimOrNull(element.getAttributeNS(null, "maxIdleEntityData")));
diff --git a/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/DynamicHTTPMetadataProviderParserTest.java b/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/DynamicHTTPMetadataProviderParserTest.java
index 21dfebb..3f8ddc5 100644
--- a/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/DynamicHTTPMetadataProviderParserTest.java
+++ b/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/DynamicHTTPMetadataProviderParserTest.java
@@ -60,6 +60,7 @@ public class DynamicHTTPMetadataProviderParserTest extends AbstractMetadataParse
Assert.assertNull(resolver.getMetadataFilter());
Assert.assertNotNull(resolver.getParserPool());
+ Assert.assertEquals(resolver.getNegativeLookupCacheDuration(), Long.valueOf(30*60*1000L));
Assert.assertEquals(resolver.getRefreshDelayFactor(), 0.75f);
Assert.assertEquals(resolver.getMinCacheDuration(), Long.valueOf(10*60*1000L));
Assert.assertEquals(resolver.getMaxCacheDuration(), Long.valueOf(8*60*60*1000L));
@@ -188,6 +189,7 @@ public class DynamicHTTPMetadataProviderParserTest extends AbstractMetadataParse
Assert.assertNull(resolver.getMetadataFilter());
Assert.assertNotNull(resolver.getParserPool());
+ Assert.assertEquals(resolver.getNegativeLookupCacheDuration(), Long.valueOf(5*60*1000L));
Assert.assertEquals(resolver.getRefreshDelayFactor(), 0.50f);
Assert.assertEquals(resolver.getMinCacheDuration(), Long.valueOf(5*60*1000L));
Assert.assertEquals(resolver.getMaxCacheDuration(), Long.valueOf(4*60*60*1000L));
diff --git a/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/LocalDynamicMetadataProviderParserTest.java b/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/LocalDynamicMetadataProviderParserTest.java
index f3546b5..69d7e59 100644
--- a/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/LocalDynamicMetadataProviderParserTest.java
+++ b/idp-profile-spring/src/test/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/LocalDynamicMetadataProviderParserTest.java
@@ -19,6 +19,7 @@ package net.shibboleth.idp.profile.spring.relyingparty.metadata;
import java.io.File;
import java.io.FileOutputStream;
+import java.util.concurrent.TimeUnit;
import org.opensaml.core.criterion.EntityIdCriterion;
import org.opensaml.core.xml.XMLObject;
@@ -34,6 +35,8 @@ import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import com.google.common.util.concurrent.Uninterruptibles;
+
import net.shibboleth.idp.saml.metadata.RelyingPartyMetadataProvider;
import net.shibboleth.utilities.java.support.codec.StringDigester;
import net.shibboleth.utilities.java.support.codec.StringDigester.OutputFormat;
@@ -72,6 +75,7 @@ public class LocalDynamicMetadataProviderParserTest extends AbstractMetadataPars
Assert.assertNull(resolver.getMetadataFilter());
Assert.assertNotNull(resolver.getParserPool());
+ Assert.assertEquals(resolver.getNegativeLookupCacheDuration(), Long.valueOf(30*60*1000L));
Assert.assertEquals(resolver.getRefreshDelayFactor(), 0.75f);
Assert.assertEquals(resolver.getMinCacheDuration(), Long.valueOf(10*60*1000L));
Assert.assertEquals(resolver.getMaxCacheDuration(), Long.valueOf(8*60*60*1000L));
@@ -117,6 +121,12 @@ public class LocalDynamicMetadataProviderParserTest extends AbstractMetadataPars
sourceManager.save(entityID, entity);
+ // Configured negative lookup cache should still be in effect
+ Assert.assertNull(resolver.resolveSingle(criteria));
+
+ // Sleep past the negative lookup cache expiration
+ Uninterruptibles.sleepUninterruptibly(resolver.getNegativeLookupCacheDuration(), TimeUnit.MILLISECONDS);
+
// In this case, will be the same instance since using in-memory map-based store.
Assert.assertSame(resolver.resolveSingle(criteria), entity);
}
@@ -151,6 +161,12 @@ public class LocalDynamicMetadataProviderParserTest extends AbstractMetadataPars
XMLObjectSupport.marshallToOutputStream(entity, new FileOutputStream(sourceFile));
Assert.assertTrue(sourceFile.exists());
+ // Configured negative lookup cache should still be in effect
+ Assert.assertNull(resolver.resolveSingle(criteria));
+
+ // Sleep past the negative lookup cache expiration
+ Uninterruptibles.sleepUninterruptibly(resolver.getNegativeLookupCacheDuration(), TimeUnit.MILLISECONDS);
+
EntityDescriptor resolved = resolver.resolveSingle(criteria);
Assert.assertNotNull(resolved);
Assert.assertEquals(resolved.getEntityID(), entityID);
diff --git a/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/dynamicBasicParams.xml b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/dynamicBasicParams.xml
index 133b6a7..448337b 100644
--- a/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/dynamicBasicParams.xml
+++ b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/dynamicBasicParams.xml
@@ -11,6 +11,7 @@
refreshDelayFactor="0.5"
minCacheDuration="PT5M"
maxCacheDuration="PT4H"
+ negativeLookupCacheDuration="PT5M"
maxIdleEntityData="PT2H"
removeIdleEntityData="false"
cleanupTaskInterval="PT20M"
diff --git a/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/localDynamicWithManagerAndGenerator.xml b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/localDynamicWithManagerAndGenerator.xml
index e026f32..ea459a2 100644
--- a/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/localDynamicWithManagerAndGenerator.xml
+++ b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/localDynamicWithManagerAndGenerator.xml
@@ -5,6 +5,7 @@
urn:oasis:names:tc:SAML:2.0:metadata http://docs.oasis-open.org/security/saml/v2.0/saml-schema-metadata-2.0.xsd"
id="localDynamicWithManagerAndGenerator" xsi:type="metadata:LocalDynamicMetadataProvider"
+ negativeLookupCacheDuration="PT1S"
sourceManagerRef="metadata.LocalDynamicSourceManager"
sourceKeyGeneratorRef="metadata.LocalDynamicSourceKeyGenerator"
>
diff --git a/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/localDynamicWithSourceDirectory.xml b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/localDynamicWithSourceDirectory.xml
index d694d42..25ee528 100644
--- a/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/localDynamicWithSourceDirectory.xml
+++ b/idp-profile-spring/src/test/resources/net/shibboleth/idp/profile/spring/relyingparty/metadata/localDynamicWithSourceDirectory.xml
@@ -5,6 +5,7 @@
urn:oasis:names:tc:SAML:2.0:metadata http://docs.oasis-open.org/security/saml/v2.0/saml-schema-metadata-2.0.xsd"
id="localDynamicWithSourceDirectory" xsi:type="metadata:LocalDynamicMetadataProvider"
+ negativeLookupCacheDuration="PT1S"
sourceDirectory="#{systemProperties['java.io.tmpdir']}/localDynamicMD"
>
diff --git a/idp-schema/src/main/resources/schema/shibboleth-metadata.xsd b/idp-schema/src/main/resources/schema/shibboleth-metadata.xsd
index 3d75fc1..07d7752 100644
--- a/idp-schema/src/main/resources/schema/shibboleth-metadata.xsd
+++ b/idp-schema/src/main/resources/schema/shibboleth-metadata.xsd
@@ -714,6 +714,15 @@
</documentation>
</annotation>
</attribute>
+ <attribute name="negativeLookupCacheDuration" type="string">
+ <annotation>
+ <documentation>
+ The duration for which a negative lookup result will be cached.
+ While the negative lookup cache for an entity's metadata is in effect, no additional lookups will be attempted.
+ This value is expressed in ISO8601 duration notation.
+ </documentation>
+ </annotation>
+ </attribute>
<attribute name="maxIdleEntityData" type="string">
<annotation>
<documentation>
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list