Author: prabath
Date: Wed Feb 20 22:36:43 2008
New Revision: 13933

Log:

set default profile per visited RP and display it as the default selection when 
prompted to select a profile

Modified:
   
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/IPPersistenceManager.java
   
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/dao/OpenIDUserRPDAO.java
   
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/OpenIDAuthVerificationAction.java

Modified: 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/IPPersistenceManager.java
==============================================================================
--- 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/IPPersistenceManager.java
  (original)
+++ 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/IPPersistenceManager.java
  Wed Feb 20 22:36:43 2008
@@ -445,9 +445,9 @@
         return dao.getOpenIDUserRP(userName);
     }
 
-    public String getOpenIDDefaultUserProfile(String userName) {
+    public String getOpenIDDefaultUserProfile(String userName,String rpUrl) {
         OpenIDUserRPDAO dao = new OpenIDUserRPDAO(hbConfig);
-        return dao.getOpenIDDefaultUserProfile(userName);
+        return dao.getOpenIDDefaultUserProfile(userName,rpUrl);
     }
 
 }

Modified: 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/dao/OpenIDUserRPDAO.java
==============================================================================
--- 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/dao/OpenIDUserRPDAO.java
   (original)
+++ 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/dao/OpenIDUserRPDAO.java
   Wed Feb 20 22:36:43 2008
@@ -74,11 +74,11 @@
      * @param userId
      * @return
      */
-    public String getOpenIDDefaultUserProfile(String userName) {
+    public String getOpenIDDefaultUserProfile(String userName, String rpUrl) {
 
         Session session = hbConfig.getCurrentSession();
         String stmt = "select c.defaultProfileName from OpenIDUserRPDO as c 
where c.userName='"
-                + userName + "'";
+                + userName + "' and c.rpUrl='"+rpUrl+"'";
         String[] profileId = new String[0];
 
         try {

Modified: 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/OpenIDAuthVerificationAction.java
==============================================================================
--- 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/OpenIDAuthVerificationAction.java
 (original)
+++ 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/OpenIDAuthVerificationAction.java
 Wed Feb 20 22:36:43 2008
@@ -52,6 +52,7 @@
         ParameterList requestParam = null;
         String user = null;
         String infoCardSignin = null;
+        String rpUrl = null;
 
         context = ActionContext.getContext();
         request = (HttpServletRequest) context.get(StrutsStatics.HTTP_REQUEST);
@@ -63,7 +64,9 @@
 
         requestParam = (ParameterList) session.getAttribute("parameterlist");
 
-        if (requestParam != null && 
requestParam.hasParameter(IdentityConstants.OpenId.ATTR_IDENTITY)) {
+        if (requestParam != null
+                && requestParam
+                        .hasParameter(IdentityConstants.OpenId.ATTR_IDENTITY)) 
{
             openID = requestParam.getParameter(
                     IdentityConstants.OpenId.ATTR_IDENTITY).getValue();
         } else {
@@ -71,13 +74,22 @@
             return ERROR;
         }
 
+        if 
(requestParam.hasParameter(IdentityConstants.OpenId.ATTR_RETURN_TO)) {
+
+            rpUrl = requestParam.getParameter(
+                    IdentityConstants.OpenId.ATTR_RETURN_TO).getValue();
+        } else {
+            addErrorMessage(getText("returnTo_required"));
+            return ERROR;
+        }
+
         user = UserUtil.getUserName(openID);
 
         if (infoCardSignin != null && "Log in".equals(infoCardSignin)) {
             // User logs in with an information card
             if (UserUtil.verifyInfoCardLogin(context, openID)) {
 
-                populateUserProfiles(user);
+                populateUserProfiles(user, rpUrl);
 
                 // Okay - user used InfoCards to login - next when tries login
                 // we'll let him use his InfoCard directly, by passing the
@@ -132,7 +144,7 @@
 
             if (UserUtil.doLogin(user, password)) {
 
-                populateUserProfiles(user);
+                populateUserProfiles(user, rpUrl);
 
                 String remeberMe = null;
 
@@ -182,7 +194,7 @@
      * @param userName
      * @throws RelyingPartyException
      */
-    protected void populateUserProfiles(String userName)
+    protected void populateUserProfiles(String userName, String rpUrl)
             throws RelyingPartyException {
 
         IdentityDefaultRealm realm = null;
@@ -199,13 +211,18 @@
             db = IPPersistenceManager.getPersistanceManager();
             admin = new RelyingPartyAdmin();
 
-            defaultUserProfileName = db.getOpenIDDefaultUserProfile(userName);
+            defaultUserProfileName = db.getOpenIDDefaultUserProfile(userName,
+                    rpUrl);
 
             if (defaultUserProfileName == null) {
                 defaultUserProfileName = reader
                         .getDefaultUserProfileName(userName);
             }
 
+            profile.remove(defaultUserProfileName);
+
+            profile.add(0, defaultUserProfileName);
+
         } catch (IdentityProviderException e) {
             throw new RelyingPartyException(
                     IdentityConstants.ErrorCodes.PROFILE_RETRIEVAL_FAILURE, e);
@@ -231,8 +248,10 @@
 
         requestParam = (ParameterList) request.getSession().getAttribute(
                 "parameterlist");
-        String openID = 
requestParam.getParameter("openid.identity").getValue();
-        String rpUrl = requestParam.getParameterValue("openid.return_to");
+        String openID = requestParam.getParameter(
+                IdentityConstants.OpenId.ATTR_IDENTITY).getValue();
+        String rpUrl = requestParam
+                .getParameterValue(IdentityConstants.OpenId.ATTR_RETURN_TO);
 
         try {
             db = IPPersistenceManager.getPersistanceManager();

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

Reply via email to