Author: prabath
Date: Tue Dec 11 03:29:48 2007
New Revision: 10966

Log:

Added control logic for OpenID 

Modified:
   
branches/solutions/identity/openid-poc/modules/admin-ui/src/main/java/org/wso2/solutions/identity/admin/ui/filter/JSPFilter.java

Modified: 
branches/solutions/identity/openid-poc/modules/admin-ui/src/main/java/org/wso2/solutions/identity/admin/ui/filter/JSPFilter.java
==============================================================================
--- 
branches/solutions/identity/openid-poc/modules/admin-ui/src/main/java/org/wso2/solutions/identity/admin/ui/filter/JSPFilter.java
    (original)
+++ 
branches/solutions/identity/openid-poc/modules/admin-ui/src/main/java/org/wso2/solutions/identity/admin/ui/filter/JSPFilter.java
    Tue Dec 11 03:29:48 2007
@@ -17,6 +17,7 @@
 package org.wso2.solutions.identity.admin.ui.filter;
 
 import org.wso2.solutions.identity.admin.ui.UIConstants;
+import org.wso2.solutions.identity.openid.OpenIdProvider;
 
 import javax.servlet.Filter;
 import javax.servlet.FilterChain;
@@ -25,32 +26,53 @@
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 
 import java.io.IOException;
+import java.io.PrintWriter;
 
 public class JSPFilter implements Filter {
 
-    private FilterConfig filterConfig;
+       private FilterConfig filterConfig;
 
-    public void destroy() {
-    }
+       public void destroy() {
+       }
 
-    public void doFilter(ServletRequest req, ServletResponse resp,
-            FilterChain chain) throws IOException, ServletException {
-        String path = ((HttpServletRequest) req).getRequestURI();
-        if (path.indexOf(UIConstants.JSP_ERROR_PAGE) < 0) {
-            this.filterConfig.getServletContext().getRequestDispatcher(
-                    UIConstants.JSP_ERROR_PAGE).forward(req, resp);
-            return;
-        } else {
-            // Only allow access to error JSP
-            chain.doFilter(req, resp);
-        }
-
-    }
-
-    public void init(FilterConfig config) throws ServletException {
-        this.filterConfig = config;
-    }
+       public void doFilter(ServletRequest req, ServletResponse resp,
+                       FilterChain chain) throws IOException, ServletException 
{
+               String path = ((HttpServletRequest) req).getRequestURI();
+
+               if (path.indexOf(UIConstants.OPENID_SERVER_PAGE) >= 0) {
+                       OpenIdProvider provider = new OpenIdProvider();
+                       try {
+                               ((HttpServletResponse) 
resp).sendRedirect(provider.processRequest((HttpServletRequest) req,
+                                               (HttpServletResponse) resp));
+                       } catch (Exception e) {
+                               // TODO : need to work on exception handling
+                               e.printStackTrace();
+                       }
+                       return;
+
+               } else if (path.indexOf(UIConstants.OPENID_USER_PAGE) >= 0) {
+                       
+                       chain.doFilter(req, resp);
+                       
+               } else if (path.indexOf(UIConstants.JSP_ERROR_PAGE) < 0) {
+                       
this.filterConfig.getServletContext().getRequestDispatcher(
+                                       
UIConstants.JSP_ERROR_PAGE).forward(req, resp);
+                       return;
+               } else if (path.indexOf(UIConstants.OPENID_USER_PAGE) > 0) {
+
+                       return;
+               } else {
+                       // Only allow access to error JSP
+                       chain.doFilter(req, resp);
+               }
+
+       }
+
+       public void init(FilterConfig config) throws ServletException {
+               this.filterConfig = config;
+       }
 
 }

_______________________________________________
Identity-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/identity-dev

Reply via email to