/** * Default constructor. This creates a <code>SimplePDP</code> with a * <code>PDP</code> based on the configuration defined by the runtime * property com.sun.xcaml.PDPConfigFile. */ public SimplePDP() throws Exception { // load the configuration ConfigurationStore store = new ConfigurationStore(); // use the default factories from the configuration store.useDefaultFactories(); // get the PDP configuration's and setup the PDP pdp = new PDP(store.getDefaultPDPConfig()); }
/** * Private helper that gets the constructor arguments for a given class. * Right now this just supports String and List, but it's trivial to * add support for other types should that be needed. Right now, it's not * clear that there's any need for other types. */ private List getArgs(Node root) { List args = new ArrayList(); NodeList children = root.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); String name = SunxacmlUtil.getNodeName(child); if (child.getNodeType() == Node.ELEMENT_NODE) { if (name.equals("string")) { args.add(child.getFirstChild().getNodeValue()); } else if (name.equals("list")) { args.add(getArgs(child)); } else { throw new IllegalArgumentException("unkown arg type: " + name); } } } return args; }
Node root = getRootNode(configFile); String defaultAF = getDefaultFactory(attrs, "defaultAttributeFactory"); String defaultCAF = getDefaultFactory(attrs, "defaultCombiningAlgFactory"); String defaultFF = getDefaultFactory(attrs, "defaultFunctionFactory"); throw new ParsingException("more that one pdp with " + "name \"" + elementName +"\""); pdpConfigMap.put(elementName, parsePDPConfig(child)); } else if (childName.equals("attributeFactory")) { if (logger.isLoggable(Level.CONFIG)) "attributeFactory with name " + elementName +"\""); attributeMap.put(elementName, parseAttributeFactory(child)); } else if (childName.equals("combiningAlgFactory")) { if (logger.isLoggable(Level.CONFIG)) "combiningAlgFactory with " + "name \"" + elementName +"\""); combiningMap.put(elementName, parseCombiningAlgFactory(child)); } else if (childName.equals("functionFactory")) { if (logger.isLoggable(Level.CONFIG)) + " with name \"" + elementName +"\""); functionMap.put(elementName, parseFunctionFactory(child));
if (useStandard(root, "useStandardDatatypes")) { logger.config("Starting with standard Datatypes"); getNamedItem("identifier").getNodeValue(); AttributeProxy proxy = (AttributeProxy)(loadClass("datatype", child));
if (useStandard(root, "useStandardFunctions")) { logger.config("Starting with standard Functions"); functionParserHelper(child, targetFactory); } else if (name.equals("condition")) { logger.config("Loading [CONDITION] functions"); functionParserHelper(child, conditionFactory); } else if (name.equals("general")) { logger.config("Loading [GENERAL] functions"); functionParserHelper(child, generalFactory);
/** * Private helper that handles the pdp elements. */ private PDPConfig parsePDPConfig(Node root) throws ParsingException { ArrayList attrModules = new ArrayList(); HashSet policyModules = new HashSet(); ArrayList rsrcModules = new ArrayList(); // go through all elements of the pdp, loading the specified modules NodeList children = root.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); String name = SunxacmlUtil.getNodeName(child); if (name.equals("policyFinderModule")) { policyModules.add(loadClass("module", child)); } else if (name.equals("attributeFinderModule")) { attrModules.add(loadClass("module", child)); } else if (name.equals("resourceFinderModule")) { rsrcModules.add(loadClass("module", child)); } } // after loading the modules, use the collections to setup a // PDPConfig based on this pdp element AttributeFinder attrFinder = new AttributeFinder(); attrFinder.setModules(attrModules); PolicyFinder policyFinder = new PolicyFinder(); policyFinder.setModules(policyModules); ResourceFinder rsrcFinder = new ResourceFinder(); rsrcFinder.setModules(rsrcModules); return new PDPConfig(attrFinder, policyFinder, rsrcFinder); }
if (useStandard(root, "useStandardAlgorithms")) { logger.config("Starting with standard Combining Algorithms"); (CombiningAlgorithm)(loadClass("algorithm", child)); try { factory.addAlgorithm(alg);
args = getArgs(root); } catch (IllegalArgumentException iae) { throw new ParsingException("illegal class arguments", iae);