moved security monitor initialization from VeniceEngineImpl down to
GlobalSiteImpl, removed env_getSecurityMonitor from envEngine
This commit is contained in:
parent
0afe28588d
commit
48266c4f73
|
@ -11,7 +11,7 @@
|
|||
*
|
||||
* 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
|
||||
* 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<nl.getLength(); i++)
|
||||
{ // get each element node...
|
||||
|
|
|
@ -29,8 +29,6 @@ import com.silverwrist.venice.core.internals.*;
|
|||
import com.silverwrist.venice.db.*;
|
||||
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;
|
||||
|
@ -263,9 +261,6 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
private HashSet no_compress_types = new HashSet(); // the file types that can't be compressed
|
||||
private HashMap password_changes = new HashMap(); // current password change requests
|
||||
private OptionSet global_flags = new OptionSet(); // global option flags
|
||||
private SecurityMonitor global_security; // the global security monitor
|
||||
private SecurityMonitor community_security; // the community security monitor
|
||||
private SecurityMonitor conference_security; // conference security monitor (will move eventually)
|
||||
private ServiceControlManager scmgr; // service control manager
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
|
@ -534,35 +529,13 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
|
|||
// Create the global site.
|
||||
globalsite = new GlobalSiteImpl(this,root,app_root);
|
||||
|
||||
// Get the <security/> section.
|
||||
sect = loader.configGetSubSection(root_h,"security");
|
||||
|
||||
// Load the security monitors.
|
||||
SecurityMonitorEnvironment sm_env = new SecurityMonitorEnvironment();
|
||||
NodeList nl = sect.getChildNodes();
|
||||
for (i=0; i<nl.getLength(); i++)
|
||||
{ // scan through and find security monitors to initialize
|
||||
Node n = nl.item(i);
|
||||
if ((n.getNodeType()==Node.ELEMENT_NODE) && (n.getNodeName().equals("security-definition")))
|
||||
{ // load one of the initial security definitions
|
||||
SecurityMonitor sm = new StaticSecurityMonitor((Element)n,sm_env);
|
||||
if (sm.getID().equals("Global"))
|
||||
global_security = sm;
|
||||
else if (sm.getID().equals("Community"))
|
||||
community_security = sm;
|
||||
else if (sm.getID().equals("Conference"))
|
||||
conference_security = sm;
|
||||
|
||||
} // end if
|
||||
|
||||
} // end for
|
||||
|
||||
// Get the <upload/> 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
|
||||
*--------------------------------------------------------------------------------
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
*
|
||||
* 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
|
||||
* 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
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
*
|
||||
* 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
|
||||
* 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
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
*
|
||||
* 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
|
||||
* 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
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
*
|
||||
* 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
|
||||
* 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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
*
|
||||
* 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
|
||||
* 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
|
||||
|
||||
|
|
|
@ -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 <html-checker/> section.
|
||||
sect = loader.configGetSubSection(config_h,"html-checker");
|
||||
NodeList nl = sect.getChildNodes();
|
||||
for (int i=0; i<nl.getLength(); i++)
|
||||
int i;
|
||||
for (i=0; i<nl.getLength(); i++)
|
||||
{ // get each node in turn and test to see if it's an element
|
||||
Node n = nl.item(i);
|
||||
if (n.getNodeType()==Node.ELEMENT_NODE)
|
||||
|
@ -134,6 +138,21 @@ public class GlobalSiteImpl implements GlobalSite
|
|||
|
||||
intermediate_map.clear(); // cut all extra references
|
||||
|
||||
// Get the <security/> section.
|
||||
sect = loader.configGetSubSection(config_h,"security");
|
||||
|
||||
// Load the security monitors.
|
||||
sm_env = new SecurityMonitorEnvironment();
|
||||
nl = sect.getChildNodes();
|
||||
for (i=0; i<nl.getLength(); i++)
|
||||
{ // scan through and find security monitors to initialize
|
||||
Node n = nl.item(i);
|
||||
if ((n.getNodeType()==Node.ELEMENT_NODE) && (n.getNodeName().equals("security-definition")))
|
||||
// load one of the initial security definitions
|
||||
new StaticSecurityMonitor((Element)n,sm_env);
|
||||
|
||||
} // end for
|
||||
|
||||
} // end class GlobalSiteImpl
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
|
@ -364,6 +383,10 @@ public class GlobalSiteImpl implements GlobalSite
|
|||
return datapool;
|
||||
if (klass==MailSend.class)
|
||||
return new BaseMailSend(this,email_props,mailsession);
|
||||
if (klass==SecurityMonitorEnvironment.class)
|
||||
return sm_env;
|
||||
if (klass==SecurityMonitor.class)
|
||||
return sm_env.getMonitor("Global");
|
||||
throw new NoSuchServiceException("GlobalSite",klass);
|
||||
|
||||
} // end queryService
|
||||
|
@ -384,6 +407,7 @@ public class GlobalSiteImpl implements GlobalSite
|
|||
} // end catch
|
||||
|
||||
} // end if
|
||||
|
||||
if (klass==HTMLCheckerConfig.class)
|
||||
{ // get the HTML Checker config
|
||||
Object rc = html_checkers.get(serviceid);
|
||||
|
@ -402,6 +426,15 @@ public class GlobalSiteImpl implements GlobalSite
|
|||
|
||||
} // end if
|
||||
|
||||
if (klass==SecurityMonitor.class)
|
||||
{ // get a security monitor from the environment
|
||||
SecurityMonitor rc = sm_env.getMonitor(serviceid);
|
||||
if (rc==null)
|
||||
throw new NoSuchServiceException("GlobalSite",klass,serviceid);
|
||||
return rc;
|
||||
|
||||
} // end if
|
||||
|
||||
return this.queryService(klass);
|
||||
|
||||
} // end queryService
|
||||
|
@ -431,8 +464,18 @@ public class GlobalSiteImpl implements GlobalSite
|
|||
|
||||
public void shutdown()
|
||||
{
|
||||
engine = null;
|
||||
if (datapool!=null)
|
||||
datapool.closeAllConnections();
|
||||
datapool = null;
|
||||
email_props = null;
|
||||
mailsession = null;
|
||||
stock_messages = null;
|
||||
html_checkers.clear();
|
||||
html_checkers = null;
|
||||
if (sm_env!=null)
|
||||
sm_env.shutdown();
|
||||
sm_env = null;
|
||||
|
||||
} // end shutdown
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
*
|
||||
* 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
|
||||
* 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
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user