1 23 package org.ofbiz.base.config; 24 25 import java.util.*; 26 import org.w3c.dom.*; 27 import org.ofbiz.base.util.*; 28 29 41 public class SecurityConfigUtil { 42 43 public static final String module = SecurityConfigUtil.class.getName(); 44 45 46 public static final String SECURITY_CONFIG_XML_FILENAME = "security.xml"; 47 48 protected static Map securityInfos = new HashMap(); 49 50 56 public static Element getXmlRootElement() throws GenericConfigException { 57 return ResourceLoader.getXmlRootElement(SecurityConfigUtil.SECURITY_CONFIG_XML_FILENAME); 58 } 59 60 66 public static Document getXmlDocument() throws GenericConfigException { 67 return ResourceLoader.getXmlDocument(SecurityConfigUtil.SECURITY_CONFIG_XML_FILENAME); 68 } 69 70 static { 71 try { 72 initialize(getXmlRootElement()); 73 } catch (Exception e) { 74 Debug.logError(e, "Error loading Security config XML file " + SECURITY_CONFIG_XML_FILENAME, module); 75 } 76 } 77 78 84 public static void initialize(Element rootElement) throws GenericConfigException { 85 List childElements = null; 86 Iterator elementIter = null; 87 88 childElements = UtilXml.childElementList(rootElement, "security"); 90 elementIter = childElements.iterator(); 91 while (elementIter.hasNext()) { 92 Element curElement = (Element) elementIter.next(); 93 SecurityConfigUtil.SecurityInfo securityInfo = new SecurityConfigUtil.SecurityInfo(curElement); 94 95 if (Debug.verboseOn()) Debug.logVerbose("LOADED SECURITY CONFIG FROM XML - NAME: " + securityInfo.name + " ClassName: " + securityInfo.className, module); 96 SecurityConfigUtil.securityInfos.put(securityInfo.name, securityInfo); 97 } 98 } 99 100 106 public static SecurityConfigUtil.SecurityInfo getSecurityInfo(String name) { 107 return (SecurityConfigUtil.SecurityInfo) securityInfos.get(name); 108 } 109 110 113 public static class SecurityInfo { 114 public String name; 115 public String className; 116 117 122 public SecurityInfo(Element element) { 123 this.name = element.getAttribute("name"); 124 this.className = element.getAttribute("class"); 125 } 126 } 127 } 128 | Popular Tags |