Skip to content

Commit

Permalink
WW-5327 Stops using JavaBeans notation for setters
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszlenart committed Jul 30, 2023
1 parent 85f7e8a commit bb1a34d
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ protected void setParameters(final Object action, ValueStack stack, HttpParamete
//block or allow access to properties
//see WW-2761 for more details
MemberAccessValueStack accessValueStack = (MemberAccessValueStack) newStack;
accessValueStack.setAcceptProperties(acceptedPatterns.getAcceptedPatterns());
accessValueStack.setExcludeProperties(excludedPatterns.getExcludedPatterns());
accessValueStack.useAcceptProperties(acceptedPatterns.getAcceptedPatterns());
accessValueStack.useExcludeProperties(excludedPatterns.getExcludedPatterns());
}

for (Map.Entry<String, Parameter> entry : acceptableParameters.entrySet()) {
Expand Down
18 changes: 9 additions & 9 deletions core/src/main/java/com/opensymphony/xwork2/ognl/OgnlUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -872,22 +872,22 @@ protected Map<String, Object> createDefaultContext(Object root, ClassResolver cl
}

SecurityMemberAccess memberAccess = new SecurityMemberAccess(allowStaticFieldAccess);
memberAccess.setDisallowProxyMemberAccess(disallowProxyMemberAccess);
memberAccess.disallowProxyMemberAccess(disallowProxyMemberAccess);

if (devMode) {
if (!warnReported.get()) {
warnReported.set(true);
LOG.warn("Working in devMode, using devMode excluded classes and packages!");
}
memberAccess.setExcludedClasses(devModeExcludedClasses);
memberAccess.setExcludedPackageNamePatterns(devModeExcludedPackageNamePatterns);
memberAccess.setExcludedPackageNames(devModeExcludedPackageNames);
memberAccess.setExcludedPackageExemptClasses(devModeExcludedPackageExemptClasses);
memberAccess.useExcludedClasses(devModeExcludedClasses);
memberAccess.useExcludedPackageNamePatterns(devModeExcludedPackageNamePatterns);
memberAccess.useExcludedPackageNames(devModeExcludedPackageNames);
memberAccess.useExcludedPackageExemptClasses(devModeExcludedPackageExemptClasses);
} else {
memberAccess.setExcludedClasses(excludedClasses);
memberAccess.setExcludedPackageNamePatterns(excludedPackageNamePatterns);
memberAccess.setExcludedPackageNames(excludedPackageNames);
memberAccess.setExcludedPackageExemptClasses(excludedPackageExemptClasses);
memberAccess.useExcludedClasses(excludedClasses);
memberAccess.useExcludedPackageNamePatterns(excludedPackageNamePatterns);
memberAccess.useExcludedPackageNames(excludedPackageNames);
memberAccess.useExcludedPackageExemptClasses(excludedPackageExemptClasses);
}

return Ognl.createDefaultContext(root, memberAccess, resolver, defaultConverter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ protected OgnlValueStack(ValueStack vs, XWorkConverter xworkConverter, CompoundR
@Inject
protected void setOgnlUtil(OgnlUtil ognlUtil) {
this.ognlUtil = ognlUtil;
securityMemberAccess.setExcludedClasses(ognlUtil.getExcludedClasses());
securityMemberAccess.setExcludedPackageNamePatterns(ognlUtil.getExcludedPackageNamePatterns());
securityMemberAccess.setExcludedPackageNames(ognlUtil.getExcludedPackageNames());
securityMemberAccess.setExcludedPackageExemptClasses(ognlUtil.getExcludedPackageExemptClasses());
securityMemberAccess.setDisallowProxyMemberAccess(ognlUtil.isDisallowProxyMemberAccess());
securityMemberAccess.useExcludedClasses(ognlUtil.getExcludedClasses());
securityMemberAccess.useExcludedPackageNamePatterns(ognlUtil.getExcludedPackageNamePatterns());
securityMemberAccess.useExcludedPackageNames(ognlUtil.getExcludedPackageNames());
securityMemberAccess.useExcludedPackageExemptClasses(ognlUtil.getExcludedPackageExemptClasses());
securityMemberAccess.disallowProxyMemberAccess(ognlUtil.isDisallowProxyMemberAccess());
}

protected void setRoot(XWorkConverter xworkConverter, CompoundRootAccessor accessor, CompoundRoot compoundRoot, boolean allowStaticFieldAccess) {
Expand Down Expand Up @@ -482,12 +482,22 @@ public void clearContextValues() {
((OgnlContext) context).getValues().clear();
}

@Deprecated
public void setAcceptProperties(Set<Pattern> acceptedProperties) {
securityMemberAccess.setAcceptProperties(acceptedProperties);
throw new UnsupportedOperationException("Please use #useAcceptProperties instead!");
}

public void useAcceptProperties(Set<Pattern> acceptedProperties) {
securityMemberAccess.useAcceptProperties(acceptedProperties);
}

@Deprecated
public void setExcludeProperties(Set<Pattern> excludeProperties) {
securityMemberAccess.setExcludeProperties(excludeProperties);
throw new UnsupportedOperationException("Please use #useExcludeProperties instead!");
}

public void useExcludeProperties(Set<Pattern> excludeProperties) {
securityMemberAccess.useExcludeProperties(excludeProperties);
}

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,31 +299,87 @@ protected boolean isExcluded(String paramName) {
return false;
}

/**
* @deprecated please use {@link #useExcludeProperties(Set)}
*/
@Deprecated
public void setExcludeProperties(Set<Pattern> excludeProperties) {
throw new UnsupportedOperationException("Please use #useExcludeProperties() instead!");
}

public void useExcludeProperties(Set<Pattern> excludeProperties) {
this.excludeProperties = excludeProperties;
}

/**
* @deprecated please use {@link #useAcceptProperties(Set)}
*/
@Deprecated
public void setAcceptProperties(Set<Pattern> acceptedProperties) {
throw new UnsupportedOperationException("Please use #useAcceptProperties() instead!");
}

public void useAcceptProperties(Set<Pattern> acceptedProperties) {
this.acceptProperties = acceptedProperties;
}

/**
* @deprecated please use {@link #useExcludedClasses(Set)}
*/
@Deprecated
public void setExcludedClasses(Set<Class<?>> excludedClasses) {
throw new UnsupportedOperationException("Please use #useExcludedClasses() instead!");
}

public void useExcludedClasses(Set<Class<?>> excludedClasses) {
this.excludedClasses = excludedClasses;
}

/**
* @deprecated please use {@link #useExcludedPackageNamePatterns(Set)}
*/
@Deprecated
public void setExcludedPackageNamePatterns(Set<Pattern> excludedPackageNamePatterns) {
throw new UnsupportedOperationException("Please use #useExcludedPackageNamePatterns() instead!");
}

public void useExcludedPackageNamePatterns(Set<Pattern> excludedPackageNamePatterns) {
this.excludedPackageNamePatterns = excludedPackageNamePatterns;
}

/**
* @deprecated please use {@link #useExcludedPackageNames(Set)}
*/
@Deprecated
public void setExcludedPackageNames(Set<String> excludedPackageNames) {
throw new UnsupportedOperationException("Please use #useExcludedPackageNames() instead!");
}

public void useExcludedPackageNames(Set<String> excludedPackageNames) {
this.excludedPackageNames = excludedPackageNames;
}

/**
* @deprecated please use {@link #useExcludedPackageExemptClasses(Set)}
*/
@Deprecated
public void setExcludedPackageExemptClasses(Set<Class<?>> excludedPackageExemptClasses) {
throw new UnsupportedOperationException("Please use #useExcludedPackageExemptClasses() instead!");
}

public void useExcludedPackageExemptClasses(Set<Class<?>> excludedPackageExemptClasses) {
this.excludedPackageExemptClasses = excludedPackageExemptClasses;
}

/**
* @deprecated please use {@link #disallowProxyMemberAccess(boolean)}
*/
@Deprecated
public void setDisallowProxyMemberAccess(boolean disallowProxyMemberAccess) {
throw new UnsupportedOperationException("Please use #disallowProxyMemberAccess() instead!");
}

public void disallowProxyMemberAccess(boolean disallowProxyMemberAccess) {
this.disallowProxyMemberAccess = disallowProxyMemberAccess;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,20 @@
*/
public interface MemberAccessValueStack {

/**
* @deprecated please use {@link #useExcludeProperties(Set)}
*/
@Deprecated
void setExcludeProperties(Set<Pattern> excludeProperties);

void useExcludeProperties(Set<Pattern> excludeProperties);

/**
* @deprecated please use {@link #useAcceptProperties(Set)}
*/
@Deprecated
void setAcceptProperties(Set<Pattern> acceptedProperties);

void useAcceptProperties(Set<Pattern> acceptedProperties);

}
Loading

0 comments on commit bb1a34d

Please sign in to comment.