[cvs] expresso commit by lhamel: cosmetic

JCorporate Ltd jcorp at jcorporate.com
Fri Jul 8 18:36:53 UTC 2005


Log Message:
-----------
cosmetic

Modified Files:
--------------
    expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj:
        RowSecuredDBObject.java

Revision Data
-------------
Index: RowSecuredDBObject.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/RowSecuredDBObject.java,v
retrieving revision 1.47
retrieving revision 1.48
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/RowSecuredDBObject.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/RowSecuredDBObject.java -u -r1.47 -r1.48
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/RowSecuredDBObject.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/RowSecuredDBObject.java
@@ -239,6 +239,7 @@
 
     /**
      * Creates a new RowSecuredDBObject using
+     *
      * @param userCredentials ReadOnlyUser
      * @throws DBException
      */
@@ -435,11 +436,11 @@
 
         if (!result) {
             throw new SecurityException("User '" + getRequestingUser().getLoginName()
-                 + "' does not have permission to perform function '"
-                 + requestedFunction + "' on database object in table '"
-                 + getJDBCMetaData().getTargetTable() + "', row: '" + getKey()
-                 + "in db/context '" + getDataContext()
-                 + "'. Please contact your system administrator if you feel this is incorrect.");
+                    + "' does not have permission to perform function '"
+                    + requestedFunction + "' on database object in table '"
+                    + getJDBCMetaData().getTargetTable() + "', row: '" + getKey()
+                    + "in db/context '" + getDataContext()
+                    + "'. Please contact your system administrator if you feel this is incorrect.");
         }
 
         return result;
@@ -674,12 +675,16 @@
 
     private boolean doUsersGroupsIntersect(ReadOnlyUser user, List groups) throws DBException {
         boolean result = false;
-        for (Iterator iterator = user.getGroupsList().iterator(); iterator.hasNext();) {
-            String userGrpname = (String) iterator.next();
-            for (Iterator iterator1 = groups.iterator(); iterator1.hasNext();) {
-                String readGrpName = (String) iterator1.next();
-                result = readGrpName.equals(userGrpname);
-                if ( result ) return true;
+        if (groups.size() > 0) {
+            for (Iterator iterator = user.getGroupsList().iterator(); iterator.hasNext();) {
+                String userGrpname = (String) iterator.next();
+                for (Iterator iterator1 = groups.iterator(); iterator1.hasNext();) {
+                    String readGrpName = (String) iterator1.next();
+                    result = readGrpName.equals(userGrpname);
+                    if (result) {
+                        return true;
+                    }
+                }
             }
         }
         return false;
@@ -693,7 +698,8 @@
         boolean result = false;
 
         ReadOnlyUser user = getRequestingUser();
-        int userId = user.getUid();
+
+        // superusers always have permission
         if (user == SuperUser.INSTANCE) {
             return true;
         }
@@ -702,6 +708,7 @@
             return true;
         }
 
+        int userId = user.getUid();
         RowPermissions rowPermissions = this.getPermissions();
 
         // do tests by cpu cheapness: easiest tests first;
@@ -709,10 +716,10 @@
         // public readability?
         result = rowPermissions.canOthersWrite() ||
                 ((userId == rowPermissions.owner()) &&
-                rowPermissions.canOwnerWrite());
+                    rowPermissions.canOwnerWrite());
 
+        // check alternative groups
         if (!result) {
-            // check  groups
             result = doUsersGroupsIntersect(user, getWriteGroups());
         }
 


More information about the cvs mailing list