[java-plugin-shibd] branch main updated: JSHIBD-29 - Distinguish User-Agent of SPs from IdPs
Codeberg
noreply at shibboleth.net
Mon Oct 19 14:16:42 UTC 2026
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch main
in repository java-plugin-shibd.
View the commit online:
https://codeberg.org/Shibboleth/java-plugin-shibd/commit/0bfddbca9db3ae2a4cebd998fe451a982d940585
The following commit(s) were added to refs/heads/main by this push:
new 0bfddbc JSHIBD-29 - Distinguish User-Agent of SPs from IdPs
0bfddbc is described below
commit 0bfddbca9db3ae2a4cebd998fe451a982d940585
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Mon Oct 19 10:16:31 2026 -0400
JSHIBD-29 - Distinguish User-Agent of SPs from IdPs
https://shibboleth.atlassian.net/browse/JSHIBD-29
Added conditional bean to contribute a plugin-specific User-Agent value.
---
.../META-INF/net.shibboleth.idp/postconfig.xml | 3 +
.../impl/ConditionalHttpClientUserAgent.java | 70 ++++++++++++++++++++++
2 files changed, 73 insertions(+)
diff --git a/sp-conf-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml b/sp-conf-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml
index b3a218f..7141dc4 100644
--- a/sp-conf-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml
+++ b/sp-conf-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml
@@ -12,6 +12,9 @@
http://www.springframework.org/schema/integration/ip https://www.springframework.org/schema/integration/ip/spring-integration-ip.xsd"
default-init-method="initialize" default-destroy-method="destroy">
+
+ <bean class="net.shibboleth.sp.service.impl.ConditionalHttpClientUserAgent"
+ c:_0="#{ 'shibd/' + (T(net.shibboleth.sp.conf.Version).getVersion() ?: 'Unknown') }" />
<!-- Agent reseolver service. -->
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/service/impl/ConditionalHttpClientUserAgent.java b/sp-server-impl/src/main/java/net/shibboleth/sp/service/impl/ConditionalHttpClientUserAgent.java
new file mode 100644
index 0000000..fba4227
--- /dev/null
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/service/impl/ConditionalHttpClientUserAgent.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed 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 net.shibboleth.sp.service.impl;
+
+import java.lang.reflect.Constructor;
+
+import javax.annotation.Nonnull;
+
+import org.springframework.beans.factory.config.AbstractFactoryBean;
+
+import net.shibboleth.shared.annotation.ParameterName;
+import net.shibboleth.shared.annotation.constraint.NotEmpty;
+import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.StringSupport;
+
+/**
+ * A reflection-driven factory bean for a class appearing only in later IdP versions.
+ *
+ * <p>This will be removed once the API baseline is updated.</p>
+ */
+public class ConditionalHttpClientUserAgent extends AbstractFactoryBean {
+
+ @Nonnull private Class<?> type;
+
+ /** Value to expose if possible. */
+ @Nonnull @NotEmpty private String userAgentComponent;
+
+ /** Constructor. */
+ public ConditionalHttpClientUserAgent(@Nonnull @NotEmpty @ParameterName(name="s") final String s) {
+ try {
+ type = Class.forName("net.shibboleth.shared.spring.httpclient.factory.HttpClientUserAgentComponent");
+ } catch (ClassNotFoundException e) {
+ type = String.class;
+ }
+
+ userAgentComponent = Constraint.isNotNull(StringSupport.trimOrNull(s),
+ "User-Agent component cannot be null or empty");
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ @Nonnull public Class<?> getObjectType() {
+ return type;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ @Nonnull protected Object createInstance() throws Exception {
+
+ try {
+ final Constructor<?> ctor = type.getConstructor(String.class);
+ return ctor.newInstance(userAgentComponent);
+ } catch (final NoSuchMethodException e) {
+ return new String(userAgentComponent);
+ }
+ }
+
+}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list