Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7308/com/sun/xacml
Modified Files:
AbstractPolicy.java BasicEvaluationCtx.java
ConfigurationStore.java PDP.java PolicyReference.java
Target.java
Log Message:
Introduced some new, basic logging
Index: BasicEvaluationCtx.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/BasicEvaluationCtx.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** BasicEvaluationCtx.java 12 May 2004 21:27:20 -0000 1.2
--- BasicEvaluationCtx.java 4 Jun 2004 17:50:39 -0000 1.3
***************
*** 65,68 ****
--- 65,71 ----
import java.util.Set;
+ import java.util.logging.Level;
+ import java.util.logging.Logger;
+
import org.w3c.dom.Node;
***************
*** 101,104 ****
--- 104,111 ----
private boolean useCachedEnvValues;
+ // the logger we'll use for all messages
+ private static final Logger logger =
+ Logger.getLogger(BasicEvaluationCtx.class.getName());
+
/**
* Constructs a new <code>BasicEvaluationCtx</code> based on the given
***************
*** 604,607 ****
--- 611,618 ----
// we failed to find any that matched the type/issuer, or all the
// Attribute types were empty...so ask the finder
+ if (logger.isLoggable(Level.FINE))
+ logger.fine("Attribute not in request: " + id.toString() +
+ " ... querying AttributeFinder");
+
return callHelper(type, id, issuer, category, designatorType);
}
***************
*** 617,625 ****
private EvaluationResult callHelper(URI type, URI id, URI issuer,
URI category, int adType) {
! if (finder != null)
return finder.findAttribute(type, id, issuer, category,
this, adType);
! else
return new EvaluationResult(BagAttribute.createEmptyBag(type));
}
--- 628,640 ----
private EvaluationResult callHelper(URI type, URI id, URI issuer,
URI category, int adType) {
! if (finder != null) {
return finder.findAttribute(type, id, issuer, category,
this, adType);
! } else {
! logger.warning("Context tried to invoke AttributeFinder but was " +
! "not configured with one");
!
return new EvaluationResult(BagAttribute.createEmptyBag(type));
+ }
}
***************
*** 641,646 ****
Node namespaceNode, URI type,
String xpathVersion) {
! return finder.findAttribute(contextPath, namespaceNode, type, this,
! xpathVersion);
}
--- 656,668 ----
Node namespaceNode, URI type,
String xpathVersion) {
! if (finder != null) {
! return finder.findAttribute(contextPath, namespaceNode, type, this,
! xpathVersion);
! } else {
! logger.warning("Context tried to invoke AttributeFinder but was " +
! "not configured with one");
!
! return new EvaluationResult(BagAttribute.createEmptyBag(type));
! }
}
Index: AbstractPolicy.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/AbstractPolicy.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** AbstractPolicy.java 14 May 2004 18:46:21 -0000 1.10
--- AbstractPolicy.java 4 Jun 2004 17:50:39 -0000 1.11
***************
*** 56,59 ****
--- 56,62 ----
import java.util.Set;
+ import java.util.logging.Level;
+ import java.util.logging.Logger;
+
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
***************
*** 94,97 ****
--- 97,104 ----
private Set obligations;
+ // the logger we'll use for all messages
+ private static final Logger logger =
+ Logger.getLogger(AbstractPolicy.class.getName());
+
/**
* Constructor used by <code>PolicyReference</code>, which supplies
Index: PDP.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/PDP.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** PDP.java 3 May 2004 18:34:36 -0000 1.7
--- PDP.java 4 Jun 2004 17:50:39 -0000 1.8
***************
*** 60,63 ****
--- 60,66 ----
import java.util.Map;
+ import java.util.logging.Level;
+ import java.util.logging.Logger;
+
/**
***************
*** 81,84 ****
--- 84,90 ----
private ResourceFinder resourceFinder;
+ // the logger we'll use for all messages
+ private static final Logger logger = Logger.getLogger(PDP.class.getName());
+
/**
* Constructs a new <code>PDP</code> object with the given configuration
***************
*** 89,92 ****
--- 95,100 ----
*/
public PDP(PDPConfig config) {
+ logger.fine("creating a PDP");
+
attributeFinder = config.getAttributeFinder();
***************
*** 117,120 ****
--- 125,130 ----
return evaluate(new BasicEvaluationCtx(request, attributeFinder));
} catch (ParsingException pe) {
+ logger.log(Level.INFO, "the PDP receieved an invalid request", pe);
+
// there was something wrong with the request, so we return
// Indeterminate with a status of syntax error...though this
***************
*** 222,238 ****
// see if there weren't any applicable policies
! if (finderResult.notApplicable()) {
! System.err.println("couldn't find an applicable policy");
return new Result(Result.DECISION_NOT_APPLICABLE,
context.getResourceId().encode());
- }
// see if there were any errors in trying to get a policy
! if (finderResult.indeterminate()) {
! System.err.println("error in trying to find top-level policy");
return new Result(Result.DECISION_INDETERMINATE,
finderResult.getStatus(),
context.getResourceId().encode());
- }
// we found a valid policy, so we can do the evaluation
--- 232,244 ----
// see if there weren't any applicable policies
! if (finderResult.notApplicable())
return new Result(Result.DECISION_NOT_APPLICABLE,
context.getResourceId().encode());
// see if there were any errors in trying to get a policy
! if (finderResult.indeterminate())
return new Result(Result.DECISION_INDETERMINATE,
finderResult.getStatus(),
context.getResourceId().encode());
// we found a valid policy, so we can do the evaluation
Index: Target.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/Target.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Target.java 14 May 2004 18:46:22 -0000 1.7
--- Target.java 4 Jun 2004 17:50:39 -0000 1.8
***************
*** 47,50 ****
--- 47,53 ----
import java.util.List;
+ import java.util.logging.Level;
+ import java.util.logging.Logger;
+
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
***************
*** 68,71 ****
--- 71,78 ----
private List actions;
+ // the logger we'll use for all messages
+ private static final Logger logger =
+ Logger.getLogger(Target.class.getName());
+
/**
* Constructor that creates a <code>Target</code> from components.
***************
*** 251,256 ****
if (subjects != null) {
MatchResult result = checkSet(subjects, context);
! if (result.getResult() != MatchResult.MATCH)
! return result;
}
--- 258,265 ----
if (subjects != null) {
MatchResult result = checkSet(subjects, context);
! if (result.getResult() != MatchResult.MATCH) {
! logger.finer("failed to match Subjects section of Target");
! return result;
! }
}
***************
*** 258,263 ****
if (resources != null) {
MatchResult result = checkSet(resources, context);
! if (result.getResult() != MatchResult.MATCH)
return result;
}
--- 267,274 ----
if (resources != null) {
MatchResult result = checkSet(resources, context);
! if (result.getResult() != MatchResult.MATCH) {
! logger.finer("failed to match Resources section of Target");
return result;
+ }
}
***************
*** 265,270 ****
if (actions != null) {
MatchResult result = checkSet(actions, context);
! if (result.getResult() != MatchResult.MATCH)
return result;
}
--- 276,283 ----
if (actions != null) {
MatchResult result = checkSet(actions, context);
! if (result.getResult() != MatchResult.MATCH) {
! logger.finer("failed to match Actions section of Target");
return result;
+ }
}
Index: ConfigurationStore.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/ConfigurationStore.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** ConfigurationStore.java 27 May 2004 19:39:35 -0000 1.6
--- ConfigurationStore.java 4 Jun 2004 17:50:39 -0000 1.7
***************
*** 81,84 ****
--- 81,87 ----
import java.util.Set;
+ import java.util.logging.Level;
+ import java.util.logging.Logger;
+
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
***************
*** 142,145 ****
--- 145,152 ----
private HashMap functionMap;
+ // the logger we'll use for all messages
+ private static final Logger logger =
+ Logger.getLogger(ConfigurationStore.class.getName());
+
/**
* Default constructor. This constructor uses the
***************
*** 157,160 ****
--- 164,170 ----
// make sure that the right property was set
if (configFile == null) {
+ logger.severe("A property defining a config file was expected, " +
+ "but none was provided");
+
throw new ParsingException("Config property " +
PDP_CONFIG_PROPERTY +
***************
*** 162,166 ****
}
! setupConfig(new File(configFile));
}
--- 172,182 ----
}
! try {
! setupConfig(new File(configFile));
! } catch (ParsingException pe) {
! logger.log(Level.SEVERE, "Runtime config file couldn't be loaded" +
! " so no configurations will be available", pe);
! throw pe;
! }
}
***************
*** 178,182 ****
*/
public ConfigurationStore(File configFile) throws ParsingException {
! setupConfig(configFile);
}
--- 194,204 ----
*/
public ConfigurationStore(File configFile) throws ParsingException {
! try {
! setupConfig(configFile);
! } catch (ParsingException pe) {
! logger.log(Level.SEVERE, "Runtime config file couldn't be loaded" +
! " so no configurations will be available", pe);
! throw pe;
! }
}
***************
*** 187,196 ****
*/
private void setupConfig(File configFile) throws ParsingException {
! Node root = null;
!
! System.out.println("Loading PDP configuration...");
// get the root node from the configuration file
! root = getRootNode(configFile);
// initialize all the maps
--- 209,216 ----
*/
private void setupConfig(File configFile) throws ParsingException {
! logger.config("Loading runtime configuration");
// get the root node from the configuration file
! Node root = getRootNode(configFile);
// initialize all the maps
***************
*** 227,239 ****
// that we're never loading something with the same name twice
if (childName.equals("pdp")) {
! System.out.println(" Loading PDP \"" + elementName + "\"...");
if (pdpConfigMap.containsKey(elementName))
throw new ParsingException("more that one pdp with " +
"name \"" + elementName +"\"");
pdpConfigMap.put(elementName, parsePDPConfig(child));
- System.out.println(" done");
} else if (childName.equals("attributeFactory")) {
! System.out.println(" Loading AttributeFactory \"" +
! elementName + "\"...");
if (attributeMap.containsKey(elementName))
throw new ParsingException("more that one " +
--- 247,259 ----
// that we're never loading something with the same name twice
if (childName.equals("pdp")) {
! if (logger.isLoggable(Level.CONFIG))
! logger.config("Loading PDP: " + elementName);
if (pdpConfigMap.containsKey(elementName))
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))
! logger.config("Loading AttributeFactory: " + elementName);
if (attributeMap.containsKey(elementName))
throw new ParsingException("more that one " +
***************
*** 241,248 ****
elementName +"\"");
attributeMap.put(elementName, parseAttributeFactory(child));
- System.out.println(" done");
} else if (childName.equals("combiningAlgFactory")) {
! System.out.println(" Loading CombiningAlgFactory \"" +
! elementName + "\"...");
if (combiningMap.containsKey(elementName))
throw new ParsingException("more that one " +
--- 261,268 ----
elementName +"\"");
attributeMap.put(elementName, parseAttributeFactory(child));
} else if (childName.equals("combiningAlgFactory")) {
! if (logger.isLoggable(Level.CONFIG))
! logger.config("Loading CombiningAlgFactory: " +
! elementName);
if (combiningMap.containsKey(elementName))
throw new ParsingException("more that one " +
***************
*** 250,257 ****
"name \"" + elementName +"\"");
combiningMap.put(elementName, parseCombiningAlgFactory(child));
- System.out.println(" done");
} else if (childName.equals("functionFactory")) {
! System.out.println(" Loading FunctionFactory \"" +
! elementName + "\"...");
if (functionMap.containsKey(elementName))
throw new ParsingException("more that one functionFactory"
--- 270,276 ----
"name \"" + elementName +"\"");
combiningMap.put(elementName, parseCombiningAlgFactory(child));
} else if (childName.equals("functionFactory")) {
! if (logger.isLoggable(Level.CONFIG))
! logger.config("Loading FunctionFactory: " + elementName);
if (functionMap.containsKey(elementName))
throw new ParsingException("more that one functionFactory"
***************
*** 259,263 ****
elementName +"\"");
functionMap.put(elementName, parseFunctionFactory(child));
- System.out.println(" done");
}
}
--- 278,281 ----
***************
*** 359,362 ****
--- 377,382 ----
// check if we're starting with the standard factory setup
if (useStandard(root, "useStandardDatatypes")) {
+ logger.config("Starting with standard Datatypes");
+
StandardAttributeFactory sf =
StandardAttributeFactory.getFactory();
***************
*** 401,404 ****
--- 421,426 ----
// check if we're starting with the standard factory setup
if (useStandard(root, "useStandardAlgorithms")) {
+ logger.config("Starting with standard Combining Algorithms");
+
StandardCombiningAlgFactory sf =
StandardCombiningAlgFactory.getFactory();
***************
*** 448,451 ****
--- 470,475 ----
// make sure that the proxy is pre-configured
if (useStandard(root, "useStandardFunctions")) {
+ logger.config("Starting with standard Functions");
+
proxy = StandardFunctionFactory.getNewFactoryProxy();
***************
*** 471,481 ****
if (name.equals("target")) {
! System.out.println(" [TARGET Functions]");
functionParserHelper(child, targetFactory);
} else if (name.equals("condition")) {
! System.out.println(" [CONDITION Functions]");
functionParserHelper(child, conditionFactory);
} else if (name.equals("general")) {
! System.out.println(" [GENERAL Functions]");
functionParserHelper(child, generalFactory);
}
--- 495,505 ----
if (name.equals("target")) {
! logger.config("Loading [TARGET] 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);
}
***************
*** 557,561 ****
root.getAttributes().getNamedItem("class").getNodeValue();
! System.out.print(" [ " + prefix + ": " + className + " ");
// use the system classloader to load the given class
--- 581,586 ----
root.getAttributes().getNamedItem("class").getNodeValue();
! if (logger.isLoggable(Level.CONFIG))
! logger.config("Loading [ " + prefix + ": " + className + " ]");
// use the system classloader to load the given class
***************
*** 648,653 ****
}
- System.out.println("]");
-
return instance;
}
--- 673,676 ----
***************
*** 887,890 ****
--- 910,915 ----
*/
public void useDefaultFactories() {
+ logger.fine("Switching to default factories from configuration");
+
// set the default attribute factory, if it exists here
if (defaultAttributeFactory != null) {
Index: PolicyReference.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/PolicyReference.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** PolicyReference.java 23 Mar 2004 23:38:51 -0000 1.6
--- PolicyReference.java 4 Jun 2004 17:50:39 -0000 1.7
***************
*** 54,57 ****
--- 54,60 ----
import java.util.Set;
+ import java.util.logging.Level;
+ import java.util.logging.Logger;
+
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
***************
*** 98,101 ****
--- 101,108 ----
private PolicyFinder finder;
+ // the logger we'll use for all messages
+ private static final Logger logger =
+ Logger.getLogger(PolicyReference.class.getName());
+
/**
* Creates a new <code>PolicyReference</code>.
***************
*** 271,278 ****
*/
private AbstractPolicy resolvePolicy() {
! if (finder == null)
! throw new ProcessingException("couldn't find the policy with" +
"a null finder");
PolicyFinderResult pfr = finder.findPolicy(reference, policyType);
--- 278,291 ----
*/
private AbstractPolicy resolvePolicy() {
+ // see if this reference was setup with a finder
+ if (finder == null) {
+ if (logger.isLoggable(Level.WARNING))
+ logger.warning("PolicyReference with id " +
+ reference.toString() + " was queried but was " +
+ "not configured with a PolicyFinder");
! throw new ProcessingException("couldn't find the policy with " +
"a null finder");
+ }
PolicyFinderResult pfr = finder.findPolicy(reference, policyType);
***************
*** 298,302 ****
*/
public Result evaluate(EvaluationCtx context) {
-
// if there is no finder, then we return NotApplicable
if (finder == null)
--- 311,314 ----
|