From: Martin Stockhammer Date: Tue, 13 Sep 2016 14:46:50 +0000 (+0200) Subject: Adding default userAgent system property X-Git-Tag: without_jdo~26 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fpull%2F24%2Fhead;p=archiva.git Adding default userAgent system property The default userAgent string used for proxy connections can be configured by a system property. --- diff --git a/archiva-modules/archiva-base/archiva-proxy-common/src/main/java/org/apache/archiva/proxy/common/WagonFactoryRequest.java b/archiva-modules/archiva-base/archiva-proxy-common/src/main/java/org/apache/archiva/proxy/common/WagonFactoryRequest.java index 0e297f508..40544022d 100644 --- a/archiva-modules/archiva-base/archiva-proxy-common/src/main/java/org/apache/archiva/proxy/common/WagonFactoryRequest.java +++ b/archiva-modules/archiva-base/archiva-proxy-common/src/main/java/org/apache/archiva/proxy/common/WagonFactoryRequest.java @@ -29,6 +29,11 @@ import java.util.Map; */ public class WagonFactoryRequest { + + public static final String USER_AGENT_SYSTEM_PROPERTY = "archiva.userAgent"; + + private static String DEFAULT_USER_AGENT = "Java-Archiva"; + /** * the protocol to find the Wagon for, which must be prefixed with wagon#, for example * wagon#http. to have a wagon supporting ntlm add -ntlm @@ -37,7 +42,13 @@ public class WagonFactoryRequest private Map headers = new HashMap<>(); - private String userAgent = "Java-Archiva"; + private String userAgent = DEFAULT_USER_AGENT; + + static { + if (System.getProperty(USER_AGENT_SYSTEM_PROPERTY)!=null && !"".equals(System.getProperty(USER_AGENT_SYSTEM_PROPERTY))) { + DEFAULT_USER_AGENT=System.getProperty(USER_AGENT_SYSTEM_PROPERTY); + } + } private NetworkProxy networkProxy;