This is an automated email from the ASF dual-hosted git repository.

bodewig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ant.git


The following commit(s) were added to refs/heads/master by this push:
     new 43214e4  add docs for #170 and make host name check strict by default
43214e4 is described below

commit 43214e4332867aa62a73df2703d6307dc966c902
Author: Stefan Bodewig <bode...@apache.org>
AuthorDate: Thu Dec 16 19:00:52 2021 +0100

    add docs for #170 and make host name check strict by default
---
 WHATSNEW                                           |  3 +++
 manual/Tasks/ftp.html                              |  7 ++++++
 .../tools/ant/taskdefs/optional/net/FTP.java       | 28 ++++++++++++----------
 3 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/WHATSNEW b/WHATSNEW
index 49c7815..8c39261 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -13,6 +13,9 @@ Other changes:
   of the generated output file from the listener.
   Github Pull Request #168
 
+* <ftp> now supports FTPs.
+  Github Pull Request #170
+
 Changes from Ant 1.10.11 TO Ant 1.10.12
 =======================================
 
diff --git a/manual/Tasks/ftp.html b/manual/Tasks/ftp.html
index 0e38723..61ba0b7 100644
--- a/manual/Tasks/ftp.html
+++ b/manual/Tasks/ftp.html
@@ -346,6 +346,13 @@ connection.</p>
       the <var>serverLanguageCode</var> attribute.<br/><em>Since Ant 
1.7</em></td>
     <td>No</td>
   </tr>
+  <tr>
+    <td>useFtps</td>
+    <td>Whether to use ftps instead of ftp. Boolean, defauls
+      to <var>false</var>.<br/>
+      <em>Since Ant 1.10.13</em></td>
+    <td>No</td>
+  </tr>
 </table>
 <h3>Note about <var>remotedir</var> attribute</h3>
 <table>
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java 
b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
index 3f45df7..8662993 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
@@ -115,7 +115,7 @@ public class FTP extends Task implements FTPTaskConfig {
     private String userid;
     private String password;
     private String account;
-    private boolean useFtps =false;
+    private boolean useFtps = false;
     private HostnameVerifier hostnameVerifier;
     private File listing;
     private boolean binary = true;
@@ -1268,15 +1268,16 @@ public class FTP extends Task implements FTPTaskConfig {
         this.userid = userid;
     }
 
+    /**
+     * Whether to use ftps instead of ftp.
+     *
+     * @since 1.10.13
+     */
     public void setUseFtps(boolean useFtps) {
         this.useFtps = useFtps;
     }
 
-    public HostnameVerifier getHostnameVerifier() {
-        return hostnameVerifier;
-    }
-
-    public void setHostnameVerifier(HostnameVerifier hostnameVerifier) {
+    public void add(HostnameVerifier hostnameVerifier) {
         this.hostnameVerifier = hostnameVerifier;
     }
 
@@ -2517,13 +2518,16 @@ public class FTP extends Task implements FTPTaskConfig {
         FTPClient ftp = null;
 
         try {
-            log("Opening FTP connection to " + server, Project.MSG_VERBOSE);
-            if( useFtps) {
-                ftp = new FTPSClient();
-                if(hostnameVerifier != null){
-                    ((FTPSClient)ftp).setHostnameVerifier(hostnameVerifier);
+            if (useFtps) {
+                log("Opening FTPs connection to " + server, 
Project.MSG_VERBOSE);
+                FTPSClient ftps = new FTPSClient();
+                ftps.setEndpointCheckingEnabled(true);
+                if (hostnameVerifier != null) {
+                    ftps.setHostnameVerifier(hostnameVerifier);
                 }
-            }else{
+                ftp = ftps;
+            } else {
+                log("Opening FTP connection to " + server, 
Project.MSG_VERBOSE);
                 ftp = new FTPClient();
             }
             if (this.isConfigurationSet) {

Reply via email to