Author: prabath
Date: Mon Jan 28 10:28:03 2008
New Revision: 13093
Log:
added new methods to handle user login
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 Jan 28 10:28:03 2008
@@ -4,9 +4,15 @@
import java.util.List;
import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
+
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.persistence.dataobject.RegisteredInfoCardInfoDO;
+import org.wso2.solutions.identity.relyingparty.TokenVerifierConstants;
public class UserUtil {
@@ -60,4 +66,53 @@
throw new Exception("No user found, correponding to the given OpenID");
}
+ /**
+ * Verify authentication.
+ *
+ * @param username
+ * User name
+ * @param password
+ * Password
+ * @return
+ */
+ public static boolean doLogin(String username, String password) {
+ try {
+ UserStore userStore = UserStore.getInstance();
+ return userStore.authenticate(username, password);
+ } catch (Exception e) {
+ return false;
+ }
+
+ }
+
+ /**
+ *
+ * @param request
+ * @return
+ */
+ public static boolean verifyInfoCardLogin(HttpServletRequest request) {
+ String state = (String)
request.getAttribute(TokenVerifierConstants.SERVLET_ATTR_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);
+
+ RegisteredInfoCardInfoAdmin admin = new RegisteredInfoCardInfoAdmin();
+ RegisteredInfoCardInfoDO info;
+ try {
+ info = admin.getInfo(ppid);
+ } catch (IdentityProviderException e) {
+ return false;
+ }
+
+ if (info != null && info.getIssuerInfo().equals(issuerInfo)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
}
_______________________________________________
Identity-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/identity-dev