]> source.dussan.org Git - archiva.git/commitdiff
Adding default userAgent system property 24/head
authorMartin Stockhammer <m.stockhammer@web.de>
Tue, 13 Sep 2016 14:46:50 +0000 (16:46 +0200)
committerMartin Stockhammer <m.stockhammer@web.de>
Tue, 13 Sep 2016 14:46:50 +0000 (16:46 +0200)
The default userAgent string used for proxy connections can be configured by
a system property.

archiva-modules/archiva-base/archiva-proxy-common/src/main/java/org/apache/archiva/proxy/common/WagonFactoryRequest.java

index 0e297f508dc56edf1ea3e45732330e4df76fd112..40544022d4bb5b68ef1bef3520f44e4b713ce399 100644 (file)
@@ -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 <code>wagon#</code>, for example
      * <code>wagon#http</code>. <b>to have a wagon supporting ntlm add -ntlm</b>
@@ -37,7 +42,13 @@ public class WagonFactoryRequest
 
     private Map<String, String> 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;