From 0b6f74e646a781e8f310e52164b6f6da4fa812be Mon Sep 17 00:00:00 2001
From: str4d <str4d@mail.i2p>
Date: Wed, 11 Mar 2015 23:46:38 +0000
Subject: [PATCH] Enable proxy authentication type to be configured

---
 .../net/i2p/i2ptunnel/ui/TunnelConfig.java    | 27 ++++++++++++++-----
 .../src/net/i2p/i2ptunnel/web/IndexBean.java  |  5 ++--
 2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ui/TunnelConfig.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ui/TunnelConfig.java
index c4f0b18fe3..603298afe2 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ui/TunnelConfig.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ui/TunnelConfig.java
@@ -334,10 +334,15 @@ public class TunnelConfig {
             _booleanOptions.remove("shouldBundleReplyInfo");
     }
 
-    /** all proxy auth */
-    public void setProxyAuth(String s) {
-        if (s != null)
-            _otherOptions.put(I2PTunnelHTTPClientBase.PROP_AUTH, I2PTunnelHTTPClientBase.DIGEST_AUTH);
+    /**
+     * Sets whether authentication should be used for client proxy tunnels.
+     * Supported authentication types: "basic", "digest".
+     *
+     * @param authType the authentication type, or "false" for no authentication
+     */
+    public void setProxyAuth(String authType) {
+        if (authType != null)
+            _otherOptions.put(I2PTunnelHTTPClientBase.PROP_AUTH, authType.trim());
     }
     
     public void setProxyUsername(String s) {
@@ -350,8 +355,16 @@ public class TunnelConfig {
             _newProxyPW = s.trim();
     }
     
-    public void setOutproxyAuth(String s) {
-        _otherOptions.put(I2PTunnelHTTPClientBase.PROP_OUTPROXY_AUTH, I2PTunnelHTTPClientBase.DIGEST_AUTH);
+    /**
+     * Sets the authentication type required for configured outproxies. The
+     * same authentication type is assumed for all configured outproxies.
+     * Supported authentication types: "basic", "digest".
+     *
+     * @param authType the authentication type, or "false" for no authentication
+     */
+    public void setOutproxyAuth(String authType) {
+        if (authType != null)
+            _otherOptions.put(I2PTunnelHTTPClientBase.PROP_OUTPROXY_AUTH, authType.trim());
     }
     
     public void setOutproxyUsername(String s) {
@@ -440,7 +453,7 @@ public class TunnelConfig {
 
     public void setSigType(String val) {
         if (val != null)
-            _otherOptions.put(I2PClient.PROP_SIGTYPE, val);
+            _otherOptions.put(I2PClient.PROP_SIGTYPE, val.trim());
     }
 
     /**
diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java
index fa440033cb..67d84fdab8 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java
@@ -25,6 +25,7 @@ import net.i2p.data.PrivateKeyFile;
 import net.i2p.data.SessionKey;
 import net.i2p.i2ptunnel.I2PTunnelClientBase;
 import net.i2p.i2ptunnel.I2PTunnelHTTPClient;
+import net.i2p.i2ptunnel.I2PTunnelHTTPClientBase;
 import net.i2p.i2ptunnel.I2PTunnelHTTPServer;
 import net.i2p.i2ptunnel.I2PTunnelServer;
 import net.i2p.i2ptunnel.SSLClientUtil;
@@ -943,7 +944,7 @@ public class IndexBean {
 
     /** all proxy auth @since 0.8.2 */
     public void setProxyAuth(String s) {
-        _config.setProxyAuth(s);
+        _config.setProxyAuth(I2PTunnelHTTPClientBase.DIGEST_AUTH);
     }
     
     public void setProxyUsername(String s) {
@@ -955,7 +956,7 @@ public class IndexBean {
     }
     
     public void setOutproxyAuth(String s) {
-        _config.setOutproxyAuth(s);
+        _config.setOutproxyAuth(I2PTunnelHTTPClientBase.DIGEST_AUTH);
     }
     
     public void setOutproxyUsername(String s) {
-- 
GitLab