SHIRO-589 - Adding servlet-fragment and sample

Copied from web sample and adjusted, embedded jetty IT fixed.


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

Branch: refs/heads/1.4.x
Commit: b05a48ff3fa2da3288760a13977f53318f6414a8
Parents: 1915802
Author: Brian Demers <bdem...@apache.org>
Authored: Fri Sep 30 09:42:06 2016 -0400
Committer: Brian Demers <bdem...@apache.org>
Committed: Fri Oct 14 15:15:50 2016 -0400

----------------------------------------------------------------------
 pom.xml                                         |  32 +++-
 samples/pom.xml                                 |   1 +
 samples/servlet-plugin/pom.xml                  | 128 ++++++++++++++++
 .../src/main/resources/log4j.properties         |  49 +++++++
 .../src/main/webapp/WEB-INF/shiro.ini           |  54 +++++++
 .../src/main/webapp/WEB-INF/web.xml             |  29 ++++
 .../src/main/webapp/account/index.jsp           |  36 +++++
 samples/servlet-plugin/src/main/webapp/home.jsp |  69 +++++++++
 .../servlet-plugin/src/main/webapp/include.jsp  |  22 +++
 .../servlet-plugin/src/main/webapp/index.jsp    |  21 +++
 .../servlet-plugin/src/main/webapp/login.jsp    | 110 ++++++++++++++
 .../servlet-plugin/src/main/webapp/style.css    |  47 ++++++
 .../apache/shiro/test/AbstractContainerIT.java  | 145 +++++++++++++++++++
 .../shiro/test/ContainerIntegrationIT.java      |  57 ++++++++
 support/pom.xml                                 |   1 +
 support/servlet-plugin/pom.xml                  |  65 +++++++++
 .../main/resources/META-INF/web-fragment.xml    |  42 ++++++
 17 files changed, 907 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/shiro/blob/b05a48ff/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 02f837a..1a3d9d6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -399,11 +399,36 @@
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-surefire-plugin</artifactId>
-                <version>2.12</version>
+                <version>2.19.1</version>
                 <configuration>
                     <printSummary>true</printSummary>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-failsafe-plugin</artifactId>
+                <version>2.19.1</version>
+                <configuration>
+                    <includes>
+                        <include>**/*IT.java</include>
+                        <include>**/*IT.groovy</include>
+                        <include>**/*ITCase.java</include>
+                        <include>**/*ITCase.groovy</include>
+                    </includes>
+                    <excludes>
+                        <exclude>**/*ManualIT.java</exclude>
+                        <exclude>**/*ManualIT.groovy</exclude>
+                    </excludes>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>integration-test</goal>
+                            <goal>verify</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
                 <plugin>
                     <groupId>org.jacoco</groupId>
                     <artifactId>jacoco-maven-plugin</artifactId>
@@ -558,6 +583,11 @@
             </dependency>
             <dependency>
                 <groupId>org.apache.shiro</groupId>
+                <artifactId>shiro-servlet-plugin</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.shiro</groupId>
                 <artifactId>shiro-ehcache</artifactId>
                 <version>${project.version}</version>
             </dependency>

http://git-wip-us.apache.org/repos/asf/shiro/blob/b05a48ff/samples/pom.xml
----------------------------------------------------------------------
diff --git a/samples/pom.xml b/samples/pom.xml
index c48092a..29c5369 100644
--- a/samples/pom.xml
+++ b/samples/pom.xml
@@ -42,6 +42,7 @@
         <module>spring-boot-web</module>
         <module>guice</module>
         <module>quickstart-guice</module>
+        <module>servlet-plugin</module>
     </modules>
 
     <reporting>

http://git-wip-us.apache.org/repos/asf/shiro/blob/b05a48ff/samples/servlet-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/samples/servlet-plugin/pom.xml b/samples/servlet-plugin/pom.xml
new file mode 100644
index 0000000..b969768
--- /dev/null
+++ b/samples/servlet-plugin/pom.xml
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<!--suppress osmorcNonOsgiMavenDependency -->
+<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/maven-v4_0_0.xsd";>
+
+    <parent>
+        <groupId>org.apache.shiro.samples</groupId>
+        <artifactId>shiro-samples</artifactId>
+        <version>1.4.0-SNAPSHOT</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>samples-servlet-plugin</artifactId>
+    <name>Apache Shiro :: Samples :: Servlet Plugin</name>
+    <packaging>war</packaging>
+
+    <properties>
+        <jetty.version>9.3.0.M1</jetty.version>
+    </properties>
+
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <forkMode>never</forkMode>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.eclipse.jetty</groupId>
+                <artifactId>jetty-maven-plugin</artifactId>
+                <version>${jetty.version}</version>
+                <configuration>
+                    <contextPath>/</contextPath>
+                    <httpConnector>
+                        <port>9080</port>
+                        <idleTimeout>60000</idleTimeout>
+                    </httpConnector>
+                    <requestLog 
implementation="org.eclipse.jetty.server.NCSARequestLog">
+                        <filename>./target/yyyy_mm_dd.request.log</filename>
+                        <retainDays>90</retainDays>
+                        <append>true</append>
+                        <extended>false</extended>
+                        <logTimeZone>GMT</logTimeZone>
+                    </requestLog>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.shiro</groupId>
+            <artifactId>shiro-servlet-plugin</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>jstl</artifactId>
+            <version>1.2</version>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>net.sourceforge.htmlunit</groupId>
+            <artifactId>htmlunit</artifactId>
+            <version>2.6</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>apache-jsp</artifactId>
+            <version>${jetty.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>apache-jstl</artifactId>
+            <version>${jetty.version}</version>
+            <type>pom</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.github.mjeanroy</groupId>
+            <artifactId>junit-servers-jetty</artifactId>
+            <version>0.4.2</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>jcl-over-slf4j</artifactId>
+            <scope>runtime</scope>
+        </dependency>
+    </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/shiro/blob/b05a48ff/samples/servlet-plugin/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/samples/servlet-plugin/src/main/resources/log4j.properties 
b/samples/servlet-plugin/src/main/resources/log4j.properties
new file mode 100644
index 0000000..51c6848
--- /dev/null
+++ b/samples/servlet-plugin/src/main/resources/log4j.properties
@@ -0,0 +1,49 @@
+#
+# 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.
+#
+
+# This file is used to format all logging output
+log4j.rootLogger=INFO, stdout
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d %-5p [%c]: %m%n
+
+# =============================================================================
+# 3rd Party Libraries
+# OFF, FATAL, ERROR, WARN, INFO, DEBUG, ALL
+# =============================================================================
+# ehcache caching manager:
+log4j.logger.net.sf.ehcache=WARN
+
+# Most all Apache libs:
+log4j.logger.org.apache=WARN
+
+# Quartz Enterprise Scheular (java 'cron' utility)
+log4j.logger.org.quartz=WARN
+
+# =============================================================================
+# Apache Shiro
+# =============================================================================
+# Shiro security framework
+log4j.logger.org.apache.shiro=TRACE
+#log4j.logger.org.apache.shiro.realm.text.PropertiesRealm=INFO
+#log4j.logger.org.apache.shiro.cache.ehcache.EhCache=INFO
+#log4j.logger.org.apache.shiro.io=INFO
+#log4j.logger.org.apache.shiro.web.servlet=INFO
+log4j.logger.org.apache.shiro.util.ThreadContext=INFO

http://git-wip-us.apache.org/repos/asf/shiro/blob/b05a48ff/samples/servlet-plugin/src/main/webapp/WEB-INF/shiro.ini
----------------------------------------------------------------------
diff --git a/samples/servlet-plugin/src/main/webapp/WEB-INF/shiro.ini 
b/samples/servlet-plugin/src/main/webapp/WEB-INF/shiro.ini
new file mode 100644
index 0000000..33c7586
--- /dev/null
+++ b/samples/servlet-plugin/src/main/webapp/WEB-INF/shiro.ini
@@ -0,0 +1,54 @@
+#
+# 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.
+
+# INI configuration is very powerful and flexible, while still remaining 
succinct.
+# Please http://shiro.apache.org/configuration.html and
+# http://shiro.apache.org/web.html for more.
+
+[main]
+listener = org.apache.shiro.config.event.LoggingBeanEventListener
+
+shiro.loginUrl = /login.jsp
+
+# We need to set the cipherKey, if you want the rememberMe cookie to work 
after restarting or on multiple nodes.
+# YOU MUST SET THIS TO A UNIQUE STRING
+#securityManager.rememberMeManager.cipherKey = kPH+bIxk5D2deZiIxcaaaA==
+
+[users]
+# format: username = password, role1, role2, ..., roleN
+root = secret,admin
+guest = guest,guest
+presidentskroob = 12345,president
+darkhelmet = ludicrousspeed,darklord,schwartz
+lonestarr = vespa,goodguy,schwartz
+
+[roles]
+# format: roleName = permission1, permission2, ..., permissionN
+admin = *
+schwartz = lightsaber:*
+goodguy = winnebago:drive:eagle5
+
+[urls]
+# The /login.jsp is not restricted to authenticated users (otherwise no one 
could log in!), but
+# the 'authc' filter must still be specified for it so it can process that 
url's
+# login submissions. It is 'smart' enough to allow those requests through as 
specified by the
+# shiro.loginUrl above.
+/login.jsp = authc
+/logout = logout
+/account/** = authc
+/remoting/** = authc, roles[b2bClient], perms["remote:invoke:lan,wan"]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/shiro/blob/b05a48ff/samples/servlet-plugin/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/samples/servlet-plugin/src/main/webapp/WEB-INF/web.xml 
b/samples/servlet-plugin/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..368fd60
--- /dev/null
+++ b/samples/servlet-plugin/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd";
+         version="3.1">
+
+    <welcome-file-list>
+        <welcome-file>index.jsp</welcome-file>
+    </welcome-file-list>
+
+</web-app>

http://git-wip-us.apache.org/repos/asf/shiro/blob/b05a48ff/samples/servlet-plugin/src/main/webapp/account/index.jsp
----------------------------------------------------------------------
diff --git a/samples/servlet-plugin/src/main/webapp/account/index.jsp 
b/samples/servlet-plugin/src/main/webapp/account/index.jsp
new file mode 100644
index 0000000..4f6c9d8
--- /dev/null
+++ b/samples/servlet-plugin/src/main/webapp/account/index.jsp
@@ -0,0 +1,36 @@
+<%--
+  ~ 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.
+  --%>
+<%@ include file="../include.jsp" %>
+
+<html>
+<head>
+    <link type="text/css" rel="stylesheet" href="<c:url value="/style.css"/>"/>
+</head>
+<body>
+
+<h2>Users only</h2>
+
+<p>You are currently logged in.</p>
+
+<p><a href="<c:url value="/home.jsp"/>">Return to the home page.</a></p>
+
+<p><a href="<c:url value="/logout"/>">Log out.</a></p>
+
+</body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/shiro/blob/b05a48ff/samples/servlet-plugin/src/main/webapp/home.jsp
----------------------------------------------------------------------
diff --git a/samples/servlet-plugin/src/main/webapp/home.jsp 
b/samples/servlet-plugin/src/main/webapp/home.jsp
new file mode 100644
index 0000000..61dee25
--- /dev/null
+++ b/samples/servlet-plugin/src/main/webapp/home.jsp
@@ -0,0 +1,69 @@
+<%--
+  ~ 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.
+  --%>
+<%@ include file="include.jsp" %>
+
+<html>
+<head>
+    <link type="text/css" rel="stylesheet" href="<c:url value="/style.css"/>"/>
+    <title>Apache Shiro Quickstart</title>
+</head>
+<body>
+
+<h1>Apache Shiro Quickstart</h1>
+
+<p>Hi 
<shiro:guest>Guest</shiro:guest><shiro:user><shiro:principal/></shiro:user>!
+    ( <shiro:user><a href="<c:url value="/logout"/>">Log out</a></shiro:user>
+    <shiro:guest><a href="<c:url value="/login.jsp"/>">Log in</a> (sample 
accounts provided)</shiro:guest> )
+</p>
+
+<p>Welcome to the Apache Shiro Quickstart sample application.
+    This page represents the home page of any web application.</p>
+
+<shiro:user><p>Visit your <a href="<c:url value="/account"/>">account 
page</a>.</p></shiro:user>
+<shiro:guest><p>If you want to access the user-only <a href="<c:url 
value="/account"/>">account page</a>,
+    you will need to log-in first.</p></shiro:guest>
+
+<h2>Roles</h2>
+
+<p>To show some taglibs, here are the roles you have and don't have. Log out 
and log back in under different user
+    accounts to see different roles.</p>
+
+<h3>Roles you have</h3>
+
+<p>
+    <shiro:hasRole name="admin">admin<br/></shiro:hasRole>
+    <shiro:hasRole name="president">president<br/></shiro:hasRole>
+    <shiro:hasRole name="darklord">darklord<br/></shiro:hasRole>
+    <shiro:hasRole name="goodguy">goodguy<br/></shiro:hasRole>
+    <shiro:hasRole name="schwartz">schwartz<br/></shiro:hasRole>
+</p>
+
+<h3>Roles you DON'T have</h3>
+
+<p>
+    <shiro:lacksRole name="admin">admin<br/></shiro:lacksRole>
+    <shiro:lacksRole name="president">president<br/></shiro:lacksRole>
+    <shiro:lacksRole name="darklord">darklord<br/></shiro:lacksRole>
+    <shiro:lacksRole name="goodguy">goodguy<br/></shiro:lacksRole>
+    <shiro:lacksRole name="schwartz">schwartz<br/></shiro:lacksRole>
+</p>
+
+
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/shiro/blob/b05a48ff/samples/servlet-plugin/src/main/webapp/include.jsp
----------------------------------------------------------------------
diff --git a/samples/servlet-plugin/src/main/webapp/include.jsp 
b/samples/servlet-plugin/src/main/webapp/include.jsp
new file mode 100644
index 0000000..fddd239
--- /dev/null
+++ b/samples/servlet-plugin/src/main/webapp/include.jsp
@@ -0,0 +1,22 @@
+<%--
+  ~ 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.
+  --%>
+<%@ page import="org.apache.shiro.SecurityUtils" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"; %>
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"; %>
+<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"; %>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/shiro/blob/b05a48ff/samples/servlet-plugin/src/main/webapp/index.jsp
----------------------------------------------------------------------
diff --git a/samples/servlet-plugin/src/main/webapp/index.jsp 
b/samples/servlet-plugin/src/main/webapp/index.jsp
new file mode 100644
index 0000000..9dedd19
--- /dev/null
+++ b/samples/servlet-plugin/src/main/webapp/index.jsp
@@ -0,0 +1,21 @@
+<%--
+  ~ 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.
+  --%>
+
+<%-- Forward the user to the home page --%>
+<jsp:forward page="home.jsp"/>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/shiro/blob/b05a48ff/samples/servlet-plugin/src/main/webapp/login.jsp
----------------------------------------------------------------------
diff --git a/samples/servlet-plugin/src/main/webapp/login.jsp 
b/samples/servlet-plugin/src/main/webapp/login.jsp
new file mode 100644
index 0000000..c80ee54
--- /dev/null
+++ b/samples/servlet-plugin/src/main/webapp/login.jsp
@@ -0,0 +1,110 @@
+<%--
+  ~ 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.
+  --%>
+<%@ include file="include.jsp" %>
+
+<html>
+<head>
+    <link type="text/css" rel="stylesheet" href="<c:url value="/style.css"/>"/>
+</head>
+<body>
+
+<h2>Please Log in</h2>
+
+<shiro:guest>
+    <p>Here are a few sample accounts to play with in the default text-based 
Realm (used for this
+        demo and test installs only). Do you remember the movie these names 
came from? ;)</p>
+
+
+    <style type="text/css">
+        table.sample {
+            border-width: 1px;
+            border-style: outset;
+            border-color: blue;
+            border-collapse: separate;
+            background-color: rgb(255, 255, 240);
+        }
+
+        table.sample th {
+            border-width: 1px;
+            padding: 1px;
+            border-style: none;
+            border-color: blue;
+            background-color: rgb(255, 255, 240);
+        }
+
+        table.sample td {
+            border-width: 1px;
+            padding: 1px;
+            border-style: none;
+            border-color: blue;
+            background-color: rgb(255, 255, 240);
+        }
+    </style>
+
+
+    <table class="sample">
+        <thead>
+        <tr>
+            <th>Username</th>
+            <th>Password</th>
+        </tr>
+        </thead>
+        <tbody>
+        <tr>
+            <td>root</td>
+            <td>secret</td>
+        </tr>
+        <tr>
+            <td>presidentskroob</td>
+            <td>12345</td>
+        </tr>
+        <tr>
+            <td>darkhelmet</td>
+            <td>ludicrousspeed</td>
+        </tr>
+        <tr>
+            <td>lonestarr</td>
+            <td>vespa</td>
+        </tr>
+        </tbody>
+    </table>
+    <br/><br/>
+</shiro:guest>
+
+<form name="loginform" action="" method="post">
+    <table align="left" border="0" cellspacing="0" cellpadding="3">
+        <tr>
+            <td>Username:</td>
+            <td><input type="text" name="username" maxlength="30"></td>
+        </tr>
+        <tr>
+            <td>Password:</td>
+            <td><input type="password" name="password" maxlength="30"></td>
+        </tr>
+        <tr>
+            <td colspan="2" align="left"><input type="checkbox" 
name="rememberMe"><font size="2">Remember Me</font></td>
+        </tr>
+        <tr>
+            <td colspan="2" align="right"><input type="submit" name="submit" 
value="Login"></td>
+        </tr>
+    </table>
+</form>
+
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/shiro/blob/b05a48ff/samples/servlet-plugin/src/main/webapp/style.css
----------------------------------------------------------------------
diff --git a/samples/servlet-plugin/src/main/webapp/style.css 
b/samples/servlet-plugin/src/main/webapp/style.css
new file mode 100644
index 0000000..1308e3f
--- /dev/null
+++ b/samples/servlet-plugin/src/main/webapp/style.css
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+body {
+    margin: 15px 0 0 15px;
+    padding: 1px; /*background: #2370cf;*/
+    font: 12px 'Lucida Grande', Geneva, Verdana, Arial, sans-serif;
+    color: #000;
+}
+
+table, td {
+    font: 12px 'Lucida Grande', Geneva, Verdana, Arial, sans-serif;
+    color: #000;
+}
+
+h1 {
+    font: 24px;
+}
+
+img {
+    border: thin black solid;
+}
+
+#contentBox {
+    text-align: center;
+    width: 50%;
+    margin: auto;
+    margin-top: 50px;
+    color: black;
+    background: #eee;
+    border: thick black solid;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/shiro/blob/b05a48ff/samples/servlet-plugin/src/test/java/org/apache/shiro/test/AbstractContainerIT.java
----------------------------------------------------------------------
diff --git 
a/samples/servlet-plugin/src/test/java/org/apache/shiro/test/AbstractContainerIT.java
 
b/samples/servlet-plugin/src/test/java/org/apache/shiro/test/AbstractContainerIT.java
new file mode 100644
index 0000000..f5b44f7
--- /dev/null
+++ 
b/samples/servlet-plugin/src/test/java/org/apache/shiro/test/AbstractContainerIT.java
@@ -0,0 +1,145 @@
+/*
+ * 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.shiro.test;
+
+import com.gargoylesoftware.htmlunit.WebClient;
+
+import static org.eclipse.jetty.util.resource.Resource.newResource;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import com.github.mjeanroy.junit.servers.jetty.EmbeddedJetty;
+import com.github.mjeanroy.junit.servers.jetty.EmbeddedJettyConfiguration;
+import org.eclipse.jetty.annotations.AnnotationConfiguration;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.util.resource.FileResource;
+import org.eclipse.jetty.webapp.Configuration;
+import org.eclipse.jetty.webapp.FragmentConfiguration;
+import org.eclipse.jetty.webapp.JettyWebXmlConfiguration;
+import org.eclipse.jetty.webapp.MetaInfConfiguration;
+import org.eclipse.jetty.webapp.WebAppContext;
+import org.eclipse.jetty.webapp.WebInfConfiguration;
+import org.eclipse.jetty.webapp.WebXmlConfiguration;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+import static com.github.mjeanroy.junit.servers.commons.Strings.isNotBlank;
+
+public abstract class AbstractContainerIT {
+
+    private static EmbeddedJetty jetty;
+
+    private static int port = 0;
+
+    protected final WebClient webClient = new WebClient();
+
+    @BeforeClass
+    public static void startContainer() throws Exception {
+
+        File[] warFiles = new File("target").listFiles(new FilenameFilter() {
+            @Override
+            public boolean accept(File dir, String name) {
+                return name.endsWith(".war");
+            }
+        });
+
+        assertEquals("Expected only one war file in target directory, run 'mvn 
clean' and try again", 1, warFiles.length);
+
+        String warDir = warFiles[0].getAbsolutePath().replaceFirst("\\.war$", 
"");
+
+        EmbeddedJettyConfiguration config = 
EmbeddedJettyConfiguration.builder()
+                .withWebapp(warDir)
+                .build();
+
+        jetty = new EmbeddedJetty(config) {
+
+            /**
+             * Overriding with contents of this pull request, to make fragment 
scanning work.
+             * https://github.com/mjeanroy/junit-servers/pull/3
+             */
+            protected WebAppContext createdWebAppContext() throws Exception {
+                final String path = configuration.getPath();
+                final String webapp = configuration.getWebapp();
+                final String classpath = configuration.getClasspath();
+
+                WebAppContext ctx = new WebAppContext();
+                
ctx.setClassLoader(Thread.currentThread().getContextClassLoader());
+                ctx.setContextPath(path);
+
+                // Useful for WebXmlConfiguration
+                ctx.setBaseResource(newResource(webapp));
+
+                ctx.setConfigurations(new Configuration[]{
+                        new WebInfConfiguration(),
+                        new WebXmlConfiguration(),
+                        new AnnotationConfiguration(),
+                        new JettyWebXmlConfiguration(),
+                        new MetaInfConfiguration(),
+                        new FragmentConfiguration(),
+                });
+
+                if (isNotBlank(classpath)) {
+                    // Fix to scan Spring WebApplicationInitializer
+                    // This will add compiled classes to jetty classpath
+                    // See: 
http://stackoverflow.com/questions/13222071/spring-3-1-webapplicationinitializer-embedded-jetty-8-annotationconfiguration
+                    // And more precisely: 
http://stackoverflow.com/a/18449506/1215828
+                    File classes = new File(classpath);
+                    FileResource containerResources = new 
FileResource(classes.toURI());
+                    ctx.getMetaData().addContainerResource(containerResources);
+                }
+
+                Server server = getDelegate();
+
+                ctx.setParentLoaderPriority(true);
+                ctx.setWar(webapp);
+                ctx.setServer(server);
+
+                // Add server context
+                server.setHandler(ctx);
+
+                return ctx;
+            }
+        };
+
+        jetty.start();
+        port = jetty.getPort();
+
+        assertTrue(jetty.isStarted());
+    }
+
+    protected static String getBaseUri() {
+        return "http://localhost:"; + port + "/";
+    }
+
+    @Before
+    public void beforeTest() {
+        webClient.setThrowExceptionOnFailingStatusCode(true);
+    }
+
+    @AfterClass
+    public static void stopContainer() {
+        if (jetty != null) {
+            jetty.stop();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/shiro/blob/b05a48ff/samples/servlet-plugin/src/test/java/org/apache/shiro/test/ContainerIntegrationIT.java
----------------------------------------------------------------------
diff --git 
a/samples/servlet-plugin/src/test/java/org/apache/shiro/test/ContainerIntegrationIT.java
 
b/samples/servlet-plugin/src/test/java/org/apache/shiro/test/ContainerIntegrationIT.java
new file mode 100644
index 0000000..4cef226
--- /dev/null
+++ 
b/samples/servlet-plugin/src/test/java/org/apache/shiro/test/ContainerIntegrationIT.java
@@ -0,0 +1,57 @@
+/*
+ * 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.shiro.test;
+
+import com.gargoylesoftware.htmlunit.ElementNotFoundException;
+import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
+import com.gargoylesoftware.htmlunit.html.HtmlForm;
+import com.gargoylesoftware.htmlunit.html.HtmlInput;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+
+public class ContainerIntegrationIT extends AbstractContainerIT {
+
+    @Before
+    public void logOut() throws IOException {
+        // Make sure we are logged out
+        final HtmlPage homePage = webClient.getPage(getBaseUri());
+        try {
+            homePage.getAnchorByHref("/logout").click();
+        }
+        catch (ElementNotFoundException e) {
+            //Ignore
+        }
+    }
+
+    @Test
+    public void logIn() throws FailingHttpStatusCodeException, 
MalformedURLException, IOException, InterruptedException {
+
+        HtmlPage page = webClient.getPage(getBaseUri() + "login.jsp");
+        HtmlForm form = page.getFormByName("loginform");
+        form.<HtmlInput>getInputByName("username").setValueAttribute("root");
+        form.<HtmlInput>getInputByName("password").setValueAttribute("secret");
+        page = form.<HtmlInput>getInputByName("submit").click();
+        // This'll throw an expection if not logged in
+        page.getAnchorByHref("/logout");
+    }
+}

http://git-wip-us.apache.org/repos/asf/shiro/blob/b05a48ff/support/pom.xml
----------------------------------------------------------------------
diff --git a/support/pom.xml b/support/pom.xml
index b30b471..9f12c69 100644
--- a/support/pom.xml
+++ b/support/pom.xml
@@ -41,6 +41,7 @@
         <module>features</module>
         <module>cas</module>
         <module>spring-boot</module>
+        <module>servlet-plugin</module>
     </modules>
 
 </project>

http://git-wip-us.apache.org/repos/asf/shiro/blob/b05a48ff/support/servlet-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/support/servlet-plugin/pom.xml b/support/servlet-plugin/pom.xml
new file mode 100644
index 0000000..4087cce
--- /dev/null
+++ b/support/servlet-plugin/pom.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2012 Stormpath, 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.
+  -->
+<!--suppress osmorcNonOsgiMavenDependency -->
+<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/maven-v4_0_0.xsd";>
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.shiro</groupId>
+        <artifactId>shiro-support</artifactId>
+        <version>1.4.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>shiro-servlet-plugin</artifactId>
+    <name>Apache Shiro :: Support :: Servlet Plugin</name>
+    <description>
+        Automatically deploys Shiro in a servlet container-based web 
application.
+    </description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.shiro</groupId>
+            <artifactId>shiro-web</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>xml-maven-plugin</artifactId>
+                <version>1.0.1</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>validate</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <validationSets>
+                        <validationSet>
+                            <dir>src/main/resources/META-INF/</dir>
+                        </validationSet>
+                    </validationSets>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/shiro/blob/b05a48ff/support/servlet-plugin/src/main/resources/META-INF/web-fragment.xml
----------------------------------------------------------------------
diff --git 
a/support/servlet-plugin/src/main/resources/META-INF/web-fragment.xml 
b/support/servlet-plugin/src/main/resources/META-INF/web-fragment.xml
new file mode 100644
index 0000000..dd478c3
--- /dev/null
+++ b/support/servlet-plugin/src/main/resources/META-INF/web-fragment.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~
+  ~ 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.
+  -->
+<web-fragment metadata-complete="true"
+              xmlns="http://xmlns.jcp.org/xml/ns/javaee";
+              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+              xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
http://xmlns.jcp.org/xml/ns/javaee/web-fragment_3_1.xsd";
+              version="3.1">
+
+    <name>ApacheShiro</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>
+
+</web-fragment>
\ No newline at end of file

Reply via email to