From f8bba8b124c4e1d9b8808b428013aa64d686897d Mon Sep 17 00:00:00 2001 From: "Eric J. Bowersox" Date: Sat, 21 Jun 2003 08:02:58 +0000 Subject: [PATCH] added the module configuration data and made use of it in the canInstall method in the conferencing module --- conf-sso/dynamo.xml | 3 + conf/dynamo-venice.xml | 3 + .../venice/conf/module/ModuleMain.java | 26 +++++- .../silverwrist/dynamo/module/ConfigData.java | 86 +++++++++++++++++++ .../module/ModuleConfigurationData.java | 24 ++++++ .../dynamo/module/ModuleManager.java | 6 ++ 6 files changed, 146 insertions(+), 2 deletions(-) create mode 100644 src/dynamo-framework/com/silverwrist/dynamo/module/ConfigData.java create mode 100644 src/dynamo-framework/com/silverwrist/dynamo/module/ModuleConfigurationData.java diff --git a/conf-sso/dynamo.xml b/conf-sso/dynamo.xml index b95984b..17c3a69 100644 --- a/conf-sso/dynamo.xml +++ b/conf-sso/dynamo.xml @@ -51,6 +51,9 @@ ${code.path}/modules + + srm + diff --git a/conf/dynamo-venice.xml b/conf/dynamo-venice.xml index 6d9e12b..d9455ae 100644 --- a/conf/dynamo-venice.xml +++ b/conf/dynamo-venice.xml @@ -51,6 +51,9 @@ ${code.path}/modules + + srm + diff --git a/src/conferencing-module/com/silverwrist/venice/conf/module/ModuleMain.java b/src/conferencing-module/com/silverwrist/venice/conf/module/ModuleMain.java index e3e9dd9..0e715e1 100644 --- a/src/conferencing-module/com/silverwrist/venice/conf/module/ModuleMain.java +++ b/src/conferencing-module/com/silverwrist/venice/conf/module/ModuleMain.java @@ -19,9 +19,13 @@ package com.silverwrist.venice.conf.module; import java.security.Principal; import java.util.*; +import com.silverwrist.dynamo.Namespaces; import com.silverwrist.dynamo.except.*; import com.silverwrist.dynamo.iface.*; +import com.silverwrist.dynamo.module.ModuleConfigurationData; +import com.silverwrist.dynamo.security.SecurityReferenceMonitor; import com.silverwrist.dynamo.util.*; +import com.silverwrist.venice.VeniceNamespaces; import com.silverwrist.venice.community.CommunityServiceInstall; import com.silverwrist.venice.util.*; import com.silverwrist.venice.conf.ConfNamespaces; @@ -120,8 +124,26 @@ public class ModuleMain implements ModuleFunctions, UseCount public boolean canInstall(ServiceProvider services, Principal installer) { - return true; // TEMP - } + try + { // get the module configuration data to get the SRM name, then use that to get the actual SRM, then get + // the global ACL, then test permissions + ModuleConfigurationData conf_data = + (ModuleConfigurationData)(services.queryService(ModuleConfigurationData.class)); + String srm_name = conf_data.getValue(Namespaces.DYNAMO_OBJECT_NAMESPACE,"security"); + SecurityReferenceMonitor srm = + (SecurityReferenceMonitor)(GetObjectUtils.getDynamoComponent(services,SecurityReferenceMonitor.class, + srm_name)); + DynamoAcl gacl = srm.getGlobalAcl(); + return gacl.testPermission((DynamoUser)installer,VeniceNamespaces.SYSTEM_PERMS_NAMESPACE,"edit.menus"); + + } // end try + catch (Exception e) + { // unable to test permission + return false; + + } // end catch + + } // end canInstall public void install(ModuleSite site, ServiceProvider services, Principal installer, DynamoLog log) throws ModuleException diff --git a/src/dynamo-framework/com/silverwrist/dynamo/module/ConfigData.java b/src/dynamo-framework/com/silverwrist/dynamo/module/ConfigData.java new file mode 100644 index 0000000..dc3ae9f --- /dev/null +++ b/src/dynamo-framework/com/silverwrist/dynamo/module/ConfigData.java @@ -0,0 +1,86 @@ +/* + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at . + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + * WARRANTY OF ANY KIND, either express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is the Venice Web Communities System. + * + * The Initial Developer of the Original Code is Eric J. Bowersox , + * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + * Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.dynamo.module; + +import java.util.*; +import org.w3c.dom.*; +import com.silverwrist.util.xml.*; +import com.silverwrist.dynamo.except.*; + +class ConfigData implements ModuleConfigurationData +{ + /*-------------------------------------------------------------------------------- + * Attributes + *-------------------------------------------------------------------------------- + */ + + private Hashtable m_store = new Hashtable(); + + /*-------------------------------------------------------------------------------- + * Constructor + *-------------------------------------------------------------------------------- + */ + + ConfigData(Element elt) throws ConfigException + { + XMLLoader loader = XMLLoader.get(); + try + { // get a list of all sub-elements + List l = loader.getMatchingSubElements(elt,"item"); + Iterator it = l.iterator(); + while (it.hasNext()) + { // get each and decode it + Element n = (Element)(it.next()); + String tmp = loader.getAttribute(n,"ns"); + Hashtable tab = (Hashtable)(m_store.get(tmp)); + if (tab==null) + { // create a Hashtable for this namespace + tab = new Hashtable(); + m_store.put(tmp,tab); + + } // end if + + tmp = loader.getAttribute(n,"name"); + tab.put(tmp,loader.getText(n)); + + } // end while + + } // end try + catch (XMLLoadException e) + { // translate XML loader exception + throw new ConfigException(e); + + } // end catch + + } // end constructor + + /*-------------------------------------------------------------------------------- + * Implementations from interface ModuleConfigurationData + *-------------------------------------------------------------------------------- + */ + + public String getValue(String namespace, String name) + { + Hashtable tab = (Hashtable)(m_store.get(namespace)); + if (tab==null) + return null; + return (String)(tab.get(name)); + + } // end getValue + +} // end class ConfigData diff --git a/src/dynamo-framework/com/silverwrist/dynamo/module/ModuleConfigurationData.java b/src/dynamo-framework/com/silverwrist/dynamo/module/ModuleConfigurationData.java new file mode 100644 index 0000000..4be21c1 --- /dev/null +++ b/src/dynamo-framework/com/silverwrist/dynamo/module/ModuleConfigurationData.java @@ -0,0 +1,24 @@ +/* + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at . + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + * WARRANTY OF ANY KIND, either express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is the Venice Web Communities System. + * + * The Initial Developer of the Original Code is Eric J. Bowersox , + * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + * Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.dynamo.module; + +public interface ModuleConfigurationData +{ + public String getValue(String namespace, String name); + +} // end interface ModuleConfigurationData diff --git a/src/dynamo-framework/com/silverwrist/dynamo/module/ModuleManager.java b/src/dynamo-framework/com/silverwrist/dynamo/module/ModuleManager.java index e19b245..ad07629 100644 --- a/src/dynamo-framework/com/silverwrist/dynamo/module/ModuleManager.java +++ b/src/dynamo-framework/com/silverwrist/dynamo/module/ModuleManager.java @@ -154,6 +154,7 @@ public class ModuleManager implements NamedObject, ComponentInitialize, Componen { XMLLoader loader = XMLLoader.get(); String mod_dir = null, conn_name = null, nscache_name = null; + ConfigData cfg_data = null; try { // verify the right node name loader.verifyNodeName(config_root,"object"); @@ -170,6 +171,10 @@ public class ModuleManager implements NamedObject, ComponentInitialize, Componen conn_name = loader.getAttribute(elt,"connection"); nscache_name = loader.getAttribute(elt,"namespaces"); + // get the module configuration data + elt = loader.getSubElement(config_root_h,"config-db"); + cfg_data = new ConfigData(elt); + } // end try catch (XMLLoadException e) { // error loading XML config data @@ -201,6 +206,7 @@ public class ModuleManager implements NamedObject, ComponentInitialize, Componen // Get the install service manager and set up the install service provider. m_instservice = new InstallServiceManager(); + m_instservice.addService(ModuleConfigurationData.class,(ModuleConfigurationData)cfg_data); m_install_services = m_instservice.getServiceProvider(m_appcon.getInitServices()); // Hook this into the service providers.