Revision: 1042
          http://stripes.svn.sourceforge.net/stripes/?rev=1042&view=rev
Author:   fdaoud
Date:     2009-02-15 18:36:49 +0000 (Sun, 15 Feb 2009)

Log Message:
-----------
Fix for STS-521 (second part) with accompanying unit test

Modified Paths:
--------------
    
trunk/stripes/src/net/sourceforge/stripes/controller/DefaultActionBeanPropertyBinder.java
    
trunk/tests/src/net/sourceforge/stripes/validation/ValidationAnnotationsTest.java

Modified: 
trunk/stripes/src/net/sourceforge/stripes/controller/DefaultActionBeanPropertyBinder.java
===================================================================
--- 
trunk/stripes/src/net/sourceforge/stripes/controller/DefaultActionBeanPropertyBinder.java
   2009-02-12 20:29:20 UTC (rev 1041)
+++ 
trunk/stripes/src/net/sourceforge/stripes/controller/DefaultActionBeanPropertyBinder.java
   2009-02-15 18:36:49 UTC (rev 1042)
@@ -773,12 +773,12 @@
           : "Constructor(String) if available"));
 
         for (String value : values) {
+            if (validationInfo != null && validationInfo.encrypted()) {
+                value = CryptoUtil.decrypt(value);
+            }
+
             if (!"".equals(value)) {
                 try {
-                    if (validationInfo != null && validationInfo.encrypted()) {
-                        value = CryptoUtil.decrypt(value);
-                    }
-
                     Object retval = null;
                     if (converter != null) {
                         retval = converter.convert(value, returnType, errors);

Modified: 
trunk/tests/src/net/sourceforge/stripes/validation/ValidationAnnotationsTest.java
===================================================================
--- 
trunk/tests/src/net/sourceforge/stripes/validation/ValidationAnnotationsTest.java
   2009-02-12 20:29:20 UTC (rev 1041)
+++ 
trunk/tests/src/net/sourceforge/stripes/validation/ValidationAnnotationsTest.java
   2009-02-15 18:36:49 UTC (rev 1042)
@@ -8,6 +8,7 @@
 import net.sourceforge.stripes.extensions.MyIntegerTypeConverter;
 import net.sourceforge.stripes.extensions.MyStringTypeConverter;
 import net.sourceforge.stripes.mock.MockRoundtrip;
+import net.sourceforge.stripes.util.CryptoUtil;
 
 import org.testng.Assert;
 import org.testng.annotations.Test;
@@ -106,4 +107,23 @@
         Assert.assertEquals(actionBean.shouldBeUpperCased, "TEST");
         Assert.assertEquals(actionBean.shouldNotBeUpperCased, "test");
     }
+
+    @Validate(encrypted=true)
+    public String encryptedParam;
+
+    public Resolution validateEncrypted() { return null; }
+
+    /**
+     * Tests that an empty string encrypted value is bound as null.
+     *
+     * @see http://www.stripesframework.org/jira/browse/STS-521
+     */
+    @Test(groups="fast")
+    public void testValidateEncryptedEmptyString() throws Exception {
+        MockRoundtrip trip = new 
MockRoundtrip(StripesTestFixture.getServletContext(), getClass());
+        trip.addParameter("encryptedParam", CryptoUtil.encrypt(""));
+        trip.execute("validateEncrypted");
+        ValidationAnnotationsTest actionBean = trip.getActionBean(getClass());
+        Assert.assertNull(actionBean.encryptedParam);
+    }
 }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to