JSEC-123 - added some configuration changes to ensure the authc filter could process the login url

git-svn-id: https://svn.apache.org/repos/asf/incubator/jsecurity/trunk@711067 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/jsecurity.iml b/jsecurity.iml
index a825883..5e1d614 100644
--- a/jsecurity.iml
+++ b/jsecurity.iml
@@ -16,6 +16,50 @@
         <customNs />

       </configuration>

     </facet>

+    <facet type="web" name="jsecurity-quickstart">

+      <configuration>

+        <descriptors>

+          <deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/samples/quickstart/WEB-INF/web.xml" optional="false" version="2.5" />

+        </descriptors>

+        <webroots>

+          <root url="file://$MODULE_DIR$/samples/quickstart" relative="/" />

+        </webroots>

+        <sourceRoots>

+          <root url="file://$MODULE_DIR$/src" />

+          <root url="file://$MODULE_DIR$/test" />

+        </sourceRoots>

+        <building>

+          <setting name="EXPLODED_URL" value="file://$MODULE_DIR$/out/exploded/jsecurity-quickstart" />

+          <setting name="EXPLODED_ENABLED" value="true" />

+          <setting name="JAR_URL" value="file://$MODULE_DIR$/out/Quickstart Webapp.war" />

+          <setting name="JAR_ENABLED" value="false" />

+          <setting name="BUILD_MODULE_ON_FRAME_DEACTIVATION" value="false" />

+          <setting name="BUILD_EXTERNAL_DEPENDENCIES" value="false" />

+          <setting name="EXCLUDE_EXPLODED_DIRECTORY" value="true" />

+          <setting name="RUN_JASPER_VALIDATION" value="true" />

+          <setting name="BUILD_ONLY_WEB_RESOURCES" value="false" />

+        </building>

+        <packaging>

+          <containerElement type="module" name="jsecurity">

+            <attribute name="method" value="1" />

+            <attribute name="URI" value="/WEB-INF/classes" />

+          </containerElement>

+          <containerElement type="library" name="all-libs" level="project">

+            <attribute name="method" value="0" />

+            <attribute name="URI" value="&lt;N/A&gt;" />

+          </containerElement>

+          <containerElement type="library" name="quickstart-libs" level="project">

+            <attribute name="method" value="1" />

+            <attribute name="URI" value="/WEB-INF/lib" />

+          </containerElement>

+          <containerElement type="library" level="module">

+            <attribute name="method" value="0" />

+            <attribute name="URI" value="&lt;N/A&gt;" />

+            <url>jar://$APPLICATION_HOME_DIR$/lib/j2ee.jar!/</url>

+          </containerElement>

+        </packaging>

+      </configuration>

+    </facet>

   </component>

   <component name="NewModuleRootManager" inherit-compiler-output="false">

     <output url="file://$MODULE_DIR$/build/classes" />

@@ -34,12 +78,170 @@
     <orderEntry type="inheritedJdk" />

     <orderEntry type="sourceFolder" forTests="false" />

     <orderEntry type="library" name="all-libs" level="project" />

+    <orderEntry type="module-library">

+      <library>

+        <CLASSES>

+          <root url="jar://$APPLICATION_HOME_DIR$/lib/j2ee.jar!/" />

+        </CLASSES>

+        <JAVADOC />

+        <SOURCES />

+      </library>

+    </orderEntry>

+    <orderEntry type="library" name="quickstart-libs2" level="project" />

+    <orderEntry type="library" name="quickstart-libs" level="project" />

     <orderEntryProperties />

   </component>

   <component name="copyright">

     <Base>

       <setting name="state" value="1" />

     </Base>

+    <LanguageOptions name="HTML">

+      <option name="templateOptions">

+        <value>

+          <option name="block" value="true" />

+          <option name="separateBefore" value="false" />

+          <option name="separateAfter" value="false" />

+          <option name="prefixLines" value="true" />

+          <option name="lenBefore" value="80" />

+          <option name="lenAfter" value="80" />

+          <option name="box" value="false" />

+          <option name="filler" value=" " />

+        </value>

+      </option>

+      <option name="notice" value="Copyright (c) &amp;#36;today.year, Your Corporation. All Rights Reserved." />

+      <option name="keyword" value="Copyright" />

+      <option name="fileTypeOverride" value="2" />

+      <option name="relativeBefore" value="true" />

+      <option name="addBlankAfter" value="true" />

+      <option name="fileLocation" value="1" />

+      <option name="useAlternate" value="false" />

+    </LanguageOptions>

+    <LanguageOptions name="JAVA">

+      <option name="templateOptions">

+        <value>

+          <option name="block" value="true" />

+          <option name="separateBefore" value="false" />

+          <option name="separateAfter" value="false" />

+          <option name="prefixLines" value="true" />

+          <option name="lenBefore" value="80" />

+          <option name="lenAfter" value="80" />

+          <option name="box" value="false" />

+          <option name="filler" value=" " />

+        </value>

+      </option>

+      <option name="notice" value="Copyright (c) &amp;#36;today.year, Your Corporation. All Rights Reserved." />

+      <option name="keyword" value="Copyright" />

+      <option name="fileTypeOverride" value="2" />

+      <option name="relativeBefore" value="true" />

+      <option name="addBlankAfter" value="true" />

+      <option name="fileLocation" value="1" />

+      <option name="useAlternate" value="false" />

+    </LanguageOptions>

+    <LanguageOptions name="JSP">

+      <option name="templateOptions">

+        <value>

+          <option name="block" value="true" />

+          <option name="separateBefore" value="false" />

+          <option name="separateAfter" value="false" />

+          <option name="prefixLines" value="true" />

+          <option name="lenBefore" value="80" />

+          <option name="lenAfter" value="80" />

+          <option name="box" value="false" />

+          <option name="filler" value=" " />

+        </value>

+      </option>

+      <option name="notice" value="Copyright (c) &amp;#36;today.year, Your Corporation. All Rights Reserved." />

+      <option name="keyword" value="Copyright" />

+      <option name="fileTypeOverride" value="2" />

+      <option name="relativeBefore" value="true" />

+      <option name="addBlankAfter" value="true" />

+      <option name="fileLocation" value="1" />

+      <option name="useAlternate" value="false" />

+    </LanguageOptions>

+    <LanguageOptions name="JavaScript">

+      <option name="templateOptions">

+        <value>

+          <option name="block" value="true" />

+          <option name="separateBefore" value="false" />

+          <option name="separateAfter" value="false" />

+          <option name="prefixLines" value="true" />

+          <option name="lenBefore" value="80" />

+          <option name="lenAfter" value="80" />

+          <option name="box" value="false" />

+          <option name="filler" value=" " />

+        </value>

+      </option>

+      <option name="notice" value="Copyright (c) &amp;#36;today.year, Your Corporation. All Rights Reserved." />

+      <option name="keyword" value="Copyright" />

+      <option name="fileTypeOverride" value="2" />

+      <option name="relativeBefore" value="true" />

+      <option name="addBlankAfter" value="true" />

+      <option name="fileLocation" value="1" />

+      <option name="useAlternate" value="false" />

+    </LanguageOptions>

+    <LanguageOptions name="Properties">

+      <option name="templateOptions">

+        <value>

+          <option name="block" value="true" />

+          <option name="separateBefore" value="false" />

+          <option name="separateAfter" value="false" />

+          <option name="prefixLines" value="true" />

+          <option name="lenBefore" value="80" />

+          <option name="lenAfter" value="80" />

+          <option name="box" value="false" />

+          <option name="filler" value=" " />

+        </value>

+      </option>

+      <option name="notice" value="Copyright (c) &amp;#36;today.year, Your Corporation. All Rights Reserved." />

+      <option name="keyword" value="Copyright" />

+      <option name="fileTypeOverride" value="2" />

+      <option name="relativeBefore" value="true" />

+      <option name="addBlankAfter" value="true" />

+      <option name="fileLocation" value="1" />

+      <option name="useAlternate" value="false" />

+    </LanguageOptions>

+    <LanguageOptions name="XML">

+      <option name="templateOptions">

+        <value>

+          <option name="block" value="true" />

+          <option name="separateBefore" value="false" />

+          <option name="separateAfter" value="false" />

+          <option name="prefixLines" value="true" />

+          <option name="lenBefore" value="80" />

+          <option name="lenAfter" value="80" />

+          <option name="box" value="false" />

+          <option name="filler" value=" " />

+        </value>

+      </option>

+      <option name="notice" value="Copyright (c) &amp;#36;today.year, Your Corporation. All Rights Reserved." />

+      <option name="keyword" value="Copyright" />

+      <option name="fileTypeOverride" value="2" />

+      <option name="relativeBefore" value="true" />

+      <option name="addBlankAfter" value="true" />

+      <option name="fileLocation" value="1" />

+      <option name="useAlternate" value="false" />

+    </LanguageOptions>

+    <LanguageOptions name="__TEMPLATE__">

+      <option name="templateOptions">

+        <value>

+          <option name="block" value="true" />

+          <option name="separateBefore" value="false" />

+          <option name="separateAfter" value="false" />

+          <option name="prefixLines" value="true" />

+          <option name="lenBefore" value="80" />

+          <option name="lenAfter" value="80" />

+          <option name="box" value="false" />

+          <option name="filler" value=" " />

+        </value>

+      </option>

+      <option name="notice" value="Licensed to the Apache Software Foundation (ASF) under one &#10;or more contributor license agreements.  See the NOTICE file&#10;distributed with this work for additional information&#10;regarding copyright ownership.  The ASF licenses this file&#10;to you under the Apache License, Version 2.0 (the &#10;&quot;License&quot;); you may not use this file except in compliance &#10;with the License.  You may obtain a copy of the License at&#10;&#10;    http://www.apache.org/licenses/LICENSE-2.0&#10;&#10;Unless required by applicable law or agreed to in writing,&#10;software distributed under the License is distributed on an&#10;&quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&#10;KIND, either express or implied.  See the License for the&#10;specific language governing permissions and limitations&#10;under the License." />

+      <option name="keyword" value="Copyright" />

+      <option name="fileTypeOverride" value="4" />

+      <option name="relativeBefore" value="true" />

+      <option name="addBlankAfter" value="false" />

+      <option name="fileLocation" value="1" />

+      <option name="useAlternate" value="false" />

+    </LanguageOptions>

   </component>

 </module>

 

diff --git a/jsecurity.ipr b/jsecurity.ipr
index 245bb47..4ab6e6c 100644
--- a/jsecurity.ipr
+++ b/jsecurity.ipr
@@ -518,6 +518,20 @@
         <root url="file://C:/java/spring/spring-framework-2.5.4/src" />

       </SOURCES>

     </library>

+    <library name="quickstart-libs">

+      <CLASSES>

+        <root url="jar://$PROJECT_DIR$/lib/test/log4j.jar!/" />

+        <root url="jar://$PROJECT_DIR$/lib/test/commons-beanutils.jar!/" />

+        <root url="jar://$PROJECT_DIR$/lib/test/ehcache.jar!/" />

+        <root url="jar://$PROJECT_DIR$/lib/test/standard.jar!/" />

+        <root url="jar://$PROJECT_DIR$/lib/test/commons-logging.jar!/" />

+        <root url="jar://$PROJECT_DIR$/lib/test/backport-util-concurrent.jar!/" />

+        <root url="jar://$PROJECT_DIR$/lib/test/jstl.jar!/" />

+        <root url="jar://$PROJECT_DIR$/lib/test/commons-collections.jar!/" />

+      </CLASSES>

+      <JAVADOC />

+      <SOURCES />

+    </library>

   </component>

 </project>

 

diff --git a/samples/quickstart/WEB-INF/web.xml b/samples/quickstart/WEB-INF/web.xml
index 4a54108..80fc86c 100644
--- a/samples/quickstart/WEB-INF/web.xml
+++ b/samples/quickstart/WEB-INF/web.xml
@@ -22,35 +22,42 @@
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
 
-  <filter>
-    <filter-name>JSecurityFilter</filter-name>
-    <filter-class>org.jsecurity.web.servlet.JSecurityFilter</filter-class>
-    <init-param>
-      <param-name>config</param-name>
-      <param-value>
+    <filter>
+        <filter-name>JSecurityFilter</filter-name>
+        <filter-class>org.jsecurity.web.servlet.JSecurityFilter</filter-class>
+        <init-param>
+            <param-name>config</param-name>
+            <param-value>
 
-        # The JSecurityFilter configuration is very powerful and flexible, while still remaining succinct.
-        # Please read the comprehensive example, with full comments and explanations, in the JavaDoc:
-        #
-        # http://www.jsecurity.org/api/org/jsecurity/web/servlet/JSecurityFilter.html
+                # The JSecurityFilter configuration is very powerful and flexible, while still remaining succinct.
+                # Please read the comprehensive example, with full comments and explanations, in the JavaDoc:
+                #
+                # http://www.jsecurity.org/api/org/jsecurity/web/servlet/JSecurityFilter.html
 
-        [filters]
-        authc.successUrl = /index.jsp
+                [filters]
+                jsecurity.loginUrl = /login.jsp
 
-        [urls]
-        /account/** = authc
-        /remoting/** = authc, roles[b2bClient], perms[remote:invoke:"lan,wan"]
-      </param-value>
-    </init-param>
-  </filter>
+                [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
+                # jsecurity.loginUrl above.
+                /login.jsp = authc
 
-  <filter-mapping>
-    <filter-name>JSecurityFilter</filter-name>
-    <url-pattern>/*</url-pattern>
-  </filter-mapping>
+                /account/** = authc
+                /remoting/** = authc, roles[b2bClient], perms[remote:invoke:"lan,wan"]
 
-  <welcome-file-list>
-    <welcome-file>index.jsp</welcome-file>
-  </welcome-file-list>
+            </param-value>
+        </init-param>
+    </filter>
+
+    <filter-mapping>
+        <filter-name>JSecurityFilter</filter-name>
+        <url-pattern>/*</url-pattern>
+    </filter-mapping>
+
+    <welcome-file-list>
+        <welcome-file>index.jsp</welcome-file>
+    </welcome-file-list>
 
 </web-app>
diff --git a/samples/quickstart/account/index.jsp b/samples/quickstart/account/index.jsp
index ef0175d..779bb93 100644
--- a/samples/quickstart/account/index.jsp
+++ b/samples/quickstart/account/index.jsp
@@ -16,25 +16,6 @@
   ~ specific language governing permissions and limitations
   ~ under the License.
   --%>
-
-<%--
-  ~ 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>
diff --git a/src/org/jsecurity/web/filter/authc/AuthenticationFilter.java b/src/org/jsecurity/web/filter/authc/AuthenticationFilter.java
index a9abe68..a053ac6 100644
--- a/src/org/jsecurity/web/filter/authc/AuthenticationFilter.java
+++ b/src/org/jsecurity/web/filter/authc/AuthenticationFilter.java
@@ -75,9 +75,11 @@
     protected void issueSuccessRedirect(ServletRequest request, ServletResponse response) throws Exception {
 
         String successUrl = null;
+        boolean contextRelative = true;
         SavedRequest savedRequest = WebUtils.getAndClearSavedRequest(request);
         if (savedRequest != null && savedRequest.getMethod().equalsIgnoreCase(GET_METHOD)) {
             successUrl = savedRequest.getRequestUrl();
+            contextRelative = false;
         }
 
         if (successUrl == null) {
@@ -89,7 +91,7 @@
                     "getSuccessUrl().  One of these must be non-null for issueSuccessRedirect() to work.");
         }
 
-        WebUtils.issueRedirect(request, response, successUrl);
+        WebUtils.issueRedirect(request, response, successUrl, null, contextRelative);
     }
 
 }