Commits

mbogaert  committed d725a98

Integrated the PrincipalInterceptor in the ServletConfigInterceptor, where it belongs.

git-svn-id: http://svn.opensymphony.com/svn/webwork/trunk@634573baa09-0c28-0410-bef9-dab3c582ae83

  • Participants
  • Parent commits 519a709

Comments (0)

Files changed (2)

File src/java/com/opensymphony/webwork/interceptor/PrincipalInterceptor.java

-package com.opensymphony.webwork.interceptor;
-
-import com.opensymphony.webwork.ServletActionContext;
-import com.opensymphony.xwork.Action;
-import com.opensymphony.xwork.ActionInvocation;
-import com.opensymphony.xwork.interceptor.AroundInterceptor;
-
-/**
- * PrincipalInterceptor gives access to principal and roles information from action, without
- * making action class tied to HttpServlerRequest.
- *
- * @author Remigijus Bauzys
- * @version $Revision$
- */
-public class PrincipalInterceptor extends AroundInterceptor {
-    protected void before(ActionInvocation invocation) throws Exception {
-        Action action = invocation.getAction();
-
-        if (action instanceof PrincipalAware) {
-            ((PrincipalAware) action).setPrincipalProxy(new PrincipalProxy(ServletActionContext.getRequest()));
-        }
-    }
-
-    protected void after(ActionInvocation dispatcher, String result) throws Exception {
-    }
-}

File src/java/com/opensymphony/webwork/interceptor/ServletConfigInterceptor.java

      * @throws Exception if an error occurs when setting action properties.
      */
     protected void before(ActionInvocation invocation) throws Exception {
-        Action action = invocation.getAction();
-        ActionContext context = ActionContext.getContext();
+        final Action action = invocation.getAction();
+        final ActionContext context = ActionContext.getContext();
 
         if (action instanceof ServletRequestAware) {
             HttpServletRequest request = (HttpServletRequest) context.get(HTTP_REQUEST);
         if (action instanceof ApplicationAware) {
             ((ApplicationAware) action).setApplication(context.getApplication());
         }
+
+        if (action instanceof PrincipalAware) {
+            HttpServletRequest request = (HttpServletRequest) context.get(HTTP_REQUEST);
+            ((PrincipalAware) action).setPrincipalProxy(new PrincipalProxy(request));
+        }
     }
 }