Author: prabath
Date: Wed Jan 23 22:24:20 2008
New Revision: 12805

Log:

OpenID integration

Modified:
   
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/OpenIDCallbackAction.java
   
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/OpenIDInfoCardSubmitAction.java
   
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/OpenIDSubmitAction.java

Modified: 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/OpenIDCallbackAction.java
==============================================================================
--- 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/OpenIDCallbackAction.java
 (original)
+++ 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/OpenIDCallbackAction.java
 Wed Jan 23 22:24:20 2008
@@ -8,8 +8,8 @@
 import com.opensymphony.xwork2.ActionSupport;
 
 import org.wso2.solutions.identity.IdentityConstants;
-import org.wso2.solutions.identity.openid.relyingparty.OpenIDConsumer;
 import org.wso2.solutions.identity.user.ui.UIConstants;
+import org.wso2.solutions.identity.user.ui.util.UserUtil;
 
 public class OpenIDCallbackAction extends ActionSupport {
 
@@ -22,22 +22,24 @@
 
         ActionContext context = null;
         HttpServletRequest request = null;
-        OpenIDConsumer consumer = null;
-        Map session = null;
-        String user = null;
+        Map map = null;
+        String openID = null;
+        String userID = null;
 
         try {
             context = ActionContext.getContext();
             request = (HttpServletRequest) context
                     .get(StrutsStatics.HTTP_REQUEST);
-            consumer = OpenIDConsumer.getInstance();
-            consumer.setSessionAttributes(request);
-            user = (String) request
-                    
.getAttribute(IdentityConstants.OpenId.SimpleRegAttributes.NICK_NAME);
-            session = ActionContext.getContext().getSession();
-            session.put(UIConstants.USER, user);
+            map = ActionContext.getContext().getSession();
+
+            openID = (String) 
request.getAttribute(IdentityConstants.OpenId.OPENID_IDENTIFIER);
+
+            userID = UserUtil.getUserName(openID);
+
+            map.put(UIConstants.USER, userID);
+
         } catch (Exception e) {
-           
+
             return ERROR;
         }
         return SUCCESS;

Modified: 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/OpenIDInfoCardSubmitAction.java
==============================================================================
--- 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/OpenIDInfoCardSubmitAction.java
   (original)
+++ 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/OpenIDInfoCardSubmitAction.java
   Wed Jan 23 22:24:20 2008
@@ -6,8 +6,8 @@
 
 import org.apache.struts2.StrutsStatics;
 import org.wso2.solutions.identity.IdentityConstants;
-import org.wso2.solutions.identity.openid.relyingparty.OpenIDConsumer;
 import org.wso2.solutions.identity.user.ui.UIConstants;
+import org.wso2.solutions.identity.user.ui.util.UserUtil;
 
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.ActionSupport;
@@ -23,33 +23,27 @@
 
         ActionContext context = null;
         HttpServletRequest request = null;
-        OpenIDConsumer consumer = null;
         Map map = null;
+        String openID = null;
+        String userID = null;
 
         try {
             context = ActionContext.getContext();
             request = (HttpServletRequest) context
                     .get(StrutsStatics.HTTP_REQUEST);
+            map = ActionContext.getContext().getSession();
 
-            consumer = OpenIDConsumer.getInstance();
+            openID = (String) 
request.getAttribute(IdentityConstants.OpenId.OPENID_IDENTIFIER);
 
-            map = ActionContext.getContext().getSession();
+            userID = UserUtil.getUserName(openID);
 
-            // This will add attribute values to the session with the
-            // corresponding attribute name as the key.
-            consumer.setInfocardSessionAttributes(request);
-            map = ActionContext.getContext().getSession();
-            map.put(UIConstants.USER,
-                            (String) request
-                                    
.getAttribute(IdentityConstants.OpenId.ExchangeAttributes.GIVEN_NAME));
+            map.put(UIConstants.USER, userID);
 
         } catch (Exception e) {
-            // TODO: catch more specific exceptions and display errors
-            // accordingly.
-            addActionError("OpenID Infomation Card processing failed");
+
             return ERROR;
         }
-
+     
         return SUCCESS;
 
     }

Modified: 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/OpenIDSubmitAction.java
==============================================================================
--- 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/OpenIDSubmitAction.java
   (original)
+++ 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/OpenIDSubmitAction.java
   Wed Jan 23 22:24:20 2008
@@ -3,6 +3,7 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import org.apache.struts2.StrutsStatics;
+import 
org.wso2.solutions.identity.openid.relyingparty.OpenIDAuthenticationRequest;
 import org.wso2.solutions.identity.openid.relyingparty.OpenIDConsumer;
 
 import com.opensymphony.xwork2.ActionContext;
@@ -23,7 +24,7 @@
         OpenIDConsumer consumer = null;
         HttpServletResponse response = null;
         HttpServletRequest request = null;
-        String returnUrl = null;
+        OpenIDAuthenticationRequest openIDAuthRequest = null;
 
         try {
             context = ActionContext.getContext();
@@ -33,12 +34,16 @@
 
             request = (HttpServletRequest) context
                     .get(StrutsStatics.HTTP_REQUEST);
-
-            returnUrl = (String) request.getParameter("returnUrl");
+            
+            openIDAuthRequest = new OpenIDAuthenticationRequest();
+            openIDAuthRequest.setReponse(response);
+            openIDAuthRequest.setRequest(request);
+            openIDAuthRequest.setOpenIDUrl(getOpenIdUrl());
 
             consumer = OpenIDConsumer.getInstance();
 
-            consumer.authRequest(openIdUrl, returnUrl, request, response);
+            consumer.doOpenIDAuthentication(openIDAuthRequest);
+            
         } catch (Exception e) {
             return ERROR;
         }

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

Reply via email to