Repository: struts Updated Branches: refs/heads/master fd0db8656 -> b532ad06b
WW-4518 Moves classes to proper packages Project: http://git-wip-us.apache.org/repos/asf/struts/repo Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/b532ad06 Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/b532ad06 Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/b532ad06 Branch: refs/heads/master Commit: b532ad06b7172e5de3dc9aa7e27b80ebe272adaf Parents: fd0db86 Author: Lukasz Lenart <[email protected]> Authored: Tue Jun 23 17:39:39 2015 +0200 Committer: Lukasz Lenart <[email protected]> Committed: Tue Jun 23 17:39:39 2015 +0200 ---------------------------------------------------------------------- .../factory/PrefixBasedActionProxyFactory.java | 89 ++++++++++++++++++++ .../struts2/factory/StrutsActionProxy.java | 80 ++++++++++++++++++ .../factory/StrutsActionProxyFactory.java | 40 +++++++++ .../impl/PrefixBasedActionProxyFactory.java | 89 -------------------- .../apache/struts2/impl/StrutsActionProxy.java | 80 ------------------ .../struts2/impl/StrutsActionProxyFactory.java | 40 --------- .../interceptor/ServletConfigInterceptor.java | 2 +- .../servlet/ServletPrincipalProxy.java | 81 ++++++++++++++++++ .../interceptor/ServletPrincipalProxy.java | 81 ------------------ core/src/main/resources/struts-default.xml | 4 +- 10 files changed, 293 insertions(+), 293 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/struts/blob/b532ad06/core/src/main/java/org/apache/struts2/factory/PrefixBasedActionProxyFactory.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/struts2/factory/PrefixBasedActionProxyFactory.java b/core/src/main/java/org/apache/struts2/factory/PrefixBasedActionProxyFactory.java new file mode 100644 index 0000000..5aa1650 --- /dev/null +++ b/core/src/main/java/org/apache/struts2/factory/PrefixBasedActionProxyFactory.java @@ -0,0 +1,89 @@ +package org.apache.struts2.factory; + +import com.opensymphony.xwork2.ActionProxy; +import com.opensymphony.xwork2.ActionProxyFactory; +import com.opensymphony.xwork2.DefaultActionProxyFactory; +import com.opensymphony.xwork2.inject.Container; +import com.opensymphony.xwork2.inject.Inject; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.struts2.StrutsConstants; + +import java.util.HashMap; +import java.util.Map; + +/** + * <!-- START SNIPPET: description --> + * Prefix based factory should be used with {@link org.apache.struts2.dispatcher.mapper.PrefixBasedActionMapper} + * to use appropriate {@link com.opensymphony.xwork2.ActionProxyFactory} connected with given + * {@link org.apache.struts2.dispatcher.mapper.ActionMapper} + * + * Add below entry to struts.xml to enable the factory: + * <p/> + * <pre> + * <constant name="struts.actionProxyFactory" value="prefix"/> + * </pre> + * + * The factory will use the same set of patterns as defined with: + * <p/> + * <pre> + * <constant name="struts.mapper.prefixMapping" value="..."/> + * </pre> + * <!-- END SNIPPET: description --> + */ +public class PrefixBasedActionProxyFactory extends DefaultActionProxyFactory { + + private static final Logger LOG = LogManager.getLogger(PrefixBasedActionProxyFactory.class); + + private Map<String, ActionProxyFactory> actionProxyFactories = new HashMap<>(); + private ActionProxyFactory defaultFactory; + + @Inject + public void setContainer(Container container) { + this.container = container; + } + + @Inject(StrutsConstants.STRUTS_ACTIONPROXYFACTORY) + public void setActionProxyFactory(ActionProxyFactory factory) { + this.defaultFactory = factory; + } + + @Inject(StrutsConstants.PREFIX_BASED_MAPPER_CONFIGURATION) + public void setPrefixBasedActionProxyFactories(String list) { + if (list != null) { + String[] factories = list.split(","); + for (String factory : factories) { + String[] thisFactory = factory.split(":"); + if (thisFactory.length == 2) { + String factoryPrefix = thisFactory[0].trim(); + String factoryName = thisFactory[1].trim(); + ActionProxyFactory obj = container.getInstance(ActionProxyFactory.class, factoryName); + if (obj != null) { + actionProxyFactories.put(factoryPrefix, obj); + } else { + LOG.warn("Invalid PrefixBasedActionProxyFactory config entry: [{}]", factory); + } + } + } + } + } + + public ActionProxy createActionProxy(String namespace, String actionName, String methodName, + Map<String, Object> extraContext, boolean executeResult, boolean cleanupContext) { + + String uri = namespace + (namespace.endsWith("/") ? actionName : "/" + actionName); + for (int lastIndex = uri.lastIndexOf('/'); lastIndex > (-1); lastIndex = uri.lastIndexOf('/', lastIndex - 1)) { + String key = uri.substring(0, lastIndex); + ActionProxyFactory actionProxyFactory = actionProxyFactories.get(key); + if (actionProxyFactory != null) { + LOG.debug("Using ActionProxyFactory [{}] for prefix [{}]", actionProxyFactory, key); + return actionProxyFactory.createActionProxy(namespace, actionName, methodName, extraContext, executeResult, cleanupContext); + } else { + LOG.debug("No ActionProxyFactory defined for [{}]", key); + } + } + LOG.debug("Cannot find any matching ActionProxyFactory, falling back to [{}]", defaultFactory); + return defaultFactory.createActionProxy(namespace, actionName, methodName, extraContext, executeResult, cleanupContext); + } + +} http://git-wip-us.apache.org/repos/asf/struts/blob/b532ad06/core/src/main/java/org/apache/struts2/factory/StrutsActionProxy.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/struts2/factory/StrutsActionProxy.java b/core/src/main/java/org/apache/struts2/factory/StrutsActionProxy.java new file mode 100644 index 0000000..52f2efb --- /dev/null +++ b/core/src/main/java/org/apache/struts2/factory/StrutsActionProxy.java @@ -0,0 +1,80 @@ +/* + * $Id$ + * + * 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. + */ + +// Copyright 2006 Google Inc. All Rights Reserved. + +package org.apache.struts2.factory; + +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.ActionInvocation; +import com.opensymphony.xwork2.DefaultActionProxy; +import com.opensymphony.xwork2.util.LocalizedTextUtil; +import org.apache.struts2.ServletActionContext; + +import java.util.Locale; + +public class StrutsActionProxy extends DefaultActionProxy { + + private static final long serialVersionUID = -2434901249671934080L; + + public StrutsActionProxy(ActionInvocation inv, String namespace, String actionName, String methodName, + boolean executeResult, boolean cleanupContext) { + super(inv, namespace, actionName, methodName, executeResult, cleanupContext); + } + + public String execute() throws Exception { + ActionContext previous = ActionContext.getContext(); + ActionContext.setContext(invocation.getInvocationContext()); + try { +// This is for the new API: +// return RequestContextImpl.callInContext(invocation, new Callable<String>() { +// public String call() throws Exception { +// return invocation.invoke(); +// } +// }); + + return invocation.invoke(); + } finally { + if (cleanupContext) + ActionContext.setContext(previous); + } + } + + @Override + protected void prepare() { + super.prepare(); + } + + @Override + protected String getErrorMessage() { + if ((namespace != null) && (namespace.trim().length() > 0)) { + String contextPath = ServletActionContext.getRequest().getContextPath(); + return LocalizedTextUtil.findDefaultText( + "struts.exception.missing-package-action.with-context", + Locale.getDefault(), + new String[]{namespace, actionName, contextPath} + ); + } else { + return super.getErrorMessage(); + } + } + +} http://git-wip-us.apache.org/repos/asf/struts/blob/b532ad06/core/src/main/java/org/apache/struts2/factory/StrutsActionProxyFactory.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/struts2/factory/StrutsActionProxyFactory.java b/core/src/main/java/org/apache/struts2/factory/StrutsActionProxyFactory.java new file mode 100644 index 0000000..5d00dde --- /dev/null +++ b/core/src/main/java/org/apache/struts2/factory/StrutsActionProxyFactory.java @@ -0,0 +1,40 @@ +/* + * $Id$ + * + * 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. + */ + +// Copyright 2006 Google Inc. All Rights Reserved. + +package org.apache.struts2.factory; + +import com.opensymphony.xwork2.ActionInvocation; +import com.opensymphony.xwork2.ActionProxy; +import com.opensymphony.xwork2.DefaultActionProxyFactory; + +public class StrutsActionProxyFactory extends DefaultActionProxyFactory { + + @Override + public ActionProxy createActionProxy(ActionInvocation inv, String namespace, String actionName, String methodName, boolean executeResult, boolean cleanupContext) { + + StrutsActionProxy proxy = new StrutsActionProxy(inv, namespace, actionName, methodName, executeResult, cleanupContext); + container.inject(proxy); + proxy.prepare(); + return proxy; + } +} http://git-wip-us.apache.org/repos/asf/struts/blob/b532ad06/core/src/main/java/org/apache/struts2/impl/PrefixBasedActionProxyFactory.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/struts2/impl/PrefixBasedActionProxyFactory.java b/core/src/main/java/org/apache/struts2/impl/PrefixBasedActionProxyFactory.java deleted file mode 100644 index 02f39a8..0000000 --- a/core/src/main/java/org/apache/struts2/impl/PrefixBasedActionProxyFactory.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.apache.struts2.impl; - -import com.opensymphony.xwork2.ActionProxy; -import com.opensymphony.xwork2.ActionProxyFactory; -import com.opensymphony.xwork2.DefaultActionProxyFactory; -import com.opensymphony.xwork2.inject.Container; -import com.opensymphony.xwork2.inject.Inject; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.apache.struts2.StrutsConstants; - -import java.util.HashMap; -import java.util.Map; - -/** - * <!-- START SNIPPET: description --> - * Prefix based factory should be used with {@link org.apache.struts2.dispatcher.mapper.PrefixBasedActionMapper} - * to use appropriate {@link com.opensymphony.xwork2.ActionProxyFactory} connected with given - * {@link org.apache.struts2.dispatcher.mapper.ActionMapper} - * - * Add below entry to struts.xml to enable the factory: - * <p/> - * <pre> - * <constant name="struts.actionProxyFactory" value="prefix"/> - * </pre> - * - * The factory will use the same set of patterns as defined with: - * <p/> - * <pre> - * <constant name="struts.mapper.prefixMapping" value="..."/> - * </pre> - * <!-- END SNIPPET: description --> - */ -public class PrefixBasedActionProxyFactory extends DefaultActionProxyFactory { - - private static final Logger LOG = LogManager.getLogger(PrefixBasedActionProxyFactory.class); - - private Map<String, ActionProxyFactory> actionProxyFactories = new HashMap<>(); - private ActionProxyFactory defaultFactory; - - @Inject - public void setContainer(Container container) { - this.container = container; - } - - @Inject(StrutsConstants.STRUTS_ACTIONPROXYFACTORY) - public void setActionProxyFactory(ActionProxyFactory factory) { - this.defaultFactory = factory; - } - - @Inject(StrutsConstants.PREFIX_BASED_MAPPER_CONFIGURATION) - public void setPrefixBasedActionProxyFactories(String list) { - if (list != null) { - String[] factories = list.split(","); - for (String factory : factories) { - String[] thisFactory = factory.split(":"); - if (thisFactory.length == 2) { - String factoryPrefix = thisFactory[0].trim(); - String factoryName = thisFactory[1].trim(); - ActionProxyFactory obj = container.getInstance(ActionProxyFactory.class, factoryName); - if (obj != null) { - actionProxyFactories.put(factoryPrefix, obj); - } else { - LOG.warn("Invalid PrefixBasedActionProxyFactory config entry: [{}]", factory); - } - } - } - } - } - - public ActionProxy createActionProxy(String namespace, String actionName, String methodName, - Map<String, Object> extraContext, boolean executeResult, boolean cleanupContext) { - - String uri = namespace + (namespace.endsWith("/") ? actionName : "/" + actionName); - for (int lastIndex = uri.lastIndexOf('/'); lastIndex > (-1); lastIndex = uri.lastIndexOf('/', lastIndex - 1)) { - String key = uri.substring(0, lastIndex); - ActionProxyFactory actionProxyFactory = actionProxyFactories.get(key); - if (actionProxyFactory != null) { - LOG.debug("Using ActionProxyFactory [{}] for prefix [{}]", actionProxyFactory, key); - return actionProxyFactory.createActionProxy(namespace, actionName, methodName, extraContext, executeResult, cleanupContext); - } else { - LOG.debug("No ActionProxyFactory defined for [{}]", key); - } - } - LOG.debug("Cannot find any matching ActionProxyFactory, falling back to [{}]", defaultFactory); - return defaultFactory.createActionProxy(namespace, actionName, methodName, extraContext, executeResult, cleanupContext); - } - -} http://git-wip-us.apache.org/repos/asf/struts/blob/b532ad06/core/src/main/java/org/apache/struts2/impl/StrutsActionProxy.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/struts2/impl/StrutsActionProxy.java b/core/src/main/java/org/apache/struts2/impl/StrutsActionProxy.java deleted file mode 100644 index 3b60387..0000000 --- a/core/src/main/java/org/apache/struts2/impl/StrutsActionProxy.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * $Id$ - * - * 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. - */ - -// Copyright 2006 Google Inc. All Rights Reserved. - -package org.apache.struts2.impl; - -import com.opensymphony.xwork2.ActionContext; -import com.opensymphony.xwork2.ActionInvocation; -import com.opensymphony.xwork2.DefaultActionProxy; -import com.opensymphony.xwork2.util.LocalizedTextUtil; -import org.apache.struts2.ServletActionContext; - -import java.util.Locale; - -public class StrutsActionProxy extends DefaultActionProxy { - - private static final long serialVersionUID = -2434901249671934080L; - - public StrutsActionProxy(ActionInvocation inv, String namespace, String actionName, String methodName, - boolean executeResult, boolean cleanupContext) { - super(inv, namespace, actionName, methodName, executeResult, cleanupContext); - } - - public String execute() throws Exception { - ActionContext previous = ActionContext.getContext(); - ActionContext.setContext(invocation.getInvocationContext()); - try { -// This is for the new API: -// return RequestContextImpl.callInContext(invocation, new Callable<String>() { -// public String call() throws Exception { -// return invocation.invoke(); -// } -// }); - - return invocation.invoke(); - } finally { - if (cleanupContext) - ActionContext.setContext(previous); - } - } - - @Override - protected void prepare() { - super.prepare(); - } - - @Override - protected String getErrorMessage() { - if ((namespace != null) && (namespace.trim().length() > 0)) { - String contextPath = ServletActionContext.getRequest().getContextPath(); - return LocalizedTextUtil.findDefaultText( - "struts.exception.missing-package-action.with-context", - Locale.getDefault(), - new String[]{namespace, actionName, contextPath} - ); - } else { - return super.getErrorMessage(); - } - } - -} http://git-wip-us.apache.org/repos/asf/struts/blob/b532ad06/core/src/main/java/org/apache/struts2/impl/StrutsActionProxyFactory.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/struts2/impl/StrutsActionProxyFactory.java b/core/src/main/java/org/apache/struts2/impl/StrutsActionProxyFactory.java deleted file mode 100644 index 7df930d..0000000 --- a/core/src/main/java/org/apache/struts2/impl/StrutsActionProxyFactory.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * $Id$ - * - * 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. - */ - -// Copyright 2006 Google Inc. All Rights Reserved. - -package org.apache.struts2.impl; - -import com.opensymphony.xwork2.ActionInvocation; -import com.opensymphony.xwork2.ActionProxy; -import com.opensymphony.xwork2.DefaultActionProxyFactory; - -public class StrutsActionProxyFactory extends DefaultActionProxyFactory { - - @Override - public ActionProxy createActionProxy(ActionInvocation inv, String namespace, String actionName, String methodName, boolean executeResult, boolean cleanupContext) { - - StrutsActionProxy proxy = new StrutsActionProxy(inv, namespace, actionName, methodName, executeResult, cleanupContext); - container.inject(proxy); - proxy.prepare(); - return proxy; - } -} http://git-wip-us.apache.org/repos/asf/struts/blob/b532ad06/core/src/main/java/org/apache/struts2/interceptor/ServletConfigInterceptor.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/struts2/interceptor/ServletConfigInterceptor.java b/core/src/main/java/org/apache/struts2/interceptor/ServletConfigInterceptor.java index df45347..12f3cbf 100644 --- a/core/src/main/java/org/apache/struts2/interceptor/ServletConfigInterceptor.java +++ b/core/src/main/java/org/apache/struts2/interceptor/ServletConfigInterceptor.java @@ -28,7 +28,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts2.StrutsStatics; -import org.apache.struts2.servlet.interceptor.ServletPrincipalProxy; +import org.apache.struts2.interceptor.servlet.ServletPrincipalProxy; import org.apache.struts2.util.ServletContextAware; import com.opensymphony.xwork2.ActionContext; http://git-wip-us.apache.org/repos/asf/struts/blob/b532ad06/core/src/main/java/org/apache/struts2/interceptor/servlet/ServletPrincipalProxy.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/struts2/interceptor/servlet/ServletPrincipalProxy.java b/core/src/main/java/org/apache/struts2/interceptor/servlet/ServletPrincipalProxy.java new file mode 100644 index 0000000..59eb9ac --- /dev/null +++ b/core/src/main/java/org/apache/struts2/interceptor/servlet/ServletPrincipalProxy.java @@ -0,0 +1,81 @@ +/* + * $Id$ + * + * 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 org.apache.struts2.interceptor.servlet; + +import org.apache.struts2.interceptor.PrincipalProxy; + +import javax.servlet.http.HttpServletRequest; +import java.security.Principal; + +/** + * PrincipalProxy implementation for using HttpServletRequest Principal related methods. + */ +public class ServletPrincipalProxy implements PrincipalProxy { + private HttpServletRequest request; + + /** + * Constructs a proxy + * + * @param request The underlying request + */ + public ServletPrincipalProxy(HttpServletRequest request) { + this.request = request; + } + + /** + * True if the user is in the given role + * + * @param role The role + * @return True if the user is in that role + */ + public boolean isUserInRole(String role) { + return request.isUserInRole(role); + } + + /** + * Gets the user principal + * + * @return The principal + */ + public Principal getUserPrincipal() { + return request.getUserPrincipal(); + } + + /** + * Gets the user id + * + * @return The user id + */ + public String getRemoteUser() { + return request.getRemoteUser(); + } + + /** + * Is the request using https? + * + * @return True if using https + */ + public boolean isRequestSecure() { + return request.isSecure(); + } + +} http://git-wip-us.apache.org/repos/asf/struts/blob/b532ad06/core/src/main/java/org/apache/struts2/servlet/interceptor/ServletPrincipalProxy.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/struts2/servlet/interceptor/ServletPrincipalProxy.java b/core/src/main/java/org/apache/struts2/servlet/interceptor/ServletPrincipalProxy.java deleted file mode 100644 index 953ef5e..0000000 --- a/core/src/main/java/org/apache/struts2/servlet/interceptor/ServletPrincipalProxy.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * $Id$ - * - * 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 org.apache.struts2.servlet.interceptor; - -import org.apache.struts2.interceptor.PrincipalProxy; - -import javax.servlet.http.HttpServletRequest; -import java.security.Principal; - -/** - * PrincipalProxy implementation for using HttpServletRequest Principal related methods. - */ -public class ServletPrincipalProxy implements PrincipalProxy { - private HttpServletRequest request; - - /** - * Constructs a proxy - * - * @param request The underlying request - */ - public ServletPrincipalProxy(HttpServletRequest request) { - this.request = request; - } - - /** - * True if the user is in the given role - * - * @param role The role - * @return True if the user is in that role - */ - public boolean isUserInRole(String role) { - return request.isUserInRole(role); - } - - /** - * Gets the user principal - * - * @return The principal - */ - public Principal getUserPrincipal() { - return request.getUserPrincipal(); - } - - /** - * Gets the user id - * - * @return The user id - */ - public String getRemoteUser() { - return request.getRemoteUser(); - } - - /** - * Is the request using https? - * - * @return True if using https - */ - public boolean isRequestSecure() { - return request.isSecure(); - } - -} http://git-wip-us.apache.org/repos/asf/struts/blob/b532ad06/core/src/main/resources/struts-default.xml ---------------------------------------------------------------------- diff --git a/core/src/main/resources/struts-default.xml b/core/src/main/resources/struts-default.xml index 33057cb..ca2a654 100644 --- a/core/src/main/resources/struts-default.xml +++ b/core/src/main/resources/struts-default.xml @@ -65,8 +65,8 @@ <bean type="com.opensymphony.xwork2.FileManager" class="com.opensymphony.xwork2.util.fs.DefaultFileManager" name="system" scope="singleton"/> <bean type="com.opensymphony.xwork2.FileManagerFactory" class="com.opensymphony.xwork2.util.fs.DefaultFileManagerFactory" name="struts" scope="singleton"/> - <bean type="com.opensymphony.xwork2.ActionProxyFactory" name="struts" class="org.apache.struts2.impl.StrutsActionProxyFactory"/> - <bean type="com.opensymphony.xwork2.ActionProxyFactory" name="prefix" class="org.apache.struts2.impl.PrefixBasedActionProxyFactory"/> + <bean type="com.opensymphony.xwork2.ActionProxyFactory" name="struts" class="org.apache.struts2.factory.StrutsActionProxyFactory"/> + <bean type="com.opensymphony.xwork2.ActionProxyFactory" name="prefix" class="org.apache.struts2.factory.PrefixBasedActionProxyFactory"/> <bean type="com.opensymphony.xwork2.conversion.ObjectTypeDeterminer" name="struts" class="com.opensymphony.xwork2.conversion.impl.DefaultObjectTypeDeterminer"/>
