This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.auth.form-1.0.2
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-auth-form.git

commit 8a77e54e294bd29fd28015e918ddfde87921f69b
Author: Felix Meschberger <[email protected]>
AuthorDate: Mon Sep 20 08:52:50 2010 +0000

    SLING-1785 Use new redirect helper method of tha 
AbstractAuthenticationHandler
    
    git-svn-id: 
https://svn.apache.org/repos/asf/sling/trunk/bundles/auth/form@998830 
13f79535-47bb-0310-9956-ffa450edef68
---
 .../auth/form/impl/FormAuthenticationHandler.java  | 30 ++++++----------------
 1 file changed, 8 insertions(+), 22 deletions(-)

diff --git 
a/src/main/java/org/apache/sling/auth/form/impl/FormAuthenticationHandler.java 
b/src/main/java/org/apache/sling/auth/form/impl/FormAuthenticationHandler.java
index 3feb882..dab932e 100644
--- 
a/src/main/java/org/apache/sling/auth/form/impl/FormAuthenticationHandler.java
+++ 
b/src/main/java/org/apache/sling/auth/form/impl/FormAuthenticationHandler.java
@@ -21,10 +21,11 @@ package org.apache.sling.auth.form.impl;
 import java.io.File;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
 import java.security.InvalidKeyException;
 import java.security.NoSuchAlgorithmException;
 import java.util.Dictionary;
+import java.util.HashMap;
+
 import javax.jcr.Credentials;
 import javax.jcr.SimpleCredentials;
 import javax.servlet.Servlet;
@@ -396,38 +397,23 @@ public class FormAuthenticationHandler extends 
AbstractAuthenticationHandler {
             }
         }
 
-        // prepare the login form redirection target
-        final StringBuilder targetBuilder = new StringBuilder();
-        targetBuilder.append(request.getContextPath());
-        targetBuilder.append(loginForm);
-
-        // append originally requested resource (for redirect after login)
-        char parSep = '?';
-
-        if (resource != null) {
-            targetBuilder.append(parSep).append(Authenticator.LOGIN_RESOURCE);
-            targetBuilder.append("=").append(
-                URLEncoder.encode(resource, "UTF-8"));
-            parSep = '&';
-        }
+        HashMap<String, String> params = new HashMap<String, String>();
+        params.put(Authenticator.LOGIN_RESOURCE, resource);
 
         // append indication of previous login failure
         if (request.getAttribute(FAILURE_REASON) != null) {
             final Object jReason = request.getAttribute(FAILURE_REASON);
-            @SuppressWarnings("unchecked")
+            @SuppressWarnings("rawtypes")
             final String reason = (jReason instanceof Enum)
                     ? ((Enum) jReason).name()
                     : jReason.toString();
-            targetBuilder.append(parSep).append(FAILURE_REASON);
-            targetBuilder.append("=").append(URLEncoder.encode(reason, 
"UTF-8"));
+            params.put(FAILURE_REASON, reason);
         }
 
-        // finally redirect to the login form
-        final String target = targetBuilder.toString();
         try {
-            response.sendRedirect(target);
+            sendRedirect(request, response, loginForm, params);
         } catch (IOException e) {
-            log.error("Failed to redirect to the page: " + target, e);
+            log.error("Failed to redirect to the login form " + loginForm, e);
         }
 
         return true;

-- 
To stop receiving notification emails like this one, please contact
"[email protected]" <[email protected]>.

Reply via email to