Author: prabath
Date: Mon Feb 11 16:32:50 2008
New Revision: 13600

Log:

added a global setting to enable/disable OpenID

Modified:
   
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/InfoCardUserRegistrationSubmitAction.java
   
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/ShowLoginAction.java
   
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/ShowMainAction.java
   
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/UserRegistrationFormSubmitAction.java
   trunk/solutions/identity/modules/user-ui/src/main/webapp/jsp/login.jsp
   trunk/solutions/identity/modules/user-ui/src/main/webapp/jsp/main.jsp

Modified: 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/InfoCardUserRegistrationSubmitAction.java
==============================================================================
--- 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/InfoCardUserRegistrationSubmitAction.java
 (original)
+++ 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/InfoCardUserRegistrationSubmitAction.java
 Mon Feb 11 16:32:50 2008
@@ -23,8 +23,10 @@
 import org.apache.axiom.om.util.UUIDGenerator;
 import org.apache.struts2.StrutsStatics;
 import org.wso2.solutions.identity.IdentityConstants;
+import org.wso2.solutions.identity.IdentityProviderConstants;
 import org.wso2.solutions.identity.UserStore;
 import org.wso2.solutions.identity.admin.ClaimsAdmin;
+import org.wso2.solutions.identity.admin.ParameterAdmin;
 import org.wso2.solutions.identity.admin.RegisteredInfoCardInfoAdmin;
 import org.wso2.solutions.identity.admin.ReportAdmin;
 import org.wso2.solutions.identity.openid.OpenIDProvider;
@@ -74,9 +76,16 @@
                             .getAttribute(claimDOs[i].getUri()));
             }
 
-            // We create an OpenID for all registering users
-            String openid = OpenIDProvider.generateOpenID(userName);
-            props.put(IdentityConstants.CLAIM_OPENID, openid);
+            ParameterAdmin paramAdmin = new ParameterAdmin();
+            boolean enableOpenIDRegistration = paramAdmin
+                    
.getParameter(IdentityProviderConstants.PARAM_NAME_ENABLE_OPENID_REGISTRATION) 
!= null;
+
+            String openid = null;
+            if (enableOpenIDRegistration) {
+                // We create an OpenID for all registering users
+                openid = OpenIDProvider.generateOpenID(userName);
+                props.put(IdentityConstants.CLAIM_OPENID, openid);
+            }
 
             store.getRealm().getUserStoreAdmin().setUserProperties(userName,
                     props);
@@ -89,7 +98,10 @@
                     "PPID=" + ppid);
             this.addInfoMessage(getText("user_successfully_added",
                     new String[] { userName }));
-            this.addInfoMessage("Your OpenID is " + openid);
+
+            if (enableOpenIDRegistration) {
+                this.addInfoMessage("Your OpenID is " + openid);
+            }
 
         } catch (RuntimeException e) {
             this.addActionError(e.getMessage());

Modified: 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/ShowLoginAction.java
==============================================================================
--- 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/ShowLoginAction.java
      (original)
+++ 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/ShowLoginAction.java
      Mon Feb 11 16:32:50 2008
@@ -26,10 +26,13 @@
 
     private boolean allowUserRegistration;
     
+    private boolean enableOpenIDRegistration;
+    
     public String execute() throws Exception {
 
         ParameterAdmin paramAdmin = new ParameterAdmin();
         this.allowUserRegistration = 
paramAdmin.getParameter(IdentityProviderConstants.PARAM_NAME_ALLOW_USER_REGISTRATION)
 != null;
+        this.enableOpenIDRegistration = 
paramAdmin.getParameter(IdentityProviderConstants.PARAM_NAME_ENABLE_OPENID_REGISTRATION)
 != null;
         loadMessages();
 
         return SUCCESS;
@@ -39,4 +42,8 @@
         return allowUserRegistration;
     }
 
+    public boolean isEnableOpenIDRegistration() {
+        return enableOpenIDRegistration;
+    }
+
 }

Modified: 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/ShowMainAction.java
==============================================================================
--- 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/ShowMainAction.java
       (original)
+++ 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/ShowMainAction.java
       Mon Feb 11 16:32:50 2008
@@ -17,8 +17,10 @@
 package org.wso2.solutions.identity.user.ui.action;
 
 import org.wso2.solutions.identity.IdentityConstants;
+import org.wso2.solutions.identity.IdentityProviderConstants;
 import org.wso2.solutions.identity.UserStore;
 import org.wso2.solutions.identity.admin.ClaimsAdmin;
+import org.wso2.solutions.identity.admin.ParameterAdmin;
 import org.wso2.solutions.identity.admin.RegisteredInfoCardInfoAdmin;
 import org.wso2.solutions.identity.admin.RelyingPartyAdmin;
 import org.wso2.solutions.identity.persistence.IPPersistenceManager;
@@ -43,12 +45,10 @@
     private List claims;
 
     private List registeredInformationCards;
-    
+
     private List openIDUserRPs;
 
-    public List getOpenIDUserRPs() {
-        return openIDUserRPs;
-    }
+    private boolean enableOpenIDRegistration;
 
     public String execute() throws Exception {
 
@@ -57,6 +57,10 @@
         Map session = ActionContext.getContext().getSession();
         String user = (String) session.get(UIConstants.USER);
 
+        ParameterAdmin paramAdmin = new ParameterAdmin();
+        this.enableOpenIDRegistration = paramAdmin
+                
.getParameter(IdentityProviderConstants.PARAM_NAME_ENABLE_OPENID_REGISTRATION) 
!= null;
+
         this.personalRPs = Arrays.asList((UserTrustedRPDO[]) admin
                 .getAllPersonalRelyingParties(user));
 
@@ -68,31 +72,38 @@
         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);
+        if (enableOpenIDRegistration) {
 
-            if (openid != null && openid.trim().length() > 0)
-                this.addInfoMessage("Your OpenID is: " + openid);
+            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);
+
+                if (openid != null && openid.trim().length() > 0)
+                    this.addInfoMessage("Your OpenID is: " + openid);
+                else
+                    enableOpenIDRegistration = false;
+
+            }
+
+            IPPersistenceManager db = IPPersistenceManager
+                    .getPersistanceManager();
+            OpenIDUserRPDO[] rpdos = null;
 
+            rpdos = db.getOpenIDUserRP(user);
+            this.openIDUserRPs = Arrays.asList((OpenIDUserRPDO[]) rpdos);
         }
-        
-        IPPersistenceManager db = IPPersistenceManager.getPersistanceManager();
-        OpenIDUserRPDO[] rpdos = null;
-
-        rpdos = db.getOpenIDUserRP(user);
-        this.openIDUserRPs = Arrays.asList((OpenIDUserRPDO[]) rpdos);
 
         this.loadMessages();
 
@@ -111,4 +122,12 @@
         return registeredInformationCards;
     }
 
+    public boolean isEnableOpenIDRegistration() {
+        return enableOpenIDRegistration;
+    }
+
+    public List getOpenIDUserRPs() {
+        return openIDUserRPs;
+    }
+
 }

Modified: 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/UserRegistrationFormSubmitAction.java
==============================================================================
--- 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/UserRegistrationFormSubmitAction.java
     (original)
+++ 
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/UserRegistrationFormSubmitAction.java
     Mon Feb 11 16:32:50 2008
@@ -78,11 +78,18 @@
             }
         }
 
-        // We create an OpenID for all registering users
-        String openid = OpenIDProvider.generateOpenID(this.username);
-        props.put(IdentityConstants.CLAIM_OPENID, openid);
-
         ParameterAdmin paramAdmin = new ParameterAdmin();
+        boolean enableOpenIDRegistration = paramAdmin
+                
.getParameter(IdentityProviderConstants.PARAM_NAME_ENABLE_OPENID_REGISTRATION) 
!= null;
+
+        String openid = null;
+        
+        if (enableOpenIDRegistration) {
+            // We create an OpenID for all registering users
+            openid = OpenIDProvider.generateOpenID(this.username);
+            props.put(IdentityConstants.CLAIM_OPENID, openid);
+        }
+
         boolean emailVerification = paramAdmin
                 
.getParameter(IdentityProviderConstants.PARAM_NAME_ENABLE_EMAIL_VERIFICATION) 
!= null;
         if (emailVerification && emailAddress != null) {
@@ -131,7 +138,9 @@
             this.addInfoMessage(getText("user_successfully_added",
                     new String[] { username }));
 
-            this.addInfoMessage("Your OpenID is " + openid);
+            if (enableOpenIDRegistration) {
+                this.addInfoMessage("Your OpenID is " + openid);
+            }
         }
 
         return SUCCESS;

Modified: trunk/solutions/identity/modules/user-ui/src/main/webapp/jsp/login.jsp
==============================================================================
--- trunk/solutions/identity/modules/user-ui/src/main/webapp/jsp/login.jsp      
(original)
+++ trunk/solutions/identity/modules/user-ui/src/main/webapp/jsp/login.jsp      
Mon Feb 11 16:32:50 2008
@@ -69,7 +69,7 @@
                                                first login with your username 
and password and register a card.</div>
                                                </td>
                                        </tr>
-
+                   <s:if test="%{enableOpenIDRegistration}">
                                        <tr>
                                                <td valign="top"><br />
                                                <br />
@@ -82,7 +82,7 @@
                                                        style="margin-right: 
10px" border="0" /></a></div>
                                                </td>
                                        </tr>
-
+                   </s:if>
                                </table>
 
                                </td>

Modified: trunk/solutions/identity/modules/user-ui/src/main/webapp/jsp/main.jsp
==============================================================================
--- trunk/solutions/identity/modules/user-ui/src/main/webapp/jsp/main.jsp       
(original)
+++ trunk/solutions/identity/modules/user-ui/src/main/webapp/jsp/main.jsp       
Mon Feb 11 16:32:50 2008
@@ -91,59 +91,62 @@
                        </tr>
                </table>
 
-               <table cellpadding="0" cellspacing="0" border="0"
-                       style="width: 100%; margin-bottom: 10px;">
-                       <tr>
-                               <td valign="top" style="line-height: 20px;"><a
-                                       href="OpenIDDownloadInfoCard.action" 
class="heading-link">Download
-                               OpenID Information Card</a> <br>
-                               This card can be used with any identity 
selector that supports
-                               Microsoft CardSpace specifications and will 
allow you to login to
-                               web applications that support OpenID 
information card logins.</td>
-                               <td></td>
-                       </tr>
-                       <tr>
-                               <td colspan="3"><a 
href="OpenIDDownloadInfoCard.action"
-                                       class="download-link"></a></td>
-                       </tr>
-               </table>
-
-               <table cellpadding="0" cellspacing="0" border="0" 
class="manage-table">
-                       <tr>
-                               <td>
-                               <p class="heading-link">OpenID relying party 
site settings</p>
+               <s:if test="%{enableOpenIDRegistration}">
+                       <table cellpadding="0" cellspacing="0" border="0"
+                               style="width: 100%; margin-bottom: 10px;">
+                               <tr>
+                                       <td valign="top" style="line-height: 
20px;"><a
+                                               
href="OpenIDDownloadInfoCard.action" class="heading-link">Download
+                                       OpenID Information Card</a> <br>
+                                       This card can be used with any identity 
selector that supports
+                                       Microsoft CardSpace specifications and 
will allow you to login to
+                                       web applications that support OpenID 
information card logins.</td>
+                                       <td></td>
+                               </tr>
+                               <tr>
+                                       <td colspan="3"><a 
href="OpenIDDownloadInfoCard.action"
+                                               class="download-link"></a></td>
+                               </tr>
+                       </table>
 
-                               <table cellpadding="0" cellspacing="0" 
border="0" class="data-table">
-                                       <s:iterator value="openIDUserRPs">
-                                               <tr>
-                                                       <td width="100%">
-                                                       <div 
style="line-height: 18px;">Relying Party: <s:property
-                                                               value="rpUrl" 
/></div>
-                                                       <div 
style="line-height: 18px;">Vists: <s:property
-                                                               
value="visitCount" /></div>
-                                                       <div 
style="line-height: 18px;">Last Visit: <s:property
-                                                               
value="lastVisit" /></div>
-                                                       </td>
-                                                       <td 
valign="middle"><s:if test="isTrustedAlways">
-                                                               <a
-                                                                       
href="UpdateOpenIDUserRP.action?rpUrl=<s:property 
value="rpUrl"/>&operation=disable"><img
-                                                                       
border="0" src="images/icon-enable.gif"
-                                                                       
alt="Click to disable trust always" /></a>
-
-                                                       </s:if> <s:else>
-                                                               <a
-                                                                       
href="UpdateOpenIDUserRP.action?rpUrl=<s:property 
value="rpUrl"/>&operation=enable"><img
-                                                                       
border="0" src="images/icon-disable.gif"
-                                                                       
alt="Click to enable trust always" /></a>
-                                                       </s:else></td>
-                                               </tr>
-                                       </s:iterator>
-                               </table>
+                       <table cellpadding="0" cellspacing="0" border="0"
+                               class="manage-table">
+                               <tr>
+                                       <td>
+                                       <p class="heading-link">OpenID relying 
party site settings</p>
 
-                               </td>
-                       </tr>
-               </table>
+                                       <table cellpadding="0" cellspacing="0" 
border="0"
+                                               class="data-table">
+                                               <s:iterator 
value="openIDUserRPs">
+                                                       <tr>
+                                                               <td 
width="100%">
+                                                               <div 
style="line-height: 18px;">Relying Party: <s:property
+                                                                       
value="rpUrl" /></div>
+                                                               <div 
style="line-height: 18px;">Vists: <s:property
+                                                                       
value="visitCount" /></div>
+                                                               <div 
style="line-height: 18px;">Last Visit: <s:property
+                                                                       
value="lastVisit" /></div>
+                                                               </td>
+                                                               <td 
valign="middle"><s:if test="isTrustedAlways">
+                                                                       <a
+                                                                               
href="UpdateOpenIDUserRP.action?rpUrl=<s:property 
value="rpUrl"/>&operation=disable"><img
+                                                                               
border="0" src="images/icon-enable.gif"
+                                                                               
alt="Click to disable trust always" /></a>
+
+                                                               </s:if> <s:else>
+                                                                       <a
+                                                                               
href="UpdateOpenIDUserRP.action?rpUrl=<s:property 
value="rpUrl"/>&operation=enable"><img
+                                                                               
border="0" src="images/icon-disable.gif"
+                                                                               
alt="Click to enable trust always" /></a>
+                                                               </s:else></td>
+                                                       </tr>
+                                               </s:iterator>
+                                       </table>
 
+                                       </td>
+                               </tr>
+                       </table>
+               </s:if>
                <table cellpadding="0" cellspacing="0" border="0" 
class="manage-table">
                        <tr>
                                <td>

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

Reply via email to