commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joe...@apache.org
Subject svn commit: r1448560 - in /commons/proper/vfs/trunk: core/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpClientFactory.java src/changes/changes.xml
Date Thu, 21 Feb 2013 09:25:37 GMT
Author: joehni
Date: Thu Feb 21 09:25:37 2013
New Revision: 1448560

URL: http://svn.apache.org/r1448560
Log:
Sent FTP/FTPS commands and the received answer is logged at debug level (VFS-459).

Modified:
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpClientFactory.java
    commons/proper/vfs/trunk/src/changes/changes.xml

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpClientFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpClientFactory.java?rev=1448560&r1=1448559&r2=1448560&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpClientFactory.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpClientFactory.java
Thu Feb 21 09:25:37 2013
@@ -17,7 +17,13 @@
 package org.apache.commons.vfs2.provider.ftp;
 
 import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.Writer;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.net.PrintCommandListener;
 import org.apache.commons.net.ftp.FTPClient;
 import org.apache.commons.net.ftp.FTPClientConfig;
 import org.apache.commons.net.ftp.FTPReply;
@@ -72,6 +78,7 @@ public final class FtpClientFactory
         private static final char[] ANON_CHAR_ARRAY = "anonymous".toCharArray();
     	private static final int BUFSZ = 40;
 
+    	protected Log log = LogFactory.getLog(getClass());
     	protected B builder;
 
         protected ConnectionFactory(B builder)
@@ -97,6 +104,23 @@ public final class FtpClientFactory
 	        {
 	            final C client = createClient(fileSystemOptions);
 	
+	            if (log.isDebugEnabled()) {
+					final Writer writer = new StringWriter(1024){
+						@Override
+						public void flush()
+						{
+							final StringBuffer buffer = getBuffer();
+							String message = buffer.toString();
+							if (message.toUpperCase().startsWith("PASS ") && message.length() > 5)
{
+								message = "PASS ***";
+							}
+							log.debug(message);
+							buffer.setLength(0);
+						}
+	            	};
+	            	client.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(writer)));
+	            }
+	            
 	            configureClient(fileSystemOptions, client);
 	
 				final FTPFileEntryParserFactory myFactory =

Modified: commons/proper/vfs/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/src/changes/changes.xml?rev=1448560&r1=1448559&r2=1448560&view=diff
==============================================================================
--- commons/proper/vfs/trunk/src/changes/changes.xml (original)
+++ commons/proper/vfs/trunk/src/changes/changes.xml Thu Feb 21 09:25:37 2013
@@ -26,7 +26,10 @@
 <!--       <action issue="VFS-443" dev="ggregory" type="update" due-to="nickallen">
-->
 <!--     	[Local] Need an easy way to convert from a FileObject to a File. -->
 <!--       </action> -->
-      <action issue="VFS-458" dev="jos" type="fix">
+      <action issue="VFS-459" dev="joehni" type="update">
+        Sent FTP/FTPS commands and the received answer is logged at debug level.
+      </action>
+      <action issue="VFS-458" dev="joehni" type="fix">
         FTPS provider missed functionality and bug fixes already available for the FTP provider.
       </action>
       <action issue="VFS-452" dev="ggregory" type="fix" due-to="Jean-Marc Borer">



Mime
View raw message