mirror of
https://github.com/apache/struts.git
synced 2026-08-05 22:56:59 +00:00
WW-5411 Delete deprecated code part 1
This commit is contained in:
+13
-5
@@ -28,16 +28,24 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: javadoc -->
|
||||
* <p>
|
||||
* Provided that the key {@link ReflectionContextState#CREATE_NULL_OBJECTS} is in the action context with a value of true (this key is set
|
||||
* only during the execution of the {@link com.opensymphony.xwork2.interceptor.ParametersInterceptor}), OGNL expressions
|
||||
* that have caused a NullPointerException will be temporarily stopped for evaluation while the system automatically
|
||||
* tries to solve the null references by automatically creating the object.
|
||||
* Provided that the key {@link ReflectionContextState#CREATE_NULL_OBJECTS} is in the action context with a value of
|
||||
* true (this key is set only during the execution of the {@link
|
||||
* org.apache.struts2.interceptor.parameter.ParametersInterceptor}), OGNL expressions that have caused a
|
||||
* NullPointerException will be temporarily stopped for evaluation while the system automatically tries to solve the
|
||||
* null references by automatically creating the object.
|
||||
* </p>
|
||||
*
|
||||
* <p>The following rules are used when handling null references:</p>
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2006 Google Inc.
|
||||
*
|
||||
* 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 com.opensymphony.xwork2.inject.util;
|
||||
|
||||
/**
|
||||
* String utilities.
|
||||
*
|
||||
* @author crazybob@google.com (Bob Lee)
|
||||
*/
|
||||
@Deprecated
|
||||
public class Strings {
|
||||
|
||||
/**
|
||||
* Returns a string that is equivalent to the specified string with its
|
||||
* first character converted to uppercase as by {@link String#toUpperCase}.
|
||||
* The returned string will have the same value as the specified string if
|
||||
* its first character is non-alphabetic, if its first character is already
|
||||
* uppercase, or if the specified string is of length 0.
|
||||
*
|
||||
* <p>For example:
|
||||
* <pre>
|
||||
* capitalize("foo bar").equals("Foo bar");
|
||||
* capitalize("2b or not 2b").equals("2b or not 2b")
|
||||
* capitalize("Foo bar").equals("Foo bar");
|
||||
* capitalize("").equals("");
|
||||
* </pre>
|
||||
*
|
||||
* @param s the string whose first character is to be uppercased
|
||||
* @return a string equivalent to <tt>s</tt> with its first character
|
||||
* converted to uppercase
|
||||
* @throws NullPointerException if <tt>s</tt> is null
|
||||
*/
|
||||
@Deprecated
|
||||
public static String capitalize(String s) {
|
||||
if (s.length() == 0)
|
||||
return s;
|
||||
char first = s.charAt(0);
|
||||
char capitalized = Character.toUpperCase(first);
|
||||
return (first == capitalized)
|
||||
? s
|
||||
: capitalized + s.substring(1);
|
||||
}
|
||||
}
|
||||
@@ -20,21 +20,21 @@ package com.opensymphony.xwork2.interceptor;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.LocalizedTextProvider;
|
||||
import com.opensymphony.xwork2.config.entities.ActionConfig;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.security.AcceptedPatternsChecker;
|
||||
import com.opensymphony.xwork2.security.ExcludedPatternsChecker;
|
||||
import com.opensymphony.xwork2.util.ClearableValueStack;
|
||||
import com.opensymphony.xwork2.util.Evaluated;
|
||||
import com.opensymphony.xwork2.LocalizedTextProvider;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.ValueStackFactory;
|
||||
import com.opensymphony.xwork2.util.reflection.ReflectionContextState;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.dispatcher.HttpParameters;
|
||||
import org.apache.struts2.dispatcher.Parameter;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -108,7 +108,7 @@ public class AliasInterceptor extends AbstractInterceptor {
|
||||
@Inject(StrutsConstants.STRUTS_DEVMODE)
|
||||
public void setDevMode(String mode) {
|
||||
this.devMode = Boolean.parseBoolean(mode);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setValueStackFactory(ValueStackFactory valueStackFactory) {
|
||||
@@ -206,7 +206,7 @@ public class AliasInterceptor extends AbstractInterceptor {
|
||||
newStack.setValue(alias, value.get());
|
||||
} catch (RuntimeException e) {
|
||||
if (devMode) {
|
||||
String developerNotification = localizedTextProvider.findText(ParametersInterceptor.class, "devmode.notification", ActionContext.getContext().getLocale(), "Developer Notification:\n{0}", new Object[]{
|
||||
String developerNotification = localizedTextProvider.findText(AliasInterceptor.class, "devmode.notification", ActionContext.getContext().getLocale(), "Developer Notification:\n{0}", new Object[]{
|
||||
"Unexpected Exception caught setting '" + entry.getKey() + "' on '" + action.getClass() + ": " + e.getMessage()
|
||||
});
|
||||
LOG.error(developerNotification);
|
||||
@@ -225,7 +225,7 @@ public class AliasInterceptor extends AbstractInterceptor {
|
||||
LOG.debug("invalid alias expression: {}", aliasesKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return invocation.invoke();
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,8 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
* Watches for {@link ModelDriven} actions and adds the action's model on to the value stack.
|
||||
*
|
||||
* <p> <b>Note:</b> The ModelDrivenInterceptor must come before the both {@link StaticParametersInterceptor} and
|
||||
* {@link ParametersInterceptor} if you want the parameters to be applied to the model.
|
||||
* {@link org.apache.struts2.interceptor.parameter.ParametersInterceptor} if you want the parameters to be applied to
|
||||
* the model.
|
||||
* </p>
|
||||
* <p> <b>Note:</b> The ModelDrivenInterceptor will only push the model into the stack when the
|
||||
* model is not null, else it will be ignored.
|
||||
@@ -71,7 +72,7 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
* </action>
|
||||
* <!-- END SNIPPET: example -->
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @author tm_jee
|
||||
* @version $Date$ $Id$
|
||||
*/
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 com.opensymphony.xwork2.interceptor;
|
||||
|
||||
/**
|
||||
* Marker interface to indicate no auto setting of parameters.
|
||||
*
|
||||
* <p>
|
||||
* This marker interface should be implemented by actions that do not want any
|
||||
* request parameters set on them automatically (by the ParametersInterceptor).
|
||||
* This may be useful if one is using the action tag and want to supply
|
||||
* the parameters to the action manually using the param tag.
|
||||
* It may also be useful if one for security reasons wants to make sure that
|
||||
* parameters cannot be set by malicious users.
|
||||
* </p>
|
||||
*
|
||||
* @deprecated since Struts 6.2.0, use {@link org.apache.struts2.action.NoParameters}
|
||||
*/
|
||||
@Deprecated
|
||||
public interface NoParameters extends org.apache.struts2.action.NoParameters {
|
||||
}
|
||||
-241
@@ -1,241 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 com.opensymphony.xwork2.interceptor;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.util.TextParseUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.dispatcher.HttpParameters;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: description -->
|
||||
*
|
||||
* The Parameter Filter Interceptor blocks parameters from getting
|
||||
* to the rest of the stack or your action. You can use multiple
|
||||
* parameter filter interceptors for a given action, so, for example,
|
||||
* you could use one in your default stack that filtered parameters
|
||||
* you wanted blocked from every action and those you wanted blocked
|
||||
* from an individual action you could add an additional interceptor
|
||||
* for each action.
|
||||
*
|
||||
* <!-- END SNIPPET: description -->
|
||||
*
|
||||
* <!-- START SNIPPET: parameters -->
|
||||
*
|
||||
* <ul>
|
||||
* <li>allowed - a comma delimited list of parameter prefixes
|
||||
* that are allowed to pass to the action</li>
|
||||
* <li>blocked - a comma delimited list of parameter prefixes
|
||||
* that are not allowed to pass to the action</li>
|
||||
* <li>defaultBlock - boolean (default to false) whether by
|
||||
* default a given parameter is blocked. If true, then a parameter
|
||||
* must have a prefix in the allowed list in order to be able
|
||||
* to pass to the action
|
||||
* </ul>
|
||||
*
|
||||
* <p>The way parameters are filtered for the least configuration is that
|
||||
* if a string is in the allowed or blocked lists, then any parameter
|
||||
* that is a member of the object represented by the parameter is allowed
|
||||
* or blocked respectively.</p>
|
||||
*
|
||||
* <p>For example, if the parameters are:
|
||||
* <ul>
|
||||
* <li>blocked: person,person.address.createDate,personDao</li>
|
||||
* <li>allowed: person.address</li>
|
||||
* <li>defaultBlock: false</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>
|
||||
* The parameters person.name, person.phoneNum etc would be blocked
|
||||
* because 'person' is in the blocked list. However, person.address.street
|
||||
* and person.address.city would be allowed because person.address is
|
||||
* in the allowed list (the longer string determines permissions).</p>
|
||||
* <!-- END SNIPPET: parameters -->
|
||||
*
|
||||
* <!-- START SNIPPET: extending -->
|
||||
* There are no known extension points to this interceptor.
|
||||
* <!-- END SNIPPET: extending -->
|
||||
*
|
||||
* <pre>
|
||||
* <!-- START SNIPPET: example -->
|
||||
* <interceptors>
|
||||
* ...
|
||||
* <interceptor name="parameterFilter" class="com.opensymphony.xwork2.interceptor.ParameterFilterInterceptor"/>
|
||||
* ...
|
||||
* </interceptors>
|
||||
*
|
||||
* <action ....>
|
||||
* ...
|
||||
* <interceptor-ref name="parameterFilter">
|
||||
* <param name="blocked">person,person.address.createDate,personDao</param>
|
||||
* </interceptor-ref>
|
||||
* ...
|
||||
* </action>
|
||||
* <!-- END SNIPPET: example -->
|
||||
* </pre>
|
||||
*
|
||||
* @author Gabe
|
||||
*
|
||||
* @deprecated since 6.4.0, use {@link org.apache.struts2.interceptor.parameter.ParametersInterceptor}.
|
||||
*/
|
||||
@Deprecated
|
||||
public class ParameterFilterInterceptor extends AbstractInterceptor {
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger(ParameterFilterInterceptor.class);
|
||||
|
||||
private Collection<String> allowed;
|
||||
private Collection<String> blocked;
|
||||
private Map<String, Boolean> includesExcludesMap;
|
||||
private boolean defaultBlock = false;
|
||||
|
||||
@Override
|
||||
public String intercept(ActionInvocation invocation) throws Exception {
|
||||
|
||||
HttpParameters parameters = invocation.getInvocationContext().getParameters();
|
||||
|
||||
Map<String, Boolean> includesExcludesMap = getIncludesExcludesMap();
|
||||
|
||||
for (String param : parameters.keySet()) {
|
||||
boolean currentAllowed = !isDefaultBlock();
|
||||
|
||||
for (Map.Entry<String, Boolean> entry : includesExcludesMap.entrySet()) {
|
||||
String currRule = entry.getKey();
|
||||
|
||||
if (param.startsWith(currRule) &&
|
||||
(param.length() == currRule.length() || isPropertySeparator(param.charAt(currRule.length())))
|
||||
) {
|
||||
currentAllowed = entry.getValue();
|
||||
}
|
||||
}
|
||||
if (!currentAllowed) {
|
||||
LOG.debug("Removing param: {}", param);
|
||||
parameters = parameters.remove(param);
|
||||
}
|
||||
}
|
||||
|
||||
invocation.getInvocationContext().withParameters(parameters);
|
||||
|
||||
return invocation.invoke();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the given char is a property separator char <code>.([</code>.
|
||||
*
|
||||
* @param c the char
|
||||
* @return <tt>true</tt>, if char is property separator, <tt>false</tt> otherwise.
|
||||
*/
|
||||
private boolean isPropertySeparator(char c) {
|
||||
return c == '.' || c == '(' || c == '[';
|
||||
}
|
||||
|
||||
private Map<String, Boolean> getIncludesExcludesMap() {
|
||||
if (this.includesExcludesMap == null) {
|
||||
this.includesExcludesMap = new TreeMap<>();
|
||||
|
||||
if (getAllowedCollection() != null) {
|
||||
for (String e : getAllowedCollection()) {
|
||||
this.includesExcludesMap.put(e, Boolean.TRUE);
|
||||
}
|
||||
}
|
||||
if (getBlockedCollection() != null) {
|
||||
for (String b : getBlockedCollection()) {
|
||||
this.includesExcludesMap.put(b, Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.includesExcludesMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the defaultBlock.
|
||||
*/
|
||||
public boolean isDefaultBlock() {
|
||||
return defaultBlock;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param defaultExclude The defaultExclude to set.
|
||||
*/
|
||||
public void setDefaultBlock(boolean defaultExclude) {
|
||||
this.defaultBlock = defaultExclude;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the blocked.
|
||||
*/
|
||||
public Collection<String> getBlockedCollection() {
|
||||
return blocked;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param blocked The blocked to set.
|
||||
*/
|
||||
public void setBlockedCollection(Collection<String> blocked) {
|
||||
this.blocked = blocked;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param blocked The blocked paramters as comma separated String.
|
||||
*/
|
||||
public void setBlocked(String blocked) {
|
||||
setBlockedCollection(asCollection(blocked));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the allowed.
|
||||
*/
|
||||
public Collection<String> getAllowedCollection() {
|
||||
return allowed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param allowed The allowed to set.
|
||||
*/
|
||||
public void setAllowedCollection(Collection<String> allowed) {
|
||||
this.allowed = allowed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param allowed The allowed paramters as comma separated String.
|
||||
*/
|
||||
public void setAllowed(String allowed) {
|
||||
setAllowedCollection(asCollection(allowed));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a collection from the comma delimited String.
|
||||
*
|
||||
* @param commaDelim the comma delimited String.
|
||||
* @return A collection from the comma delimited String. Returns <tt>null</tt> if the string is empty.
|
||||
*/
|
||||
private Collection<String> asCollection(String commaDelim) {
|
||||
if (StringUtils.isBlank(commaDelim)) {
|
||||
return null;
|
||||
}
|
||||
return TextParseUtil.commaDelimitedStringToSet(commaDelim);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 com.opensymphony.xwork2.interceptor;
|
||||
|
||||
/**
|
||||
* @deprecated since 6.4.0, use {@link org.apache.struts2.action.ParameterNameAware}.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface ParameterNameAware extends org.apache.struts2.action.ParameterNameAware {
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 com.opensymphony.xwork2.interceptor;
|
||||
|
||||
/**
|
||||
* @deprecated since 6.4.0, use {@link org.apache.struts2.action.ParameterValueAware}.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface ParameterValueAware extends org.apache.struts2.action.ParameterValueAware {
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 com.opensymphony.xwork2.interceptor;
|
||||
|
||||
/**
|
||||
* @deprecated since 6.4.0, use {@link org.apache.struts2.interceptor.parameter.ParametersInterceptor}.
|
||||
*/
|
||||
public class ParametersInterceptor extends org.apache.struts2.interceptor.parameter.ParametersInterceptor {
|
||||
}
|
||||
+3
-3
@@ -20,11 +20,11 @@ package com.opensymphony.xwork2.interceptor;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.LocalizedTextProvider;
|
||||
import com.opensymphony.xwork2.config.entities.ActionConfig;
|
||||
import com.opensymphony.xwork2.config.entities.Parameterizable;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.ClearableValueStack;
|
||||
import com.opensymphony.xwork2.LocalizedTextProvider;
|
||||
import com.opensymphony.xwork2.util.TextParseUtil;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.ValueStackFactory;
|
||||
@@ -169,7 +169,7 @@ public class StaticParametersInterceptor extends AbstractInterceptor {
|
||||
|
||||
for (Map.Entry<String, String> entry : parameters.entrySet()) {
|
||||
Object val = entry.getValue();
|
||||
if (parse && val instanceof String) {
|
||||
if (parse && val != null) {
|
||||
val = TextParseUtil.translateVariables(val.toString(), stack);
|
||||
}
|
||||
try {
|
||||
@@ -177,7 +177,7 @@ public class StaticParametersInterceptor extends AbstractInterceptor {
|
||||
} catch (RuntimeException e) {
|
||||
if (devMode) {
|
||||
|
||||
String developerNotification = localizedTextProvider.findText(ParametersInterceptor.class, "devmode.notification", ActionContext.getContext().getLocale(), "Developer Notification:\n{0}", new Object[]{
|
||||
String developerNotification = localizedTextProvider.findText(StaticParametersInterceptor.class, "devmode.notification", ActionContext.getContext().getLocale(), "Developer Notification:\n{0}", new Object[]{
|
||||
"Unexpected Exception caught setting '" + entry.getKey() + "' on '" + action.getClass() + ": " + e.getMessage()
|
||||
});
|
||||
LOG.error(developerNotification);
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 com.opensymphony.xwork2.interceptor.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Declares that it is permitted for the field be mutated through
|
||||
* a HttpRequest parameter.
|
||||
*
|
||||
* @author martin.gilday
|
||||
* @deprecated since 6.6.0, use {@link org.apache.struts2.interceptor.parameter.StrutsParameter}.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@Deprecated
|
||||
public @interface Allowed {
|
||||
|
||||
}
|
||||
-115
@@ -1,115 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 com.opensymphony.xwork2.interceptor.annotations;
|
||||
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
|
||||
import com.opensymphony.xwork2.interceptor.Interceptor;
|
||||
import com.opensymphony.xwork2.interceptor.ParameterFilterInterceptor;
|
||||
import com.opensymphony.xwork2.util.AnnotationUtils;
|
||||
import org.apache.struts2.dispatcher.HttpParameters;
|
||||
import org.apache.struts2.interceptor.parameter.ParametersInterceptor;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Annotation based version of {@link ParameterFilterInterceptor}.
|
||||
*
|
||||
* <p>
|
||||
* This {@link Interceptor} must be placed in the stack before the {@link ParametersInterceptor}
|
||||
* When a parameter matches a field that is marked {@link Blocked} then it is removed from
|
||||
* the parameter map.
|
||||
* </p>
|
||||
* <p>
|
||||
* If an {@link Action} class is marked with {@link BlockByDefault} then all parameters are
|
||||
* removed unless a field on the Action exists and is marked with {@link Allowed}
|
||||
* </p>
|
||||
*
|
||||
* @author martin.gilday
|
||||
* @deprecated since 6.6.0, integrated into {@link ParametersInterceptor} with {@link StrutsParameter} using
|
||||
* {@code struts.parameters.requireAnnotations=true}
|
||||
*/
|
||||
@Deprecated
|
||||
public class AnnotationParameterFilterInterceptor extends AbstractInterceptor {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.opensymphony.xwork2.interceptor.AbstractInterceptor#intercept(com.opensymphony.xwork2.ActionInvocation)
|
||||
*/
|
||||
@Override public String intercept(ActionInvocation invocation) throws Exception {
|
||||
|
||||
final Object action = invocation.getAction();
|
||||
HttpParameters parameters = invocation.getInvocationContext().getParameters();
|
||||
|
||||
Object model = invocation.getStack().peek();
|
||||
if (model == action) {
|
||||
model = null;
|
||||
}
|
||||
|
||||
boolean blockByDefault = action.getClass().isAnnotationPresent(BlockByDefault.class);
|
||||
List<Field> annotatedFields = new ArrayList<>();
|
||||
|
||||
if (blockByDefault) {
|
||||
AnnotationUtils.addAllFields(Allowed.class, action.getClass(), annotatedFields);
|
||||
if (model != null) {
|
||||
AnnotationUtils.addAllFields(Allowed.class, model.getClass(), annotatedFields);
|
||||
}
|
||||
|
||||
for (String paramName : parameters.keySet()) {
|
||||
boolean allowed = false;
|
||||
|
||||
for (Field field : annotatedFields) {
|
||||
//TODO only matches exact field names. need to change to it matches start of ognl expression
|
||||
//i.e take param name up to first . (period) and match against that
|
||||
if (field.getName().equals(paramName)) {
|
||||
allowed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!allowed) {
|
||||
parameters = parameters.remove(paramName);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
AnnotationUtils.addAllFields(Blocked.class, action.getClass(), annotatedFields);
|
||||
if (model != null) {
|
||||
AnnotationUtils.addAllFields(Blocked.class, model.getClass(), annotatedFields);
|
||||
}
|
||||
|
||||
for (String paramName : parameters.keySet()) {
|
||||
for (Field field : annotatedFields) {
|
||||
//TODO only matches exact field names. need to change to it matches start of ognl expression
|
||||
//i.e take param name up to first . (period) and match against that
|
||||
if (field.getName().equals(paramName)) {
|
||||
parameters = parameters.remove(paramName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
invocation.getInvocationContext().withParameters(parameters);
|
||||
|
||||
return invocation.invoke();
|
||||
}
|
||||
|
||||
}
|
||||
-41
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 com.opensymphony.xwork2.interceptor.annotations;
|
||||
|
||||
import com.opensymphony.xwork2.Action;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Declares that by default fields on the {@link Action} class
|
||||
* are NOT permitted to be set from HttpRequest parameters.
|
||||
* To allow access to a field it must be annotated with {@link Allowed}
|
||||
*
|
||||
* @author martin.gilday
|
||||
* @deprecated since 6.6.0, use {@code struts.parameters.requireAnnotations=true} to block all parameters globally.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
@Deprecated
|
||||
public @interface BlockByDefault {
|
||||
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 com.opensymphony.xwork2.interceptor.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Declares that the given field should NOT be able to be mutated through
|
||||
* a HttpRequest parameter.
|
||||
*
|
||||
* @author martin.gilday
|
||||
* @deprecated since 6.6.0, use {@code struts.parameters.requireAnnotations=true} to block all parameters globally.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@Deprecated
|
||||
public @interface Blocked {
|
||||
|
||||
}
|
||||
@@ -20,12 +20,11 @@ package org.apache.struts2;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import org.apache.struts2.dispatcher.mapper.ActionMapping;
|
||||
|
||||
import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.jsp.PageContext;
|
||||
import org.apache.struts2.dispatcher.mapper.ActionMapping;
|
||||
|
||||
/**
|
||||
* Web-specific context information for actions. This class subclasses <tt>ActionContext</tt> which
|
||||
@@ -55,16 +54,6 @@ public class ServletActionContext implements StrutsStatics {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not use this method, use {@link #getActionContext()}
|
||||
* @return action context
|
||||
* @deprecated Use {@link #getActionContext()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static ActionContext getContext() {
|
||||
return ActionContext.getContext();
|
||||
}
|
||||
|
||||
public static ActionContext getActionContext() {
|
||||
return ActionContext.getContext();
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
<interceptor name="modelDriven" class="com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor"/>
|
||||
<interceptor name="scopedModelDriven"
|
||||
class="com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor"/>
|
||||
<interceptor name="params" class="com.opensymphony.xwork2.interceptor.ParametersInterceptor"/>
|
||||
<interceptor name="params" class="org.apache.struts2.interceptor.parameter.ParametersInterceptor"/>
|
||||
<interceptor name="paramRemover" class="com.opensymphony.xwork2.interceptor.ParameterRemoverInterceptor"/>
|
||||
<interceptor name="actionMappingParams"
|
||||
class="org.apache.struts2.interceptor.ActionMappingParametersInterceptor"/>
|
||||
@@ -83,8 +83,6 @@
|
||||
<interceptor name="roles" class="org.apache.struts2.interceptor.RolesInterceptor"/>
|
||||
<interceptor name="annotationWorkflow"
|
||||
class="com.opensymphony.xwork2.interceptor.annotations.AnnotationWorkflowInterceptor"/>
|
||||
<interceptor name="annotationParameterFilter"
|
||||
class="com.opensymphony.xwork2.interceptor.annotations.AnnotationParameterFilterInterceptor"/>
|
||||
<interceptor name="multiselect" class="org.apache.struts2.interceptor.MultiselectInterceptor"/>
|
||||
<interceptor name="noop" class="org.apache.struts2.interceptor.NoOpInterceptor"/>
|
||||
<interceptor name="fetchMetadata" class="org.apache.struts2.interceptor.FetchMetadataInterceptor"/>
|
||||
|
||||
@@ -38,8 +38,7 @@
|
||||
<interceptor name="logger" class="com.opensymphony.xwork2.interceptor.LoggingInterceptor"/>
|
||||
<interceptor name="chain" class="com.opensymphony.xwork2.interceptor.ChainingInterceptor"/>
|
||||
<interceptor name="staticParams" class="com.opensymphony.xwork2.interceptor.StaticParametersInterceptor"/>
|
||||
<interceptor name="params" class="com.opensymphony.xwork2.interceptor.ParametersInterceptor"/>
|
||||
<interceptor name="filterParams" class="com.opensymphony.xwork2.interceptor.ParameterFilterInterceptor"/>
|
||||
<interceptor name="params" class="org.apache.struts2.interceptor.parameter.ParametersInterceptor"/>
|
||||
<interceptor name="removeParams" class="com.opensymphony.xwork2.interceptor.ParameterRemoverInterceptor"/>
|
||||
<interceptor name="modelDriven" class="com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor"/>
|
||||
<interceptor name="scopedModelDriven"
|
||||
@@ -55,7 +54,6 @@
|
||||
<!-- END SNIPPET: xwork2-default-interceptors -->
|
||||
|
||||
<!--interceptor name="static-params" class="com.opensymphony.xwork2.interceptor.StaticParametersInterceptor"/>
|
||||
<interceptor name="filter-params" class="com.opensymphony.xwork2.interceptor.ParameterFilterInterceptor"/>
|
||||
<interceptor name="remove-params" class="com.opensymphony.xwork2.interceptor.ParameterRemoverInterceptor"/>
|
||||
<interceptor name="model-driven" class="com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor"/>
|
||||
<interceptor name="scoped-model-driven"
|
||||
|
||||
+25
-13
@@ -18,21 +18,33 @@
|
||||
*/
|
||||
package com.opensymphony.xwork2.config.providers;
|
||||
|
||||
import com.opensymphony.xwork2.*;
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import com.opensymphony.xwork2.ActionChainResult;
|
||||
import com.opensymphony.xwork2.ModelDrivenAction;
|
||||
import com.opensymphony.xwork2.ObjectFactory;
|
||||
import com.opensymphony.xwork2.SimpleAction;
|
||||
import com.opensymphony.xwork2.config.Configuration;
|
||||
import com.opensymphony.xwork2.config.ConfigurationException;
|
||||
import com.opensymphony.xwork2.config.ConfigurationProvider;
|
||||
import com.opensymphony.xwork2.config.entities.*;
|
||||
import com.opensymphony.xwork2.config.entities.ActionConfig;
|
||||
import com.opensymphony.xwork2.config.entities.InterceptorConfig;
|
||||
import com.opensymphony.xwork2.config.entities.InterceptorMapping;
|
||||
import com.opensymphony.xwork2.config.entities.PackageConfig;
|
||||
import com.opensymphony.xwork2.config.entities.ResultConfig;
|
||||
import com.opensymphony.xwork2.inject.ContainerBuilder;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor;
|
||||
import com.opensymphony.xwork2.interceptor.ParametersInterceptor;
|
||||
import com.opensymphony.xwork2.interceptor.StaticParametersInterceptor;
|
||||
import com.opensymphony.xwork2.mock.MockResult;
|
||||
import com.opensymphony.xwork2.util.location.LocatableProperties;
|
||||
import com.opensymphony.xwork2.validator.ValidationInterceptor;
|
||||
import org.apache.struts2.interceptor.parameter.ParametersInterceptor;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
@@ -68,18 +80,18 @@ public class MockConfigurationProvider implements ConfigurationProvider {
|
||||
*/
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
|
||||
public void init(Configuration config) {
|
||||
this.configuration = config;
|
||||
}
|
||||
|
||||
|
||||
@Inject
|
||||
public void setObjectFactory(ObjectFactory fac) {
|
||||
this.objectFactory = fac;
|
||||
}
|
||||
|
||||
public void loadPackages() {
|
||||
|
||||
|
||||
PackageConfig.Builder defaultPackageContext = new PackageConfig.Builder("defaultPackage");
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("bar", "5");
|
||||
@@ -109,7 +121,7 @@ public class MockConfigurationProvider implements ConfigurationProvider {
|
||||
defaultPackageContext.addActionConfig(PARAM_INTERCEPTOR_ACTION_NAME, paramInterceptorActionConfig);
|
||||
|
||||
interceptors = new ArrayList<>();
|
||||
interceptors.add(new InterceptorMapping("model",
|
||||
interceptors.add(new InterceptorMapping("model",
|
||||
objectFactory.buildInterceptor(new InterceptorConfig.Builder("model", ModelDrivenInterceptor.class.getName()).build(), EMPTY_STRING_MAP)));
|
||||
interceptors.add(new InterceptorMapping("params",
|
||||
objectFactory.buildInterceptor(new InterceptorConfig.Builder("model", ParametersInterceptor.class.getName()).build(), EMPTY_STRING_MAP)));
|
||||
@@ -119,7 +131,7 @@ public class MockConfigurationProvider implements ConfigurationProvider {
|
||||
.addResultConfig(new ResultConfig.Builder(Action.SUCCESS, MockResult.class.getName()).build())
|
||||
.build();
|
||||
defaultPackageContext.addActionConfig(MODEL_DRIVEN_PARAM_TEST, modelParamActionConfig);
|
||||
|
||||
|
||||
//List paramFilterInterceptor=new ArrayList();
|
||||
//paramFilterInterceptor.add(new ParameterFilterInterC)
|
||||
//ActionConfig modelParamFilterActionConfig = new ActionConfig(null, ModelDrivenAction.class, null, null, interceptors);
|
||||
@@ -132,13 +144,13 @@ public class MockConfigurationProvider implements ConfigurationProvider {
|
||||
results.put(Action.ERROR, new ResultConfig.Builder(Action.ERROR, MockResult.class.getName()).build());
|
||||
|
||||
interceptors = new ArrayList<>();
|
||||
interceptors.add(new InterceptorMapping("staticParams",
|
||||
interceptors.add(new InterceptorMapping("staticParams",
|
||||
objectFactory.buildInterceptor(new InterceptorConfig.Builder("model", StaticParametersInterceptor.class.getName()).build(), EMPTY_STRING_MAP)));
|
||||
interceptors.add(new InterceptorMapping("model",
|
||||
interceptors.add(new InterceptorMapping("model",
|
||||
objectFactory.buildInterceptor(new InterceptorConfig.Builder("model", ModelDrivenInterceptor.class.getName()).build(), EMPTY_STRING_MAP)));
|
||||
interceptors.add(new InterceptorMapping("params",
|
||||
interceptors.add(new InterceptorMapping("params",
|
||||
objectFactory.buildInterceptor(new InterceptorConfig.Builder("model", ParametersInterceptor.class.getName()).build(), EMPTY_STRING_MAP)));
|
||||
interceptors.add(new InterceptorMapping("validation",
|
||||
interceptors.add(new InterceptorMapping("validation",
|
||||
objectFactory.buildInterceptor(new InterceptorConfig.Builder("model", ValidationInterceptor.class.getName()).build(), EMPTY_STRING_MAP)));
|
||||
|
||||
//Explicitly set an out-of-range date for DateRangeValidatorTest
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import com.opensymphony.xwork2.config.entities.ActionConfig;
|
||||
import com.opensymphony.xwork2.config.entities.InterceptorMapping;
|
||||
import com.opensymphony.xwork2.config.entities.PackageConfig;
|
||||
import com.opensymphony.xwork2.config.entities.ResultConfig;
|
||||
import com.opensymphony.xwork2.interceptor.ParametersInterceptor;
|
||||
import org.apache.struts2.interceptor.parameter.ParametersInterceptor;
|
||||
import org.junit.Assert;
|
||||
|
||||
|
||||
|
||||
-127
@@ -1,127 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 com.opensymphony.xwork2.interceptor;
|
||||
|
||||
import com.mockobjects.dynamic.Mock;
|
||||
import com.opensymphony.xwork2.*;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import org.apache.struts2.dispatcher.HttpParameters;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Unit test for {@link ParameterFilterInterceptor}.
|
||||
*
|
||||
* @author Gabe
|
||||
*/
|
||||
public class ParameterFilterInterceptorTest extends XWorkTestCase {
|
||||
|
||||
private ActionInvocation invocation;
|
||||
private ParameterFilterInterceptor interceptor;
|
||||
private Mock mockInvocation;
|
||||
private ValueStack stack;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
stack = ActionContext.getContext().getValueStack();
|
||||
mockInvocation = new Mock(ActionInvocation.class);
|
||||
mockInvocation.expectAndReturn("getInvocationContext", ActionContext.getContext());
|
||||
mockInvocation.expectAndReturn("getStack", stack);
|
||||
mockInvocation.expectAndReturn("invoke", Action.SUCCESS);
|
||||
mockInvocation.expectAndReturn("getInvocationContext", ActionContext.getContext());
|
||||
mockInvocation.matchAndReturn("getAction", new SimpleAction());
|
||||
invocation = (ActionInvocation) mockInvocation.proxy();
|
||||
interceptor = new ParameterFilterInterceptor();
|
||||
interceptor.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
interceptor.destroy();
|
||||
}
|
||||
|
||||
public void testBasicBlockAll() throws Exception {
|
||||
runFilterTest(null,null,true,new String[] {"blah", "bladeblah", "bladebladeblah"});
|
||||
assertEquals(0, getParameterNames().size());
|
||||
}
|
||||
|
||||
public void testBasicAllowed() throws Exception {
|
||||
runFilterTest("blah",null,true,new String[] {"blah"});
|
||||
assertEquals(1, getParameterNames().size());
|
||||
}
|
||||
|
||||
public void testBasicBlocked() throws Exception {
|
||||
runFilterTest(null,"blah",false,new String[] {"blah"});
|
||||
assertEquals(0, getParameterNames().size());
|
||||
}
|
||||
public void testAllSubpropertiesBlocked() throws Exception {
|
||||
runFilterTest(null,"blah",false,new String[] {"blah.deblah", "blah.somethingelse", "blah(22)"});
|
||||
assertEquals(0, getParameterNames().size());
|
||||
}
|
||||
|
||||
public void testAllSubpropertiesAllowed() throws Exception {
|
||||
runFilterTest("blah",null,true,
|
||||
new String[] {"blah.deblah", "blah.somethingelse", "blah(22)"});
|
||||
assertEquals(3, getParameterNames().size());
|
||||
}
|
||||
|
||||
public void testTreeBlocking() throws Exception {
|
||||
runFilterTest("blah.deblah","blah,blah.deblah.deblah",false,
|
||||
new String[] {"blah", "blah.deblah", "blah.deblah.deblah"});
|
||||
assertEquals(1, getParameterNames().size());
|
||||
assertEquals(getParameterNames().iterator().next(),"blah.deblah");
|
||||
}
|
||||
|
||||
public void testEnsureOnlyPropsBlocked() throws Exception {
|
||||
runFilterTest(null,"blah",false,new String[] {"blahdeblah"});
|
||||
assertEquals(1, getParameterNames().size());
|
||||
}
|
||||
|
||||
|
||||
private void runFilterTest(String allowed, String blocked, boolean defaultBlocked, String[] paramNames) throws Exception {
|
||||
interceptor.setAllowed(allowed);
|
||||
interceptor.setBlocked(blocked);
|
||||
interceptor.setDefaultBlock(defaultBlocked);
|
||||
setUpParameters(paramNames);
|
||||
runAction();
|
||||
|
||||
}
|
||||
|
||||
private void setUpParameters(String [] paramNames) {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
for (String paramName : paramNames) {
|
||||
params.put(paramName, "irrelevant what this is");
|
||||
|
||||
}
|
||||
ActionContext.getContext().withParameters(HttpParameters.create(params).build());
|
||||
}
|
||||
|
||||
private Collection<String> getParameterNames() {
|
||||
return ActionContext.getContext().getParameters().keySet();
|
||||
}
|
||||
|
||||
public void runAction() throws Exception {
|
||||
interceptor.intercept(invocation);
|
||||
}
|
||||
|
||||
}
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 com.opensymphony.xwork2.interceptor.annotations;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
/**
|
||||
* @author martin.gilday
|
||||
*
|
||||
*/
|
||||
public class AllowingByDefaultAction extends ActionSupport {
|
||||
|
||||
@Blocked
|
||||
private String name;
|
||||
private String job;
|
||||
|
||||
@StrutsParameter
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setJob(String job) {
|
||||
this.job = job;
|
||||
}
|
||||
|
||||
}
|
||||
-41
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 com.opensymphony.xwork2.interceptor.annotations;
|
||||
|
||||
|
||||
/**
|
||||
* @author jafl
|
||||
*
|
||||
*/
|
||||
public class AllowingByDefaultModel {
|
||||
|
||||
@Blocked
|
||||
private String m1;
|
||||
private String m2;
|
||||
|
||||
public void setM1(String s) {
|
||||
m1 = s;
|
||||
}
|
||||
|
||||
public void setM2(String s) {
|
||||
m2 = s;
|
||||
}
|
||||
|
||||
}
|
||||
-199
@@ -1,199 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 com.opensymphony.xwork2.interceptor.annotations;
|
||||
|
||||
import com.mockobjects.dynamic.Mock;
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.StubValueStack;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.struts2.dispatcher.HttpParameters;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author martin.gilday
|
||||
* @author jafl
|
||||
*/
|
||||
public class AnnotationParameterFilterInterceptorTest extends TestCase {
|
||||
|
||||
ValueStack stack;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
stack = new StubValueStack();
|
||||
}
|
||||
|
||||
/**
|
||||
* Only "name" should remain in the parameter map. All others
|
||||
* should be removed
|
||||
*/
|
||||
public void testBlockingByDefault() throws Exception {
|
||||
|
||||
Map<String, Object> parameterMap = new HashMap<>();
|
||||
|
||||
parameterMap.put("job", "Baker");
|
||||
parameterMap.put("name", "Martin");
|
||||
|
||||
ActionContext actionContext = ActionContext.of().bind();
|
||||
actionContext.withParameters(HttpParameters.create(parameterMap).build());
|
||||
|
||||
Action action = new BlockingByDefaultAction();
|
||||
stack.push(action);
|
||||
|
||||
Mock mockInvocation = new Mock(ActionInvocation.class);
|
||||
mockInvocation.expectAndReturn("getInvocationContext", actionContext);
|
||||
mockInvocation.matchAndReturn("getAction", action);
|
||||
mockInvocation.matchAndReturn("getStack", stack);
|
||||
mockInvocation.expectAndReturn("invoke", Action.SUCCESS);
|
||||
mockInvocation.expectAndReturn("getInvocationContext", actionContext);
|
||||
mockInvocation.expectAndReturn("getInvocationContext", actionContext);
|
||||
|
||||
ActionInvocation invocation = (ActionInvocation) mockInvocation.proxy();
|
||||
|
||||
AnnotationParameterFilterInterceptor interceptor = new AnnotationParameterFilterInterceptor();
|
||||
interceptor.intercept(invocation);
|
||||
|
||||
HttpParameters parameters = invocation.getInvocationContext().getParameters();
|
||||
assertEquals("Parameter map should contain one entry", 1, parameters.keySet().size());
|
||||
assertFalse(parameters.get("job").isDefined());
|
||||
assertTrue(parameters.get("name").isDefined());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* "name" should be removed from the map, as it is blocked.
|
||||
* All other parameters should remain
|
||||
*/
|
||||
public void testAllowingByDefault() throws Exception {
|
||||
|
||||
Map<String, Object> parameterMap = new HashMap<>();
|
||||
|
||||
parameterMap.put("job", "Baker");
|
||||
parameterMap.put("name", "Martin");
|
||||
|
||||
ActionContext actionContext = ActionContext.of().bind();
|
||||
actionContext.withParameters(HttpParameters.create(parameterMap).build());
|
||||
|
||||
Action action = new AllowingByDefaultAction();
|
||||
stack.push(action);
|
||||
|
||||
Mock mockInvocation = new Mock(ActionInvocation.class);
|
||||
mockInvocation.expectAndReturn("getInvocationContext", actionContext);
|
||||
mockInvocation.matchAndReturn("getAction", action);
|
||||
mockInvocation.matchAndReturn("getStack", stack);
|
||||
mockInvocation.expectAndReturn("invoke", Action.SUCCESS);
|
||||
mockInvocation.expectAndReturn("getInvocationContext", actionContext);
|
||||
mockInvocation.expectAndReturn("getInvocationContext", actionContext);
|
||||
|
||||
ActionInvocation invocation = (ActionInvocation) mockInvocation.proxy();
|
||||
|
||||
AnnotationParameterFilterInterceptor interceptor = new AnnotationParameterFilterInterceptor();
|
||||
interceptor.intercept(invocation);
|
||||
|
||||
HttpParameters parameters = invocation.getInvocationContext().getParameters();
|
||||
assertEquals("Paramwter map should contain one entry", 1, parameters.keySet().size());
|
||||
assertTrue(parameters.get("job").isDefined());
|
||||
assertFalse(parameters.get("name").isDefined());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Only "name" should remain in the parameter map. All others
|
||||
* should be removed
|
||||
*/
|
||||
public void testBlockingByDefaultWithModel() throws Exception {
|
||||
|
||||
Map<String, Object> parameterMap = new HashMap<>();
|
||||
|
||||
parameterMap.put("job", "Baker");
|
||||
parameterMap.put("name", "Martin");
|
||||
parameterMap.put("m1", "s1");
|
||||
parameterMap.put("m2", "s2");
|
||||
|
||||
ActionContext actionContext = ActionContext.of().bind();
|
||||
actionContext.withParameters(HttpParameters.create(parameterMap).build());
|
||||
stack.push(new BlockingByDefaultModel());
|
||||
|
||||
Mock mockInvocation = new Mock(ActionInvocation.class);
|
||||
mockInvocation.expectAndReturn("getInvocationContext", actionContext);
|
||||
mockInvocation.matchAndReturn("getAction", new BlockingByDefaultAction());
|
||||
mockInvocation.matchAndReturn("getStack", stack);
|
||||
mockInvocation.expectAndReturn("invoke", Action.SUCCESS);
|
||||
mockInvocation.expectAndReturn("getInvocationContext", actionContext);
|
||||
mockInvocation.expectAndReturn("getInvocationContext", actionContext);
|
||||
|
||||
ActionInvocation invocation = (ActionInvocation) mockInvocation.proxy();
|
||||
|
||||
AnnotationParameterFilterInterceptor interceptor = new AnnotationParameterFilterInterceptor();
|
||||
interceptor.intercept(invocation);
|
||||
|
||||
HttpParameters parameters = invocation.getInvocationContext().getParameters();
|
||||
assertEquals("Parameter map should contain two entries", 2, parameters.keySet().size());
|
||||
assertFalse(parameters.get("job").isDefined());
|
||||
assertTrue(parameters.get("name").isDefined());
|
||||
assertTrue(parameters.get("m1").isDefined());
|
||||
assertFalse(parameters.get("m2").isDefined());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* "name" should be removed from the map, as it is blocked.
|
||||
* All other parameters should remain
|
||||
*/
|
||||
public void testAllowingByDefaultWithModel() throws Exception {
|
||||
|
||||
Map<String, Object> parameterMap = new HashMap<>();
|
||||
|
||||
parameterMap.put("job", "Baker");
|
||||
parameterMap.put("name", "Martin");
|
||||
parameterMap.put("m1", "s1");
|
||||
parameterMap.put("m2", "s2");
|
||||
|
||||
ActionContext actionContext = ActionContext.of().bind();
|
||||
actionContext.withParameters(HttpParameters.create(parameterMap).build());
|
||||
stack.push(new AllowingByDefaultModel());
|
||||
|
||||
Mock mockInvocation = new Mock(ActionInvocation.class);
|
||||
mockInvocation.expectAndReturn("getInvocationContext", actionContext);
|
||||
mockInvocation.matchAndReturn("getAction", new AllowingByDefaultAction());
|
||||
mockInvocation.matchAndReturn("getStack", stack);
|
||||
mockInvocation.expectAndReturn("invoke", Action.SUCCESS);
|
||||
mockInvocation.expectAndReturn("getInvocationContext", actionContext);
|
||||
mockInvocation.expectAndReturn("getInvocationContext", actionContext);
|
||||
|
||||
ActionInvocation invocation = (ActionInvocation) mockInvocation.proxy();
|
||||
|
||||
AnnotationParameterFilterInterceptor interceptor = new AnnotationParameterFilterInterceptor();
|
||||
interceptor.intercept(invocation);
|
||||
|
||||
HttpParameters parameters = invocation.getInvocationContext().getParameters();
|
||||
assertEquals("Parameter map should contain two entries", 2, parameters.keySet().size());
|
||||
assertTrue(parameters.get("job").isDefined());
|
||||
assertFalse(parameters.get("name").isDefined());
|
||||
assertFalse(parameters.get("m1").isDefined());
|
||||
assertTrue(parameters.get("m2").isDefined());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 com.opensymphony.xwork2.interceptor.annotations;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
/**
|
||||
* @author martin.gilday
|
||||
*
|
||||
*/
|
||||
@BlockByDefault
|
||||
public class BlockingByDefaultAction extends ActionSupport {
|
||||
|
||||
@Allowed
|
||||
private String name;
|
||||
private String job;
|
||||
|
||||
@StrutsParameter
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setJob(String job) {
|
||||
this.job = job;
|
||||
}
|
||||
|
||||
}
|
||||
-40
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 com.opensymphony.xwork2.interceptor.annotations;
|
||||
|
||||
/**
|
||||
* @author jafl
|
||||
*
|
||||
*/
|
||||
@BlockByDefault
|
||||
public class BlockingByDefaultModel {
|
||||
|
||||
@Allowed
|
||||
private String m1;
|
||||
private String m2;
|
||||
|
||||
public void setM1(String s) {
|
||||
m1 = s;
|
||||
}
|
||||
|
||||
public void setM2(String s) {
|
||||
m2 = s;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,7 +30,6 @@ import com.opensymphony.xwork2.config.entities.InterceptorMapping;
|
||||
import com.opensymphony.xwork2.config.entities.PackageConfig;
|
||||
import com.opensymphony.xwork2.config.entities.ResultConfig;
|
||||
import com.opensymphony.xwork2.inject.ContainerBuilder;
|
||||
import com.opensymphony.xwork2.interceptor.ParametersInterceptor;
|
||||
import com.opensymphony.xwork2.mock.MockResult;
|
||||
import com.opensymphony.xwork2.security.DefaultExcludedPatternsChecker;
|
||||
import com.opensymphony.xwork2.security.DefaultNotExcludedAcceptedPatternsChecker;
|
||||
@@ -38,9 +37,10 @@ import com.opensymphony.xwork2.security.ExcludedPatternsChecker;
|
||||
import com.opensymphony.xwork2.security.NotExcludedAcceptedPatternsChecker;
|
||||
import com.opensymphony.xwork2.util.location.LocatableProperties;
|
||||
import com.opensymphony.xwork2.validator.ValidationInterceptor;
|
||||
import org.apache.struts2.result.ServletDispatcherResult;
|
||||
import org.apache.struts2.interceptor.TokenInterceptor;
|
||||
import org.apache.struts2.interceptor.TokenSessionStoreInterceptor;
|
||||
import org.apache.struts2.interceptor.parameter.ParametersInterceptor;
|
||||
import org.apache.struts2.result.ServletDispatcherResult;
|
||||
import org.apache.struts2.views.jsp.ui.DoubleValidationAction;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -67,7 +67,7 @@ public class TestConfigurationProvider implements ConfigurationProvider {
|
||||
*/
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
|
||||
public void init(Configuration config) {
|
||||
this.configuration = config;
|
||||
}
|
||||
|
||||
+2
-2
@@ -32,17 +32,17 @@ import com.opensymphony.xwork2.config.entities.InterceptorMapping;
|
||||
import com.opensymphony.xwork2.config.entities.PackageConfig;
|
||||
import com.opensymphony.xwork2.config.entities.ResultConfig;
|
||||
import com.opensymphony.xwork2.inject.ContainerBuilder;
|
||||
import com.opensymphony.xwork2.interceptor.ParametersInterceptor;
|
||||
import com.opensymphony.xwork2.mock.MockResult;
|
||||
import com.opensymphony.xwork2.ognl.OgnlUtil;
|
||||
import com.opensymphony.xwork2.util.location.LocatableProperties;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import org.apache.struts2.StrutsInternalTestCase;
|
||||
import org.apache.struts2.dispatcher.HttpParameters;
|
||||
import org.apache.struts2.interceptor.exec.ExecutorProvider;
|
||||
import org.apache.struts2.interceptor.parameter.ParametersInterceptor;
|
||||
import org.apache.struts2.views.jsp.StrutsMockHttpServletRequest;
|
||||
import org.apache.struts2.views.jsp.StrutsMockHttpSession;
|
||||
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@
|
||||
<result-type name="chain" class="com.opensymphony.xwork2.ActionChainResult" default="true"/>
|
||||
</result-types>
|
||||
<interceptors>
|
||||
<interceptor name="params" class="com.opensymphony.xwork2.interceptor.ParametersInterceptor"/>
|
||||
<interceptor name="params" class="org.apache.struts2.interceptor.parameter.ParametersInterceptor"/>
|
||||
</interceptors>
|
||||
</package>
|
||||
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@
|
||||
<result-type name="chain" class="com.opensymphony.xwork2.ActionChainResult" default="true"/>
|
||||
</result-types>
|
||||
<interceptors>
|
||||
<interceptor name="params" class="com.opensymphony.xwork2.interceptor.ParametersInterceptor"/>
|
||||
<interceptor name="params" class="org.apache.struts2.interceptor.parameter.ParametersInterceptor"/>
|
||||
</interceptors>
|
||||
</package>
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<interceptors>
|
||||
<interceptor name="logger" class="com.opensymphony.xwork2.interceptor.LoggingInterceptor"/>
|
||||
<interceptor name="chain" class="com.opensymphony.xwork2.interceptor.ChainingInterceptor"/>
|
||||
<interceptor name="params" class="com.opensymphony.xwork2.interceptor.ParametersInterceptor"/>
|
||||
<interceptor name="params" class="org.apache.struts2.interceptor.parameter.ParametersInterceptor"/>
|
||||
<interceptor name="staticParams" class="com.opensymphony.xwork2.interceptor.StaticParametersInterceptor"/>
|
||||
<interceptor name="modelDriven" class="com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor"/>
|
||||
<interceptor name="validation" class="com.opensymphony.xwork2.validator.ValidationInterceptor"/>
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<interceptors>
|
||||
<interceptor name="logger" class="com.opensymphony.xwork2.interceptor.LoggingInterceptor"/>
|
||||
<interceptor name="chain" class="com.opensymphony.xwork2.interceptor.ChainingInterceptor"/>
|
||||
<interceptor name="params" class="com.opensymphony.xwork2.interceptor.ParametersInterceptor"/>
|
||||
<interceptor name="params" class="org.apache.struts2.interceptor.parameter.ParametersInterceptor"/>
|
||||
<interceptor name="staticParams" class="com.opensymphony.xwork2.interceptor.StaticParametersInterceptor"/>
|
||||
<interceptor name="modelDriven" class="com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor"/>
|
||||
<interceptor name="validation" class="com.opensymphony.xwork2.validator.ValidationInterceptor"/>
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<interceptors>
|
||||
<interceptor name="logger" class="com.opensymphony.xwork2.interceptor.LoggingInterceptor"/>
|
||||
<interceptor name="chain" class="com.opensymphony.xwork2.interceptor.ChainingInterceptor"/>
|
||||
<interceptor name="params" class="com.opensymphony.xwork2.interceptor.ParametersInterceptor"/>
|
||||
<interceptor name="params" class="org.apache.struts2.interceptor.parameter.ParametersInterceptor"/>
|
||||
<interceptor name="staticParams" class="com.opensymphony.xwork2.interceptor.StaticParametersInterceptor"/>
|
||||
<interceptor name="modelDriven" class="com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor"/>
|
||||
<interceptor name="validation" class="com.opensymphony.xwork2.validator.ValidationInterceptor">
|
||||
|
||||
@@ -25,6 +25,10 @@ import com.opensymphony.xwork2.config.Configuration;
|
||||
import com.opensymphony.xwork2.interceptor.ValidationAware;
|
||||
import com.opensymphony.xwork2.interceptor.annotations.After;
|
||||
import com.opensymphony.xwork2.interceptor.annotations.Before;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.struts2.dispatcher.Dispatcher;
|
||||
@@ -39,10 +43,6 @@ import org.springframework.mock.web.MockHttpSession;
|
||||
import org.springframework.mock.web.MockPageContext;
|
||||
import org.springframework.mock.web.MockServletContext;
|
||||
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
@@ -130,7 +130,7 @@ public abstract class StrutsJUnit4TestCase<T> extends XWorkJUnit4TestCase {
|
||||
ServletActionContext.setRequest(request);
|
||||
ServletActionContext.setResponse(response);
|
||||
|
||||
ServletActionContext.getContext().put(ServletActionContext.ACTION_MAPPING, mapping);
|
||||
ServletActionContext.getActionContext().put(ServletActionContext.ACTION_MAPPING, mapping);
|
||||
|
||||
return proxy;
|
||||
}
|
||||
|
||||
+2
-4
@@ -35,10 +35,8 @@
|
||||
</result-types>
|
||||
|
||||
<interceptors>
|
||||
<interceptor name="chain"
|
||||
class="com.opensymphony.xwork2.interceptor.ChainingInterceptor"/>
|
||||
<interceptor name="params"
|
||||
class="com.opensymphony.xwork2.interceptor.ParametersInterceptor"/>
|
||||
<interceptor name="chain" class="com.opensymphony.xwork2.interceptor.ChainingInterceptor"/>
|
||||
<interceptor name="params" class="org.apache.struts2.interceptor.parameter.ParametersInterceptor"/>
|
||||
</interceptors>
|
||||
|
||||
<action name="simpleAction" class="simple-action"/>
|
||||
|
||||
+8
-16
@@ -19,6 +19,14 @@
|
||||
package org.apache.struts2.tiles;
|
||||
|
||||
import com.opensymphony.xwork2.util.TextParseUtil;
|
||||
import jakarta.el.ArrayELResolver;
|
||||
import jakarta.el.BeanELResolver;
|
||||
import jakarta.el.CompositeELResolver;
|
||||
import jakarta.el.ELResolver;
|
||||
import jakarta.el.ListELResolver;
|
||||
import jakarta.el.MapELResolver;
|
||||
import jakarta.el.ResourceBundleELResolver;
|
||||
import jakarta.servlet.jsp.JspFactory;
|
||||
import ognl.OgnlException;
|
||||
import ognl.OgnlRuntime;
|
||||
import ognl.PropertyAccessor;
|
||||
@@ -59,14 +67,6 @@ import org.apache.tiles.request.render.BasicRendererFactory;
|
||||
import org.apache.tiles.request.render.ChainedDelegateRenderer;
|
||||
import org.apache.tiles.request.render.Renderer;
|
||||
|
||||
import jakarta.el.ArrayELResolver;
|
||||
import jakarta.el.BeanELResolver;
|
||||
import jakarta.el.CompositeELResolver;
|
||||
import jakarta.el.ELResolver;
|
||||
import jakarta.el.ListELResolver;
|
||||
import jakarta.el.MapELResolver;
|
||||
import jakarta.el.ResourceBundleELResolver;
|
||||
import jakarta.servlet.jsp.JspFactory;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -105,14 +105,6 @@ public class StrutsTilesContainerFactory extends BasicTilesContainerFactory {
|
||||
*/
|
||||
public static final Set<String> TILES_DEFAULT_PATTERNS = TextParseUtil.commaDelimitedStringToSet("*tiles*.xml");
|
||||
|
||||
/**
|
||||
* Default pattern to be used to collect Tiles definitions if user didn't configure any
|
||||
*
|
||||
* @deprecated since Struts 6.4.0, use {@link #TILES_DEFAULT_PATTERNS} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String TILES_DEFAULT_PATTERN = String.join(",", TILES_DEFAULT_PATTERNS);
|
||||
|
||||
/**
|
||||
* Supported expression languages
|
||||
*/
|
||||
|
||||
-18
@@ -22,7 +22,6 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
import org.apache.struts2.util.ValueStackProvider;
|
||||
import org.apache.velocity.VelocityContext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
@@ -44,23 +43,6 @@ public class StrutsVelocityContext extends VelocityContext implements ValueStack
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated please use {@link #StrutsVelocityContext(List, ValueStack)}
|
||||
* and pass {null} or empty list if no chained contexts were defined
|
||||
*/
|
||||
@Deprecated
|
||||
public StrutsVelocityContext(ValueStack stack) {
|
||||
this((List<VelocityContext>) null, stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated please use {@link #StrutsVelocityContext(List, ValueStack)}
|
||||
*/
|
||||
@Deprecated
|
||||
public StrutsVelocityContext(VelocityContext[] chainedContexts, ValueStack stack) {
|
||||
this(new ArrayList<>(Arrays.asList(chainedContexts)), stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean internalContainsKey(String key) {
|
||||
return internalGet(key) != null;
|
||||
|
||||
-8
@@ -102,12 +102,4 @@ public class VelocityTagLibrary implements TagLibraryDirectiveProvider {
|
||||
return Arrays.asList(directives);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated please use {#getDirectiveClasses}
|
||||
*/
|
||||
@Deprecated()
|
||||
public List<Class<?>> getVelocityDirectiveClasses() {
|
||||
return getDirectiveClasses();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user