[java-opensaml COMMIT] /trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynam...
noreply at shibboleth.net
noreply at shibboleth.net
Wed Oct 29 15:41:19 EDT 2014
Author: putmanb
Date: Wed Oct 29 15:41:19 2014
New Revision: 4118
URL: http://svn.shibboleth.net/view/java-opensaml?rev=4118&view=rev
Log:
Compute and store expiration time for dynamic metadata.
Implement removal of expired metadata in cleanup sweeper task.
Modified:
trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java
Modified: trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java?rev=4118&r1=4117&r2=4118&view=diff
==============================================================================
--- trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java (original)
+++ trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java Wed Oct 29 15:41:19 2014
@@ -45,6 +45,7 @@
import org.opensaml.core.xml.XMLObject;
import org.opensaml.saml.metadata.resolver.DynamicMetadataResolver;
import org.opensaml.saml.metadata.resolver.filter.FilterException;
+import org.opensaml.saml.saml2.common.SAML2Support;
import org.opensaml.saml.saml2.metadata.EntityDescriptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -66,6 +67,12 @@
/** Whether we created our own task timer during object construction. */
private boolean createdOwnTaskTimer;
+ /** Minimum cache duration. */
+ private Long minCacheDuration;
+
+ /** Maximum cache duration. */
+ private Long maxCacheDuration;
+
/** The maximum idle time in milliseconds for which the resolver will keep data for a given entityID,
* before it is removed. */
private Long maxIdleEntityData;
@@ -94,6 +101,12 @@
taskTimer = backgroundTaskTimer;
}
+ // Default to 10 minutes.
+ minCacheDuration = 10*60*1000L;
+
+ // Default to 8 hours.
+ maxCacheDuration = 8*60*60*1000L;
+
// Default to 30 minutes.
cleanupTaskInterval = 30*60*1000L;
@@ -104,6 +117,54 @@
removeIdleEntityData = true;
}
+ /**
+ * Get the minimum cache duration for metadata.
+ *
+ * <p>Defaults to: 10 minutes.</p>
+ *
+ * @return the minimum cache duration, in milliseconds
+ */
+ @Nonnull public Long getMinCacheDuration() {
+ return minCacheDuration;
+ }
+
+ /**
+ * Set the minimum cache duration for metadata.
+ *
+ * <p>Defaults to: 10 minutes.</p>
+ *
+ * @param duration the minimum cache duration, in milliseconds
+ */
+ public void setMinCacheDuration(@Nonnull final Long duration) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
+ minCacheDuration = Constraint.isNotNull(duration, "Minimum cache duration may not be null");
+ }
+
+ /**
+ * Get the maximum cache duration for metadata.
+ *
+ * <p>Defaults to: 8 hours.</p>
+ *
+ * @return the maximum cache duration, in milliseconds
+ */
+ @Nonnull public Long getMaxCacheDuration() {
+ return maxCacheDuration;
+ }
+
+ /**
+ * Set the maximum cache duration for metadata.
+ *
+ * <p>Defaults to: 8 hours.</p>
+ *
+ * @param duration the maximum cache duration, in milliseconds
+ */
+ public void setMaxCacheDuration(@Nonnull final Long duration) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
+ maxCacheDuration = Constraint.isNotNull(duration, "Maximum cache duration may not be null");
+ }
+
/**
* Get the flag indicating whether idle entity data should be removed.
*
@@ -268,6 +329,36 @@
}
/** {@inheritDoc} */
+ protected void preProcessEntityDescriptor(@Nonnull EntityDescriptor entityDescriptor,
+ @Nonnull EntityBackingStore backingStore) {
+
+ super.preProcessEntityDescriptor(entityDescriptor, backingStore);
+
+ DynamicEntityBackingStore dynamicBackingStore = (DynamicEntityBackingStore) backingStore;
+ EntityManagementData mgmtData = dynamicBackingStore.getManagementData(entityDescriptor.getEntityID());
+ mgmtData.setExpirationTime(computeExpirationTime(entityDescriptor));
+ }
+
+ /**
+ * Compute the effective expiration time for the specified metadata.
+ *
+ * @param entityDescriptor the EntityDescriptor instance to evaluate
+ * @return the effective expiration time for the metadata
+ */
+ @Nonnull protected DateTime computeExpirationTime(@Nonnull final EntityDescriptor entityDescriptor) {
+ DateTime now = new DateTime(ISOChronology.getInstanceUTC());
[... 187 lines stripped ...]
More information about the commits
mailing list