Author: channa
Date: Wed Jan 23 11:32:29 2008
New Revision: 12784

Log:

Preventing deletion of explicitly created 'admin'. Making 'sign me in' default 
on admin self registration.

Modified:
   trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
   
trunk/mashup/java/modules/core/src/org/wso2/mashup/transport/MashupServerInitializer.java
   
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
   trunk/mashup/java/modules/www/register_admin.jsp

Modified: 
trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
==============================================================================
--- trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java     
(original)
+++ trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java     
Wed Jan 23 11:32:29 2008
@@ -77,6 +77,7 @@
     public static final String LAST_NAME = "lastname";
     public static final String EMAIL_ID = "email";
     public static final String ENABLED = "enabled";
+    public static final String ORIGIN_MASHUP = "origin_mashup";
     public static final String PRIMARY = "primary";
 
     public static final String INFOCARD_PPID = "ppid";

Modified: 
trunk/mashup/java/modules/core/src/org/wso2/mashup/transport/MashupServerInitializer.java
==============================================================================
--- 
trunk/mashup/java/modules/core/src/org/wso2/mashup/transport/MashupServerInitializer.java
   (original)
+++ 
trunk/mashup/java/modules/core/src/org/wso2/mashup/transport/MashupServerInitializer.java
   Wed Jan 23 11:32:29 2008
@@ -108,10 +108,10 @@
                                                   new String[] {
                                                           
MashupConstants.MASHUP_USER_ROLE });
 
-            // Delete wsas-created 'admin' user, as a primary user is 
explicitly created.
+            // Delete wsas-created 'admin' user, unless created within mashup 
server.
             UserStoreAdmin userStoreAdmin = realm.getUserStoreAdmin();
             if (userStoreAdmin.isExistingUser(RegistryConstants.ADMIN_USER) &&
-                    !RegistryUtils.isUserPrimary(realm, 
RegistryConstants.ADMIN_USER)) {
+                    !RegistryUtils.isMashupUser(realm, 
RegistryConstants.ADMIN_USER)) {
                 userStoreAdmin.deleteUser(RegistryConstants.ADMIN_USER);
             }
 

Modified: 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
==============================================================================
--- 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
  (original)
+++ 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
  Wed Jan 23 11:32:29 2008
@@ -528,6 +528,7 @@
         Map properties = userStoreAdmin.getUserProperties(userName);
         properties.put(MashupConstants.PROFILE_PATH, profilePath);
         properties.put(MashupConstants.FULL_NAME, fullName);
+        properties.put(MashupConstants.ORIGIN_MASHUP, String.valueOf(true));
         userStoreAdmin.setUserProperties(userName, properties);
 
         // Create instance of user object and assign property values.
@@ -655,6 +656,22 @@
     }
 
     /**
+     * Gets the profile for a given user and returns if it was created in the 
mashup server.
+     *
+     * @param realm    Registry realm.
+     * @param userName User name to be checked for origin.
+     * @return true if user profile is enabled.
+     */
+    public static boolean isMashupUser(Realm realm, String userName) throws 
UserManagerException {
+        // Get the user's properties.
+        UserStoreReader userStoreReader = realm.getUserStoreReader();
+        Map userProps = userStoreReader.getUserProperties(userName);
+
+        // Check if origin is the mashup server.
+        return userProps.containsKey(MashupConstants.ORIGIN_MASHUP);
+    }
+
+    /**
      * Checks a given mashup to find out whether the underlying service is a 
faulty service.
      *
      * @param registry Instance of the Registry where the mashup resource is 
stired

Modified: trunk/mashup/java/modules/www/register_admin.jsp
==============================================================================
--- trunk/mashup/java/modules/www/register_admin.jsp    (original)
+++ trunk/mashup/java/modules/www/register_admin.jsp    Wed Jan 23 11:32:29 2008
@@ -105,7 +105,7 @@
                             <tr>
                                 <td><label><strong>Sign me in 
now:</strong></label></td>
                                 <td><input type="checkbox" name="<%= 
MashupConstants.SIGNIN %>"
-                                           value="<%= MashupConstants.TRUE 
%>"/></td>
+                                           value="<%= MashupConstants.TRUE %>" 
checked="true"/></td>
                             </tr>
                             <tr>
                                 <td>&nbsp;</td>

_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to