Author: prabath
Date: Wed Dec 12 21:20:15 2007
New Revision: 11047

Log:

OpenID related authentication logic

Added:
   
branches/solutions/identity/openid-poc/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/OpenIdAuthenticationAction.java
Modified:
   
branches/solutions/identity/openid-poc/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/UIConstants.java
   
branches/solutions/identity/openid-poc/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/UserRegistrationFormSubmitAction.java
   
branches/solutions/identity/openid-poc/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/filter/JSPFilter.java
   
branches/solutions/identity/openid-poc/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/interceptor/SessionInterceptor.java
   
branches/solutions/identity/openid-poc/modules/user-ui/src/main/resources/struts.xml
   
branches/solutions/identity/openid-poc/modules/user-ui/src/main/webapp/WEB-INF/web.xml

Modified: 
branches/solutions/identity/openid-poc/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/UIConstants.java
==============================================================================
--- 
branches/solutions/identity/openid-poc/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/UIConstants.java
   (original)
+++ 
branches/solutions/identity/openid-poc/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/UIConstants.java
   Wed Dec 12 21:20:15 2007
@@ -54,5 +54,11 @@
     public final static String USER_REGISTRATION_OPENDID_ACTION = 
"OpenIdUserRegistration.action";    
     
     public final static String OPENDID_CALLBACK_ACTION = 
"OpenIdCallback.action";
+    
+    public final static String OPENID_SERVER_PAGE = "/server";
+    
+    public final static String OPENID_USER_PAGE = "/user";
+    
+    public final static String OPENID_AUTH_ACTION = 
"OpenIdAuthentication.action";
 
 }

Added: 
branches/solutions/identity/openid-poc/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/OpenIdAuthenticationAction.java
==============================================================================
--- (empty file)
+++ 
branches/solutions/identity/openid-poc/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/OpenIdAuthenticationAction.java
     Wed Dec 12 21:20:15 2007
@@ -0,0 +1,13 @@
+package org.wso2.solutions.identity.user.ui.action;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+public class OpenIdAuthenticationAction extends ActionSupport {
+
+       private static final long serialVersionUID = 2379986821364538695L;
+
+       public String execute() throws Exception {
+               return SUCCESS;
+       }
+
+}
\ No newline at end of file

Modified: 
branches/solutions/identity/openid-poc/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/UserRegistrationFormSubmitAction.java
==============================================================================
--- 
branches/solutions/identity/openid-poc/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/UserRegistrationFormSubmitAction.java
       (original)
+++ 
branches/solutions/identity/openid-poc/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/UserRegistrationFormSubmitAction.java
       Wed Dec 12 21:20:15 2007
@@ -77,7 +77,7 @@
         // whether to register for an OpenID at the time of normal 
registration.
         // Create an OpenID for the user
         // TODO : remove the hard-coded port number
-        String openid = request.getServerName() + ":" +12080+ 
"/admin/user/"+this.username;
+        String openid = request.getServerName() + ":" +12080+ 
"/user/"+this.username;
         props.put(IdentityConstants.CLAIM_OPENID, openid);
         
         store.getRealm().getUserStoreAdmin().setUserProperties(this.username, 
props);

Modified: 
branches/solutions/identity/openid-poc/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/filter/JSPFilter.java
==============================================================================
--- 
branches/solutions/identity/openid-poc/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/filter/JSPFilter.java
      (original)
+++ 
branches/solutions/identity/openid-poc/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/filter/JSPFilter.java
      Wed Dec 12 21:20:15 2007
@@ -16,6 +16,7 @@
 
 package org.wso2.solutions.identity.user.ui.filter;
 
+import org.wso2.solutions.identity.openid.OpenIdProvider;
 import org.wso2.solutions.identity.user.ui.UIConstants;
 
 import javax.servlet.Filter;
@@ -25,32 +26,55 @@
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 
 import java.io.IOException;
 
 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 
{
+
+               HttpServletRequest request = (HttpServletRequest) req;
+               String path = request.getRequestURI();
+
+               if (path.indexOf(UIConstants.OPENID_SERVER_PAGE) >= 0) {
+                       OpenIdProvider provider = new OpenIdProvider();
+                       // TODO: remove hard-coded protocol and port number
+                       provider.setAuthPage("http://"; + 
request.getServerName() + ":"
+                                       + 12080 + 
"/OpenIdAuthentication.action");
+                       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 {
+                       // Only allow access to error JSP
+                       chain.doFilter(req, resp);
+               }
+
+       }
+
+       public void init(FilterConfig config) throws ServletException {
+               this.filterConfig = config;
+       }
 
 }

Modified: 
branches/solutions/identity/openid-poc/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/interceptor/SessionInterceptor.java
==============================================================================
--- 
branches/solutions/identity/openid-poc/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/interceptor/SessionInterceptor.java
        (original)
+++ 
branches/solutions/identity/openid-poc/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/interceptor/SessionInterceptor.java
        Wed Dec 12 21:20:15 2007
@@ -52,8 +52,10 @@
                                                                
UIConstants.USER_REGISTRATION_OPENDID_ACTION) < 0
                                && requestURL.toString().indexOf(
                                                                                
UIConstants.OPENDID_CALLBACK_ACTION) < 0
+                               && 
requestURL.indexOf(UIConstants.OPENID_AUTH_ACTION)<0 
                                && requestURL.toString().indexOf(
-                                               
UIConstants.OPENID_LOGIN_ACTION) < 0) {
+                                               
UIConstants.OPENID_LOGIN_ACTION) < 0
+                                               ) {
                        // If the request is not Login.action
                        HttpSession session = request.getSession(true);
                        Object user = session.getAttribute(UIConstants.USER);

Modified: 
branches/solutions/identity/openid-poc/modules/user-ui/src/main/resources/struts.xml
==============================================================================
--- 
branches/solutions/identity/openid-poc/modules/user-ui/src/main/resources/struts.xml
        (original)
+++ 
branches/solutions/identity/openid-poc/modules/user-ui/src/main/resources/struts.xml
        Wed Dec 12 21:20:15 2007
@@ -78,6 +78,10 @@
             <result name="success">/jsp/openidlogin.jsp</result>
             <result name="error" type="redirect">Login.action</result>        
         </action>  
+        
+        <action name="OpenIdAuthentication" 
class="org.wso2.solutions.identity.user.ui.action.OpenIdAuthenticationAction">
+                       <result 
name="success">/jsp/openidauthorization.jsp</result>
+               </action>
        
           <action name="OpenIdSubmit"
                 
class="org.wso2.solutions.identity.user.ui.action.OpenIdSubmitAction">

Modified: 
branches/solutions/identity/openid-poc/modules/user-ui/src/main/webapp/WEB-INF/web.xml
==============================================================================
--- 
branches/solutions/identity/openid-poc/modules/user-ui/src/main/webapp/WEB-INF/web.xml
      (original)
+++ 
branches/solutions/identity/openid-poc/modules/user-ui/src/main/webapp/WEB-INF/web.xml
      Wed Dec 12 21:20:15 2007
@@ -59,10 +59,30 @@
     <filter-mapping>
         <filter-name>jspFilter</filter-name>
         <url-pattern>/jsp/*</url-pattern>
+    </filter-mapping>
+    
+      <filter-mapping>
+        <filter-name>jspFilter</filter-name>
+        <url-pattern>/server/*</url-pattern>
     </filter-mapping>
 
     <welcome-file-list>
         <welcome-file>index.html</welcome-file>
-    </welcome-file-list>
+    </welcome-file-list>
+    
+    <servlet>
+        <servlet-name>server</servlet-name>
+        
<servlet-class>org.wso2.solutions.identity.openid.UserInfoServlet</servlet-class>
+    </servlet>
+
+    <servlet-mapping>
+        <servlet-name>server</servlet-name>
+        <url-pattern>/user</url-pattern>
+    </servlet-mapping>
+
+   <servlet-mapping>
+        <servlet-name>server</servlet-name>
+        <url-pattern>/user/*</url-pattern>
+    </servlet-mapping>
 
 </web-app>
\ No newline at end of file

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

Reply via email to