Revision: 1281
Author:   mathiasbr
Date:     2006-08-07 14:18:43 -0700 (Mon, 07 Aug 2006)
ViewCVS:  http://svn.sourceforge.net/spring-rich-c/?rev=1281&view=rev

Log Message:
-----------
added support for protectable fields whose values should not be revealed to the 
user or log reader
see RCP-312

Modified Paths:
--------------
    
trunk/spring-richclient/support/src/main/java/org/springframework/binding/form/support/DefaultBindingErrorMessageProvider.java
    
trunk/spring-richclient/support/src/main/java/org/springframework/binding/form/support/DefaultFormModel.java

Added Paths:
-----------
    
trunk/spring-richclient/support/src/main/java/org/springframework/binding/form/support/UserMetadata.java
Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/form/support/DefaultBindingErrorMessageProvider.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/form/support/DefaultBindingErrorMessageProvider.java
      2006-08-07 19:03:37 UTC (rev 1280)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/form/support/DefaultBindingErrorMessageProvider.java
      2006-08-07 21:18:43 UTC (rev 1281)
@@ -48,7 +48,7 @@
     public ValidationMessage getErrorMessage(FormModel formModel, String 
propertyName, Object valueBeingSet, Exception e) {
         String messageCode = getMessageCodeForException(e);
         Object[] args = new Object[] 
{formModel.getFieldFace(propertyName).getDisplayName(),
-                valueBeingSet};
+                UserMetadata.isFieldProtected(formModel, propertyName) ? "***" 
: valueBeingSet};
         String message = getMessageSourceAccessor().getMessage(messageCode, 
args, messageCode);
         return new DefaultValidationMessage(propertyName, Severity.ERROR, 
message);
     }
@@ -73,4 +73,4 @@
             return "unknown";
         }
     }
-}
\ No newline at end of file
+    }
\ No newline at end of file

Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/form/support/DefaultFormModel.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/form/support/DefaultFormModel.java
        2006-08-07 19:03:37 UTC (rev 1280)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/form/support/DefaultFormModel.java
        2006-08-07 21:18:43 UTC (rev 1281)
@@ -22,6 +22,7 @@
 
 import org.springframework.binding.MutablePropertyAccessStrategy;
 import org.springframework.binding.form.BindingErrorMessageProvider;
+import org.springframework.binding.form.FieldMetadata;
 import org.springframework.binding.form.ValidatingFormModel;
 import org.springframework.binding.validation.DefaultValidationResults;
 import org.springframework.binding.validation.DefaultValidationResultsModel;
@@ -64,7 +65,7 @@
     private boolean oldValidating = true;
 
     private Validator validator;
-
+    
     private BindingErrorMessageProvider bindingErrorMessageProvider = new 
DefaultBindingErrorMessageProvider();
 
     public DefaultFormModel() {
@@ -305,8 +306,9 @@
             try {
                 if (logger.isDebugEnabled()) {
                     Class valueClass = (value != null ? value.getClass() : 
null);
-                    logger.debug("Setting '" + formProperty + "' value to 
convert/validate '" + value + "', class="
-                            + valueClass);
+                    logger.debug("Setting '" + formProperty + "' value to 
convert/validate '"
+                            + 
(UserMetadata.isFieldProtected(DefaultFormModel.this, formProperty) ? "***" : 
value)
+                            + "', class=" + valueClass);
                 }
                 super.setValueSilently(value, listenerToSkip);
                 clearBindingError(this);

Added: 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/form/support/UserMetadata.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/form/support/UserMetadata.java
                            (rev 0)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/form/support/UserMetadata.java
    2006-08-07 21:18:43 UTC (rev 1281)
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy 
of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.springframework.binding.form.support;
+
+import org.springframework.binding.form.FieldMetadata;
+import org.springframework.binding.form.FormModel;
+
+
+/**
+ * Class which holds keys for user metadata used in spring rich
+ * 
+ * @author Mathias Broekelmann
+ * 
+ */
+public abstract class UserMetadata {
+    /**
+     * The name of a user metadata value which is used to determine if a value 
for a form field is protected and should
+     * be hidden on logging or error messages.
+     * <p>
+     * The value must be an instance of [EMAIL PROTECTED] Boolean}, if true 
any value of the field will not be displayed either
+     * through logging or showing value errors
+     */
+    public static final String PROTECTED_FIELD = UserMetadata.class.getName() 
+ ".ProtectedField";
+
+    /**
+     * tests if the usermetadata of the field has a boolean value true for the 
key [EMAIL PROTECTED] #PROTECTED_FIELD}
+     * 
+     * @param fieldName
+     *            the fieldname
+     * @return true if the field is protected, otherwise false
+     */
+    public static boolean isFieldProtected(FormModel formModel, String 
fieldName) {
+        FieldMetadata metaData = formModel.getFieldMetadata(fieldName);
+        return 
Boolean.TRUE.equals(metaData.getUserMetadata(UserMetadata.PROTECTED_FIELD));
+    }
+}


Property changes on: 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/form/support/UserMetadata.java
___________________________________________________________________
Name: svn:keywords
   + Revision Author Date Id
Name: svn:eol-style
   + native


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


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
spring-rich-c-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs

Reply via email to