Author: prabath
Date: Tue Dec 11 02:37:38 2007
New Revision: 10931

Log:

Displayed the OpenID, once the user logged in

Modified:
   
branches/solutions/identity/openid-poc/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/ShowMainAction.java

Modified: 
branches/solutions/identity/openid-poc/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/ShowMainAction.java
==============================================================================
--- 
branches/solutions/identity/openid-poc/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/ShowMainAction.java
 (original)
+++ 
branches/solutions/identity/openid-poc/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/ShowMainAction.java
 Tue Dec 11 02:37:38 2007
@@ -16,6 +16,8 @@
 
 package org.wso2.solutions.identity.user.ui.action;
 
+import org.wso2.solutions.identity.IdentityConstants;
+import org.wso2.solutions.identity.UserStore;
 import org.wso2.solutions.identity.admin.ClaimsAdmin;
 import org.wso2.solutions.identity.admin.RegisteredInfoCardInfoAdmin;
 import org.wso2.solutions.identity.admin.RelyingPartyAdmin;
@@ -23,6 +25,7 @@
 import 
org.wso2.solutions.identity.persistence.dataobject.UserPersonalRelyingPartyDO;
 import org.wso2.solutions.identity.user.ui.UIConstants;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
@@ -31,78 +34,101 @@
 
 public class ShowMainAction extends ManagedAction {
 
-    private static final long serialVersionUID = -420264928772655254L;
+       private static final long serialVersionUID = -420264928772655254L;
 
-    private List personalRPs;
+       private List personalRPs;
 
-    private List claims;
+       private List claims;
 
-    private List registeredInformationCards;
+       private List registeredInformationCards;
 
-    private List errorMessages;
-    
-    private List infoMessages;
-
-    public String execute() throws Exception {
-
-        RelyingPartyAdmin admin = new RelyingPartyAdmin();
-
-        Map session = ActionContext.getContext().getSession();
-        String user = (String) session.get(UIConstants.USER);
-                
-        this.personalRPs = Arrays.asList((UserPersonalRelyingPartyDO[]) admin
-                .getAllPersonalRelyingParties(user));
-
-        ClaimsAdmin ClaimsAdmin = new ClaimsAdmin();
-        ClaimDO[] claimDOs = ClaimsAdmin.getAllMappedEnabledClaims();
-        this.claims = Arrays.asList((ClaimDO[]) claimDOs);
-
-        RegisteredInfoCardInfoAdmin regCardInfoAdmin = new 
RegisteredInfoCardInfoAdmin();
-        this.registeredInformationCards = 
regCardInfoAdmin.getAllRegisteredInfoCards(user);
-
-        this.errorMessages = this.getMessages(Message.ERROR);
-        this.infoMessages = this.getMessages(Message.INFO);
-        this.resetMessages();
-        
-        return SUCCESS;
-    }
-
-//    /**
-//     * @param allRegisteredInfoCards
-//     * @return
-//     */
-//    private List processRegisteredPpids(List allRegisteredInfoCards)
-//            throws IdentityProviderException {
-//        ArrayList list = new ArrayList();
-//        Iterator it = allRegisteredInfoCards.iterator();
-//        while (it.hasNext()) {
-//            RegisteredInfoCardInfoDO cardDo = (RegisteredInfoCardInfoDO) it
-//                    .next();
-//            list.add(IdentityProviderUtil.getPPIDDisplayValue(cardDo
-//                            .getPpid()));
-//        }
-//        return list;
-//    }
-
-    public List getPersonalRPs() {
-        return personalRPs;
-    }
-
-    public List getClaims() {
-        return claims;
-    }
-
-    public List getRegisteredInformationCards() {
-        return registeredInformationCards;
-    }
-
-    public List getErrorMessages() {
-        return errorMessages;
-    }
-
-    public List getInfoMessages() {
-        return infoMessages;
-    }
+       private List errorMessages;
 
+       private List infoMessages;
+
+       public String execute() throws Exception {
+
+               RelyingPartyAdmin admin = new RelyingPartyAdmin();
+
+               Map session = ActionContext.getContext().getSession();
+               String user = (String) session.get(UIConstants.USER);
+
+               this.personalRPs = Arrays.asList((UserPersonalRelyingPartyDO[]) 
admin
+                               .getAllPersonalRelyingParties(user));
+
+               ClaimsAdmin ClaimsAdmin = new ClaimsAdmin();
+               ClaimDO[] claimDOs = ClaimsAdmin.getAllMappedEnabledClaims();
+               this.claims = Arrays.asList((ClaimDO[]) claimDOs);
+
+               RegisteredInfoCardInfoAdmin regCardInfoAdmin = new 
RegisteredInfoCardInfoAdmin();
+               this.registeredInformationCards = regCardInfoAdmin
+                               .getAllRegisteredInfoCards(user);
+
+               UserStore userStore = null;
+               List propertyNames = null;
+               Map mapValues = null;
+
+               userStore = UserStore.getInstance();
+
+               propertyNames = new ArrayList();
+               propertyNames.add(IdentityConstants.CLAIM_OPENID);
+
+               // Right now we don't have a single method in UserStore, which 
returns
+               // the value of a single claim so we use a List.
+               mapValues = userStore.getClaimValues(user, propertyNames);
+
+               if (mapValues != null && !mapValues.isEmpty()) {
+                       String openid = (String) mapValues
+                                       .get(IdentityConstants.CLAIM_OPENID);
+
+                       // TODO: use getText of the base class to get the text 
string.
+                       if (openid != null && openid.trim().length() > 0)
+                               this.addInfoMessage("Your OpenID is: " + 
openid);
+
+               }
+
+               this.errorMessages = this.getMessages(Message.ERROR);
+               this.infoMessages = this.getMessages(Message.INFO);
+               this.resetMessages();
+
+               return SUCCESS;
+       }
+
+       // /**
+       // * @param allRegisteredInfoCards
+       // * @return
+       // */
+       // private List processRegisteredPpids(List allRegisteredInfoCards)
+       // throws IdentityProviderException {
+       // ArrayList list = new ArrayList();
+       // Iterator it = allRegisteredInfoCards.iterator();
+       // while (it.hasNext()) {
+       // RegisteredInfoCardInfoDO cardDo = (RegisteredInfoCardInfoDO) it
+       // .next();
+       // list.add(IdentityProviderUtil.getPPIDDisplayValue(cardDo
+       // .getPpid()));
+       // }
+       // return list;
+       // }
+
+       public List getPersonalRPs() {
+               return personalRPs;
+       }
+
+       public List getClaims() {
+               return claims;
+       }
+
+       public List getRegisteredInformationCards() {
+               return registeredInformationCards;
+       }
+
+       public List getErrorMessages() {
+               return errorMessages;
+       }
+
+       public List getInfoMessages() {
+               return infoMessages;
+       }
 
 }

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

Reply via email to