[java-opensaml COMMIT] in /trunk/opensaml-saml-impl/src: main/java/org/opensaml/saml/metadata/resolver/impl/FileBacke...
noreply at shibboleth.net
noreply at shibboleth.net
Fri Apr 1 20:57:36 EDT 2016
Author: putmanb
Date: Fri Apr 1 20:57:36 2016
New Revision: 4443
URL: http://svn.shibboleth.net/view/java-opensaml?rev=4443&view=rev
Log:
OSJ-161: Investigate initing FileBackedHTTPMetadataResolver from backing file before refreshing from HTTP
Modified:
trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/FileBackedHTTPMetadataResolver.java
trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/FileBackedHTTPMetadataResolverTest.java
Modified: trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/FileBackedHTTPMetadataResolver.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/FileBackedHTTPMetadataResolver.java?rev=4443&r1=4442&r2=4443&view=diff
==============================================================================
--- trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/FileBackedHTTPMetadataResolver.java (original)
+++ trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/FileBackedHTTPMetadataResolver.java Fri Apr 1 20:57:36 2016
@@ -25,11 +25,14 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import net.shibboleth.utilities.java.support.annotation.Duration;
+import net.shibboleth.utilities.java.support.annotation.constraint.Positive;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.resolver.ResolverException;
import org.apache.http.client.HttpClient;
+import org.joda.time.DateTime;
import org.opensaml.core.xml.XMLObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -53,6 +56,18 @@
/** File containing the backup of the metadata. */
@Nullable private File metadataBackupFile;
+ /** Flag used to track state of whether currently initializing or not. */
+ private boolean initializing;
+
+ /** Flag indicating whether initialization should first attempt to load metadata from backup file. */
+ private boolean initializeFromBackupFile = true;
+
+ /** Flag indicating whether metadata load during init was from backup file. */
+ private boolean initializedFromBackupFile;
+
+ /** Duration in milliseconds after which to schedule next refresh, when initialized from backup file. */
+ @Duration @Positive private long backupFileInitNextRefreshDelay = 5000;
+
/**
* Constructor.
*
@@ -85,6 +100,66 @@
setBackupFile(backupFilePath);
}
+ /**
+ * Get the flag indicating whether metadata load during initialization was from backup file.
+ *
+ * @return true if initial load was from backup file, false otherwise
+ */
+ public boolean isInitializedFromBackupFile() {
+ return initializedFromBackupFile;
+ }
+
+ /**
+ * Get the flag indicating whether initialization should first attempt to load metadata from backup file,
+ * if it exists.
+ *
+ * @return true if should initialize from backup file, false otherwise
+ */
+ public boolean isInitializeFromBackupFile() {
+ return initializeFromBackupFile;
+ }
+
+ /**
+ * Set the flag indicating whether initialization should first attempt to load metadata from backup file,
+ * if it exists.
+ *
+ * @param flag true if should initialize from backup file, false otherwise
+ */
+ public void setInitializeFromBackupFile(boolean flag) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
+
+ initializeFromBackupFile = flag;
+ }
+
+ /**
+ * Get the duration in milliseconds after which to schedule next refresh, when initialized from backup file.
+ *
+ * <p>Defaults to 5000ms.</p>
+ *
+ * @return the duration in milliseconds
+ */
+ public long getBackupFileInitNextRefreshDelay() {
+ return backupFileInitNextRefreshDelay;
+ }
+
+ /**
+ * Set the duration in milliseconds after which to schedule next refresh, when initialized from backup file.
+ *
+ * <p>Defaults to 5000ms.</p>
+ *
+ * @param delay the next refresh delay, in milliseconds
+ */
+ public void setBackupFileInitNextRefreshDelay(long delay) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
+
+ if (delay < 0) {
+ throw new IllegalArgumentException("Backup file init next refresh delay must be greater than 0");
+ }
+ backupFileInitNextRefreshDelay = delay;
+ }
+
/** {@inheritDoc} */
protected void doDestroy() {
metadataBackupFile = null;
@@ -105,7 +180,12 @@
}
}
- super.initMetadataResolver();
+ try {
[... 209 lines stripped ...]
More information about the commits
mailing list