[jboss-cvs] JBossAS SVN: r95424 - trunk/console/src/main/java/org/jboss/console/twiddle.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Oct 22 12:16:58 EDT 2009
Author: mmoyses
Date: 2009-10-22 12:16:56 -0400 (Thu, 22 Oct 2009)
New Revision: 95424
Modified:
trunk/console/src/main/java/org/jboss/console/twiddle/Twiddle.java
Log:
JBAS-7307: masking all variations of password argument
Modified: trunk/console/src/main/java/org/jboss/console/twiddle/Twiddle.java
===================================================================
--- trunk/console/src/main/java/org/jboss/console/twiddle/Twiddle.java 2009-10-22 16:08:49 UTC (rev 95423)
+++ trunk/console/src/main/java/org/jboss/console/twiddle/Twiddle.java 2009-10-22 16:16:56 UTC (rev 95424)
@@ -404,18 +404,8 @@
{
for(int a = 0; a < args.length; a ++)
{
- //masks password
- try {
- if (args[a-1].equals("-p"))
- log.debug("args["+a+"]=xxxx");
- else
- log.debug("args["+a+"]="+args[a]);
- }
- catch (IndexOutOfBoundsException ioobe)
- {
- //takes care of the first argument
+ if (!logPassword(args, a))
log.debug("args["+a+"]="+args[a]);
- }
}
String sopts = "-:hH:u:p:c:D:s:a:q";
LongOpt[] lopts =
@@ -553,4 +543,35 @@
}
}
}
+
+ private static boolean logPassword(final String args[], int a)
+ {
+ // check current argument
+ if (args[a].startsWith("-p") && args[a].length() > 2)
+ {
+ log.debug("args["+a+"]=-pxxxx");
+ return true;
+ }
+ else if (args[a].indexOf('=') != -1)
+ {
+ String[] split = args[a].split("=");
+ if ("--password".indexOf(split[0]) != -1)
+ {
+ log.debug("args["+a+"]="+split[0]+"=xxxx");
+ return true;
+ }
+ }
+ // check previous argument
+ try {
+ if (args[a-1].equals("-p") || (args[a-1].indexOf('=') == -1 && "--password".indexOf(args[a-1]) != -1))
+ {
+ log.debug("args["+a+"]=xxxx");
+ return true;
+ }
+ }
+ catch (IndexOutOfBoundsException ioobe)
+ {
+ }
+ return false;
+ }
}
More information about the jboss-cvs-commits
mailing list