bugfixes and enhancements to the ACL operations, etc.

This commit is contained in:
Eric J. Bowersox 2003-06-25 09:14:13 +00:00
parent db492cf185
commit f6f6403f6b
6 changed files with 40 additions and 9 deletions

View File

@ -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). # system administrators can add or remove members (without going through the "join" process).
# (ACL 3, ACEs 5 and 6) # (ACL 3, ACEs 5 and 6)
INSERT INTO acl (aclid, aclname) VALUES (3, 'Members:piazza'); 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 ace (aceid, pri, flags) VALUES (5, 5, 1);
INSERT INTO acldata (aclid, seq, aceid) VALUES (3, 0, 5); INSERT INTO acldata (aclid, seq, aceid) VALUES (3, 0, 5);
INSERT INTO acedata (aceid, perm_nsid, perm_name) VALUES 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. # and system administrators can add or remove members.
# (ACL 4, ACEs 7 and 8) # (ACL 4, ACEs 7 and 8)
INSERT INTO acl (aclid, aclname) VALUES (4, 'Hosts:piazza'); 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 ace (aceid, pri, flags) VALUES (7, 2, 0);
INSERT INTO acldata (aclid, seq, aceid) VALUES (4, 0, 7); INSERT INTO acldata (aclid, seq, aceid) VALUES (4, 0, 7);
INSERT INTO acedata (aceid, perm_nsid, perm_name) VALUES 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. # Create the ACL for the initial community.
# (ACL 5, ACEs 9, 10, 11, 12) # (ACL 5, ACEs 9, 10, 11, 12)
INSERT INTO acl (aclid, aclname) VALUES (5, 'ACL:piazza'); 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 ace (aceid, pri, flags) VALUES (12, 2, 16);
INSERT INTO acldata (aclid, seq, aceid) VALUES (5, 0, 12); INSERT INTO acldata (aclid, seq, aceid) VALUES (5, 0, 12);
INSERT INTO acedata (aceid, perm_nsid, perm_name) VALUES INSERT INTO acedata (aceid, perm_nsid, perm_name) VALUES

View File

@ -11,7 +11,7 @@
* *
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>, * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * 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): * Contributor(s):
*/ */
@ -20,6 +20,7 @@ package com.silverwrist.dynamo.db;
import java.lang.reflect.*; import java.lang.reflect.*;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException; import java.sql.SQLException;
import org.apache.log4j.Logger;
import com.silverwrist.dynamo.except.*; import com.silverwrist.dynamo.except.*;
import com.silverwrist.dynamo.iface.*; 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 }; private static final Class[] ARGS_CLASS = { DBConnectionPool.class };
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
@ -69,6 +72,7 @@ public class OpsBase
protected final DatabaseException generalException(SQLException e) protected final DatabaseException generalException(SQLException e)
{ {
logger.error("generalException(): processing SQLException",e);
DatabaseException dbe = new DatabaseException(OpsBase.class,"DatabaseMessages","general",e); DatabaseException dbe = new DatabaseException(OpsBase.class,"DatabaseMessages","general",e);
dbe.setParameter(0,e.getMessage()); dbe.setParameter(0,e.getMessage());
return dbe; return dbe;
@ -94,9 +98,11 @@ public class OpsBase
protected static Object get(DBConnectionPool pool, ClassLoader loader, String stem_name, String type) protected static Object get(DBConnectionPool pool, ClassLoader loader, String stem_name, String type)
throws ConfigException throws ConfigException
{ {
String klassname = stem_name + pool.getDatabaseType().toLowerCase();
try try
{ // load the specified ops class and return a new instance { // 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); Constructor c = loader.loadClass(klassname).getConstructor(ARGS_CLASS);
Object[] args = new Object[1]; Object[] args = new Object[1];
args[0] = pool; args[0] = pool;
@ -105,6 +111,7 @@ public class OpsBase
} // end try } // end try
catch (Exception e) catch (Exception e)
{ // error loading the ops class... { // error loading the ops class...
logger.error("error loading class \"" + klassname + "\"",e);
ConfigException ce = new ConfigException(OpsBase.class,"DatabaseMessages","load.opsClass",e); ConfigException ce = new ConfigException(OpsBase.class,"DatabaseMessages","load.opsClass",e);
ce.setParameter(0,e.getMessage()); ce.setParameter(0,e.getMessage());
ce.setParameter(1,pool.getDatabaseType()); ce.setParameter(1,pool.getDatabaseType());

View File

@ -279,6 +279,17 @@ class ModuleLoader extends URLClassLoader implements Module
} // end urlFromPath } // end urlFromPath
/*--------------------------------------------------------------------------------
* Overrides from class Object
*--------------------------------------------------------------------------------
*/
public String toString()
{
return "{ModuleLoader for module \"" + m_filename + "\"}";
} // end toString
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Implementations from interface Module * Implementations from interface Module
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------

View File

@ -82,6 +82,8 @@ class AclOperations_mysql extends AclOperations
private static final boolean testOwner(Connection conn, int aclid, PrincipalID owner) throws SQLException 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; PreparedStatement stmt = null;
ResultSet rs = null; ResultSet rs = null;
try try
@ -389,6 +391,8 @@ class AclOperations_mysql extends AclOperations
int getMatchingAceID(int aclid, PrincipalID caller, PrincipalID target, boolean negative) int getMatchingAceID(int aclid, PrincipalID caller, PrincipalID target, boolean negative)
throws DatabaseException, NotOwnerException throws DatabaseException, NotOwnerException
{ {
if (logger.isDebugEnabled())
logger.debug("getMatchingAceID(" + aclid + "," + caller + "," + target + "," + negative + ")");
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
Statement stmt2 = null; Statement stmt2 = null;
@ -399,7 +403,7 @@ class AclOperations_mysql extends AclOperations
// lock the tables we need // lock the tables we need
stmt2 = conn.createStatement(); 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 // test to see if we own the thing first
ensureOwner(conn,aclid,caller); ensureOwner(conn,aclid,caller);
@ -819,7 +823,7 @@ class AclOperations_mysql extends AclOperations
stmt.close(); stmt.close();
stmt = conn.prepareStatement("SELECT DISTINCT a.aceid, a.flags FROM acedata d, ace a, acldata f, groupmembers m " 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 " + "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 = ?;"); + "AND a.pri = m.gid AND m.uid = ?;");
stmt.setInt(1,perm.getNamespaceID()); stmt.setInt(1,perm.getNamespaceID());
stmt.setString(2,perm.getName()); stmt.setString(2,perm.getName());

View File

@ -11,7 +11,7 @@
* *
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>, * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * 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): * Contributor(s):
*/ */
@ -81,6 +81,15 @@ final class PrincipalID
} // end hashCode } // end hashCode
public String toString()
{
if (m_group)
return "{PrincipalID: group#" + m_id + "}";
else
return "{PrincipalID: user#" + m_id + "}";
} // end toString
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* External operations * External operations
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------

View File

@ -150,7 +150,7 @@
</td> </td>
</tr> </tr>
<tr valign="top"><td align="right" class="framefooter"> <tr valign="top"><td align="right" class="framefooter">
#comment( "HITCOUNTER FOR QID: $qid" ) #comment( "HITCOUNTER FOR QID: $!qid" )
</td></tr> </td></tr>
</table> </table>