From f6f6403f6befdcfd7d5ccd4d986d3131bbe3e87f Mon Sep 17 00:00:00 2001 From: "Eric J. Bowersox" Date: Wed, 25 Jun 2003 09:14:13 +0000 Subject: [PATCH] bugfixes and enhancements to the ACL operations, etc. --- conf/venice-db-init-mysql.sql | 6 +++--- .../com/silverwrist/dynamo/db/OpsBase.java | 11 +++++++++-- .../com/silverwrist/dynamo/module/ModuleLoader.java | 11 +++++++++++ .../dynamo/security/AclOperations_mysql.java | 8 ++++++-- .../com/silverwrist/dynamo/security/PrincipalID.java | 11 ++++++++++- venice-data/velocity/frame.vm | 2 +- 6 files changed, 40 insertions(+), 9 deletions(-) diff --git a/conf/venice-db-init-mysql.sql b/conf/venice-db-init-mysql.sql index 718c66c..234fcf9 100644 --- a/conf/venice-db-init-mysql.sql +++ b/conf/venice-db-init-mysql.sql @@ -910,7 +910,7 @@ INSERT INTO groupmembers (gid, uid) VALUES (5, 2); # system administrators can add or remove members (without going through the "join" process). # (ACL 3, ACEs 5 and 6) INSERT INTO acl (aclid, aclname) VALUES (3, 'Members:piazza'); -INSERT INTO aclowner (aclid, ownerid, flags) VALUES (3, 2, 0); +INSERT INTO aclowner (aclid, ownerid, flags) VALUES (3, 2, 0), (3, 1, 1); INSERT INTO ace (aceid, pri, flags) VALUES (5, 5, 1); INSERT INTO acldata (aclid, seq, aceid) VALUES (3, 0, 5); INSERT INTO acedata (aceid, perm_nsid, perm_name) VALUES @@ -927,7 +927,7 @@ UPDATE groups SET gaclid = 3 WHERE gid = 4; # and system administrators can add or remove members. # (ACL 4, ACEs 7 and 8) INSERT INTO acl (aclid, aclname) VALUES (4, 'Hosts:piazza'); -INSERT INTO aclowner (aclid, ownerid, flags) VALUES (4, 2, 0); +INSERT INTO aclowner (aclid, ownerid, flags) VALUES (4, 2, 0), (4, 1, 1); INSERT INTO ace (aceid, pri, flags) VALUES (7, 2, 0); INSERT INTO acldata (aclid, seq, aceid) VALUES (4, 0, 7); INSERT INTO acedata (aceid, perm_nsid, perm_name) VALUES @@ -943,7 +943,7 @@ UPDATE groups SET gaclid = 4 WHERE gid = 5; # Create the ACL for the initial community. # (ACL 5, ACEs 9, 10, 11, 12) INSERT INTO acl (aclid, aclname) VALUES (5, 'ACL:piazza'); -INSERT INTO aclowner (aclid, ownerid, flags) VALUES (5, 5, 1), (5, 1, 1), (5, 1, 0); +INSERT INTO aclowner (aclid, ownerid, flags) VALUES (5, 5, 1), (5, 1, 1), (5, 2, 0); INSERT INTO ace (aceid, pri, flags) VALUES (12, 2, 16); INSERT INTO acldata (aclid, seq, aceid) VALUES (5, 0, 12); INSERT INTO acedata (aceid, perm_nsid, perm_name) VALUES diff --git a/src/dynamo-framework/com/silverwrist/dynamo/db/OpsBase.java b/src/dynamo-framework/com/silverwrist/dynamo/db/OpsBase.java index bbc7a96..233923a 100644 --- a/src/dynamo-framework/com/silverwrist/dynamo/db/OpsBase.java +++ b/src/dynamo-framework/com/silverwrist/dynamo/db/OpsBase.java @@ -11,7 +11,7 @@ * * The Initial Developer of the Original Code is Eric J. Bowersox , * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are - * Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * * Contributor(s): */ @@ -20,6 +20,7 @@ package com.silverwrist.dynamo.db; import java.lang.reflect.*; import java.sql.Connection; import java.sql.SQLException; +import org.apache.log4j.Logger; import com.silverwrist.dynamo.except.*; import com.silverwrist.dynamo.iface.*; @@ -30,6 +31,8 @@ public class OpsBase *-------------------------------------------------------------------------------- */ + private static Logger logger = Logger.getLogger(OpsBase.class); + private static final Class[] ARGS_CLASS = { DBConnectionPool.class }; /*-------------------------------------------------------------------------------- @@ -69,6 +72,7 @@ public class OpsBase protected final DatabaseException generalException(SQLException e) { + logger.error("generalException(): processing SQLException",e); DatabaseException dbe = new DatabaseException(OpsBase.class,"DatabaseMessages","general",e); dbe.setParameter(0,e.getMessage()); return dbe; @@ -94,9 +98,11 @@ public class OpsBase protected static Object get(DBConnectionPool pool, ClassLoader loader, String stem_name, String type) throws ConfigException { + String klassname = stem_name + pool.getDatabaseType().toLowerCase(); try { // load the specified ops class and return a new instance - String klassname = stem_name + pool.getDatabaseType().toLowerCase(); + if (logger.isDebugEnabled()) + logger.debug("loading classname \"" + klassname + "\" from this loader: " + loader.toString()); Constructor c = loader.loadClass(klassname).getConstructor(ARGS_CLASS); Object[] args = new Object[1]; args[0] = pool; @@ -105,6 +111,7 @@ public class OpsBase } // end try catch (Exception e) { // error loading the ops class... + logger.error("error loading class \"" + klassname + "\"",e); ConfigException ce = new ConfigException(OpsBase.class,"DatabaseMessages","load.opsClass",e); ce.setParameter(0,e.getMessage()); ce.setParameter(1,pool.getDatabaseType()); diff --git a/src/dynamo-framework/com/silverwrist/dynamo/module/ModuleLoader.java b/src/dynamo-framework/com/silverwrist/dynamo/module/ModuleLoader.java index 6cd6341..a225bb1 100644 --- a/src/dynamo-framework/com/silverwrist/dynamo/module/ModuleLoader.java +++ b/src/dynamo-framework/com/silverwrist/dynamo/module/ModuleLoader.java @@ -279,6 +279,17 @@ class ModuleLoader extends URLClassLoader implements Module } // end urlFromPath + /*-------------------------------------------------------------------------------- + * Overrides from class Object + *-------------------------------------------------------------------------------- + */ + + public String toString() + { + return "{ModuleLoader for module \"" + m_filename + "\"}"; + + } // end toString + /*-------------------------------------------------------------------------------- * Implementations from interface Module *-------------------------------------------------------------------------------- diff --git a/src/dynamo-framework/com/silverwrist/dynamo/security/AclOperations_mysql.java b/src/dynamo-framework/com/silverwrist/dynamo/security/AclOperations_mysql.java index fef3366..eaed54f 100644 --- a/src/dynamo-framework/com/silverwrist/dynamo/security/AclOperations_mysql.java +++ b/src/dynamo-framework/com/silverwrist/dynamo/security/AclOperations_mysql.java @@ -82,6 +82,8 @@ class AclOperations_mysql extends AclOperations private static final boolean testOwner(Connection conn, int aclid, PrincipalID owner) throws SQLException { + if (logger.isDebugEnabled()) + logger.debug("testOwner(conn," + aclid + "," + owner + ")"); PreparedStatement stmt = null; ResultSet rs = null; try @@ -389,6 +391,8 @@ class AclOperations_mysql extends AclOperations int getMatchingAceID(int aclid, PrincipalID caller, PrincipalID target, boolean negative) throws DatabaseException, NotOwnerException { + if (logger.isDebugEnabled()) + logger.debug("getMatchingAceID(" + aclid + "," + caller + "," + target + "," + negative + ")"); Connection conn = null; PreparedStatement stmt = null; Statement stmt2 = null; @@ -399,7 +403,7 @@ class AclOperations_mysql extends AclOperations // lock the tables we need stmt2 = conn.createStatement(); - stmt2.executeUpdate("LOCK TABLES acldata READ, ace READ, aclowner READ;"); + stmt2.executeUpdate("LOCK TABLES acldata AS f READ, ace AS a READ, aclowner READ;"); // test to see if we own the thing first ensureOwner(conn,aclid,caller); @@ -819,7 +823,7 @@ class AclOperations_mysql extends AclOperations stmt.close(); stmt = conn.prepareStatement("SELECT DISTINCT a.aceid, a.flags FROM acedata d, ace a, acldata f, groupmembers m " + "WHERE d.perm_nsid = ? AND d.perm_name = ? AND d.aceid = a.aceid " - + "AND a.aceid = f.aceid AND d.aclid = ? AND (a.flags = 1 OR a.flags = 17) " + + "AND a.aceid = f.aceid AND f.aclid = ? AND (a.flags = 1 OR a.flags = 17) " + "AND a.pri = m.gid AND m.uid = ?;"); stmt.setInt(1,perm.getNamespaceID()); stmt.setString(2,perm.getName()); diff --git a/src/dynamo-framework/com/silverwrist/dynamo/security/PrincipalID.java b/src/dynamo-framework/com/silverwrist/dynamo/security/PrincipalID.java index 2e1b2f1..069002d 100644 --- a/src/dynamo-framework/com/silverwrist/dynamo/security/PrincipalID.java +++ b/src/dynamo-framework/com/silverwrist/dynamo/security/PrincipalID.java @@ -11,7 +11,7 @@ * * The Initial Developer of the Original Code is Eric J. Bowersox , * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are - * Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * * Contributor(s): */ @@ -81,6 +81,15 @@ final class PrincipalID } // end hashCode + public String toString() + { + if (m_group) + return "{PrincipalID: group#" + m_id + "}"; + else + return "{PrincipalID: user#" + m_id + "}"; + + } // end toString + /*-------------------------------------------------------------------------------- * External operations *-------------------------------------------------------------------------------- diff --git a/venice-data/velocity/frame.vm b/venice-data/velocity/frame.vm index 8bf5f46..3bc846c 100644 --- a/venice-data/velocity/frame.vm +++ b/venice-data/velocity/frame.vm @@ -150,7 +150,7 @@ - #comment( "HITCOUNTER FOR QID: $qid" ) + #comment( "HITCOUNTER FOR QID: $!qid" )