Author: fmeschbe
Date: Mon Sep 20 14:03:01 2010
New Revision: 998936

URL: http://svn.apache.org/viewvc?rev=998936&view=rev
Log:
Handle empty redirect target due to empty context path ourselves instead of 
using side-effect prone setLoginResourceAttribute

Modified:
    
sling/trunk/bundles/auth/core/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java

Modified: 
sling/trunk/bundles/auth/core/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/auth/core/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java?rev=998936&r1=998935&r2=998936&view=diff
==============================================================================
--- 
sling/trunk/bundles/auth/core/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java
 (original)
+++ 
sling/trunk/bundles/auth/core/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java
 Mon Sep 20 14:03:01 2010
@@ -850,24 +850,24 @@ public class SlingAuthenticator implemen
     private void doLogin(HttpServletRequest request,
             HttpServletResponse response) {
 
-        try {
+            try {
 
-            login(request, response);
+                login(request, response);
 
-        } catch (IllegalStateException ise) {
+            } catch (IllegalStateException ise) {
 
-            log.error("doLogin: Cannot login: Response already committed");
+                log.error("doLogin: Cannot login: Response already committed");
 
-        } catch (NoAuthenticationHandlerException nahe) {
+            } catch (NoAuthenticationHandlerException nahe) {
 
-            log.error("doLogin: Cannot login: No AuthenticationHandler 
available to handle the request");
+                log.error("doLogin: Cannot login: No AuthenticationHandler 
available to handle the request");
 
-            try {
+        try {
                 response.sendError(HttpServletResponse.SC_FORBIDDEN,
                     "Cannot login");
-            } catch (IOException ioe) {
-                log.error("doLogin: Failed sending 403 status", ioe);
-            }
+        } catch (IOException ioe) {
+            log.error("doLogin: Failed sending 403 status", ioe);
+        }
 
         }
     }
@@ -1081,8 +1081,11 @@ public class SlingAuthenticator implemen
 
         // find the redirect target from the resource attribute or parameter
         // falling back to the reuest context path (or /) if not set
-        final String target = 
AbstractAuthenticationHandler.setLoginResourceAttribute(
-            request, request.getContextPath());
+        String target = AbstractAuthenticationHandler.getLoginResource(request,
+            request.getContextPath());
+        if (target.length() == 0) {
+            target = "/";
+        }
 
         // redirect to there
         try {


Reply via email to