You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by th...@apache.org on 2011/12/20 12:49:53 UTC

svn commit: r1221209 - /cocoon/cocoon3/trunk/cocoon-shiro/src/main/java/org/apache/cocoon/shiro/rest/AbstractShiroLogin.java

Author: thorsten
Date: Tue Dec 20 11:49:52 2011
New Revision: 1221209

URL: http://svn.apache.org/viewvc?rev=1221209&view=rev
Log:
Refactoring AbstractLogin to expose the error/success response in an overridable method. Suggestion by Ajay Deshwal.

Modified:
    cocoon/cocoon3/trunk/cocoon-shiro/src/main/java/org/apache/cocoon/shiro/rest/AbstractShiroLogin.java

Modified: cocoon/cocoon3/trunk/cocoon-shiro/src/main/java/org/apache/cocoon/shiro/rest/AbstractShiroLogin.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-shiro/src/main/java/org/apache/cocoon/shiro/rest/AbstractShiroLogin.java?rev=1221209&r1=1221208&r2=1221209&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-shiro/src/main/java/org/apache/cocoon/shiro/rest/AbstractShiroLogin.java (original)
+++ cocoon/cocoon3/trunk/cocoon-shiro/src/main/java/org/apache/cocoon/shiro/rest/AbstractShiroLogin.java Tue Dec 20 11:49:52 2011
@@ -18,6 +18,7 @@
  */
 package org.apache.cocoon.shiro.rest;
 
+import java.net.MalformedURLException;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -81,12 +82,20 @@ public abstract class AbstractShiroLogin
             Map<String, Object> data = new HashMap<String, Object>();
             data.put("error", true);
             data.put("to", getTo());
-            return new URLResponse(getErrorLogin(), data);
+            return getErrorResponse(data);
         } else {
-            return new RedirectResponse(getTo());
+            return getSuccessResponse();
         }
     }
 
+    protected RestResponse getSuccessResponse(){
+      return new RedirectResponse(getTo());
+    }
+
+    protected RestResponse getErrorResponse(Map<String, Object> data) throws MalformedURLException{
+       return new URLResponse(getErrorLogin(), data);
+    }
+
     public RestResponse doGet() throws Exception {
         Subject subject = SecurityUtils.getSubject();
         Session session = subject.getSession();
@@ -109,4 +118,4 @@ public abstract class AbstractShiroLogin
         }
         return to;
     }
-}
\ No newline at end of file
+}