[java-opensaml] branch main updated: IDP-2116 - Add metrics for MetadataResolvers
Scott Cantor
cantor.2 at osu.edu
Mon May 22 19:54:02 UTC 2023
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-opensaml.
View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=5e06e58824cb23286ea89ff479860bf794fbf7c8
The following commit(s) were added to refs/heads/main by this push:
new 5e06e5882 IDP-2116 - Add metrics for MetadataResolvers
5e06e5882 is described below
commit 5e06e58824cb23286ea89ff479860bf794fbf7c8
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon May 22 15:54:00 2023 -0400
IDP-2116 - Add metrics for MetadataResolvers
https://shibboleth.atlassian.net/browse/IDP-2116
Add RemoteMetadataResolver interface to expose metadata URL.
Expose MDQ base URL via the interface.
---
.../metadata/resolver/RemoteMetadataResolver.java | 36 ++++++++++++++++++++++
.../FunctionDrivenDynamicHTTPMetadataResolver.java | 13 +++++++-
.../resolver/impl/HTTPMetadataResolver.java | 9 ++----
.../MetadataQueryProtocolRequestURLBuilder.java | 14 ++++++++-
4 files changed, 64 insertions(+), 8 deletions(-)
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/metadata/resolver/RemoteMetadataResolver.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/metadata/resolver/RemoteMetadataResolver.java
new file mode 100644
index 000000000..bf9e306c7
--- /dev/null
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/metadata/resolver/RemoteMetadataResolver.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.opensaml.saml.metadata.resolver;
+
+import javax.annotation.Nullable;
+
+/**
+ * A {@link MetadataResolver} that obtains metadata from a remote source.
+ *
+ * @since 5.0.0
+ */
+public interface RemoteMetadataResolver extends MetadataResolver {
+
+ /**
+ * Gets the URI from which this resolver is obtaining metadata.
+ *
+ * @return URL source of metadata
+ */
+ @Nullable String getMetadataURI();
+
+}
\ No newline at end of file
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/FunctionDrivenDynamicHTTPMetadataResolver.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/FunctionDrivenDynamicHTTPMetadataResolver.java
index 88f0d0f40..aa6f27b64 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/FunctionDrivenDynamicHTTPMetadataResolver.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/FunctionDrivenDynamicHTTPMetadataResolver.java
@@ -24,6 +24,7 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.apache.hc.client5.http.classic.HttpClient;
+import org.opensaml.saml.metadata.resolver.RemoteMetadataResolver;
import org.slf4j.Logger;
import net.shibboleth.shared.logic.Constraint;
@@ -40,7 +41,8 @@ import net.shibboleth.shared.resolver.CriteriaSet;
* is an HTTP or HTTPS URL.
* </p>
*/
-public class FunctionDrivenDynamicHTTPMetadataResolver extends AbstractDynamicHTTPMetadataResolver {
+public class FunctionDrivenDynamicHTTPMetadataResolver extends AbstractDynamicHTTPMetadataResolver
+ implements RemoteMetadataResolver {
/** Logger. */
@Nonnull private final Logger log = LoggerFactory.getLogger(FunctionDrivenDynamicHTTPMetadataResolver.class);
@@ -103,4 +105,13 @@ public class FunctionDrivenDynamicHTTPMetadataResolver extends AbstractDynamicHT
return url;
}
+ /** {@inheritDoc} */
+ @Nullable public String getMetadataURI() {
+ // This is for metrics exposure.
+ if (requestURLBuilder instanceof MetadataQueryProtocolRequestURLBuilder mdq) {
+ return mdq.getBaseURL();
+ }
+ return null;
+ }
+
}
\ No newline at end of file
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/HTTPMetadataResolver.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/HTTPMetadataResolver.java
index 9960d2dd4..b43a8882d 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/HTTPMetadataResolver.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/HTTPMetadataResolver.java
@@ -35,6 +35,7 @@ import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HttpStatus;
import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.opensaml.saml.metadata.resolver.RemoteMetadataResolver;
import org.opensaml.security.httpclient.HttpClientSecurityParameters;
import org.opensaml.security.httpclient.HttpClientSecuritySupport;
import org.slf4j.Logger;
@@ -58,7 +59,7 @@ import net.shibboleth.shared.resolver.ResolverException;
* It is the responsibility of the caller to re-initialize, via {@link #initialize()}, if any properties of this
* provider are changed.
*/
-public class HTTPMetadataResolver extends AbstractReloadingMetadataResolver {
+public class HTTPMetadataResolver extends AbstractReloadingMetadataResolver implements RemoteMetadataResolver {
/** Class logger. */
@Nonnull private final Logger log = LoggerFactory.getLogger(HTTPMetadataResolver.class);
@@ -112,11 +113,7 @@ public class HTTPMetadataResolver extends AbstractReloadingMetadataResolver {
}
}
- /**
- * Gets the URL to fetch the metadata.
- *
- * @return the URL to fetch the metadata
- */
+ /** {@inheritDoc} */
@Nonnull public String getMetadataURI() {
return metadataURI.toASCIIString();
}
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/MetadataQueryProtocolRequestURLBuilder.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/MetadataQueryProtocolRequestURLBuilder.java
index 082b8b80f..040fcca5c 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/MetadataQueryProtocolRequestURLBuilder.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/MetadataQueryProtocolRequestURLBuilder.java
@@ -65,6 +65,7 @@ public class MetadataQueryProtocolRequestURLBuilder implements Function<Criteria
@Nullable private Function<String, String> transformer;
/** Path escaper for escaping the input value inserted into the URL path. */
+ @SuppressWarnings("null")
@Nonnull private final Escaper pathEscaper = UrlEscapers.urlPathSegmentEscaper();
/** List of secondary URL builders. */
@@ -80,7 +81,6 @@ public class MetadataQueryProtocolRequestURLBuilder implements Function<Criteria
this(baseURL, null, null);
}
-
/**
* Constructor.
*
@@ -92,6 +92,7 @@ public class MetadataQueryProtocolRequestURLBuilder implements Function<Criteria
@ParameterName(name="transform") @Nullable final Function<String,String> transform) {
this(baseURL, transform, null);
}
+
/**
* Constructor.
*
@@ -132,6 +133,17 @@ public class MetadataQueryProtocolRequestURLBuilder implements Function<Criteria
}
}
+ /**
+ * Gets the base URL configured into function.
+ *
+ * @return base URL
+ *
+ * @since 5.0.0
+ */
+ @Nonnull @NotEmpty public String getBaseURL() {
+ return base;
+ }
+
/** {@inheritDoc} */
@Nullable public String apply(@Nullable final CriteriaSet criteria) {
final EntityIdCriterion criterion = criteria != null ? criteria.get(EntityIdCriterion.class) : null;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list