From d7c3883e533c667d6d09d775b25b6d4c2d0bc41e Mon Sep 17 00:00:00 2001
From: Matthew Jason Benson <input>
will not prompt for input if
a property should be set by the task that has already been set in the
project (and the task wouldn't have any effect).
A regular complaint about this task is that it echoes characters to the -console, this is a critical security defect, we must fix it immediately, etc, etc. -We know it leaves something to be desired, but the problem is Java, not Ant. -There is nothing we can do to stop the console echoing.
+Historically, a regular complaint about this task has been that it echoes +characters to the console, this is a critical security defect, we must fix it +immediately, etc, etc. This problem was due to the lack in early versions of +Java of a (fully functional) facility for handling secure console input. +In Java 1.6 that shortcoming in Java's API was addressed and Ant versions 1.7.1 +and 1.8 have added support for Java 1.6's secure console input feature +(see handler type).
IDE behaviour depends upon the IDE: some hang waiting for input, some let you @@ -107,8 +110,8 @@ among different Input tasks.
ANT_OPTS
environment variable.
input. However, it consumes all available input. This behavior is
useful for sending Ant input via an OS pipe. Since Ant 1.7.
+This InputHandler calls System.console().readPassword()
,
+available since Java 1.6. On earlier platforms it falls back to the
+behavior of DefaultInputHandler. Since Ant 1.7.1.
Instances of org.apache.tools.ant.input.InputRequest
diff --git a/src/main/org/apache/tools/ant/taskdefs/Input.java b/src/main/org/apache/tools/ant/taskdefs/Input.java
index 72479c44d..11817a75f 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Input.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Input.java
@@ -28,6 +28,7 @@ import org.apache.tools.ant.input.InputHandler;
import org.apache.tools.ant.input.InputRequest;
import org.apache.tools.ant.input.MultipleChoiceInputRequest;
import org.apache.tools.ant.input.PropertyFileInputHandler;
+import org.apache.tools.ant.input.SecureInputHandler;
import org.apache.tools.ant.types.EnumeratedAttribute;
import org.apache.tools.ant.util.ClasspathUtils;
import org.apache.tools.ant.util.StringUtils;
@@ -116,16 +117,16 @@ public class Input extends Task {
/**
* EnumeratedAttribute representing the built-in input handler types:
- * "default", "propertyfile", "greedy".
+ * "default", "propertyfile", "greedy", "secure" (since Ant 1.8).
*/
public static class HandlerType extends EnumeratedAttribute {
- private static final String[] VALUES
- = {"default", "propertyfile", "greedy"};
+ private static final String[] VALUES = { "default", "propertyfile", "greedy", "secure" };
private static final InputHandler[] HANDLERS
- = {new DefaultInputHandler(),
+ = { new DefaultInputHandler(),
new PropertyFileInputHandler(),
- new GreedyInputHandler()};
+ new GreedyInputHandler(),
+ new SecureInputHandler() };
/** {@inheritDoc} */
public String[] getValues() {