Author: prabath
Date: Thu Jan 24 03:23:54 2008
New Revision: 12818

Log:

added for OpenID related stuff

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

Added: 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/util/UserUtil.java
==============================================================================
--- (empty file)
+++ 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/util/UserUtil.java
       Thu Jan 24 03:23:54 2008
@@ -0,0 +1,55 @@
+package org.wso2.solutions.identity.user.ui.util;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.openid4java.server.ServerException;
+import org.wso2.solutions.identity.IdentityConstants;
+import org.wso2.solutions.identity.IdentityProviderException;
+import org.wso2.solutions.identity.UserStore;
+
+public class UserUtil {
+
+    public static String getUserName(String openId) throws ServerException,
+            IdentityProviderException {
+
+        UserStore userStore = null;
+        List users = null;
+
+        userStore = UserStore.getInstance();
+        users = userStore.getAllUserNames();
+
+        if (users == null)
+            throw new IdentityProviderException("No users found");
+
+        Map mapValues = null;
+        Iterator iterator = null;
+
+        iterator = users.iterator();
+
+        while (iterator.hasNext()) {
+
+            String user = (String) iterator.next();
+            mapValues = userStore.getClaimValues(user, null);
+
+            if (mapValues != null) {
+
+                // User has defined claims!
+                String claimId = (String) mapValues
+                        .get(IdentityConstants.CLAIM_OPENID);
+
+                if (mapValues != null && !mapValues.isEmpty()) {
+                    if (openId.indexOf(claimId) >= 0
+                            && openId.endsWith(claimId.substring(claimId
+                                    .length() - 1))) {
+                        return user;
+                    }
+                }
+            }
+        }
+
+        return null;
+    }
+
+}

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

Reply via email to