[java-opensaml] 21/24: OSJ-200: Improve logging around expired metadata refresh attempts

Brent Putman putmanb at georgetown.edu
Wed Sep 27 16:46:15 EDT 2017


This is an automated email from the git hooks/post-receive script.

putmanb pushed a commit to branch maint-3.3
in repository java-opensaml.

View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=beb6f5a13b142c547e8d8c80620b6fccecc9f5d4

commit beb6f5a13b142c547e8d8c80620b6fccecc9f5d4
Author: Brent Putman <putmanb at georgetown.edu>
AuthorDate: Fri Sep 22 19:24:01 2017 -0400

    OSJ-200: Improve logging around expired metadata refresh attempts
    
    Add WARN logging if post-refresh cached metadata will expire
    before the next scheduled refresh.
    
    This is a partial port of c04827b6a4e2c6000ce7941cde46adf0b6a53420
    and f7bf1a8f5961fb0e09034bf8f1ab94739784a079, which excludes the
    new expiration warning threshold configuration parameter.
---
 .../impl/AbstractReloadingMetadataResolver.java    | 29 ++++++++++++++++++----
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractReloadingMetadataResolver.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractReloadingMetadataResolver.java
index 2f98ebb..b9fc43d 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractReloadingMetadataResolver.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractReloadingMetadataResolver.java
@@ -40,6 +40,7 @@ import org.opensaml.core.xml.io.UnmarshallingException;
 import org.opensaml.saml.metadata.resolver.RefreshableMetadataResolver;
 import org.opensaml.saml.metadata.resolver.filter.FilterException;
 import org.opensaml.saml.saml2.common.SAML2Support;
+import org.opensaml.saml.saml2.common.TimeBoundSAMLObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
@@ -315,11 +316,8 @@ public abstract class AbstractReloadingMetadataResolver extends AbstractBatchMet
                         t.getClass().getName(), t.getMessage()));
             }
         } finally {
-            final XMLObject cached = getBackingStore().getCachedOriginalMetadata();
-            if (cached != null && !isValid(cached)) {
-                log.warn("{} Metadata root from '{}' currently live (post-refresh) is expired or otherwise invalid", 
-                        getLogPrefix(), mdId);
-            }
+            logCachedMetadataExpiration();
+            
             refreshMetadataTask = new RefreshMetadataTask();
             final long nextRefreshDelay = nextRefresh.getMillis() - System.currentTimeMillis();
             taskTimer.schedule(refreshMetadataTask, nextRefreshDelay);
@@ -331,6 +329,27 @@ public abstract class AbstractReloadingMetadataResolver extends AbstractBatchMet
     }
 
     /**
+     * Check cached metadata for expiration or pending expiration and log appropriately.
+     */
+    private void logCachedMetadataExpiration() {
+        final String mdId = getMetadataIdentifier();
+        final XMLObject cached = getBackingStore().getCachedOriginalMetadata();
+        if (cached != null && !isValid(cached)) {
+            log.warn("{} Metadata root from '{}' currently live (post-refresh) is expired or otherwise invalid", 
+                    getLogPrefix(), mdId);
+        } else if (cached instanceof TimeBoundSAMLObject) {
+            final TimeBoundSAMLObject timebound = (TimeBoundSAMLObject) cached;
+            if (isRequireValidMetadata() && timebound.getValidUntil()  != null) {
+                if (timebound.getValidUntil().isBefore(nextRefresh)) {
+                    log.warn("{} Metadata root from '{}' currently live (post-refresh) will expire " 
+                            + "at '{}' before the next refresh scheduled for {}'", 
+                            getLogPrefix(), mdId, timebound.getValidUntil(), nextRefresh);
+                }
+            }
+        }
+    }
+
+    /**
      * Gets an identifier which may be used to distinguish this metadata in logging statements.
      * 
      * @return identifier which may be used to distinguish this metadata in logging statements

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list