The class org.jboss.security.integration.password.PasswordTool is called from the command-line script $JBOSS_DIST/bin/password_tool.sh to perform command-line processing of user options when creating a security domain password file to be using in password masking (i.e. the @Password annotation included in bean deployment descriptors).
QA wants to automate the testing of the password_tool.sh script, but the current implementation of PasswordTool.java prevents this.
We want to be able to execute password_tool.sh, for example, as follows:
> cd $DIST_JBOSS/bin
> echo "0 password alongsaltstring 4 1 password/server.keystore jboss 5" | ./password_tool.sh
This command string would perform option 0, followed by option 1, followed by option 5. By capturing and parsing the output, we can check if the shell script is performing correctly.
The problem is that the line
Scanner in = new Scanner(System.in) ;
is placed within the command processing loop, and after the processing of the first command and its arguments, it re-initialises the input stream and loses the subsequent commands and their arguments. This prevents us from easily automating the testing of this shell script.
Moving the command just outside the while loop fixes the problem.
I'd like to ask that this line be moved so that we can automate the testing of this script.