mbenson 2005/02/10 14:32:21
Modified: . WHATSNEW
docs/manual/CoreTypes redirector.html
src/main/org/apache/tools/ant/taskdefs Redirector.java
src/main/org/apache/tools/ant/types RedirectorElement.java
src/testcases/org/apache/tools/ant/types
RedirectorElementTest.java
src/etc/testcases/types redirector.xml
Log:
Added loginputstring attribute to redirector.
Revision Changes Path
1.744 +2 -0 ant/WHATSNEW
Index: WHATSNEW
===================================================================
RCS file: /home/cvs/ant/WHATSNEW,v
retrieving revision 1.743
retrieving revision 1.744
diff -u -r1.743 -r1.744
--- WHATSNEW 10 Feb 2005 21:10:10 -0000 1.743
+++ WHATSNEW 10 Feb 2005 22:32:20 -0000 1.744
@@ -108,6 +108,8 @@
* zip/jar/war/ear supports level attribute for deflate compression level.
Bugzilla report 25513.
+* Added loginputstring attribute to the redirector type.
+
Changes from Ant 1.6.2 to current Ant 1.6 CVS version
=====================================================
1.5 +11 -4 ant/docs/manual/CoreTypes/redirector.html
Index: redirector.html
===================================================================
RCS file: /home/cvs/ant/docs/manual/CoreTypes/redirector.html,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- redirector.html 19 Nov 2004 09:07:10 -0000 1.4
+++ redirector.html 10 Feb 2005 22:32:20 -0000 1.5
@@ -107,10 +107,17 @@
<tr>
<td valign="top">alwayslog</td>
<td valign="top">Always send to the log in addition to
- any other destination. Default <code>false</code>.
- <i>Since Ant 1.6.3</i>.
+ any other destination. <i>Since Ant 1.6.3</i>.
</td>
- <td align="center" valign="top">No</td>
+ <td align="center" valign="top">No, default is <code>false</code></td>
+ </tr>
+ <tr>
+ <td valign="top">loginputstring</td>
+ <td valign="top">Controls the display of <i>inputstring</i>'s value in
+ log messages. Set to <code>false</code> when sending sensitive data
+ (e.g. passwords) to external processes. <i>Since Ant 1.6.3</i>.
+ </td>
+ <td align="center" valign="top">No, default is <code>true</code></td>
</tr>
</table>
<h3>Parameters specified as nested elements</h3>
@@ -153,7 +160,7 @@
dependent on the supporting task. Any possible points of confusion
should be noted at the task level.</p>
<hr />
-<p align="center">Copyright © 2004 The Apache Software Foundation. All
rights
+<p align="center">Copyright © 2004-2005 The Apache Software Foundation.
All rights
Reserved.</p>
</body>
1.26 +20 -2
ant/src/main/org/apache/tools/ant/taskdefs/Redirector.java
Index: Redirector.java
===================================================================
RCS file:
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Redirector.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- Redirector.java 2 Feb 2005 12:52:47 -0000 1.25
+++ Redirector.java 10 Feb 2005 22:32:20 -0000 1.26
@@ -167,6 +167,9 @@
/** The thread group used for starting <code>StreamPumper</code> threads
*/
private ThreadGroup threadGroup = new ThreadGroup("redirector");
+ /** whether to log the inputstring */
+ private boolean logInputString = true;
+
/**
* Create a redirector instance for the given task
*
@@ -215,6 +218,16 @@
}
/**
+ * Set whether to include the value of the input string in log messages.
+ * Defaults to true.
+ * @param logInputString true or false.
+ * @since Ant 1.7
+ */
+ public void setLogInputString(boolean logInputString) {
+ this.logInputString = logInputString;
+ }
+
+ /**
* Set a stream to use as input.
*
* @param inputStream the stream from which input will be read
@@ -577,8 +590,13 @@
}
((ConcatFileInputStream)
inputStream).setManagingComponent(managingTask);
} else if (inputString != null) {
- managingTask.log("Using input \"" + inputString + "\"",
- Project.MSG_VERBOSE);
+ StringBuffer buf = new StringBuffer("Using input ");
+ if (logInputString) {
+ buf.append('"').append(inputString).append('"');
+ } else {
+ buf.append("string");
+ }
+ managingTask.log(buf.toString(), Project.MSG_VERBOSE);
inputStream = new ByteArrayInputStream(inputString.getBytes());
}
1.5 +19 -1
ant/src/main/org/apache/tools/ant/types/RedirectorElement.java
Index: RedirectorElement.java
===================================================================
RCS file:
/home/cvs/ant/src/main/org/apache/tools/ant/types/RedirectorElement.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- RedirectorElement.java 22 Nov 2004 09:23:36 -0000 1.4
+++ RedirectorElement.java 10 Feb 2005 22:32:20 -0000 1.5
@@ -1,5 +1,5 @@
/*
- * Copyright 2004 The Apache Software Foundation.
+ * Copyright 2004-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -98,6 +98,9 @@
/** The input encoding */
private String inputEncoding;
+ /** whether to log the inputstring */
+ private Boolean logInputString;
+
/**
* Add the input file mapper.
* @param inputMapper <CODE>Mapper</CODE>.
@@ -210,6 +213,18 @@
this.inputString = inputString;
}
+ /**
+ * Set whether to include the value of the input string in log messages.
+ * Defaults to true.
+ * @param logInputString true or false.
+ * @since Ant 1.7
+ */
+ public void setLogInputString(boolean logInputString) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ this.logInputString = logInputString ? Boolean.TRUE : Boolean.FALSE;
+ }
/**
* File the output of the process is redirected to. If error is not
@@ -439,6 +454,9 @@
if (inputString != null) {
redirector.setInputString(inputString);
}
+ if (logInputString != null) {
+ redirector.setLogInputString(logInputString.booleanValue());
+ }
if (inputMapper != null) {
String[] inputTargets = null;
try {
1.2 +7 -2
ant/src/testcases/org/apache/tools/ant/types/RedirectorElementTest.java
Index: RedirectorElementTest.java
===================================================================
RCS file:
/home/cvs/ant/src/testcases/org/apache/tools/ant/types/RedirectorElementTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RedirectorElementTest.java 27 Mar 2004 21:33:49 -0000 1.1
+++ RedirectorElementTest.java 10 Feb 2005 22:32:20 -0000 1.2
@@ -1,5 +1,5 @@
/*
- * Copyright 2004 The Apache Software Foundation.
+ * Copyright 2004-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
*/
package org.apache.tools.ant.types;
+import org.apache.tools.ant.Project;
import org.apache.tools.ant.BuildFileTest;
public class RedirectorElementTest extends BuildFileTest {
@@ -25,7 +26,7 @@
}
public void setUp() {
- configureProject("src/etc/testcases/types/redirector.xml");
+ configureProject("src/etc/testcases/types/redirector.xml",
Project.MSG_VERBOSE);
}
public void test1() {
@@ -48,4 +49,8 @@
executeTarget("test4");
}
+ public void testLogInputString() {
+ executeTarget("testLogInputString");
+ assertDebuglogContaining("Using input string");
+ }
}
1.3 +17 -0 ant/src/etc/testcases/types/redirector.xml
Index: redirector.xml
===================================================================
RCS file: /home/cvs/ant/src/etc/testcases/types/redirector.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- redirector.xml 10 Feb 2005 20:34:06 -0000 1.2
+++ redirector.xml 10 Feb 2005 22:32:21 -0000 1.3
@@ -21,4 +21,21 @@
</redirector>
</target>
+ <target name="testLogInputString" depends="cat-check" if="can-cat">
+ <exec executable="cat">
+ <redirector inputstring="foo" loginputstring="false" />
+ </exec>
+ </target>
+
+ <target name="cat-check">
+ <property environment="env" />
+ <condition property="can-cat">
+ <or>
+ <available file="cat" filepath="${env.PATH}" property="can-cat" />
+ <available file="cat.exe" filepath="${env.PATH}" property="can-cat"
/>
+ <available file="cat.exe" filepath="${env.Path}" property="can-cat"
/>
+ </or>
+ </condition>
+ </target>
+
</project>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]