Author: markt
Date: Tue May 30 11:42:16 2017
New Revision: 1796836

URL: http://svn.apache.org/viewvc?rev=1796836&view=rev
Log:
Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=45832
Add HTTP DIGEST support

Modified:
    tomcat/trunk/java/org/apache/catalina/ant/AbstractCatalinaTask.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/catalina/ant/AbstractCatalinaTask.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ant/AbstractCatalinaTask.java?rev=1796836&r1=1796835&r2=1796836&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/ant/AbstractCatalinaTask.java 
(original)
+++ tomcat/trunk/java/org/apache/catalina/ant/AbstractCatalinaTask.java Tue May 
30 11:42:16 2017
@@ -20,12 +20,12 @@ import java.io.BufferedOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.net.Authenticator;
 import java.net.HttpURLConnection;
+import java.net.PasswordAuthentication;
 import java.net.URL;
 import java.net.URLConnection;
-import java.nio.charset.StandardCharsets;
 
-import org.apache.tomcat.util.codec.binary.Base64;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 
@@ -200,10 +200,8 @@ public abstract class AbstractCatalinaTa
             }
             hconn.setRequestProperty("User-Agent", "Catalina-Ant-Task/1.0");
 
-            // Set up an authorization header with our credentials
-            String input = username + ":" + password;
-            String output = 
Base64.encodeBase64String(input.getBytes(StandardCharsets.ISO_8859_1));
-            hconn.setRequestProperty("Authorization", "Basic " + output);
+            // Set up authorization with our credentials
+            Authenticator.setDefault(new TaskAuthenticator(username, 
password));
 
             // Establish the connection with the server
             hconn.connect();
@@ -292,4 +290,21 @@ public abstract class AbstractCatalinaTa
             }
         }
     }
+
+
+    private static class TaskAuthenticator extends Authenticator {
+
+        private final String user;
+        private final String password;
+
+        private TaskAuthenticator(String user, String password) {
+            this.user = user;
+            this.password = password;
+        }
+
+        @Override
+        protected PasswordAuthentication getPasswordAuthentication() {
+            return new PasswordAuthentication(user, password.toCharArray());
+        }
+    }
 }

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1796836&r1=1796835&r2=1796836&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Tue May 30 11:42:16 2017
@@ -102,6 +102,10 @@
   </subsection>
   <subsection name="Other">
     <changelog>
+      <add>
+        <bug>45832</bug>: Add HTTP DIGEST authentication support to the 
Catalina
+        Ant tasks used to communicate with the Manager application. (markt)
+      </add>
       <fix>
         <bug>61055</bug>: Clarify the code comments in the rewrite valve to 
make
         clear that there are no plans to provide proxy support for this valve



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to