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)
This commit is contained in:
Eric J. Bowersox 2001-11-19 18:17:40 +00:00
parent a376aad722
commit 41299f6d85
4 changed files with 32 additions and 8 deletions

View File

@ -967,7 +967,12 @@ class TopicMessageUserContextImpl implements TopicMessageContext
public boolean canPublish() public boolean canPublish()
{ {
if (!(env.testPermission(EnvUser.PERM_PUBLISH_FP))) 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) if ((scribble_date!=null) || nuked)
return false; // cannot publish a scribbled or nuked message return false; // cannot publish a scribbled or nuked message

View File

@ -45,6 +45,7 @@ public class EnvCommunity extends EnvUser
*/ */
private CommunityBackend comm; // the community back end private CommunityBackend comm; // the community back end
private SecurityMonitor sm; // the security monitor
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Constructors * Constructors
@ -55,6 +56,7 @@ public class EnvCommunity extends EnvUser
{ {
super(parent); super(parent);
this.comm = comm; this.comm = comm;
this.sm = getEngine().env_getSecurityMonitor(EngineBackend.SM_COMMUNITY);
} // end constructor } // end constructor
@ -62,6 +64,7 @@ public class EnvCommunity extends EnvUser
{ {
super(other); super(other);
this.comm = other.comm; this.comm = other.comm;
this.sm = other.sm;
} // end constructor } // end constructor
@ -72,7 +75,7 @@ public class EnvCommunity extends EnvUser
protected SecurityMonitor getStaticMonitor() protected SecurityMonitor getStaticMonitor()
{ {
return getEngine().env_getSecurityMonitor(EngineBackend.SM_COMMUNITY); return sm;
} // end getStaticMonitor } // end getStaticMonitor
@ -116,7 +119,6 @@ public class EnvCommunity extends EnvUser
public boolean testPermission(String symbol, String errormsg) throws AccessError 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) if ( symbol.equals(PERM_READ) || symbol.equals(PERM_WRITE) || symbol.equals(PERM_CREATE)
|| symbol.equals(PERM_DELETE) || symbol.equals(PERM_JOIN)) || symbol.equals(PERM_DELETE) || symbol.equals(PERM_JOIN))
{ // fall back to the backend object to test this { // fall back to the backend object to test this
@ -136,7 +138,6 @@ public class EnvCommunity extends EnvUser
public boolean testPermission(String symbol) public boolean testPermission(String symbol)
{ {
SecurityMonitor sm = getStaticMonitor();
if ( symbol.equals(PERM_READ) || symbol.equals(PERM_WRITE) || symbol.equals(PERM_CREATE) if ( symbol.equals(PERM_READ) || symbol.equals(PERM_WRITE) || symbol.equals(PERM_CREATE)
|| symbol.equals(PERM_DELETE) || symbol.equals(PERM_JOIN)) || symbol.equals(PERM_DELETE) || symbol.equals(PERM_JOIN))
return comm.env_testPermission(symbol); return comm.env_testPermission(symbol);
@ -165,7 +166,7 @@ public class EnvCommunity extends EnvUser
public final boolean isLevelAdmin(int level) public final boolean isLevelAdmin(int level)
{ {
return getStaticMonitor().testPermission(PERM_SHOWADMIN,level); return sm.testPermission(PERM_SHOWADMIN,level);
} // end isLevelAdmin } // end isLevelAdmin

View File

@ -33,6 +33,7 @@ public class EnvConference extends EnvCommunity
*/ */
private ConferenceBackend conf; private ConferenceBackend conf;
private SecurityMonitor sm;
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Constructors * Constructors
@ -43,6 +44,7 @@ public class EnvConference extends EnvCommunity
{ {
super(parent); super(parent);
this.conf = conf; this.conf = conf;
this.sm = getEngine().env_getSecurityMonitor(EngineBackend.SM_CONFERENCE);
} // end constructor } // end constructor
@ -50,6 +52,7 @@ public class EnvConference extends EnvCommunity
{ {
super(other); super(other);
this.conf = other.conf; this.conf = other.conf;
this.sm = other.sm;
} // end constructor } // end constructor
@ -60,7 +63,7 @@ public class EnvConference extends EnvCommunity
protected SecurityMonitor getStaticMonitor() protected SecurityMonitor getStaticMonitor()
{ {
return getEngine().env_getSecurityMonitor(EngineBackend.SM_CONFERENCE); return sm;
} // end getStaticMonitor } // end getStaticMonitor

View File

@ -21,6 +21,7 @@ import org.apache.log4j.*;
import com.silverwrist.venice.except.AccessError; import com.silverwrist.venice.except.AccessError;
import com.silverwrist.venice.security.AuditRecord; import com.silverwrist.venice.security.AuditRecord;
import com.silverwrist.venice.security.Role; import com.silverwrist.venice.security.Role;
import com.silverwrist.venice.security.SecurityMonitor;
public class EnvUser extends EnvEngine public class EnvUser extends EnvEngine
{ {
@ -48,6 +49,7 @@ public class EnvUser extends EnvEngine
*/ */
private UserBackend user; // the user backend object private UserBackend user; // the user backend object
private SecurityMonitor sm; // security monitor at this level
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Constructors * Constructors
@ -58,6 +60,7 @@ public class EnvUser extends EnvEngine
{ {
super(parent); super(parent);
this.user = user; this.user = user;
this.sm = getEngine().env_getSecurityMonitor(EngineBackend.SM_GLOBAL);
} // end constructor } // end constructor
@ -65,9 +68,21 @@ public class EnvUser extends EnvEngine
{ {
super(other); super(other);
this.user = other.user; this.user = other.user;
this.sm = other.sm;
} // end constructor } // end constructor
/*--------------------------------------------------------------------------------
* Overrides from class EnvEngine
*--------------------------------------------------------------------------------
*/
protected SecurityMonitor getStaticMonitor()
{
return sm;
} // end getStaticMonitor
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* External operations * External operations
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
@ -117,7 +132,7 @@ public class EnvUser extends EnvEngine
} // end if } // end if
return getStaticMonitor().testPermission(symbol,user.realBaseLevel(),errormsg); return sm.testPermission(symbol,user.realBaseLevel(),errormsg);
} // end testPermission } // end testPermission
@ -130,7 +145,7 @@ public class EnvUser extends EnvEngine
} // end if } // end if
return getStaticMonitor().testPermission(symbol,user.realBaseLevel()); return sm.testPermission(symbol,user.realBaseLevel());
} // end testPermission } // end testPermission