struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [1/7] struts-examples git commit: Initial commit
Date Fri, 07 Jul 2017 06:15:12 GMT
Repository: struts-examples
Updated Branches:
  refs/heads/master 9f8e55972 -> dece3f955


Initial commit


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

Branch: refs/heads/master
Commit: 876600a345cd34f4a52634ebc8b1fe0769585eb3
Parents: d07e954
Author: tkofford <tkofford@home.ku.edu>
Authored: Thu Jul 6 07:59:44 2017 -0500
Committer: tkofford <tkofford@home.ku.edu>
Committed: Thu Jul 6 07:59:44 2017 -0500

----------------------------------------------------------------------
 shiro-basic/pom.xml                             |  79 +++++++++++++
 .../struts2shiro/action/LoginAction.java        | 113 +++++++++++++++++++
 .../struts2shiro/action/LogoutAction.java       |  18 +++
 .../struts2shiro/action/ShiroBaseAction.java    |  34 ++++++
 .../struts2shiro/action/WelcomeAction.java      | 101 +++++++++++++++++
 .../interceptor/ShiroUserInterceptor.java       |  64 +++++++++++
 shiro-basic/src/main/resources/log4j2.xml       |  25 ++++
 shiro-basic/src/main/resources/shiro.ini        |  25 ++++
 shiro-basic/src/main/resources/struts.xml       |  37 ++++++
 shiro-basic/src/main/webapp/WEB-INF/web.xml     |  27 +++++
 shiro-basic/src/main/webapp/css/main.css        |  56 +++++++++
 shiro-basic/src/main/webapp/index.jsp           |   1 +
 shiro-basic/src/main/webapp/pages/login.jsp     |  27 +++++
 shiro-basic/src/main/webapp/pages/welcome.jsp   |  39 +++++++
 14 files changed, 646 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts-examples/blob/876600a3/shiro-basic/pom.xml
----------------------------------------------------------------------
diff --git a/shiro-basic/pom.xml b/shiro-basic/pom.xml
new file mode 100644
index 0000000..3dfe907
--- /dev/null
+++ b/shiro-basic/pom.xml
@@ -0,0 +1,79 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>struts2shiro</groupId>
+    <artifactId>struts2shiro</artifactId>
+    <version>1.0.0</version>
+    <packaging>war</packaging>
+    
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <shiro.version>1.3.2</shiro.version>
+        <struts.version>2.5.10.1</struts.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.struts</groupId>
+            <artifactId>struts2-core</artifactId>
+            <version>${struts.version}</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.shiro</groupId>
+            <artifactId>shiro-core</artifactId>
+            <version>${shiro.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.shiro</groupId>
+            <artifactId>shiro-web</artifactId>
+            <version>${shiro.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-api</artifactId>
+            <version>2.8.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-core</artifactId>
+            <version>2.8.2</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+            <version>2.4</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet.jsp</groupId>
+            <artifactId>jsp-api</artifactId>
+            <version>2.1</version>
+            <scope>provided</scope>
+        </dependency>
+                
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.1</version>
+                <configuration>
+                    <source>1.8</source>
+                    <target>1.8</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <artifactId>maven-war-plugin</artifactId>
+                <version>2.4</version>
+                <configuration>
+                    <failOnMissingWebXml>false</failOnMissingWebXml>
+                </configuration>
+            </plugin>
+        </plugins>
+        <finalName>${project.artifactId}</finalName>
+    </build>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/876600a3/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
new file mode 100644
index 0000000..fbfceb3
--- /dev/null
+++ b/shiro-basic/src/main/java/example/struts2shiro/action/LoginAction.java
@@ -0,0 +1,113 @@
+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/876600a3/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
new file mode 100644
index 0000000..731447b
--- /dev/null
+++ b/shiro-basic/src/main/java/example/struts2shiro/action/LogoutAction.java
@@ -0,0 +1,18 @@
+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/876600a3/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
new file mode 100644
index 0000000..49c60ca
--- /dev/null
+++ b/shiro-basic/src/main/java/example/struts2shiro/action/ShiroBaseAction.java
@@ -0,0 +1,34 @@
+/**
+ * 
+ */
+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/876600a3/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
new file mode 100644
index 0000000..2906c4b
--- /dev/null
+++ b/shiro-basic/src/main/java/example/struts2shiro/action/WelcomeAction.java
@@ -0,0 +1,101 @@
+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/876600a3/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
new file mode 100644
index 0000000..cbfe19b
--- /dev/null
+++ b/shiro-basic/src/main/java/example/struts2shiro/interceptor/ShiroUserInterceptor.java
@@ -0,0 +1,64 @@
+/**
+ * 
+ */
+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/876600a3/shiro-basic/src/main/resources/log4j2.xml
----------------------------------------------------------------------
diff --git a/shiro-basic/src/main/resources/log4j2.xml b/shiro-basic/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..26eb0c2
--- /dev/null
+++ b/shiro-basic/src/main/resources/log4j2.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration monitorinterval="30" status="info" strict="true">
+    <Properties>
+        <Property name="filename">${sys:catalina.home}/logs/struts2shiro.log</Property>
+    </Properties>
+    <Appenders>
+        <Appender type="Console" name="Console">
+            <Layout type="PatternLayout" pattern="%d %p [%t] %m%n" />
+        </Appender>
+        <Appender type="Console" name="FLOW">
+            <Layout type="PatternLayout" pattern="%C{1}.%M %m %ex%n" />
+        </Appender>
+        <Appender type="File" name="File" fileName="${filename}">
+            <Layout type="PatternLayout" pattern="%d %p %C{1.} [%t] %m%n" />
+        </Appender>
+    </Appenders>
+    <Loggers>
+        <Root level="info">
+            <AppenderRef ref="File" />
+            <AppenderRef ref="Console" />
+            <!-- Use FLOW to trace down exact method sending the msg -->
+            <!-- <AppenderRef ref="FLOW" /> -->
+        </Root>
+    </Loggers>
+</Configuration>

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/876600a3/shiro-basic/src/main/resources/shiro.ini
----------------------------------------------------------------------
diff --git a/shiro-basic/src/main/resources/shiro.ini b/shiro-basic/src/main/resources/shiro.ini
new file mode 100644
index 0000000..436c465
--- /dev/null
+++ b/shiro-basic/src/main/resources/shiro.ini
@@ -0,0 +1,25 @@
+# =============================================================================
+# Tutorial INI configuration
+#
+# Usernames/passwords are based on the classic Mel Brooks' film "Spaceballs" :)
+# =============================================================================
+
+# -----------------------------------------------------------------------------
+# Users and their (optional) assigned roles
+# username = password, role1, role2, ..., roleN
+# -----------------------------------------------------------------------------
+[users]
+root = secret, admin
+guest = guest, guest
+presidentskroob = 12345, president
+darkhelmet = ludicrousspeed, darklord, schwartz
+lonestarr = vespa, goodguy, schwartz
+
+# -----------------------------------------------------------------------------
+# Roles with assigned permissions
+# roleName = perm1, perm2, ..., permN
+# -----------------------------------------------------------------------------
+[roles]
+admin = *
+schwartz = lightsaber:*
+goodguy = winnebago:drive:eagle5
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/876600a3/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
new file mode 100644
index 0000000..c22a7e6
--- /dev/null
+++ b/shiro-basic/src/main/resources/struts.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE struts PUBLIC
+    "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
+    "http://struts.apache.org/dtds/struts-2.3.dtd">
+<struts>
+    <package name="default" namespace="/" extends="struts-default">
+        <interceptors>
+            <interceptor name="shiroUser" class="example.struts2shiro.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.
-->
+                <interceptor-ref name="defaultStack"/>
+            </interceptor-stack>
+        </interceptors>
+        <default-interceptor-ref name="shiro-default"/>
+
+        <action name="login">
+            <result>pages/login.jsp</result>
+        </action>
+        <action name="welcome" class="example.struts2shiro.action.WelcomeAction">
+            <result>pages/welcome.jsp</result>
+        </action>
+        <action name="authuser" class="example.struts2shiro.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">
+            <result name="success">pages/login.jsp</result>
+        </action>
+
+    </package>
+
+</struts>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/876600a3/shiro-basic/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/shiro-basic/src/main/webapp/WEB-INF/web.xml b/shiro-basic/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..c62e000
--- /dev/null
+++ b/shiro-basic/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
+  <display-name>struts2shiro</display-name>
+  <listener>
+    <listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
+  </listener>
+  <filter>
+    <filter-name>shiroFilter</filter-name>
+    <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
+  </filter>
+  <filter-mapping>
+    <filter-name>shiroFilter</filter-name>
+    <url-pattern>/*</url-pattern>
+    <dispatcher>REQUEST</dispatcher>
+    <dispatcher>FORWARD</dispatcher>
+    <dispatcher>INCLUDE</dispatcher>
+    <dispatcher>ERROR</dispatcher>
+  </filter-mapping>
+  <filter>
+    <filter-name>struts2</filter-name>
+    <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
+  </filter>
+  <filter-mapping>
+    <filter-name>struts2</filter-name>
+    <url-pattern>/*</url-pattern>
+  </filter-mapping>
+</web-app>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/876600a3/shiro-basic/src/main/webapp/css/main.css
----------------------------------------------------------------------
diff --git a/shiro-basic/src/main/webapp/css/main.css b/shiro-basic/src/main/webapp/css/main.css
new file mode 100644
index 0000000..27b210b
--- /dev/null
+++ b/shiro-basic/src/main/webapp/css/main.css
@@ -0,0 +1,56 @@
+html, body  {
+    margin-left: 10px;
+    margin-right: 10px;
+    margin-bottom: 5px;
+    color: black;
+    background-color: white;
+    font-family: Verdana, Arial, sans-serif;
+    font-size:12px;
+}
+.titleDiv {
+    background-color: #EFFBEF;
+    font-weight:bold;
+    font-size:18px;
+    text-align:left;
+    padding-left:10px;
+    padding-top:10px;
+    padding-bottom:10px;
+    border:2px solid #8F99EF;
+}
+h1 { font-weight:bold; color: brown; font-size:15px; text-align:left;}
+
+td { font-size:12px; padding-right:10px; }
+th { text-align:left; font-weight:bold; font-size:13px; padding-right:10px; }
+.tdLabel { font-weight: bold; white-space:nowrap; vertical-align:top;}
+
+A { color:#4A825A; text-decoration:none;}
+A:link { text-decoration:none;}
+A:visited { text-decoration:none;}
+A:hover { text-decoration:none; color: red;}
+
+.borderAll {
+    border: 2px solid #8F99EF;
+}
+
+.butStnd {
+    font-family:arial,sans-serif;
+    font-size:11px;
+    width:105px;
+    background-color:#DCDFFA ;color:#4A825A;font-weight:bold;
+}
+
+.error {
+    color: red;
+    font-weight: bold;
+}
+.errorSection {
+    padding-left:18px;
+    padding-top:2px;
+    padding-bottom:10px;
+    padding-right:5px;
+}
+
+.even { background-color: #EFFBEF; }
+.odd { background-color: white; }
+
+.nowrap { white-space:nowrap; }

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/876600a3/shiro-basic/src/main/webapp/index.jsp
----------------------------------------------------------------------
diff --git a/shiro-basic/src/main/webapp/index.jsp b/shiro-basic/src/main/webapp/index.jsp
new file mode 100644
index 0000000..ca4c39d
--- /dev/null
+++ b/shiro-basic/src/main/webapp/index.jsp
@@ -0,0 +1 @@
+<% response.sendRedirect("login.action"); %> 

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/876600a3/shiro-basic/src/main/webapp/pages/login.jsp
----------------------------------------------------------------------
diff --git a/shiro-basic/src/main/webapp/pages/login.jsp b/shiro-basic/src/main/webapp/pages/login.jsp
new file mode 100644
index 0000000..8d62758
--- /dev/null
+++ b/shiro-basic/src/main/webapp/pages/login.jsp
@@ -0,0 +1,27 @@
+<%@ page language="java" contentType="text/html; charset=US-ASCII"
+    pageEncoding="US-ASCII"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<%-- Using Struts2 Tags in JSP --%>
+<%@ taglib uri="/struts-tags" prefix="s"%>
+<html>
+<head>
+	<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+	<title>Login Page</title>
+    <link href="<s:url value='/css/main.css'/>" rel="stylesheet" type="text/css"/>
+</head>
+<s:head theme="xhtml" />
+
+<body>
+<h3>Welcome User, please login below</h3>
+<s:form action="authuser" theme="xhtml">
+	<s:textfield name="username" label="User Name"></s:textfield>
+	<s:textfield name="password" label="Password" type="password"></s:textfield>
+	<s:submit value="Login"></s:submit>
+	<s:if test="hasActionErrors()">
+	   <div class="errors">
+	      <s:actionerror/>
+	   </div>
+	</s:if>
+</s:form>
+</body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/876600a3/shiro-basic/src/main/webapp/pages/welcome.jsp
----------------------------------------------------------------------
diff --git a/shiro-basic/src/main/webapp/pages/welcome.jsp b/shiro-basic/src/main/webapp/pages/welcome.jsp
new file mode 100644
index 0000000..813d3ab
--- /dev/null
+++ b/shiro-basic/src/main/webapp/pages/welcome.jsp
@@ -0,0 +1,39 @@
+<%@ page language="java" contentType="text/html; charset=US-ASCII" pageEncoding="US-ASCII"%>
+<%@ taglib uri="/struts-tags" prefix="s"%>
+<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+	<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+	<title>Welcome Page</title>
+	<link href="<s:url value='/css/main.css'/>" rel="stylesheet" type="text/css"/>
+</head>
+<s:head theme="xhtml" />
+
+<body>
+  <shiro:authenticated>
+    <h3>Welcome <s:property value="username"></s:property></h3>
+    <h4>Roles:</h4>
+    <ul>
+        <shiro:hasRole name="schwartz"><li>May the Schwartz be with you!</shiro:hasRole>
+        <shiro:lacksRole name="schwartz"><li>Hello, mere mortal.</shiro:lacksRole>
+    </ul>
+    <h4>Permissions:</h4>
+    <ul>
+	    <shiro:hasPermission name="lightsaber:weild"><li>You may use a lightsaber
ring.  Use it wisely.<br></shiro:hasPermission>
+	    <shiro:lacksPermission name="lightsaber:weild"><li>Sorry, lightsaber rings
are for schwartz masters only.</shiro:lacksPermission>
+	    <shiro:hasPermission name="winnebago:drive:eagle5"><li>You are permitted
to 'drive' the winnebago with license plate (id) 'eagle5'.<br>Here are the keys - have
fun!<br></shiro:hasPermission>
+	    <shiro:lacksPermission name="winnebago:drive:eagle5"><li>Sorry, you aren't
allowed to drive the 'eagle5' winnebago!</shiro:lacksPermission>
+    </ul>
+  </shiro:authenticated>
+  <shiro:notAuthenticated>
+    <h3>Welcome Guest</h3>
+  </shiro:notAuthenticated>
+
+  <br>
+  <s:form action="logout">
+	<s:submit value="Logout"></s:submit>
+  </s:form>
+</body>
+</html>
\ No newline at end of file


Mime
View raw message