Author: prabath
Date: Thu Jan 24 05:17:53 2008
New Revision: 12833

Log:

exception handling

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
       Thu Jan 24 05:17:53 2008
@@ -6,13 +6,19 @@
 
 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 {
+    /**
+     * 
+     * @param openID
+     * @return
+     * @throws ServerException
+     * @throws Exception
+     */
+    public static String getUserName(String openID) throws ServerException,
+            Exception {
 
         UserStore userStore = null;
         List users = null;
@@ -21,7 +27,8 @@
         users = userStore.getAllUserNames();
 
         if (users == null)
-            throw new IdentityProviderException("No users found");
+            // TODO: Define a custom exception or use a more appropriate one.
+            throw new Exception("No users found");
 
         Map mapValues = null;
         Iterator iterator = null;
@@ -40,8 +47,8 @@
                         .get(IdentityConstants.CLAIM_OPENID);
 
                 if (mapValues != null && !mapValues.isEmpty()) {
-                    if (openId.indexOf(claimId) >= 0
-                            && openId.endsWith(claimId.substring(claimId
+                    if (openID.indexOf(claimId) >= 0
+                            && openID.endsWith(claimId.substring(claimId
                                     .length() - 1))) {
                         return user;
                     }
@@ -49,7 +56,8 @@
             }
         }
 
-        return null;
+        // TODO: Define a custom exception or use a more appropriate one.
+        throw new Exception("No user found, correponding to the given OpenID");
     }
 
 }

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

Reply via email to