This is an automated email from the ASF dual-hosted git repository.
lukaszlenart pushed a commit to branch WW-5054-debug-browser
in repository https://gitbox.apache.org/repos/asf/struts.git
commit 8326535c3e2637352f8d4b7801059fbf34ee4e46
Author: Lukasz Lenart
AuthorDate: Sun Jan 12 12:07:56 2020 +0100
WW-5054 Allows omit class/packages restrictions in devMode
---
.../com/opensymphony/xwork2/ognl/OgnlUtil.java | 39 ++-
.../debugging/DebuggingInterceptor.java| 128 +++--
.../interceptor/debugging/ObjectToHTMLWriter.java | 36 --
3 files changed, 126 insertions(+), 77 deletions(-)
diff --git a/core/src/main/java/com/opensymphony/xwork2/ognl/OgnlUtil.java
b/core/src/main/java/com/opensymphony/xwork2/ognl/OgnlUtil.java
index 01d5374..9798974 100644
--- a/core/src/main/java/com/opensymphony/xwork2/ognl/OgnlUtil.java
+++ b/core/src/main/java/com/opensymphony/xwork2/ognl/OgnlUtil.java
@@ -65,6 +65,10 @@ public class OgnlUtil {
private Set excludedPackageNamePatterns;
private Set excludedPackageNames;
+private Set> excludedClassesCopy;
+private Set excludedPackageNamePatternsCopy;
+private Set excludedPackageNamesCopy;
+
private Container container;
private boolean allowStaticFieldAccess = true;
private boolean allowStaticMethodAccess;
@@ -111,6 +115,33 @@ public class OgnlUtil {
this.excludedClasses = Collections.unmodifiableSet(excludedClasses);
}
+public void avoidAccessControl() {
+if (devMode) {
+LOG.warn("Cleans up excluded classes and packages in devMode");
+excludedClassesCopy = new HashSet<>(excludedClasses);
+excludedClasses = Collections.unmodifiableSet(new HashSet<>());
+
+excludedPackageNamePatternsCopy = new
HashSet<>(excludedPackageNamePatterns);
+excludedPackageNamePatterns = Collections.unmodifiableSet(new
HashSet<>());
+
+excludedPackageNamesCopy = new HashSet<>(excludedPackageNames);
+excludedPackageNames = Collections.unmodifiableSet(new
HashSet<>());
+}
+}
+public void restoreAccessControl() {
+if (devMode) {
+LOG.warn("Restores excluded classes and packages in devMode");
+excludedClasses = Collections.unmodifiableSet(excludedClassesCopy);
+excludedClassesCopy = null;
+
+excludedPackageNamePatterns =
Collections.unmodifiableSet(excludedPackageNamePatternsCopy);
+excludedPackageNamePatternsCopy = null;
+
+excludedPackageNames =
Collections.unmodifiableSet(excludedPackageNamesCopy);
+excludedPackageNamesCopy = null;
+}
+}
+
private Set> parseExcludedClasses(String commaDelimitedClasses) {
Set classNames =
TextParseUtil.commaDelimitedStringToSet(commaDelimitedClasses);
Set> classes = new HashSet<>();
@@ -339,7 +370,7 @@ public class OgnlUtil {
*problems setting the properties
*/
public void setProperties(Map properties, Object o, boolean
throwPropertyExceptions) {
-Map context = createDefaultContext(o, null);
+Map context = createDefaultContext(o);
setProperties(properties, o, context, throwPropertyExceptions);
}
@@ -608,8 +639,8 @@ public class OgnlUtil {
return;
}
-final Map contextFrom = createDefaultContext(from, null);
-final Map contextTo = createDefaultContext(to, null);
+final Map contextFrom = createDefaultContext(from);
+final Map contextTo = createDefaultContext(to);
PropertyDescriptor[] fromPds;
PropertyDescriptor[] toPds;
@@ -719,7 +750,7 @@ public class OgnlUtil {
*/
public Map getBeanMap(final Object source) throws
IntrospectionException, OgnlException {
Map beanMap = new HashMap<>();
-final Map sourceMap = createDefaultContext(source, null);
+final Map sourceMap = createDefaultContext(source);
PropertyDescriptor[] propertyDescriptors =
getPropertyDescriptors(source);
for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
final String propertyName = propertyDescriptor.getDisplayName();
diff --git
a/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
b/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
index 7e995f8..ff7e2d3 100644
---
a/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
+++
b/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
@@ -23,6 +23,7 @@ import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.opensymphony.xwork2.interceptor.PreResultListener;
+import com.opensymphony.xwork2.ognl.OgnlUtil;
import com.opensymphony.xwork2.