From 41299f6d851005df4f4db2cd78de477cbd1361ef Mon Sep 17 00:00:00 2001 From: "Eric J. Bowersox" Date: Mon, 19 Nov 2001 18:17:40 +0000 Subject: [PATCH] the permissions system was screwing up somehow for static permissions - EnvUser, EnvCommunity, and EnvConference each need to keep a reference to their own SecurityMonitor, we can't rely on getStaticMonitor() (but we still need it, to make the other "wrapper" functions work) --- .../impl/TopicMessageUserContextImpl.java | 7 ++++++- .../venice/core/internals/EnvCommunity.java | 9 +++++---- .../venice/core/internals/EnvConference.java | 5 ++++- .../venice/core/internals/EnvUser.java | 19 +++++++++++++++++-- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/com/silverwrist/venice/core/impl/TopicMessageUserContextImpl.java b/src/com/silverwrist/venice/core/impl/TopicMessageUserContextImpl.java index bdaddd6..d776d94 100644 --- a/src/com/silverwrist/venice/core/impl/TopicMessageUserContextImpl.java +++ b/src/com/silverwrist/venice/core/impl/TopicMessageUserContextImpl.java @@ -967,7 +967,12 @@ class TopicMessageUserContextImpl implements TopicMessageContext public boolean canPublish() { if (!(env.testPermission(EnvUser.PERM_PUBLISH_FP))) - return false; // must be a sysadmin to publish + { // must be a sysadmin to publish + if (logger.isDebugEnabled()) + logger.debug("canPublish(): permission test failed"); + return false; + + } // end if if ((scribble_date!=null) || nuked) return false; // cannot publish a scribbled or nuked message diff --git a/src/com/silverwrist/venice/core/internals/EnvCommunity.java b/src/com/silverwrist/venice/core/internals/EnvCommunity.java index 3677cdb..097f297 100644 --- a/src/com/silverwrist/venice/core/internals/EnvCommunity.java +++ b/src/com/silverwrist/venice/core/internals/EnvCommunity.java @@ -45,6 +45,7 @@ public class EnvCommunity extends EnvUser */ private CommunityBackend comm; // the community back end + private SecurityMonitor sm; // the security monitor /*-------------------------------------------------------------------------------- * Constructors @@ -55,6 +56,7 @@ public class EnvCommunity extends EnvUser { super(parent); this.comm = comm; + this.sm = getEngine().env_getSecurityMonitor(EngineBackend.SM_COMMUNITY); } // end constructor @@ -62,6 +64,7 @@ public class EnvCommunity extends EnvUser { super(other); this.comm = other.comm; + this.sm = other.sm; } // end constructor @@ -72,7 +75,7 @@ public class EnvCommunity extends EnvUser protected SecurityMonitor getStaticMonitor() { - return getEngine().env_getSecurityMonitor(EngineBackend.SM_COMMUNITY); + return sm; } // end getStaticMonitor @@ -116,7 +119,6 @@ public class EnvCommunity extends EnvUser public boolean testPermission(String symbol, String errormsg) throws AccessError { - SecurityMonitor sm = getStaticMonitor(); if ( symbol.equals(PERM_READ) || symbol.equals(PERM_WRITE) || symbol.equals(PERM_CREATE) || symbol.equals(PERM_DELETE) || symbol.equals(PERM_JOIN)) { // fall back to the backend object to test this @@ -136,7 +138,6 @@ public class EnvCommunity extends EnvUser public boolean testPermission(String symbol) { - SecurityMonitor sm = getStaticMonitor(); if ( symbol.equals(PERM_READ) || symbol.equals(PERM_WRITE) || symbol.equals(PERM_CREATE) || symbol.equals(PERM_DELETE) || symbol.equals(PERM_JOIN)) return comm.env_testPermission(symbol); @@ -165,7 +166,7 @@ public class EnvCommunity extends EnvUser public final boolean isLevelAdmin(int level) { - return getStaticMonitor().testPermission(PERM_SHOWADMIN,level); + return sm.testPermission(PERM_SHOWADMIN,level); } // end isLevelAdmin diff --git a/src/com/silverwrist/venice/core/internals/EnvConference.java b/src/com/silverwrist/venice/core/internals/EnvConference.java index aa20410..7909597 100644 --- a/src/com/silverwrist/venice/core/internals/EnvConference.java +++ b/src/com/silverwrist/venice/core/internals/EnvConference.java @@ -33,6 +33,7 @@ public class EnvConference extends EnvCommunity */ private ConferenceBackend conf; + private SecurityMonitor sm; /*-------------------------------------------------------------------------------- * Constructors @@ -43,6 +44,7 @@ public class EnvConference extends EnvCommunity { super(parent); this.conf = conf; + this.sm = getEngine().env_getSecurityMonitor(EngineBackend.SM_CONFERENCE); } // end constructor @@ -50,6 +52,7 @@ public class EnvConference extends EnvCommunity { super(other); this.conf = other.conf; + this.sm = other.sm; } // end constructor @@ -60,7 +63,7 @@ public class EnvConference extends EnvCommunity protected SecurityMonitor getStaticMonitor() { - return getEngine().env_getSecurityMonitor(EngineBackend.SM_CONFERENCE); + return sm; } // end getStaticMonitor diff --git a/src/com/silverwrist/venice/core/internals/EnvUser.java b/src/com/silverwrist/venice/core/internals/EnvUser.java index 117cd53..20fb045 100644 --- a/src/com/silverwrist/venice/core/internals/EnvUser.java +++ b/src/com/silverwrist/venice/core/internals/EnvUser.java @@ -21,6 +21,7 @@ import org.apache.log4j.*; import com.silverwrist.venice.except.AccessError; import com.silverwrist.venice.security.AuditRecord; import com.silverwrist.venice.security.Role; +import com.silverwrist.venice.security.SecurityMonitor; public class EnvUser extends EnvEngine { @@ -48,6 +49,7 @@ public class EnvUser extends EnvEngine */ private UserBackend user; // the user backend object + private SecurityMonitor sm; // security monitor at this level /*-------------------------------------------------------------------------------- * Constructors @@ -58,6 +60,7 @@ public class EnvUser extends EnvEngine { super(parent); this.user = user; + this.sm = getEngine().env_getSecurityMonitor(EngineBackend.SM_GLOBAL); } // end constructor @@ -65,9 +68,21 @@ public class EnvUser extends EnvEngine { super(other); this.user = other.user; + this.sm = other.sm; } // end constructor + /*-------------------------------------------------------------------------------- + * Overrides from class EnvEngine + *-------------------------------------------------------------------------------- + */ + + protected SecurityMonitor getStaticMonitor() + { + return sm; + + } // end getStaticMonitor + /*-------------------------------------------------------------------------------- * External operations *-------------------------------------------------------------------------------- @@ -117,7 +132,7 @@ public class EnvUser extends EnvEngine } // end if - return getStaticMonitor().testPermission(symbol,user.realBaseLevel(),errormsg); + return sm.testPermission(symbol,user.realBaseLevel(),errormsg); } // end testPermission @@ -130,7 +145,7 @@ public class EnvUser extends EnvEngine } // end if - return getStaticMonitor().testPermission(symbol,user.realBaseLevel()); + return sm.testPermission(symbol,user.realBaseLevel()); } // end testPermission