struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [5/7] struts-examples git commit: Modifying package name to be consistent with other projects in the 'struts-examples' parent project
Date Fri, 07 Jul 2017 06:15:16 GMT
Modifying package name to be consistent with other projects in the 'struts-examples' parent
project


Project: http://git-wip-us.apache.org/repos/asf/struts-examples/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts-examples/commit/a6ad31df
Tree: http://git-wip-us.apache.org/repos/asf/struts-examples/tree/a6ad31df
Diff: http://git-wip-us.apache.org/repos/asf/struts-examples/diff/a6ad31df

Branch: refs/heads/master
Commit: a6ad31df3956cc4b30eb8635b76cee9a54725fab
Parents: d5420bb
Author: tkofford <tkofford@home.ku.edu>
Authored: Thu Jul 6 08:58:26 2017 -0500
Committer: tkofford <tkofford@home.ku.edu>
Committed: Thu Jul 6 08:58:26 2017 -0500

----------------------------------------------------------------------
 .../struts2shiro/action/LoginAction.java        | 113 -------------------
 .../struts2shiro/action/LogoutAction.java       |  18 ---
 .../struts2shiro/action/ShiroBaseAction.java    |  34 ------
 .../struts2shiro/action/WelcomeAction.java      | 101 -----------------
 .../interceptor/ShiroUserInterceptor.java       |  64 -----------
 .../struts2shiro/action/LoginAction.java        | 113 +++++++++++++++++++
 .../struts2shiro/action/LogoutAction.java       |  18 +++
 .../struts2shiro/action/ShiroBaseAction.java    |  28 +++++
 .../struts2shiro/action/WelcomeAction.java      | 101 +++++++++++++++++
 .../interceptor/ShiroUserInterceptor.java       |  57 ++++++++++
 shiro-basic/src/main/resources/struts.xml       |   8 +-
 11 files changed, 321 insertions(+), 334 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts-examples/blob/a6ad31df/shiro-basic/src/main/java/example/struts2shiro/action/LoginAction.java
----------------------------------------------------------------------
diff --git a/shiro-basic/src/main/java/example/struts2shiro/action/LoginAction.java b/shiro-basic/src/main/java/example/struts2shiro/action/LoginAction.java
deleted file mode 100644
index fbfceb3..0000000
--- a/shiro-basic/src/main/java/example/struts2shiro/action/LoginAction.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package example.struts2shiro.action;
-
-import org.apache.shiro.SecurityUtils;
-import org.apache.shiro.authc.AuthenticationException;
-import org.apache.shiro.authc.IncorrectCredentialsException;
-import org.apache.shiro.authc.LockedAccountException;
-import org.apache.shiro.authc.UnknownAccountException;
-import org.apache.shiro.authc.UsernamePasswordToken;
-import org.apache.shiro.session.Session;
-import org.apache.shiro.subject.Subject;
-import com.opensymphony.xwork2.ActionSupport;
-import com.opensymphony.xwork2.Preparable;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-public class LoginAction extends ActionSupport implements Preparable
-{
-
-    private static final long serialVersionUID = 1L;
-    private static final transient Logger log = LogManager.getLogger(LoginAction.class);
-
-    private String username;
-    private String password;
-    private Subject shiroUser;
-    
-    @Override
-    public void prepare() throws Exception 
-    {
-        shiroUser = SecurityUtils.getSubject();
-    }
-    
-    @Override
-    public String execute()
-    {
-        String result = INPUT;
-                
-        // Do some stuff with a Session
-        Session session = shiroUser.getSession();
-        session.setAttribute("MyUsername", username);
-        log.info("Saving 'username' value to session [" + username + "]");
-        
-        // let's login the current user so we can check against roles and permissions:
-        if (shiroUser != null && ! shiroUser.isAuthenticated()) 
-        {
-            UsernamePasswordToken token = new UsernamePasswordToken(username, password);
-            token.setRememberMe(true);
-            try 
-            {
-                shiroUser.login(token);                
-                result = SUCCESS;
-            } 
-            catch (UnknownAccountException uae) 
-            {
-                addActionError("There is no user with username of '" + token.getPrincipal()
+ "'");
-                log.error(uae.getMessage());
-            } 
-            catch (IncorrectCredentialsException ice) 
-            {
-                addActionError("Password for account '" + token.getPrincipal() + "' was incorrect!");
-                log.error(ice.getMessage());
-            } 
-            catch (LockedAccountException lae) 
-            {
-                addActionError("The account for username '" + token.getPrincipal() + "' is
locked.  " +
-                        "Please contact your administrator to unlock it.");
-                log.error(lae.getMessage());
-            }
-            // ... catch more exceptions here (maybe custom ones specific to your application?
-            catch (AuthenticationException ae) 
-            {
-                addActionError("An authentication exception has occurred trying to login
user: " + token.getPrincipal());
-                log.error(ae.getMessage());
-            }        
-        }
-        else if (shiroUser.isAuthenticated())
-        {
-            result = SUCCESS;
-        }
-        
-        return result;
-    }
-    
-    public Subject getShiroUser() 
-    {
-        return shiroUser;
-    }
-
-    public void setShiroUser(Subject shiroUser) 
-    {
-        this.shiroUser = shiroUser;
-    }
-
-    public String getUsername() 
-    {
-        return username;
-    }
-
-    public void setUsername(String username) 
-    {
-        this.username = username;
-    }
-
-    public String getPassword() 
-    {
-        return password;
-    }
-
-    public void setPassword(String password) 
-    {
-        this.password = password;
-    }    
-    
-}

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/a6ad31df/shiro-basic/src/main/java/example/struts2shiro/action/LogoutAction.java
----------------------------------------------------------------------
diff --git a/shiro-basic/src/main/java/example/struts2shiro/action/LogoutAction.java b/shiro-basic/src/main/java/example/struts2shiro/action/LogoutAction.java
deleted file mode 100644
index 731447b..0000000
--- a/shiro-basic/src/main/java/example/struts2shiro/action/LogoutAction.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package example.struts2shiro.action;
-
-public class LogoutAction extends ShiroBaseAction
-{
-    private static final long serialVersionUID = 1L;
-
-    @Override
-    public String execute()
-    {
-        if (isAuthenticated())
-        {
-            getShiroUser().logout(); // isAuthenticated = true -> getShiroUser() != null
-        }
-        
-        return SUCCESS;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/a6ad31df/shiro-basic/src/main/java/example/struts2shiro/action/ShiroBaseAction.java
----------------------------------------------------------------------
diff --git a/shiro-basic/src/main/java/example/struts2shiro/action/ShiroBaseAction.java b/shiro-basic/src/main/java/example/struts2shiro/action/ShiroBaseAction.java
deleted file mode 100644
index 49c60ca..0000000
--- a/shiro-basic/src/main/java/example/struts2shiro/action/ShiroBaseAction.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * 
- */
-package example.struts2shiro.action;
-
-import org.apache.shiro.subject.Subject;
-
-import com.opensymphony.xwork2.ActionSupport;
-
-/**
- * @author tkofford
- *
- */
-public class ShiroBaseAction extends ActionSupport
-{
-    private static final long serialVersionUID = 1L;
-    
-    private Subject shiroUser;
-
-    public boolean isAuthenticated() 
-    {
-        return shiroUser != null && shiroUser.isAuthenticated();
-    }
-
-    public Subject getShiroUser() 
-    {
-        return shiroUser;
-    }
-
-    public void setShiroUser(Subject shiroUser) 
-    {
-        this.shiroUser = shiroUser;
-    }
-}

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/a6ad31df/shiro-basic/src/main/java/example/struts2shiro/action/WelcomeAction.java
----------------------------------------------------------------------
diff --git a/shiro-basic/src/main/java/example/struts2shiro/action/WelcomeAction.java b/shiro-basic/src/main/java/example/struts2shiro/action/WelcomeAction.java
deleted file mode 100644
index 2906c4b..0000000
--- a/shiro-basic/src/main/java/example/struts2shiro/action/WelcomeAction.java
+++ /dev/null
@@ -1,101 +0,0 @@
-package example.struts2shiro.action;
-
-import org.apache.shiro.session.Session;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-public class WelcomeAction extends ShiroBaseAction
-{
-    private static final long serialVersionUID = 1L;
-    private static final Logger log = LogManager.getLogger(WelcomeAction.class);
-
-    private String username;
-    
-    @Override
-    public String execute()
-    {
-        String result = ERROR;
-        
-        if (isAuthenticated())
-        {
-            // Retrieve value from session
-            Session session = getShiroUser().getSession();
-            String value = (String) session.getAttribute("MyUsername");
-            if (value.equals(username)) {
-                log.info("Retrieved the correct 'username' value [" + value + "] from session");
-            }
-        
-            printRoles();
-            printPermissions();
-            result = SUCCESS;
-        }
-        
-        return result;
-    }
-    
-    public void printRoles()
-    {
-        if (getShiroUser().hasRole("admin"))
-        {
-            log.info("User '" + username + "' has role of 'admin'");
-        }
-        else
-        {
-            log.info("User '" + username + "' is missing role 'admin'");
-        }
-        if (getShiroUser().hasRole("schwartz"))
-        {
-            log.info("User '" + username + "' has role of 'schwartz'");
-        }
-        else
-        {
-            log.info("User '" + username + "' is missing role 'schwartz'");
-        }
-        if (getShiroUser().hasRole("goodguy"))
-        {
-            log.info("User '" + username + "' has role of 'goodguy'");
-        }
-        else
-        {
-            log.info("User '" + username + "' is missing role 'goodguy'");
-        }
-    }
-
-    public void printPermissions()
-    {
-        if (getShiroUser().isPermitted("lightsaber"))
-        {
-            log.info("User '" + username + "' has 'lightsaber' permission");
-        }
-        else
-        {
-            log.info("User '" + username + "' is missing permission 'lightsaber'");
-        }
-        if (getShiroUser().isPermitted("winnebago"))
-        {
-            log.info("User '" + username + "' has 'winnebago' permission");
-        }
-        else
-        {
-            log.info("User '" + username + "' is missing permission 'winnebago'");
-        }
-        if (getShiroUser().isPermitted("winnebago:drive:eagle5"))
-        {
-            log.info("User '" + username + "' has 'winnebago:drive:eagle5' permission");
-        }
-        else
-        {
-            log.info("User '" + username + "' is missing permission 'winnebago:drive:eagle5'");
-        }
-    }
-    public String getUsername() 
-    {
-        return username;
-    }
-
-    public void setUsername(String username) 
-    {
-        this.username = username;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/a6ad31df/shiro-basic/src/main/java/example/struts2shiro/interceptor/ShiroUserInterceptor.java
----------------------------------------------------------------------
diff --git a/shiro-basic/src/main/java/example/struts2shiro/interceptor/ShiroUserInterceptor.java
b/shiro-basic/src/main/java/example/struts2shiro/interceptor/ShiroUserInterceptor.java
deleted file mode 100644
index cbfe19b..0000000
--- a/shiro-basic/src/main/java/example/struts2shiro/interceptor/ShiroUserInterceptor.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * 
- */
-package example.struts2shiro.interceptor;
-
-import org.apache.shiro.SecurityUtils;
-import org.apache.shiro.subject.Subject;
-
-import com.opensymphony.xwork2.ActionInvocation;
-import com.opensymphony.xwork2.interceptor.Interceptor;
-
-/**
- * @author tkofford
- *
- */
-
-/**
- * Inserts the current Shiro user into the value stack so that it can be
- * injected into Struts 2 actions should they have a JavaBeans setter
- * <code>setShiroUser(org.apache.shiro.subject.Subject shiroUser)</code>.
- *
- * @version $Revision: $ $Date: $
- */
-public class ShiroUserInterceptor implements Interceptor {
-
-    /**
-     * 
-     */
-    private static final long serialVersionUID = 1L;
-
-    /* (non-Javadoc)
-     * @see com.opensymphony.xwork2.interceptor.Interceptor#destroy()
-     */
-    @Override
-    public void destroy() 
-    {
-        //release resources here
-    }
-
-    /* (non-Javadoc)
-     * @see com.opensymphony.xwork2.interceptor.Interceptor#init()
-     */
-    @Override
-    public void init() 
-    {
-        // create resources here
-    }
-
-    /* (non-Javadoc)
-     * @see com.opensymphony.xwork2.interceptor.Interceptor#intercept(com.opensymphony.xwork2.ActionInvocation)
-     */
-    @Override
-    public String intercept(ActionInvocation actionInvocation) throws Exception 
-    {
-        if (actionInvocation.getAction() instanceof example.struts2shiro.action.ShiroBaseAction)
-        {
-            Subject shiroUser = SecurityUtils.getSubject();
-            actionInvocation.getStack().setValue("shiroUser", shiroUser);
-        }
-            
-        return actionInvocation.invoke();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/a6ad31df/shiro-basic/src/main/java/org/apache/struts2/shiro/example/struts2shiro/action/LoginAction.java
----------------------------------------------------------------------
diff --git a/shiro-basic/src/main/java/org/apache/struts2/shiro/example/struts2shiro/action/LoginAction.java
b/shiro-basic/src/main/java/org/apache/struts2/shiro/example/struts2shiro/action/LoginAction.java
new file mode 100644
index 0000000..ebaf866
--- /dev/null
+++ b/shiro-basic/src/main/java/org/apache/struts2/shiro/example/struts2shiro/action/LoginAction.java
@@ -0,0 +1,113 @@
+package org.apache.struts2.shiro.example.action;
+
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.authc.AuthenticationException;
+import org.apache.shiro.authc.IncorrectCredentialsException;
+import org.apache.shiro.authc.LockedAccountException;
+import org.apache.shiro.authc.UnknownAccountException;
+import org.apache.shiro.authc.UsernamePasswordToken;
+import org.apache.shiro.session.Session;
+import org.apache.shiro.subject.Subject;
+import com.opensymphony.xwork2.ActionSupport;
+import com.opensymphony.xwork2.Preparable;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+public class LoginAction extends ActionSupport implements Preparable
+{
+
+    private static final long serialVersionUID = 1L;
+    private static final transient Logger log = LogManager.getLogger(LoginAction.class);
+
+    private String username;
+    private String password;
+    private Subject shiroUser;
+    
+    @Override
+    public void prepare() throws Exception 
+    {
+        shiroUser = SecurityUtils.getSubject();
+    }
+    
+    @Override
+    public String execute()
+    {
+        String result = INPUT;
+                
+        // Do some stuff with a Session
+        Session session = shiroUser.getSession();
+        session.setAttribute("MyUsername", username);
+        log.info("Saving 'username' value to session [" + username + "]");
+        
+        // let's login the current user so we can check against roles and permissions:
+        if (shiroUser != null && ! shiroUser.isAuthenticated()) 
+        {
+            UsernamePasswordToken token = new UsernamePasswordToken(username, password);
+            token.setRememberMe(true);
+            try 
+            {
+                shiroUser.login(token);                
+                result = SUCCESS;
+            } 
+            catch (UnknownAccountException uae) 
+            {
+                addActionError("There is no user with username of '" + token.getPrincipal()
+ "'");
+                log.error(uae.getMessage());
+            } 
+            catch (IncorrectCredentialsException ice) 
+            {
+                addActionError("Password for account '" + token.getPrincipal() + "' was incorrect!");
+                log.error(ice.getMessage());
+            } 
+            catch (LockedAccountException lae) 
+            {
+                addActionError("The account for username '" + token.getPrincipal() + "' is
locked.  " +
+                        "Please contact your administrator to unlock it.");
+                log.error(lae.getMessage());
+            }
+            // ... catch more exceptions here (maybe custom ones specific to your application?
+            catch (AuthenticationException ae) 
+            {
+                addActionError("An authentication exception has occurred trying to login
user: " + token.getPrincipal());
+                log.error(ae.getMessage());
+            }        
+        }
+        else if (shiroUser.isAuthenticated())
+        {
+            result = SUCCESS;
+        }
+        
+        return result;
+    }
+    
+    public Subject getShiroUser() 
+    {
+        return shiroUser;
+    }
+
+    public void setShiroUser(Subject shiroUser) 
+    {
+        this.shiroUser = shiroUser;
+    }
+
+    public String getUsername() 
+    {
+        return username;
+    }
+
+    public void setUsername(String username) 
+    {
+        this.username = username;
+    }
+
+    public String getPassword() 
+    {
+        return password;
+    }
+
+    public void setPassword(String password) 
+    {
+        this.password = password;
+    }    
+    
+}

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/a6ad31df/shiro-basic/src/main/java/org/apache/struts2/shiro/example/struts2shiro/action/LogoutAction.java
----------------------------------------------------------------------
diff --git a/shiro-basic/src/main/java/org/apache/struts2/shiro/example/struts2shiro/action/LogoutAction.java
b/shiro-basic/src/main/java/org/apache/struts2/shiro/example/struts2shiro/action/LogoutAction.java
new file mode 100644
index 0000000..defab7d
--- /dev/null
+++ b/shiro-basic/src/main/java/org/apache/struts2/shiro/example/struts2shiro/action/LogoutAction.java
@@ -0,0 +1,18 @@
+package org.apache.struts2.shiro.example.action;
+
+public class LogoutAction extends ShiroBaseAction
+{
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public String execute()
+    {
+        if (isAuthenticated())
+        {
+            getShiroUser().logout(); // isAuthenticated = true -> getShiroUser() != null
+        }
+        
+        return SUCCESS;
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/a6ad31df/shiro-basic/src/main/java/org/apache/struts2/shiro/example/struts2shiro/action/ShiroBaseAction.java
----------------------------------------------------------------------
diff --git a/shiro-basic/src/main/java/org/apache/struts2/shiro/example/struts2shiro/action/ShiroBaseAction.java
b/shiro-basic/src/main/java/org/apache/struts2/shiro/example/struts2shiro/action/ShiroBaseAction.java
new file mode 100644
index 0000000..b5702fa
--- /dev/null
+++ b/shiro-basic/src/main/java/org/apache/struts2/shiro/example/struts2shiro/action/ShiroBaseAction.java
@@ -0,0 +1,28 @@
+package org.apache.struts2.shiro.example.action;
+
+import org.apache.shiro.subject.Subject;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+
+public class ShiroBaseAction extends ActionSupport
+{
+    private static final long serialVersionUID = 1L;
+    
+    private Subject shiroUser;
+
+    public boolean isAuthenticated() 
+    {
+        return shiroUser != null && shiroUser.isAuthenticated();
+    }
+
+    public Subject getShiroUser() 
+    {
+        return shiroUser;
+    }
+
+    public void setShiroUser(Subject shiroUser) 
+    {
+        this.shiroUser = shiroUser;
+    }
+}

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/a6ad31df/shiro-basic/src/main/java/org/apache/struts2/shiro/example/struts2shiro/action/WelcomeAction.java
----------------------------------------------------------------------
diff --git a/shiro-basic/src/main/java/org/apache/struts2/shiro/example/struts2shiro/action/WelcomeAction.java
b/shiro-basic/src/main/java/org/apache/struts2/shiro/example/struts2shiro/action/WelcomeAction.java
new file mode 100644
index 0000000..797df1d
--- /dev/null
+++ b/shiro-basic/src/main/java/org/apache/struts2/shiro/example/struts2shiro/action/WelcomeAction.java
@@ -0,0 +1,101 @@
+package org.apache.struts2.shiro.example.action;
+
+import org.apache.shiro.session.Session;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+public class WelcomeAction extends ShiroBaseAction
+{
+    private static final long serialVersionUID = 1L;
+    private static final Logger log = LogManager.getLogger(WelcomeAction.class);
+
+    private String username;
+    
+    @Override
+    public String execute()
+    {
+        String result = ERROR;
+        
+        if (isAuthenticated())
+        {
+            // Retrieve value from session
+            Session session = getShiroUser().getSession();
+            String value = (String) session.getAttribute("MyUsername");
+            if (value.equals(username)) {
+                log.info("Retrieved the correct 'username' value [" + value + "] from session");
+            }
+        
+            printRoles();
+            printPermissions();
+            result = SUCCESS;
+        }
+        
+        return result;
+    }
+    
+    public void printRoles()
+    {
+        if (getShiroUser().hasRole("admin"))
+        {
+            log.info("User '" + username + "' has role of 'admin'");
+        }
+        else
+        {
+            log.info("User '" + username + "' is missing role 'admin'");
+        }
+        if (getShiroUser().hasRole("schwartz"))
+        {
+            log.info("User '" + username + "' has role of 'schwartz'");
+        }
+        else
+        {
+            log.info("User '" + username + "' is missing role 'schwartz'");
+        }
+        if (getShiroUser().hasRole("goodguy"))
+        {
+            log.info("User '" + username + "' has role of 'goodguy'");
+        }
+        else
+        {
+            log.info("User '" + username + "' is missing role 'goodguy'");
+        }
+    }
+
+    public void printPermissions()
+    {
+        if (getShiroUser().isPermitted("lightsaber"))
+        {
+            log.info("User '" + username + "' has 'lightsaber' permission");
+        }
+        else
+        {
+            log.info("User '" + username + "' is missing permission 'lightsaber'");
+        }
+        if (getShiroUser().isPermitted("winnebago"))
+        {
+            log.info("User '" + username + "' has 'winnebago' permission");
+        }
+        else
+        {
+            log.info("User '" + username + "' is missing permission 'winnebago'");
+        }
+        if (getShiroUser().isPermitted("winnebago:drive:eagle5"))
+        {
+            log.info("User '" + username + "' has 'winnebago:drive:eagle5' permission");
+        }
+        else
+        {
+            log.info("User '" + username + "' is missing permission 'winnebago:drive:eagle5'");
+        }
+    }
+    public String getUsername() 
+    {
+        return username;
+    }
+
+    public void setUsername(String username) 
+    {
+        this.username = username;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/a6ad31df/shiro-basic/src/main/java/org/apache/struts2/shiro/example/struts2shiro/interceptor/ShiroUserInterceptor.java
----------------------------------------------------------------------
diff --git a/shiro-basic/src/main/java/org/apache/struts2/shiro/example/struts2shiro/interceptor/ShiroUserInterceptor.java
b/shiro-basic/src/main/java/org/apache/struts2/shiro/example/struts2shiro/interceptor/ShiroUserInterceptor.java
new file mode 100644
index 0000000..794422c
--- /dev/null
+++ b/shiro-basic/src/main/java/org/apache/struts2/shiro/example/struts2shiro/interceptor/ShiroUserInterceptor.java
@@ -0,0 +1,57 @@
+/**
+ * 
+ */
+package org.apache.struts2.shiro.example.interceptor;
+
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.subject.Subject;
+
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.interceptor.Interceptor;
+
+/**
+ * Inserts the current Shiro user into the value stack so that it can be
+ * injected into Struts 2 actions should they have a JavaBeans setter
+ * <code>setShiroUser(org.apache.shiro.subject.Subject shiroUser)</code>.
+ */
+public class ShiroUserInterceptor implements Interceptor {
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 1L;
+
+    /* (non-Javadoc)
+     * @see com.opensymphony.xwork2.interceptor.Interceptor#destroy()
+     */
+    @Override
+    public void destroy() 
+    {
+        //release resources here
+    }
+
+    /* (non-Javadoc)
+     * @see com.opensymphony.xwork2.interceptor.Interceptor#init()
+     */
+    @Override
+    public void init() 
+    {
+        // create resources here
+    }
+
+    /* (non-Javadoc)
+     * @see com.opensymphony.xwork2.interceptor.Interceptor#intercept(com.opensymphony.xwork2.ActionInvocation)
+     */
+    @Override
+    public String intercept(ActionInvocation actionInvocation) throws Exception 
+    {
+        if (actionInvocation.getAction() instanceof org.apache.struts2.shiro.example.action.ShiroBaseAction)
+        {
+            Subject shiroUser = SecurityUtils.getSubject();
+            actionInvocation.getStack().setValue("shiroUser", shiroUser);
+        }
+            
+        return actionInvocation.invoke();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/a6ad31df/shiro-basic/src/main/resources/struts.xml
----------------------------------------------------------------------
diff --git a/shiro-basic/src/main/resources/struts.xml b/shiro-basic/src/main/resources/struts.xml
index c22a7e6..0fe7a9f 100644
--- a/shiro-basic/src/main/resources/struts.xml
+++ b/shiro-basic/src/main/resources/struts.xml
@@ -6,7 +6,7 @@
 <struts>
     <package name="default" namespace="/" extends="struts-default">
         <interceptors>
-            <interceptor name="shiroUser" class="example.struts2shiro.interceptor.ShiroUserInterceptor"/>
+            <interceptor name="shiroUser" class="org.apache.struts2.shiro.example.interceptor.ShiroUserInterceptor"/>
             <interceptor-stack name="shiro-default">
                 <interceptor-ref name="shiroUser"/>
                 <interceptor-ref name="params"/> <!-- Run the params interceptor
before the default stack. This allows us to access param values in our prepare() methods.
-->
@@ -18,17 +18,17 @@
         <action name="login">
             <result>pages/login.jsp</result>
         </action>
-        <action name="welcome" class="example.struts2shiro.action.WelcomeAction">
+        <action name="welcome" class="org.apache.struts2.shiro.example.action.WelcomeAction">
             <result>pages/welcome.jsp</result>
         </action>
-        <action name="authuser" class="example.struts2shiro.action.LoginAction">
+        <action name="authuser" class="org.apache.struts2.shiro.example.action.LoginAction">
             <result name="success" type="redirectAction">
                 <param name="actionName">welcome</param>
                 <param name="username">${username}</param>
             </result>
             <result name="input">pages/login.jsp</result>
         </action>
-        <action name="logout" class="example.struts2shiro.action.LogoutAction">
+        <action name="logout" class="org.apache.struts2.shiro.example.action.LogoutAction">
             <result name="success">pages/login.jsp</result>
         </action>
 


Mime
View raw message