[jboss-cvs] Picketbox SVN: r492 - in trunk/security-jboss-sx/jbosssx/src: test/java/org/jboss/test/security/helpers and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jan 7 11:05:02 EST 2014


Author: pskopek at redhat.com
Date: 2014-01-07 11:05:00 -0500 (Tue, 07 Jan 2014)
New Revision: 492

Modified:
   trunk/security-jboss-sx/jbosssx/src/main/java/org/jboss/security/Util.java
   trunk/security-jboss-sx/jbosssx/src/test/java/org/jboss/test/security/helpers/SecurityUtilUnitTestCase.java
Log:
[SECURITY-780] Fixing {EXTC:timeout} detection problem.

Modified: trunk/security-jboss-sx/jbosssx/src/main/java/org/jboss/security/Util.java
===================================================================
--- trunk/security-jboss-sx/jbosssx/src/main/java/org/jboss/security/Util.java	2014-01-06 21:35:29 UTC (rev 491)
+++ trunk/security-jboss-sx/jbosssx/src/main/java/org/jboss/security/Util.java	2014-01-07 16:05:00 UTC (rev 492)
@@ -379,7 +379,7 @@
    {
       return (passwordCmd != null)
             && (passwordCmd.startsWith("{EXT}")
-                  || passwordCmd.startsWith("{EXTC}")
+                  || passwordCmd.startsWith("{EXTC")  // it has to be without closing brace to cover :<time in millis>
                   || passwordCmd.startsWith("{CMD}")
                   || passwordCmd.startsWith("{CMDC}")
                   || passwordCmd.startsWith("{CLASS}"));

Modified: trunk/security-jboss-sx/jbosssx/src/test/java/org/jboss/test/security/helpers/SecurityUtilUnitTestCase.java
===================================================================
--- trunk/security-jboss-sx/jbosssx/src/test/java/org/jboss/test/security/helpers/SecurityUtilUnitTestCase.java	2014-01-06 21:35:29 UTC (rev 491)
+++ trunk/security-jboss-sx/jbosssx/src/test/java/org/jboss/test/security/helpers/SecurityUtilUnitTestCase.java	2014-01-07 16:05:00 UTC (rev 492)
@@ -86,6 +86,9 @@
    {
       String passwordCmd = "{CLASS}org.jboss.security.plugins.TmpFilePassword:${java.io.tmpdir}/tmp.password";
       passwordCmd = StringPropertyReplacer.replaceProperties(passwordCmd);
+      if (!Util.isPasswordCommand(passwordCmd)) {
+         fail(passwordCmd + " should be treated as external password with comand");
+      }
       char[] password = Util.loadPassword(passwordCmd);
       assertTrue("password1", Arrays.equals(password, "password1".toCharArray()));
    }
@@ -97,6 +100,9 @@
    {
       String passwordCmd = "{CLASS}org.jboss.security.plugins.FilePassword:${java.io.tmpdir}/tst.password";
       passwordCmd = StringPropertyReplacer.replaceProperties(passwordCmd);
+      if (!Util.isPasswordCommand(passwordCmd)) {
+         fail(passwordCmd + " should be treated as class call password");
+      }
       char[] password = Util.loadPassword(passwordCmd);
       assertTrue("password2", Arrays.equals(password, "password2".toCharArray()));
    }
@@ -108,6 +114,9 @@
    {
       String passwordCmd = buildExtCommand("EXT");
       log.info("Executing password command:" + passwordCmd);
+      if (!Util.isPasswordCommand(passwordCmd)) {
+         fail(passwordCmd + " should be treated as external password with comand");
+      }
       char[] password = Util.loadPassword(passwordCmd);
       assertTrue("password3", Arrays.equals(password, "password3".toCharArray()));
    }
@@ -119,6 +128,9 @@
       
       String passwordCmd = buildExtCommand("EXTC");
       char[] password = Util.loadPassword(passwordCmd + " 4");
+      if (!Util.isPasswordCommand(passwordCmd)) {
+         fail(passwordCmd + " should be treated as external password with comand");
+      }
       assertTrue("password4", Arrays.equals(password, "password4".toCharArray()));
       char[] cachedPassword = Util.loadPassword(passwordCmd + " 4");
       assertTrue("password4 cached:1", Arrays.equals(password, "password4".toCharArray()));
@@ -147,6 +159,9 @@
       final String TO = "500";
       
       String passwordCmd = buildExtCommand("EXTC:" + TO);
+      if (!Util.isPasswordCommand(passwordCmd)) {
+         fail(passwordCmd + " should be treated as external password with comand");
+      }
       char[] password4 = Util.loadPassword(passwordCmd + " 4 timeOut");
       assertTrue("password4 timeOut = " + TO, Arrays.equals(new String(password4).substring(0,  9).toCharArray(), "password4".toCharArray()));
 
@@ -179,6 +194,9 @@
    public void testCmdPassword() throws Exception
    {
       String passwordCmd = buildExtCommand("CMD", ',');
+      if (!Util.isPasswordCommand(passwordCmd)) {
+         fail(passwordCmd + " should be treated as external password with comand");
+      }
       log.info("Executing password command:" + passwordCmd);
       char[] password = Util.loadPassword(passwordCmd);
       assertTrue("password3", Arrays.equals(password, "password3".toCharArray()));



More information about the jboss-cvs-commits mailing list