svn commit: r1604967 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1604967 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java

doogie-3
Author: doogie
Date: Tue Jun 24 00:23:11 2014
New Revision: 1604967

URL: http://svn.apache.org/r1604967
Log:
Fix EntityExpr encryptConditionFields; in normal use, lhs would never be
a String, because it would end up being wrapped in an EntityFieldValue
object.  The only way it would be a String is during incorrect
Freemarker lookups(which no longer happen, as the
EntityCondition.makeCondition factory pattern is now in use).

With this fix in place, EntityExpr can finally start encrypting it's
field values, so that direct matching on encrypted fields can work.

This is part one to fix OFBIZ-5959: Person.socialSecurityNumber can't be
used for findByAnd.

Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java?rev=1604967&r1=1604966&r2=1604967&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java Tue Jun 24 00:23:11 2014
@@ -160,16 +160,22 @@ public class EntityExpr extends EntityCo
 
     @Override
     public void encryptConditionFields(ModelEntity modelEntity, Delegator delegator) {
+        if (rhs instanceof EntityConditionValue) {
+            return;
+        }
+        ModelField modelField;
         if (this.lhs instanceof String) {
-            ModelField modelField = modelEntity.getField((String) this.lhs);
-            if (modelField != null && modelField.getEncrypt()) {
-                if (!(rhs instanceof EntityConditionValue)) {
-                    try {
-                        this.rhs = delegator.encryptFieldValue(modelEntity.getEntityName(), this.rhs);
-                    } catch (EntityCryptoException e) {
-                        Debug.logWarning(e, "Error encrypting field [" + modelEntity.getEntityName() + "." + modelField.getName() + "] with value: " + this.rhs, module);
-                    }
-                }
+            modelField = modelEntity.getField((String) this.lhs);
+        } else if (this.lhs instanceof EntityFieldValue) {
+            modelField = ((EntityFieldValue) this.lhs).getModelField(modelEntity);
+        } else {
+            return;
+        }
+        if (modelField != null && modelField.getEncrypt()) {
+            try {
+                this.rhs = delegator.encryptFieldValue(modelEntity.getEntityName(), this.rhs);
+            } catch (EntityCryptoException e) {
+                Debug.logWarning(e, "Error encrypting field [" + modelEntity.getEntityName() + "." + modelField.getName() + "] with value: " + this.rhs, module);
             }
         }
     }