Ant secureInputHandler: requires the user to press enter before accepting input

I use SecureInputHandler to receive passwords from the end user in an ant script, but it forces the user to press Enter before he allows text input. Is this expected behavior? Also, I did not find much documentation on this topic, please feel free to point me any resources on this.

<input message="Please enter password:" addproperty="password.property"> <handler classname="org.apache.tools.ant.input.SecureInputHandler" /> </input> 
+4
source share
2 answers

SecureInputHandler requires Ant 1.7.1 or higher (to support the handler) and Java 6 or higher (to provide the Console class).

If you do not have the correct version of Ant, you will receive an error message. If you do not have the correct version of Java, Ant reverts to the default input handler.

Please note that you can also use:

 <handler type="secure"/> 

Javadoc and source can be seen here .

Using Ant 1.8.2 and Java 1.6 in the windows cmd command shell, I get the following:

 test: Please enter password:<cursor here> 

Password is masked. You enter the password and press Enter .

Using the Cygwin shell or Java 1.5 in the CMD shell, I get the following:

 test: [input] Please enter password: <cursor here> 

Password is not masked. You enter the password and press Enter .

Using the Eclipse console, I could not get the password for input at all. I print, it appears on the console, I press Enter , nothing happens.

I notice that in the Input documentation the task reads:

IDE behavior is dependent on the IDE: some freeze while waiting for input, some let you enter it. In this situation, put the password in the (secure) properties file and load it before setting the input.

In other words, it may not work in the IDE, use the work.

+4
source

exec interfered with input tasks. It can be solved by specifying inputstring="" in the exec task. See exec causes other tasks to freeze or lead to strange behavior of <input> tasks in Ant Frequently Asked Questions .

0
source

Source: https://habr.com/ru/post/1383670/


All Articles