Author: prabath
Date: Mon Feb 11 05:48:04 2008
New Revision: 13587

Log:

self-issued infocard login to OP

Modified:
   
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/util/UserUtil.java

Modified: 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/util/UserUtil.java
==============================================================================
--- 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/util/UserUtil.java
       (original)
+++ 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/util/UserUtil.java
       Mon Feb 11 05:48:04 2008
@@ -6,13 +6,19 @@
 
 import javax.servlet.http.HttpServletRequest;
 
+import org.apache.struts2.StrutsStatics;
 import org.openid4java.server.ServerException;
 import org.wso2.solutions.identity.IdentityConstants;
 import org.wso2.solutions.identity.IdentityProviderException;
 import org.wso2.solutions.identity.UserStore;
 import org.wso2.solutions.identity.admin.RegisteredInfoCardInfoAdmin;
+import org.wso2.solutions.identity.admin.ReportAdmin;
+import org.wso2.solutions.identity.persistence.dataobject.ActionDO;
 import 
org.wso2.solutions.identity.persistence.dataobject.RegisteredInfoCardInfoDO;
 import org.wso2.solutions.identity.relyingparty.TokenVerifierConstants;
+import org.wso2.solutions.identity.user.ui.UIConstants;
+
+import com.opensymphony.xwork2.ActionContext;
 
 public class UserUtil {
 
@@ -52,7 +58,8 @@
                 String claimId = (String) mapValues
                         .get(IdentityConstants.CLAIM_OPENID);
 
-                if (mapValues != null && !mapValues.isEmpty() && 
claimId!=null) {
+                if (mapValues != null && !mapValues.isEmpty()
+                        && claimId != null) {
                     if (openID.indexOf(claimId) >= 0
                             && openID.endsWith(claimId.substring(claimId
                                     .length() - 1))) {
@@ -89,16 +96,25 @@
      * 
      * @param request
      * @return
+     * @throws IdentityProviderException 
      */
-    public static boolean verifyInfoCardLogin(HttpServletRequest request) {
-        String state = (String) 
request.getAttribute(TokenVerifierConstants.SERVLET_ATTR_STATE);
+    public static boolean verifyInfoCardLogin(ActionContext context)
+            throws IdentityProviderException {
+
+        HttpServletRequest request = (HttpServletRequest) context
+                .get(StrutsStatics.HTTP_REQUEST);
+
+        String state = (String) request
+                .getAttribute(TokenVerifierConstants.SERVLET_ATTR_STATE);
 
-        if (state == null || 
!TokenVerifierConstants.STATE_SUCCESS.equals(state))
+        if (state == null
+                || !TokenVerifierConstants.STATE_SUCCESS.equals(state))
             return false;
 
         String ppid = (String) request
                 .getAttribute(IdentityConstants.CLAIM_PPID);
-        String issuerInfo = (String) 
request.getAttribute(TokenVerifierConstants.ISSUER_INFO);
+        String issuerInfo = (String) request
+                .getAttribute(TokenVerifierConstants.ISSUER_INFO);
 
         RegisteredInfoCardInfoAdmin admin = new RegisteredInfoCardInfoAdmin();
         RegisteredInfoCardInfoDO info;
@@ -109,6 +125,10 @@
         }
 
         if (info != null && info.getIssuerInfo().equals(issuerInfo)) {
+            context.getSession().put(UIConstants.USER, info.getUserId());
+            context.getSession().put(UIConstants.PPID, ppid);
+            ReportAdmin.record(info.getUserId(),
+                    ActionDO.ACTION_USER_LOG_IN_CARD, "PPID=" + ppid);
             return true;
         } else {
             return false;

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

Reply via email to