[java-identity-provider] 03/03: IDP-2378 Accessing metrics/updates always triggers four HTTPS requests
Rod Widdowson
rdw at steadingsoftware.com
Sun Nov 9 14:10:16 UTC 2025
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch main
in repository java-identity-provider.
View the commit online:
https://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=fd29deeefe65b037cc47e986f0748e465f54e81a
commit fd29deeefe65b037cc47e986f0748e465f54e81a
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Sun Nov 9 13:56:19 2025 +0000
IDP-2378 Accessing metrics/updates always triggers four HTTPS requests
https://shibboleth.atlassian.net/browse/IDP-2378
Plumb in the cache which stops metrics and ReportUpdateStatus going off site.
---
.../admin/impl/InstallableComponentGaugeSet.java | 23 +++++++++++++++++-----
.../idp/admin/impl/ReportUpdateStatus.java | 15 +++++++++++++-
.../net/shibboleth/idp/conf/admin-system.xml | 1 +
.../net/shibboleth/idp/conf/global-system.xml | 6 ++++++
.../net/shibboleth/idp/conf/metrics-system.xml | 1 +
.../net/shibboleth/idp/module/conf/idp.properties | 14 ++++++++-----
6 files changed, 49 insertions(+), 11 deletions(-)
diff --git a/idp-admin-impl/src/main/java/net/shibboleth/idp/admin/impl/InstallableComponentGaugeSet.java b/idp-admin-impl/src/main/java/net/shibboleth/idp/admin/impl/InstallableComponentGaugeSet.java
index dccb8676e..e6d0f90b8 100644
--- a/idp-admin-impl/src/main/java/net/shibboleth/idp/admin/impl/InstallableComponentGaugeSet.java
+++ b/idp-admin-impl/src/main/java/net/shibboleth/idp/admin/impl/InstallableComponentGaugeSet.java
@@ -79,10 +79,13 @@ public class InstallableComponentGaugeSet extends AbstractIdentifiableInitializa
/** any security parameters needed. */
@Nullable private HttpClientSecurityParameters securityParams;
-
+
/** IdP Version to check. */
@NonnullAfterInit private InstallableComponentVersion idpVersion;
-
+
+ /** The cache (to stop us going offsite). */
+ @NonnullAfterInit private InstallableComponentPropertyCache cache;
+
/** Is update check enabled.*/
private boolean updateCheckEnabled;
@@ -119,6 +122,13 @@ public class InstallableComponentGaugeSet extends AbstractIdentifiableInitializa
updateCheckEnabled = what;
}
+ /** Set the the bean which caches information we have phoned home about.
+ * @param what what to set
+ */
+ public void setCache(InstallableComponentPropertyCache what) {
+ cache = what;
+ }
+
/**
* Null safe IdP Version.
*
@@ -201,7 +211,7 @@ public class InstallableComponentGaugeSet extends AbstractIdentifiableInitializa
}
}
assert httpClient != null;
- final Properties result = InstallableComponentSupport.loadInfo(urls, httpClient, securityParams);
+ final Properties result = cache.loadInfo(urls, httpClient, securityParams);
for (final URL url:urls) {
// Note - negative caching too.
pluginInfoCache.put(url, result);
@@ -217,8 +227,7 @@ public class InstallableComponentGaugeSet extends AbstractIdentifiableInitializa
@Nullable private InstallableComponentDetails getIdPDetails() {
try {
assert httpClient!=null;
- final Properties properties =
- InstallableComponentSupport.loadInfo(idpUpdateUrls, httpClient, securityParams);
+ final Properties properties = cache.loadInfo(idpUpdateUrls, httpClient, securityParams);
if (properties == null) {
log.warn("Could not locate IdP update information");
return null;
@@ -245,6 +254,10 @@ public class InstallableComponentGaugeSet extends AbstractIdentifiableInitializa
if (httpClient == null) {
throw new ComponentInitializationException("HttpClient was null");
}
+ if (cache == null) {
+ throw new ComponentInitializationException("Cache was null");
+ }
+
final String idpVersionStr = Version.getVersion();
if (idpVersionStr == null) {
// So things work inside Eclipse.
diff --git a/idp-admin-impl/src/main/java/net/shibboleth/idp/admin/impl/ReportUpdateStatus.java b/idp-admin-impl/src/main/java/net/shibboleth/idp/admin/impl/ReportUpdateStatus.java
index c1f59c624..ba113e66a 100644
--- a/idp-admin-impl/src/main/java/net/shibboleth/idp/admin/impl/ReportUpdateStatus.java
+++ b/idp-admin-impl/src/main/java/net/shibboleth/idp/admin/impl/ReportUpdateStatus.java
@@ -60,6 +60,9 @@ public class ReportUpdateStatus extends AbstractIdentifiableInitializableCompone
/** any security parameters needed. */
@Nullable private HttpClientSecurityParameters securityParams;
+ /** The cache (to stop us going offsite if someone already has). */
+ @NonnullAfterInit private InstallableComponentPropertyCache cache;
+
/** Set where to look.
* @param urls what to set.
*/
@@ -92,12 +95,22 @@ public class ReportUpdateStatus extends AbstractIdentifiableInitializableCompone
enabled = on;
}
+ /** Set the cache of information we have phoned home about;
+ * @param what what to set
+ */
+ public void setCache(InstallableComponentPropertyCache what) {
+ cache = what;
+ }
+
/** {@inheritDoc} */
@Override
protected void doInitialize() throws ComponentInitializationException {
if (!enabled) {
return;
}
+ if (cache == null) {
+ throw new ComponentInitializationException("Cache not specified was null");
+ }
if (httpClient == null) {
throw new ComponentInitializationException("HttpClient was not set");
}
@@ -123,7 +136,7 @@ public class ReportUpdateStatus extends AbstractIdentifiableInitializableCompone
}
@Nonnull final InstallableComponentVersion version = new InstallableComponentVersion(versionStr);
assert httpClient!=null;
- final Properties properties = InstallableComponentSupport.loadInfo(updateUrls, httpClient, securityParams);
+ final Properties properties = cache.loadInfo(updateUrls, httpClient, securityParams);
if (properties == null) {
log.warn("Could not locate IdP update information");
return;
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/admin-system.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/admin-system.xml
index d1ea01b18..c5f5fd071 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/admin-system.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/admin-system.xml
@@ -236,6 +236,7 @@
depends-on="shibboleth.LoggingService"
p:updateUrls-ref="%{idp.updateCheck.urls:shibboleth.IdPUpdateCheckUrls}"
p:enabled="%{idp.updateCheck.enable:true}"
+ p:cache-ref="shibboleth.InstallableComponent.CachedStatus"
p:httpClient-ref="%{idp.updateCheck.httpClient:shibboleth.CallHomeHttpClient}"
p:securityParams="#{ environment.containsProperty('idp.updateCheck.httpSecurityParameters') ? getObject('idp.updateCheck.httpSecurityParameters') :null}"/>
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/global-system.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/global-system.xml
index 29c2ac5c6..092670094 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/global-system.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/global-system.xml
@@ -523,4 +523,10 @@
<bean id="shibboleth.DefaultAttributeHelper" class="net.shibboleth.idp.ui.helper.AttributeHelper"/>
+ <!-- cache for ReportUpdateStatus and InstallableComponentGuageSet -->
+ <bean id="shibboleth.InstallableComponent.CachedStatus"
+ class="net.shibboleth.idp.admin.impl.InstallableComponentPropertyCache"
+ depends-on="shibboleth.LoggingService"
+ p:cacheLife="%{idp.updateCheck.cacheInterval:PT24H}" />
+
</beans>
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/metrics-system.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/metrics-system.xml
index 42307778e..28e688b9a 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/metrics-system.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/metrics-system.xml
@@ -84,6 +84,7 @@
class="net.shibboleth.idp.admin.impl.InstallableComponentGaugeSet" lazy-init="true"
p:updateCheckEnabled="%{idp.updateCheck.enable:true}"
p:idpUpdateUrls-ref="%{idp.updateCheck.urls:shibboleth.IdPUpdateCheckUrls}"
+ p:cache-ref="shibboleth.InstallableComponent.CachedStatus"
p:httpClient-ref="%{idp.updateCheck.httpClient:shibboleth.CallHomeHttpClient}"
p:securityParams="#{ environment.containsProperty('idp.updateCheck.httpSecurityParameters') ? getObject('idp.updateCheck.httpSecurityParameters') :null}"/>
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/module/conf/idp.properties b/idp-conf-impl/src/main/resources/net/shibboleth/idp/module/conf/idp.properties
index e09177936..fdf1d1089 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/module/conf/idp.properties
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/module/conf/idp.properties
@@ -1,8 +1,3 @@
-# Set false if you do not want the IdP to check (asynchronously) whether
-# it can be updated or not when the container starts and when
-# evaulating the net.shibboleth.idp.installation metrics
-#idp.updateCheck.enable=true
-
# Auto-load all files matching conf/**/*.properties
# Disable if you want to manually maintain a list of sources.
idp.searchForProperties = true
@@ -266,3 +261,12 @@ idp.audit.shortenBindings = true
# Set true if you want inbound SAML requests to enforce that only
# allowed HTTP parameters are present
#idp.http.saml.enforceAllowedParameters = false
+
+# Set false if you do not want the IdP to check (asynchronously) whether
+# it can be updated or not when the container starts and when
+# evaluating the net.shibboleth.idp.installation metrics
+#idp.updateCheck.enable=true
+#
+# Set how long to cache the result of checking of IdP and plugin version
+# updates
+#idp.updateCheck.cacheInterval=PT24H
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list