[java-opensaml] branch master updated: IDP-1286: Support expirationWarningThreshold in dynamic resolvers
Brent Putman
putmanb at georgetown.edu
Mon Oct 1 19:51:38 EDT 2018
This is an automated email from the git hooks/post-receive script.
putmanb pushed a commit to branch master
in repository java-opensaml.
View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=aad528cf1f7273fe90de7d013962e3d7fcb3f747
The following commit(s) were added to refs/heads/master by this push:
new aad528c IDP-1286: Support expirationWarningThreshold in dynamic resolvers
aad528c is described below
commit aad528cf1f7273fe90de7d013962e3d7fcb3f747
Author: Brent Putman <putmanb at georgetown.edu>
AuthorDate: Mon Oct 1 19:42:37 2018 -0400
IDP-1286: Support expirationWarningThreshold in dynamic resolvers
---
.../impl/AbstractDynamicMetadataResolver.java | 64 ++++++++++++++++++++++
1 file changed, 64 insertions(+)
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java
index 5814ac0..43492e5 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java
@@ -156,6 +156,10 @@ public abstract class AbstractDynamicMetadataResolver extends AbstractMetadataRe
/** Flag indicating whether idle entity data should be removed. */
private boolean removeIdleEntityData;
+ /** Impending expiration warning threshold for metadata refresh, in milliseconds.
+ * Default value: 0ms (disabled). */
+ @Duration @Positive private Long expirationWarningThreshold;
+
/** The interval in milliseconds at which the cleanup task should run. */
@Duration @Positive private Long cleanupTaskInterval;
@@ -204,6 +208,9 @@ public abstract class AbstractDynamicMetadataResolver extends AbstractMetadataRe
taskTimer = backgroundTaskTimer;
}
+ // Default to 0ms
+ expirationWarningThreshold = 0L;
+
// Default to 10 minutes.
minCacheDuration = 10*60*1000L;
@@ -500,6 +507,33 @@ public abstract class AbstractDynamicMetadataResolver extends AbstractMetadataRe
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
maxIdleEntityData = Constraint.isNotNull(max, "Max idle entity data may not be null");
}
+
+ /**
+ * Gets the impending expiration warning threshold used at refresh time.
+ *
+ * @return threshold for logging a warning if live metadata will soon expire
+ */
+ @Duration @Nonnull public Long getExpirationWarningThreshold() {
+ return expirationWarningThreshold;
+ }
+
+ /**
+ * Sets the impending expiration warning threshold used at refresh time.
+ *
+ * @param threshold the threshold for logging a warning if live metadata will soon expire
+ */
+ @Duration public void setExpirationWarningThreshold(@Nullable @Duration @Positive final Long threshold) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
+
+ if (threshold == null) {
+ expirationWarningThreshold = 0L;
+ }
+ if (threshold < 0) {
+ throw new IllegalArgumentException("Expiration warning threshold must be greater than or equal to 0");
+ }
+ expirationWarningThreshold = threshold;
+ }
/**
* Get the interval in milliseconds at which the cleanup task should run.
@@ -1139,6 +1173,36 @@ public abstract class AbstractDynamicMetadataResolver extends AbstractMetadataRe
mgmtData.setRefreshTriggerTime(computeRefreshTriggerTime(mgmtData.getExpirationTime(), now));
log.debug("{} Computed refresh trigger time: {}", getLogPrefix(), mgmtData.getRefreshTriggerTime());
+
+ logMetadataExpiration(entityDescriptor, now, mgmtData.getRefreshTriggerTime());
+ }
+
+ /**
+ * Check metadata for expiration or pending expiration and log appropriately.
+ *
+ * @param descriptor the entity descriptor being processes
+ * @param now the current date/time
+ * @param nextRefresh the next refresh trigger time for the entity descriptor
+ */
+ private void logMetadataExpiration(@Nonnull final EntityDescriptor descriptor,
+ @Nonnull final DateTime now, @Nonnull final DateTime nextRefresh) {
+ if (!isValid(descriptor)) {
+ log.warn("{} Metadata with ID '{}' currently live is expired or otherwise invalid",
+ getLogPrefix(), descriptor.getEntityID());
+ } else {
+ if (isRequireValidMetadata() && descriptor.getValidUntil() != null) {
+ if (getExpirationWarningThreshold() > 0
+ && descriptor.getValidUntil().isBefore(now.plus(getExpirationWarningThreshold()))) {
+ log.warn("{} Metadata with ID '{}' currently live will expire "
+ + "within the configured threshhold at '{}'",
+ getLogPrefix(), descriptor.getEntityID(), descriptor.getValidUntil());
+ } else if (descriptor.getValidUntil().isBefore(nextRefresh)) {
+ log.warn("{} Metadata with ID '{}' currently live will expire "
+ + "at '{}' before the next refresh scheduled for {}'",
+ getLogPrefix(), descriptor.getEntityID(), descriptor.getValidUntil(), nextRefresh);
+ }
+ }
+ }
}
/**
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list