This is an automated email from the ASF dual-hosted git repository. kusal pushed a commit to branch 7.0.x/WW-5411-delete-deprecated in repository https://gitbox.apache.org/repos/asf/struts.git
commit 5919178ce956d6db679b8cf307ae75f49f026735 Author: Kusal Kithul-Godage <g...@kusal.io> AuthorDate: Thu Jul 25 19:52:01 2024 +1000 WW-5411 Delete deprecated code part 1 --- .../conversion/impl/InstantiatingNullHandler.java | 18 +- .../opensymphony/xwork2/inject/util/Strings.java | 57 ----- .../xwork2/interceptor/AliasInterceptor.java | 10 +- .../xwork2/interceptor/ModelDrivenInterceptor.java | 5 +- .../xwork2/interceptor/NoParameters.java | 37 ---- .../interceptor/ParameterFilterInterceptor.java | 241 --------------------- .../xwork2/interceptor/ParameterNameAware.java | 26 --- .../xwork2/interceptor/ParameterValueAware.java | 26 --- .../xwork2/interceptor/ParametersInterceptor.java | 25 --- .../interceptor/StaticParametersInterceptor.java | 6 +- .../xwork2/interceptor/annotations/Allowed.java | 38 ---- .../AnnotationParameterFilterInterceptor.java | 115 ---------- .../interceptor/annotations/BlockByDefault.java | 41 ---- .../xwork2/interceptor/annotations/Blocked.java | 38 ---- .../org/apache/struts2/ServletActionContext.java | 13 +- core/src/main/resources/struts-default.xml | 4 +- core/src/main/resources/xwork-default.xml | 4 +- .../providers/MockConfigurationProvider.java | 38 ++-- .../XmlConfigurationProviderMultilevelTest.java | 2 +- .../ParameterFilterInterceptorTest.java | 127 ----------- .../annotations/AllowingByDefaultAction.java | 44 ---- .../annotations/AllowingByDefaultModel.java | 41 ---- .../AnnotationParameterFilterInterceptorTest.java | 199 ----------------- .../annotations/BlockingByDefaultAction.java | 45 ---- .../annotations/BlockingByDefaultModel.java | 40 ---- .../apache/struts2/TestConfigurationProvider.java | 6 +- .../interceptor/ExecuteAndWaitInterceptorTest.java | 4 +- .../config/providers/xwork-include-parent.xml | 2 +- .../config/providers/xwork-test-multilevel.xml | 2 +- core/src/test/resources/xwork-proxyinvoke.xml | 2 +- core/src/test/resources/xwork-test-default.xml | 2 +- core/src/test/resources/xwork-test-validation.xml | 2 +- .../apache/struts2/junit/StrutsJUnit4TestCase.java | 10 +- .../xwork2/spring/actionContext-xwork.xml | 6 +- .../struts2/tiles/StrutsTilesContainerFactory.java | 24 +- .../views/velocity/StrutsVelocityContext.java | 18 -- .../struts2/views/velocity/VelocityTagLibrary.java | 8 - 37 files changed, 78 insertions(+), 1248 deletions(-) diff --git a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/InstantiatingNullHandler.java b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/InstantiatingNullHandler.java index 9b74f76fc..e7cc1713b 100644 --- a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/InstantiatingNullHandler.java +++ b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/InstantiatingNullHandler.java @@ -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> diff --git a/core/src/main/java/com/opensymphony/xwork2/inject/util/Strings.java b/core/src/main/java/com/opensymphony/xwork2/inject/util/Strings.java deleted file mode 100644 index 2c4df91d9..000000000 --- a/core/src/main/java/com/opensymphony/xwork2/inject/util/Strings.java +++ /dev/null @@ -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 crazy...@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); - } -} diff --git a/core/src/main/java/com/opensymphony/xwork2/interceptor/AliasInterceptor.java b/core/src/main/java/com/opensymphony/xwork2/interceptor/AliasInterceptor.java index 9edafe3fc..c57df3dab 100644 --- a/core/src/main/java/com/opensymphony/xwork2/interceptor/AliasInterceptor.java +++ b/core/src/main/java/com/opensymphony/xwork2/interceptor/AliasInterceptor.java @@ -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(); } diff --git a/core/src/main/java/com/opensymphony/xwork2/interceptor/ModelDrivenInterceptor.java b/core/src/main/java/com/opensymphony/xwork2/interceptor/ModelDrivenInterceptor.java index fa90a315c..f1919a8c9 100644 --- a/core/src/main/java/com/opensymphony/xwork2/interceptor/ModelDrivenInterceptor.java +++ b/core/src/main/java/com/opensymphony/xwork2/interceptor/ModelDrivenInterceptor.java @@ -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$ */ diff --git a/core/src/main/java/com/opensymphony/xwork2/interceptor/NoParameters.java b/core/src/main/java/com/opensymphony/xwork2/interceptor/NoParameters.java deleted file mode 100644 index d4fb7ad14..000000000 --- a/core/src/main/java/com/opensymphony/xwork2/interceptor/NoParameters.java +++ /dev/null @@ -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 { -} diff --git a/core/src/main/java/com/opensymphony/xwork2/interceptor/ParameterFilterInterceptor.java b/core/src/main/java/com/opensymphony/xwork2/interceptor/ParameterFilterInterceptor.java deleted file mode 100644 index 1b402509c..000000000 --- a/core/src/main/java/com/opensymphony/xwork2/interceptor/ParameterFilterInterceptor.java +++ /dev/null @@ -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); - } - -} diff --git a/core/src/main/java/com/opensymphony/xwork2/interceptor/ParameterNameAware.java b/core/src/main/java/com/opensymphony/xwork2/interceptor/ParameterNameAware.java deleted file mode 100644 index ae73871cd..000000000 --- a/core/src/main/java/com/opensymphony/xwork2/interceptor/ParameterNameAware.java +++ /dev/null @@ -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 { -} diff --git a/core/src/main/java/com/opensymphony/xwork2/interceptor/ParameterValueAware.java b/core/src/main/java/com/opensymphony/xwork2/interceptor/ParameterValueAware.java deleted file mode 100644 index 4c9a4e109..000000000 --- a/core/src/main/java/com/opensymphony/xwork2/interceptor/ParameterValueAware.java +++ /dev/null @@ -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 { -} diff --git a/core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java b/core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java deleted file mode 100644 index aa9518208..000000000 --- a/core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java +++ /dev/null @@ -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 { -} diff --git a/core/src/main/java/com/opensymphony/xwork2/interceptor/StaticParametersInterceptor.java b/core/src/main/java/com/opensymphony/xwork2/interceptor/StaticParametersInterceptor.java index 9d32a8a18..b95a0e6e6 100644 --- a/core/src/main/java/com/opensymphony/xwork2/interceptor/StaticParametersInterceptor.java +++ b/core/src/main/java/com/opensymphony/xwork2/interceptor/StaticParametersInterceptor.java @@ -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); diff --git a/core/src/main/java/com/opensymphony/xwork2/interceptor/annotations/Allowed.java b/core/src/main/java/com/opensymphony/xwork2/interceptor/annotations/Allowed.java deleted file mode 100644 index 39bfdcb26..000000000 --- a/core/src/main/java/com/opensymphony/xwork2/interceptor/annotations/Allowed.java +++ /dev/null @@ -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 { - -} diff --git a/core/src/main/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationParameterFilterInterceptor.java b/core/src/main/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationParameterFilterInterceptor.java deleted file mode 100644 index d1b7260ac..000000000 --- a/core/src/main/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationParameterFilterInterceptor.java +++ /dev/null @@ -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(); - } - -} diff --git a/core/src/main/java/com/opensymphony/xwork2/interceptor/annotations/BlockByDefault.java b/core/src/main/java/com/opensymphony/xwork2/interceptor/annotations/BlockByDefault.java deleted file mode 100644 index e7b452022..000000000 --- a/core/src/main/java/com/opensymphony/xwork2/interceptor/annotations/BlockByDefault.java +++ /dev/null @@ -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 { - -} diff --git a/core/src/main/java/com/opensymphony/xwork2/interceptor/annotations/Blocked.java b/core/src/main/java/com/opensymphony/xwork2/interceptor/annotations/Blocked.java deleted file mode 100644 index 17ec80940..000000000 --- a/core/src/main/java/com/opensymphony/xwork2/interceptor/annotations/Blocked.java +++ /dev/null @@ -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 { - -} diff --git a/core/src/main/java/org/apache/struts2/ServletActionContext.java b/core/src/main/java/org/apache/struts2/ServletActionContext.java index bf0cd8493..e6038e302 100644 --- a/core/src/main/java/org/apache/struts2/ServletActionContext.java +++ b/core/src/main/java/org/apache/struts2/ServletActionContext.java @@ -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(); } diff --git a/core/src/main/resources/struts-default.xml b/core/src/main/resources/struts-default.xml index 326477bc4..70e06ce5c 100644 --- a/core/src/main/resources/struts-default.xml +++ b/core/src/main/resources/struts-default.xml @@ -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"/> diff --git a/core/src/main/resources/xwork-default.xml b/core/src/main/resources/xwork-default.xml index c25cdc59c..152236e8e 100644 --- a/core/src/main/resources/xwork-default.xml +++ b/core/src/main/resources/xwork-default.xml @@ -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" diff --git a/core/src/test/java/com/opensymphony/xwork2/config/providers/MockConfigurationProvider.java b/core/src/test/java/com/opensymphony/xwork2/config/providers/MockConfigurationProvider.java index 824d21890..782f4c344 100644 --- a/core/src/test/java/com/opensymphony/xwork2/config/providers/MockConfigurationProvider.java +++ b/core/src/test/java/com/opensymphony/xwork2/config/providers/MockConfigurationProvider.java @@ -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 diff --git a/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderMultilevelTest.java b/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderMultilevelTest.java index 1ee3a98ea..c76ada3cb 100644 --- a/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderMultilevelTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderMultilevelTest.java @@ -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; diff --git a/core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterFilterInterceptorTest.java b/core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterFilterInterceptorTest.java deleted file mode 100644 index da7cefc03..000000000 --- a/core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterFilterInterceptorTest.java +++ /dev/null @@ -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); - } - -} diff --git a/core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/AllowingByDefaultAction.java b/core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/AllowingByDefaultAction.java deleted file mode 100644 index 21ec5462e..000000000 --- a/core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/AllowingByDefaultAction.java +++ /dev/null @@ -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; - } - -} diff --git a/core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/AllowingByDefaultModel.java b/core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/AllowingByDefaultModel.java deleted file mode 100644 index ce8fb4dd8..000000000 --- a/core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/AllowingByDefaultModel.java +++ /dev/null @@ -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; - } - -} diff --git a/core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationParameterFilterInterceptorTest.java b/core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationParameterFilterInterceptorTest.java deleted file mode 100644 index 7f9b6766a..000000000 --- a/core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationParameterFilterInterceptorTest.java +++ /dev/null @@ -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()); - - } - -} diff --git a/core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/BlockingByDefaultAction.java b/core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/BlockingByDefaultAction.java deleted file mode 100644 index 499fb2c94..000000000 --- a/core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/BlockingByDefaultAction.java +++ /dev/null @@ -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; - } - -} diff --git a/core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/BlockingByDefaultModel.java b/core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/BlockingByDefaultModel.java deleted file mode 100644 index fb62f5189..000000000 --- a/core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/BlockingByDefaultModel.java +++ /dev/null @@ -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; - } - -} diff --git a/core/src/test/java/org/apache/struts2/TestConfigurationProvider.java b/core/src/test/java/org/apache/struts2/TestConfigurationProvider.java index ce6bcc10c..9be3f2233 100644 --- a/core/src/test/java/org/apache/struts2/TestConfigurationProvider.java +++ b/core/src/test/java/org/apache/struts2/TestConfigurationProvider.java @@ -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; } diff --git a/core/src/test/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptorTest.java b/core/src/test/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptorTest.java index 8e94382fa..3a6a25227 100644 --- a/core/src/test/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptorTest.java +++ b/core/src/test/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptorTest.java @@ -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; diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-include-parent.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-include-parent.xml index b02746dfb..fc7ca3829 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-include-parent.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-include-parent.xml @@ -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> diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-multilevel.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-multilevel.xml index 2d4b0a6a2..b86dbc2e4 100644 --- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-multilevel.xml +++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-multilevel.xml @@ -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> diff --git a/core/src/test/resources/xwork-proxyinvoke.xml b/core/src/test/resources/xwork-proxyinvoke.xml index ca2555ed7..8686bbfc8 100644 --- a/core/src/test/resources/xwork-proxyinvoke.xml +++ b/core/src/test/resources/xwork-proxyinvoke.xml @@ -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"/> diff --git a/core/src/test/resources/xwork-test-default.xml b/core/src/test/resources/xwork-test-default.xml index 95da09c49..5d27f64b8 100644 --- a/core/src/test/resources/xwork-test-default.xml +++ b/core/src/test/resources/xwork-test-default.xml @@ -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"/> diff --git a/core/src/test/resources/xwork-test-validation.xml b/core/src/test/resources/xwork-test-validation.xml index 90721d763..a570f9335 100644 --- a/core/src/test/resources/xwork-test-validation.xml +++ b/core/src/test/resources/xwork-test-validation.xml @@ -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"> diff --git a/plugins/junit/src/main/java/org/apache/struts2/junit/StrutsJUnit4TestCase.java b/plugins/junit/src/main/java/org/apache/struts2/junit/StrutsJUnit4TestCase.java index 75e061c84..f57c985a2 100644 --- a/plugins/junit/src/main/java/org/apache/struts2/junit/StrutsJUnit4TestCase.java +++ b/plugins/junit/src/main/java/org/apache/struts2/junit/StrutsJUnit4TestCase.java @@ -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; } diff --git a/plugins/spring/src/test/resources/com/opensymphony/xwork2/spring/actionContext-xwork.xml b/plugins/spring/src/test/resources/com/opensymphony/xwork2/spring/actionContext-xwork.xml index c454bac3e..044dc3356 100644 --- a/plugins/spring/src/test/resources/com/opensymphony/xwork2/spring/actionContext-xwork.xml +++ b/plugins/spring/src/test/resources/com/opensymphony/xwork2/spring/actionContext-xwork.xml @@ -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"/> diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java index d6e7cf9b3..41d5ccbfd 100644 --- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java +++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java @@ -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 */ diff --git a/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/StrutsVelocityContext.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/StrutsVelocityContext.java index d18ca6bcf..217d2ad28 100644 --- a/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/StrutsVelocityContext.java +++ b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/StrutsVelocityContext.java @@ -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; diff --git a/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityTagLibrary.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityTagLibrary.java index f4d37d02d..eb37a93e6 100644 --- a/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityTagLibrary.java +++ b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityTagLibrary.java @@ -102,12 +102,4 @@ public class VelocityTagLibrary implements TagLibraryDirectiveProvider { return Arrays.asList(directives); } - /** - * @deprecated please use {#getDirectiveClasses} - */ - @Deprecated() - public List<Class<?>> getVelocityDirectiveClasses() { - return getDirectiveClasses(); - } - }