struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject svn commit: r1487092 - in /struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2: interceptor/ParametersInterceptor.java ognl/OgnlValueStack.java ognl/PropertiesJudge.java ognl/SecurityMemberAccess.java util/MemberAccessValueStack.java
Date Tue, 28 May 2013 20:14:16 GMT
Author: lukaszlenart
Date: Tue May 28 20:14:15 2013
New Revision: 1487092

URL: http://svn.apache.org/r1487092
Log:
WW-4083 Extends support of ParametersNameAware to pass the same behaviour to OgnlValueStack

Added:
    struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/PropertiesJudge.java
Modified:
    struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java
    struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java
    struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/SecurityMemberAccess.java
    struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/MemberAccessValueStack.java

Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java?rev=1487092&r1=1487091&r2=1487092&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java
(original)
+++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java
Tue May 28 20:14:15 2013
@@ -22,23 +22,13 @@ import com.opensymphony.xwork2.XWorkCons
 import com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler;
 import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
 import com.opensymphony.xwork2.inject.Inject;
-import com.opensymphony.xwork2.util.ArrayUtils;
-import com.opensymphony.xwork2.util.ClearableValueStack;
-import com.opensymphony.xwork2.util.LocalizedTextUtil;
-import com.opensymphony.xwork2.util.MemberAccessValueStack;
-import com.opensymphony.xwork2.util.ValueStack;
-import com.opensymphony.xwork2.util.ValueStackFactory;
+import com.opensymphony.xwork2.ognl.PropertiesJudge;
+import com.opensymphony.xwork2.util.*;
 import com.opensymphony.xwork2.util.logging.Logger;
 import com.opensymphony.xwork2.util.logging.LoggerFactory;
 import com.opensymphony.xwork2.util.reflection.ReflectionContextState;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
+import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -272,7 +262,7 @@ public class ParametersInterceptor exten
     protected void addParametersToContext(ActionContext ac, Map<String, Object> newParams)
{
     }
 
-    protected void setParameters(Object action, ValueStack stack, final Map<String, Object>
parameters) {
+    protected void setParameters(final Object action, ValueStack stack, final Map<String,
Object> parameters) {
         Map<String, Object> params;
         Map<String, Object> acceptableParameters;
         if (ordered) {
@@ -313,6 +303,12 @@ public class ParametersInterceptor exten
             MemberAccessValueStack accessValueStack = (MemberAccessValueStack) newStack;
             accessValueStack.setAcceptProperties(acceptParams);
             accessValueStack.setExcludeProperties(excludeParams);
+            if (action instanceof ParameterNameAware)
+            accessValueStack.setPropertiesJudge(new PropertiesJudge() {
+                public boolean acceptProperty(String propertyName) {
+                    return ((ParameterNameAware) action).acceptableParameterName(propertyName);
+                }
+            });
         }
 
         for (Map.Entry<String, Object> entry : acceptableParameters.entrySet()) {

Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java?rev=1487092&r1=1487091&r2=1487092&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java
(original)
+++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java
Tue May 28 20:14:15 2013
@@ -31,11 +31,7 @@ import com.opensymphony.xwork2.util.logg
 import com.opensymphony.xwork2.util.logging.LoggerFactory;
 import com.opensymphony.xwork2.util.logging.LoggerUtils;
 import com.opensymphony.xwork2.util.reflection.ReflectionContextState;
-import ognl.NoSuchPropertyException;
-import ognl.Ognl;
-import ognl.OgnlContext;
-import ognl.OgnlException;
-import ognl.PropertyAccessor;
+import ognl.*;
 
 import java.io.Serializable;
 import java.util.HashMap;
@@ -463,6 +459,10 @@ public class OgnlValueStack implements S
         securityMemberAccess.setAcceptProperties(acceptedProperties);
     }
 
+    public void setPropertiesJudge(PropertiesJudge judge) {
+        securityMemberAccess.setPropertiesJudge(judge);
+    }
+
     public void setExcludeProperties(Set<Pattern> excludeProperties) {
         securityMemberAccess.setExcludeProperties(excludeProperties);
     }

Added: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/PropertiesJudge.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/PropertiesJudge.java?rev=1487092&view=auto
==============================================================================
--- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/PropertiesJudge.java
(added)
+++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/PropertiesJudge.java
Tue May 28 20:14:15 2013
@@ -0,0 +1,7 @@
+package com.opensymphony.xwork2.ognl;
+
+public interface PropertiesJudge {
+
+    boolean acceptProperty(String propertyName);
+
+}

Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/SecurityMemberAccess.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/SecurityMemberAccess.java?rev=1487092&r1=1487091&r2=1487092&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/SecurityMemberAccess.java
(original)
+++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/SecurityMemberAccess.java
Tue May 28 20:14:15 2013
@@ -33,8 +33,9 @@ import java.util.regex.Pattern;
 public class SecurityMemberAccess extends DefaultMemberAccess {
 
     private final boolean allowStaticMethodAccess;
-    Set<Pattern> excludeProperties = Collections.emptySet();
-    Set<Pattern> acceptProperties = Collections.emptySet();
+    private Set<Pattern> excludeProperties = Collections.emptySet();
+    private Set<Pattern> acceptProperties = Collections.emptySet();
+    private PropertiesJudge propertiesJudge;
 
     public SecurityMemberAccess(boolean method) {
         super(false);
@@ -79,7 +80,7 @@ public class SecurityMemberAccess extend
             return true;
         }
 
-        if (isAccepted(name) && !isExcluded(name)) {
+        if ((isAccepted(name) && !isExcluded(name)) || (propertiesJudge != null &&
propertiesJudge.acceptProperty(name))) {
             return true;
         }
         return false;
@@ -121,4 +122,8 @@ public class SecurityMemberAccess extend
     public void setAcceptProperties(Set<Pattern> acceptedProperties) {
         this.acceptProperties = acceptedProperties;
     }
+
+    public void setPropertiesJudge(PropertiesJudge judge) {
+        this.propertiesJudge = judge;
+    }
 }

Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/MemberAccessValueStack.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/MemberAccessValueStack.java?rev=1487092&r1=1487091&r2=1487092&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/MemberAccessValueStack.java
(original)
+++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/MemberAccessValueStack.java
Tue May 28 20:14:15 2013
@@ -1,5 +1,7 @@
 package com.opensymphony.xwork2.util;
 
+import com.opensymphony.xwork2.ognl.PropertiesJudge;
+
 import java.util.Set;
 import java.util.regex.Pattern;
 
@@ -8,7 +10,11 @@ import java.util.regex.Pattern;
  * to properties using regular expressions
  */
 public interface MemberAccessValueStack {
+
     void setExcludeProperties(Set<Pattern> excludeProperties);
 
     void setAcceptProperties(Set<Pattern> acceptedProperties);
+
+    void setPropertiesJudge(PropertiesJudge judge);
+
 }



Mime
View raw message