diff options
author | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2020-04-08 16:23:51 +0200 |
---|---|---|
committer | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2020-04-08 16:23:51 +0200 |
commit | f220f54579f5975586b4dcd7634668815c208eda (patch) | |
tree | e57d292efc3b520f35e613285f2355bebb1d5e47 /eaaf_modules/eaaf_module_pvp2_core/src/main/java/at/gv/egiz/eaaf/modules/pvp2/impl/metadata | |
parent | bfaeb328b295a9508e351068b5061de4efb47645 (diff) | |
download | EAAF-Components-f220f54579f5975586b4dcd7634668815c208eda.tar.gz EAAF-Components-f220f54579f5975586b4dcd7634668815c208eda.tar.bz2 EAAF-Components-f220f54579f5975586b4dcd7634668815c208eda.zip |
refactor to OpenSAML 4.x
Diffstat (limited to 'eaaf_modules/eaaf_module_pvp2_core/src/main/java/at/gv/egiz/eaaf/modules/pvp2/impl/metadata')
3 files changed, 55 insertions, 36 deletions
diff --git a/eaaf_modules/eaaf_module_pvp2_core/src/main/java/at/gv/egiz/eaaf/modules/pvp2/impl/metadata/AbstractChainingMetadataProvider.java b/eaaf_modules/eaaf_module_pvp2_core/src/main/java/at/gv/egiz/eaaf/modules/pvp2/impl/metadata/AbstractChainingMetadataProvider.java index 40448b45..3a21b15d 100644 --- a/eaaf_modules/eaaf_module_pvp2_core/src/main/java/at/gv/egiz/eaaf/modules/pvp2/impl/metadata/AbstractChainingMetadataProvider.java +++ b/eaaf_modules/eaaf_module_pvp2_core/src/main/java/at/gv/egiz/eaaf/modules/pvp2/impl/metadata/AbstractChainingMetadataProvider.java @@ -21,6 +21,7 @@ package at.gv.egiz.eaaf.modules.pvp2.impl.metadata; import java.io.IOException; import java.security.cert.CertificateException; +import java.time.Instant; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -33,15 +34,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.naming.ConfigurationException; -import at.gv.egiz.components.spring.api.IDestroyableObject; -import at.gv.egiz.eaaf.core.api.IGarbageCollectorProcessing; -import at.gv.egiz.eaaf.core.exceptions.EaafConfigurationException; -import at.gv.egiz.eaaf.modules.pvp2.api.metadata.IPvp2MetadataProvider; -import at.gv.egiz.eaaf.modules.pvp2.api.metadata.IPvpAddableChainingMetadataProvider; -import at.gv.egiz.eaaf.modules.pvp2.api.metadata.IRefreshableMetadataProvider; - import org.apache.commons.lang3.StringUtils; -import org.joda.time.DateTime; import org.opensaml.core.criterion.EntityIdCriterion; import org.opensaml.saml.metadata.resolver.ClearableMetadataResolver; import org.opensaml.saml.metadata.resolver.MetadataResolver; @@ -50,6 +43,12 @@ import org.opensaml.saml.metadata.resolver.filter.MetadataFilter; import org.opensaml.saml.metadata.resolver.impl.AbstractMetadataResolver; import org.opensaml.saml.saml2.metadata.EntityDescriptor; +import at.gv.egiz.components.spring.api.IDestroyableObject; +import at.gv.egiz.eaaf.core.api.IGarbageCollectorProcessing; +import at.gv.egiz.eaaf.core.exceptions.EaafConfigurationException; +import at.gv.egiz.eaaf.modules.pvp2.api.metadata.IPvp2MetadataProvider; +import at.gv.egiz.eaaf.modules.pvp2.api.metadata.IPvpAddableChainingMetadataProvider; +import at.gv.egiz.eaaf.modules.pvp2.api.metadata.IRefreshableMetadataProvider; import lombok.extern.slf4j.Slf4j; import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements; import net.shibboleth.utilities.java.support.component.IdentifiedComponent; @@ -64,7 +63,7 @@ public abstract class AbstractChainingMetadataProvider implements IGarbageCollec @Nonnull @NonnullElements private final List<MetadataResolver> internalResolvers; - private DateTime lastRefeshTimestamp; + private Instant lastRefeshTimestamp; private boolean lastRefeshSuccessful; private static Object mutex = new Object(); @@ -111,10 +110,10 @@ public abstract class AbstractChainingMetadataProvider implements IGarbageCollec @Override public synchronized boolean refreshMetadataProvider(final String entityId) { try { - //if (resolveEntityDescriporForRefesh(entityId)) { - // return true; + // if (resolveEntityDescriporForRefesh(entityId)) { + // return true; // - //} + // } // reload metadata provider final String metadataUrl = getMetadataUrl(entityId); @@ -160,7 +159,6 @@ public abstract class AbstractChainingMetadataProvider implements IGarbageCollec } - @Override public final MetadataFilter getMetadataFilter() { log.warn("{} does NOT support {}", AbstractChainingMetadataProvider.class.getName(), @@ -275,17 +273,17 @@ public abstract class AbstractChainingMetadataProvider implements IGarbageCollec } } - this.lastRefeshTimestamp = DateTime.now(); + this.lastRefeshTimestamp = Instant.now(); this.lastRefeshSuccessful = true; } @Override @Nullable - public final DateTime getLastUpdate() { - DateTime ret = null; + public final Instant getLastUpdate() { + Instant ret = null; for (final MetadataResolver resolver : internalResolvers) { if (resolver instanceof RefreshableMetadataResolver) { - final DateTime lastUpdate = ((RefreshableMetadataResolver) resolver).getLastUpdate(); + final Instant lastUpdate = ((RefreshableMetadataResolver) resolver).getLastUpdate(); if (ret == null || ret.isBefore(lastUpdate)) { ret = lastUpdate; } @@ -297,11 +295,11 @@ public abstract class AbstractChainingMetadataProvider implements IGarbageCollec @Override @Nullable - public final DateTime getLastRefresh() { - DateTime ret = null; + public final Instant getLastRefresh() { + Instant ret = null; for (final MetadataResolver resolver : internalResolvers) { if (resolver instanceof RefreshableMetadataResolver) { - final DateTime lastRefresh = ((RefreshableMetadataResolver) resolver).getLastRefresh(); + final Instant lastRefresh = ((RefreshableMetadataResolver) resolver).getLastRefresh(); if (ret == null || ret.isBefore(lastRefresh)) { ret = lastRefresh; } @@ -312,7 +310,7 @@ public abstract class AbstractChainingMetadataProvider implements IGarbageCollec } @Override - public final DateTime getLastSuccessfulRefresh() { + public final Instant getLastSuccessfulRefresh() { return this.lastRefeshTimestamp; } @@ -347,6 +345,20 @@ public abstract class AbstractChainingMetadataProvider implements IGarbageCollec } + @Override + public final Throwable getLastFailureCause() { + for (final MetadataResolver resolver : internalResolvers) { + if (resolver instanceof RefreshableMetadataResolver) { + final RefreshableMetadataResolver refreshable = (RefreshableMetadataResolver) resolver; + if (refreshable.getLastFailureCause() != null) { + return refreshable.getLastFailureCause(); + } + } + } + + return null; + } + /** * Get the URL to metadata for a specific entityID. * diff --git a/eaaf_modules/eaaf_module_pvp2_core/src/main/java/at/gv/egiz/eaaf/modules/pvp2/impl/metadata/PvpMetadataResolverAdapter.java b/eaaf_modules/eaaf_module_pvp2_core/src/main/java/at/gv/egiz/eaaf/modules/pvp2/impl/metadata/PvpMetadataResolverAdapter.java index d2b861dc..1b44afe4 100644 --- a/eaaf_modules/eaaf_module_pvp2_core/src/main/java/at/gv/egiz/eaaf/modules/pvp2/impl/metadata/PvpMetadataResolverAdapter.java +++ b/eaaf_modules/eaaf_module_pvp2_core/src/main/java/at/gv/egiz/eaaf/modules/pvp2/impl/metadata/PvpMetadataResolverAdapter.java @@ -1,14 +1,14 @@ package at.gv.egiz.eaaf.modules.pvp2.impl.metadata; -import at.gv.egiz.eaaf.modules.pvp2.api.metadata.IPvp2MetadataProvider; -import at.gv.egiz.eaaf.modules.pvp2.api.metadata.IRefreshableMetadataProvider; +import java.time.Instant; -import org.joda.time.DateTime; import org.opensaml.core.criterion.EntityIdCriterion; -import org.opensaml.saml.metadata.resolver.ExtendedRefreshableMetadataResolver; +import org.opensaml.saml.metadata.resolver.RefreshableMetadataResolver; import org.opensaml.saml.metadata.resolver.filter.MetadataFilter; import org.opensaml.saml.saml2.metadata.EntityDescriptor; +import at.gv.egiz.eaaf.modules.pvp2.api.metadata.IPvp2MetadataProvider; +import at.gv.egiz.eaaf.modules.pvp2.api.metadata.IRefreshableMetadataProvider; import lombok.extern.slf4j.Slf4j; import net.shibboleth.utilities.java.support.resolver.CriteriaSet; import net.shibboleth.utilities.java.support.resolver.ResolverException; @@ -16,9 +16,9 @@ import net.shibboleth.utilities.java.support.resolver.ResolverException; @Slf4j public class PvpMetadataResolverAdapter implements IPvp2MetadataProvider, IRefreshableMetadataProvider { - private final ExtendedRefreshableMetadataResolver internalProvider; + private final RefreshableMetadataResolver internalProvider; - public PvpMetadataResolverAdapter(ExtendedRefreshableMetadataResolver provider) { + public PvpMetadataResolverAdapter(RefreshableMetadataResolver provider) { this.internalProvider = provider; } @@ -29,13 +29,13 @@ public class PvpMetadataResolverAdapter implements IPvp2MetadataProvider, IRefre } @Override - public DateTime getLastRefresh() { + public Instant getLastRefresh() { return internalProvider.getLastRefresh(); } @Override - public DateTime getLastUpdate() { + public Instant getLastUpdate() { return internalProvider.getLastUpdate(); } @@ -88,7 +88,7 @@ public class PvpMetadataResolverAdapter implements IPvp2MetadataProvider, IRefre } @Override - public DateTime getLastSuccessfulRefresh() { + public Instant getLastSuccessfulRefresh() { return internalProvider.getLastSuccessfulRefresh(); } @@ -112,4 +112,10 @@ public class PvpMetadataResolverAdapter implements IPvp2MetadataProvider, IRefre } } + @Override + public Throwable getLastFailureCause() { + return internalProvider.getLastFailureCause(); + + } + } diff --git a/eaaf_modules/eaaf_module_pvp2_core/src/main/java/at/gv/egiz/eaaf/modules/pvp2/impl/metadata/PvpMetadataResolverFactory.java b/eaaf_modules/eaaf_module_pvp2_core/src/main/java/at/gv/egiz/eaaf/modules/pvp2/impl/metadata/PvpMetadataResolverFactory.java index d29f1a0e..bf541b67 100644 --- a/eaaf_modules/eaaf_module_pvp2_core/src/main/java/at/gv/egiz/eaaf/modules/pvp2/impl/metadata/PvpMetadataResolverFactory.java +++ b/eaaf_modules/eaaf_module_pvp2_core/src/main/java/at/gv/egiz/eaaf/modules/pvp2/impl/metadata/PvpMetadataResolverFactory.java @@ -1,6 +1,7 @@ package at.gv.egiz.eaaf.modules.pvp2.impl.metadata; import java.io.IOException; +import java.time.Duration; import java.util.Timer; import javax.annotation.Nonnull; @@ -10,7 +11,7 @@ import javax.net.ssl.SSLHandshakeException; import org.apache.http.client.HttpClient; import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport; -import org.opensaml.saml.metadata.resolver.ExtendedRefreshableMetadataResolver; +import org.opensaml.saml.metadata.resolver.RefreshableMetadataResolver; import org.opensaml.saml.metadata.resolver.filter.MetadataFilter; import org.opensaml.saml.metadata.resolver.impl.AbstractReloadingMetadataResolver; import org.opensaml.saml.metadata.resolver.impl.HTTPMetadataResolver; @@ -102,7 +103,7 @@ public class PvpMetadataResolverFactory implements IDestroyableObject { @Nullable final MetadataFilter filter, @Nonnull final String idForLogging, @Nullable final ParserPool pool, @Nullable final HttpClient httpClient) throws Pvp2MetadataException { - ExtendedRefreshableMetadataResolver internalProvider = null; + RefreshableMetadataResolver internalProvider = null; try { if (metadataLocation.startsWith(URI_PREFIX_HTTP) @@ -181,7 +182,7 @@ public class PvpMetadataResolverFactory implements IDestroyableObject { * @throws ComponentInitializationException In case of a metadata resolver * initialization error */ - private ExtendedRefreshableMetadataResolver createNewFileSystemMetaDataProvider(final Resource metadataFile, + private RefreshableMetadataResolver createNewFileSystemMetaDataProvider(final Resource metadataFile, final MetadataFilter filter, final String idForLogging, final Timer timer, final ParserPool pool) throws IOException, ComponentInitializationException { ResourceBackedMetadataResolver fileSystemResolver = null; @@ -212,7 +213,7 @@ public class PvpMetadataResolverFactory implements IDestroyableObject { * @throws ResolverException In case of an internal OpenSAML * resolver error */ - private ExtendedRefreshableMetadataResolver createNewHttpMetaDataProvider(final String metadataUrl, + private RefreshableMetadataResolver createNewHttpMetaDataProvider(final String metadataUrl, final MetadataFilter filter, final String idForLogging, final Timer timer, final ParserPool pool, final HttpClient httpClient) throws ComponentInitializationException, ResolverException { @@ -241,8 +242,8 @@ public class PvpMetadataResolverFactory implements IDestroyableObject { } resolver.setRequireValidMetadata(true); - resolver.setMinRefreshDelay(1000 * 60 * 15); // 15 minutes - resolver.setMaxRefreshDelay(1000 * 60 * 60 * 24); // 24 hours + resolver.setMinRefreshDelay(Duration.ofMinutes(15)); + resolver.setMaxRefreshDelay(Duration.ofHours(24)); resolver.setMetadataFilter(filter); } |