[java-shib-shared] branch main updated: IDP-2486 - Adjust default UserAgent handling in IdP to be extensible
Codeberg
noreply at shibboleth.net
Thu Oct 15 19:40:24 UTC 2026
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch main
in repository java-shib-shared.
View the commit online:
https://codeberg.org/Shibboleth/java-shib-shared/commit/6e8b63800258849054815afa4a1940d99cae0451
The following commit(s) were added to refs/heads/main by this push:
new 6e8b6380 IDP-2486 - Adjust default UserAgent handling in IdP to be extensible
6e8b6380 is described below
commit 6e8b63800258849054815afa4a1940d99cae0451
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Thu Oct 15 14:40:13 2026 -0400
IDP-2486 - Adjust default UserAgent handling in IdP to be extensible
https://shibboleth.atlassian.net/browse/IDP-2486
Add machinery to auto-wire User Agent components into a final result.
---
.../factory/HttpClientUserAgentComponent.java | 72 ++++++++++++++++++++++
.../factory/HttpClientUserAgentFactoryBean.java | 64 +++++++++++++++++++
.../UsernamePasswoordCredentialsFactoryBean.java | 4 +-
3 files changed, 138 insertions(+), 2 deletions(-)
diff --git a/shib-networking-spring/src/main/java/net/shibboleth/shared/spring/httpclient/factory/HttpClientUserAgentComponent.java b/shib-networking-spring/src/main/java/net/shibboleth/shared/spring/httpclient/factory/HttpClientUserAgentComponent.java
new file mode 100644
index 00000000..2e888ccc
--- /dev/null
+++ b/shib-networking-spring/src/main/java/net/shibboleth/shared/spring/httpclient/factory/HttpClientUserAgentComponent.java
@@ -0,0 +1,72 @@
+/*
+ * 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.shared.spring.httpclient.factory;
+
+import javax.annotation.Nonnull;
+
+import org.springframework.core.Ordered;
+
+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;
+
+/**
+ *
+ */
+public class HttpClientUserAgentComponent implements Ordered {
+
+ /** Component of string to contrbute. */
+ @Nonnull @NotEmpty private final String component;
+
+ /** Relative order of component. */
+ private final int order;
+
+ /**
+ * Constructor.
+ *
+ * @param s component of User-Agent string
+ * @param priority relative priority
+ */
+ public HttpClientUserAgentComponent(@Nonnull @NotEmpty @ParameterName(name="s") final String s,
+ @ParameterName(name="priority") final int priority) {
+ component = Constraint.isNotNull(StringSupport.trimOrNull(s), "UserAgent component cannot be null or empty");
+ order = priority;
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param s component of UserAgent string
+ */
+ public HttpClientUserAgentComponent(@Nonnull @NotEmpty @ParameterName(name="s") final String s) {
+ this(s, Ordered.LOWEST_PRECEDENCE);
+ }
+
+ /**
+ * Gets the component wrapped by this object.
+ *
+ * @return User-Agent component
+ */
+ @Nonnull @NotEmpty public String getComponent() {
+ return component;
+ }
+
+ /** {@inheritDoc} */
+ public int getOrder() {
+ return order;
+ }
+
+}
\ No newline at end of file
diff --git a/shib-networking-spring/src/main/java/net/shibboleth/shared/spring/httpclient/factory/HttpClientUserAgentFactoryBean.java b/shib-networking-spring/src/main/java/net/shibboleth/shared/spring/httpclient/factory/HttpClientUserAgentFactoryBean.java
new file mode 100644
index 00000000..669a2e47
--- /dev/null
+++ b/shib-networking-spring/src/main/java/net/shibboleth/shared/spring/httpclient/factory/HttpClientUserAgentFactoryBean.java
@@ -0,0 +1,64 @@
+/*
+ * 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.shared.spring.httpclient.factory;
+
+import java.util.List;
+
+import javax.annotation.Nullable;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.config.AbstractFactoryBean;
+
+import net.shibboleth.shared.primitive.StringSupport;
+
+/**
+ * A factory bean that auto-wires a set of User-Agent substrings into a final result.
+ */
+public class HttpClientUserAgentFactoryBean extends AbstractFactoryBean<String> {
+
+ @Nullable final String userAgentString;
+
+ /**
+ * Constructor.
+ *
+ * @param components auto-wired instamces of Strings to combine
+ */
+ @Autowired
+ public HttpClientUserAgentFactoryBean(@Nullable final List<HttpClientUserAgentComponent> components) {
+ final StringBuilder builder = new StringBuilder();
+
+ if (components != null) {
+ for (final HttpClientUserAgentComponent c : components) {
+ builder.append(' ').append(c.getComponent());
+ }
+ userAgentString = StringSupport.trimOrNull(builder.toString());
+ } else {
+ userAgentString = null;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ @Nullable public Class<?> getObjectType() {
+ return String.class;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ @Nullable protected String createInstance() throws Exception {
+ return userAgentString;
+ }
+
+}
\ No newline at end of file
diff --git a/shib-networking-spring/src/main/java/net/shibboleth/shared/spring/httpclient/factory/UsernamePasswoordCredentialsFactoryBean.java b/shib-networking-spring/src/main/java/net/shibboleth/shared/spring/httpclient/factory/UsernamePasswoordCredentialsFactoryBean.java
index 2fab9375..ede0a448 100644
--- a/shib-networking-spring/src/main/java/net/shibboleth/shared/spring/httpclient/factory/UsernamePasswoordCredentialsFactoryBean.java
+++ b/shib-networking-spring/src/main/java/net/shibboleth/shared/spring/httpclient/factory/UsernamePasswoordCredentialsFactoryBean.java
@@ -28,9 +28,9 @@ import net.shibboleth.shared.primitive.DeprecationSupport.ObjectType;
* @deprecated use {@link UsernamePasswordCredentials}
*/
public class UsernamePasswoordCredentialsFactoryBean extends UsernamePasswordCredentialsFactoryBean {
-
+
+ /** Constructor. */
public UsernamePasswoordCredentialsFactoryBean() {
- super();
DeprecationSupport.warnOnce(ObjectType.CLASS, "UsernamePasswoordCredentialsFactoryBean", null, "UsernamePasswordCredentialsFactoryBean");
}
}
\ 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