From 48266c4f73f6cc81c38ab3870a33ab054d8b4fbc Mon Sep 17 00:00:00 2001 From: "Eric J. Bowersox" Date: Mon, 27 May 2002 04:09:38 +0000 Subject: [PATCH] moved security monitor initialization from VeniceEngineImpl down to GlobalSiteImpl, removed env_getSecurityMonitor from envEngine --- .../core/impl/ServiceControlManager.java | 7 +-- .../venice/core/impl/VeniceEngineImpl.java | 57 +++++-------------- .../venice/core/internals/EngineBackend.java | 9 --- .../venice/core/internals/EnvCommunity.java | 7 ++- .../core/internals/EnvCommunityData.java | 4 +- .../venice/core/internals/EnvConference.java | 4 +- .../core/internals/EnvConferenceData.java | 4 +- .../venice/core/internals/EnvEngine.java | 2 +- .../venice/core/internals/EnvUser.java | 7 ++- .../venice/core/internals/GlobalSiteImpl.java | 45 ++++++++++++++- .../svc/SecurityMonitorEnvironment.java | 11 +++- 11 files changed, 85 insertions(+), 72 deletions(-) diff --git a/src/com/silverwrist/venice/core/impl/ServiceControlManager.java b/src/com/silverwrist/venice/core/impl/ServiceControlManager.java index 47182cd..1da37a7 100644 --- a/src/com/silverwrist/venice/core/impl/ServiceControlManager.java +++ b/src/com/silverwrist/venice/core/impl/ServiceControlManager.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) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * * Contributor(s): */ @@ -80,8 +80,7 @@ class ServiceControlManager implements ServiceControl *-------------------------------------------------------------------------------- */ - ServiceControlManager(GlobalSite globalsite, Document cfg, SecurityMonitorEnvironment sm_env) - throws ConfigException + ServiceControlManager(GlobalSite globalsite, Document cfg) throws ConfigException { XMLLoader loader = XMLLoader.get(); Element root = loader.configGetRootElement(cfg,"services-config"); @@ -98,7 +97,7 @@ class ServiceControlManager implements ServiceControl { // load the services for the section HashMap tmp_symbol_to_service = new HashMap(); HashMap tmp_index_to_service = new HashMap(); - SecurityMonitor sm_comm = sm_env.getMonitor("Community"); + SecurityMonitor sm_comm = (SecurityMonitor)(globalsite.queryService(SecurityMonitor.class,"Community")); nl = sect.getChildNodes(); for (i=0; i section. - sect = loader.configGetSubSection(root_h,"security"); - - // Load the security monitors. - SecurityMonitorEnvironment sm_env = new SecurityMonitorEnvironment(); - NodeList nl = sect.getChildNodes(); - for (i=0; i section. sect = loader.configGetSubSection(root_h,"upload"); sect_h = new DOMElementHelper(sect); // Look for a "no-compress" blacklist. Element subsect = sect_h.getSubElement("no-compress"); + NodeList nl; if (subsect!=null) { // Initialize the no-compress list. nl = subsect.getChildNodes(); @@ -607,7 +580,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend // Now done with the sidebox config... // Load the services config file. subdoc = loader.loadConfigDocument(services_config); - scmgr = new ServiceControlManager(globalsite,subdoc,sm_env); + scmgr = new ServiceControlManager(globalsite,subdoc); } // end try catch (ConfigException ce) @@ -667,6 +640,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend } // end if scmgr.shutdown(); + scmgr = null; env = null; globalsite.shutdown(); globalsite = null; @@ -888,7 +862,8 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend throws DataException, AccessError { checkInitialized(); - Role new_role = global_security.getDefaultRole("Global.NewUser"); + SecurityMonitor smon = (SecurityMonitor)(globalsite.queryService(SecurityMonitor.class)); + Role new_role = smon.getDefaultRole("Global.NewUser"); // email confirmation # is between 1000000 and 9999999 int confirm_num = Generator.get().getNewConfirmationNumber(); @@ -1350,7 +1325,8 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend public SecurityInfo getSecurityInfo() { - return new SecurityInfoWrapper(global_security); + SecurityMonitor smon = (SecurityMonitor)(globalsite.queryService(SecurityMonitor.class)); + return new SecurityInfoWrapper(smon); } // end getSecurityInfo @@ -1474,7 +1450,12 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend public Role getParamRole(int selector) { if (selector==ROLEP_CREATECOMMUNITY) - return global_security.getRoleForLevel(gp_ints[IP_CREATECOMMUNITYLVL]); + { // resolve with respect to the global security monitor + SecurityMonitor smon = (SecurityMonitor)(globalsite.queryService(SecurityMonitor.class)); + return smon.getRoleForLevel(gp_ints[IP_CREATECOMMUNITYLVL]); + + } // end if + return null; } // end getParamRole @@ -1596,18 +1577,6 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend } // end setProperties - public SecurityMonitor env_getSecurityMonitor(int selector) - { - if (selector==SM_GLOBAL) - return global_security; - if (selector==SM_COMMUNITY) - return community_security; - if (selector==SM_CONFERENCE) - return conference_security; - return null; - - } // end env_getSecurityMonitor - /*-------------------------------------------------------------------------------- * Static initializer *-------------------------------------------------------------------------------- diff --git a/src/com/silverwrist/venice/core/internals/EngineBackend.java b/src/com/silverwrist/venice/core/internals/EngineBackend.java index 48d0971..3969f6d 100644 --- a/src/com/silverwrist/venice/core/internals/EngineBackend.java +++ b/src/com/silverwrist/venice/core/internals/EngineBackend.java @@ -20,8 +20,6 @@ package com.silverwrist.venice.core.internals; import java.util.BitSet; import java.util.List; import com.silverwrist.venice.security.Role; -import com.silverwrist.venice.security.SecurityMonitor; -import com.silverwrist.venice.htmlcheck.HTMLChecker; import com.silverwrist.venice.core.GlobalProperties; import com.silverwrist.venice.core.SideBoxDescriptor; import com.silverwrist.venice.core.TopicMessageContext; @@ -48,11 +46,6 @@ public interface EngineBackend // role parameter indexes public static final int ROLEP_CREATECOMMUNITY = 0; - // Selectors for security monitors - public static final int SM_GLOBAL = 0; - public static final int SM_COMMUNITY = 1; - public static final int SM_CONFERENCE = 2; - public abstract VeniceEngine getSelf(); public abstract CommunityData getCommunityDataObject(int cid) throws DataException; @@ -89,6 +82,4 @@ public interface EngineBackend public abstract void setProperties(GlobalProperties props) throws DataException; - public abstract SecurityMonitor env_getSecurityMonitor(int selector); - } // end interface EngineBackend diff --git a/src/com/silverwrist/venice/core/internals/EnvCommunity.java b/src/com/silverwrist/venice/core/internals/EnvCommunity.java index 2d95c2f..ad9e470 100644 --- a/src/com/silverwrist/venice/core/internals/EnvCommunity.java +++ b/src/com/silverwrist/venice/core/internals/EnvCommunity.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) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * * Contributor(s): */ @@ -56,7 +56,7 @@ public class EnvCommunity extends EnvUser { super(parent); this.comm = comm; - this.sm = getEngine().env_getSecurityMonitor(EngineBackend.SM_COMMUNITY); + this.sm = (SecurityMonitor)(getGlobalSite().queryService(SecurityMonitor.class,"Community")); } // end constructor @@ -178,7 +178,8 @@ public class EnvCommunity extends EnvUser public final Role getConferenceDefaultRole(String symbol) { - return getEngine().env_getSecurityMonitor(EngineBackend.SM_CONFERENCE).getDefaultRole(symbol); + SecurityMonitor smon = (SecurityMonitor)(getGlobalSite().queryService(SecurityMonitor.class,"Conference")); + return smon.getDefaultRole(symbol); } // end getCommunityDefaultRole diff --git a/src/com/silverwrist/venice/core/internals/EnvCommunityData.java b/src/com/silverwrist/venice/core/internals/EnvCommunityData.java index ca2509a..fd67f86 100644 --- a/src/com/silverwrist/venice/core/internals/EnvCommunityData.java +++ b/src/com/silverwrist/venice/core/internals/EnvCommunityData.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) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * * Contributor(s): */ @@ -62,7 +62,7 @@ public class EnvCommunityData extends EnvEngine protected SecurityMonitor getStaticMonitor() { - return getEngine().env_getSecurityMonitor(EngineBackend.SM_COMMUNITY); + return (SecurityMonitor)(getGlobalSite().queryService(SecurityMonitor.class,"Community")); } // end getStaticMonitor diff --git a/src/com/silverwrist/venice/core/internals/EnvConference.java b/src/com/silverwrist/venice/core/internals/EnvConference.java index 2ed59b9..93d9a6b 100644 --- a/src/com/silverwrist/venice/core/internals/EnvConference.java +++ b/src/com/silverwrist/venice/core/internals/EnvConference.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) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * * Contributor(s): */ @@ -40,7 +40,7 @@ public class EnvConference extends EnvCommunity { super(parent); this.conf = conf; - this.sm = getEngine().env_getSecurityMonitor(EngineBackend.SM_CONFERENCE); + this.sm = (SecurityMonitor)(getGlobalSite().queryService(SecurityMonitor.class,"Conference")); } // end constructor diff --git a/src/com/silverwrist/venice/core/internals/EnvConferenceData.java b/src/com/silverwrist/venice/core/internals/EnvConferenceData.java index 7b6c936..cca5517 100644 --- a/src/com/silverwrist/venice/core/internals/EnvConferenceData.java +++ b/src/com/silverwrist/venice/core/internals/EnvConferenceData.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) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * * Contributor(s): */ @@ -46,7 +46,7 @@ public class EnvConferenceData extends EnvEngine protected SecurityMonitor getStaticMonitor() { - return getEngine().env_getSecurityMonitor(EngineBackend.SM_CONFERENCE); + return (SecurityMonitor)(getGlobalSite().queryService(SecurityMonitor.class,"Conference")); } // end getStaticMonitor diff --git a/src/com/silverwrist/venice/core/internals/EnvEngine.java b/src/com/silverwrist/venice/core/internals/EnvEngine.java index b8d8b4e..8e08021 100644 --- a/src/com/silverwrist/venice/core/internals/EnvEngine.java +++ b/src/com/silverwrist/venice/core/internals/EnvEngine.java @@ -76,7 +76,7 @@ public class EnvEngine protected SecurityMonitor getStaticMonitor() { - return engine.env_getSecurityMonitor(EngineBackend.SM_GLOBAL); + return (SecurityMonitor)(globalsite.queryService(SecurityMonitor.class)); } // end getStaticMonitor diff --git a/src/com/silverwrist/venice/core/internals/EnvUser.java b/src/com/silverwrist/venice/core/internals/EnvUser.java index d9d87fd..4cf758e 100644 --- a/src/com/silverwrist/venice/core/internals/EnvUser.java +++ b/src/com/silverwrist/venice/core/internals/EnvUser.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) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * * Contributor(s): */ @@ -60,7 +60,7 @@ public class EnvUser extends EnvEngine { super(parent); this.user = user; - this.sm = getEngine().env_getSecurityMonitor(EngineBackend.SM_GLOBAL); + this.sm = (SecurityMonitor)(getGlobalSite().queryService(SecurityMonitor.class)); } // end constructor @@ -213,7 +213,8 @@ public class EnvUser extends EnvEngine public final Role getCommunityDefaultRole(String symbol) { - return getEngine().env_getSecurityMonitor(EngineBackend.SM_COMMUNITY).getDefaultRole(symbol); + SecurityMonitor smon = (SecurityMonitor)(getGlobalSite().queryService(SecurityMonitor.class,"Community")); + return smon.getDefaultRole(symbol); } // end getCommunityDefaultRole diff --git a/src/com/silverwrist/venice/core/internals/GlobalSiteImpl.java b/src/com/silverwrist/venice/core/internals/GlobalSiteImpl.java index a3e2e1d..ee1a734 100644 --- a/src/com/silverwrist/venice/core/internals/GlobalSiteImpl.java +++ b/src/com/silverwrist/venice/core/internals/GlobalSiteImpl.java @@ -27,6 +27,8 @@ import com.silverwrist.venice.except.*; import com.silverwrist.venice.htmlcheck.*; import com.silverwrist.venice.htmlcheck.dict.*; import com.silverwrist.venice.htmlcheck.filters.*; +import com.silverwrist.venice.security.*; +import com.silverwrist.venice.svc.*; import com.silverwrist.venice.svc.internal.GlobalSite; import com.silverwrist.venice.util.ServiceProvider; import com.silverwrist.venice.util.MailSend; @@ -52,6 +54,7 @@ public class GlobalSiteImpl implements GlobalSite private javax.mail.Session mailsession = null; // email session object private StockMessages stock_messages = null; // stock messages holder private HashMap html_checkers = new HashMap(); // HTML checkers + private SecurityMonitorEnvironment sm_env; // security monitor environment /*-------------------------------------------------------------------------------- * Constructor @@ -117,7 +120,8 @@ public class GlobalSiteImpl implements GlobalSite // Get the section. sect = loader.configGetSubSection(config_h,"html-checker"); NodeList nl = sect.getChildNodes(); - for (int i=0; i section. + sect = loader.configGetSubSection(config_h,"security"); + + // Load the security monitors. + sm_env = new SecurityMonitorEnvironment(); + nl = sect.getChildNodes(); + for (i=0; i, * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are - * Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * * Contributor(s): */ @@ -77,4 +77,13 @@ public final class SecurityMonitorEnvironment } // end storeMonitor + public final void shutdown() + { + map.clear(); + map = null; + root = null; + + } // end shutdown + } // end class SecurityMonitorEnvironment +