eu.xtreemos.xosd.security.vops.xacml.utils
Class XmlPolicyModule

java.lang.Object
  extended by com.sun.xacml.finder.PolicyFinderModule
      extended by eu.xtreemos.xosd.security.vops.xacml.utils.XmlPolicyModule
All Implemented Interfaces:
org.xml.sax.ErrorHandler

public class XmlPolicyModule
extends com.sun.xacml.finder.PolicyFinderModule
implements org.xml.sax.ErrorHandler

This module represents a collection of files containing polices, each of which will be searched through when trying to find a policy that is applicable to a specific request.

Note: this module is provided only as an example and for testing purposes. It is not part of the standard, and it should not be relied upon for production systems. In the future, this will likely be moved into a package with other similar example and testing code.

Since:
1.0
Author:
Seth Proctor, ales.cernivec@xlab.si

Field Summary
private  com.sun.xacml.finder.PolicyFinder finder
           
static java.lang.String JAXP_SCHEMA_LANGUAGE
           
static java.lang.String JAXP_SCHEMA_SOURCE
           
private static java.util.logging.Logger logger
           
private  java.util.Set policies
           
private  java.util.Set policiesSource
           
static java.lang.String POLICY_SCHEMA_PROPERTY
          The property which is used to specify the schema file to validate against (if any)
private  java.io.File schemaFile
           
static java.lang.String W3C_XML_SCHEMA
           
 
Constructor Summary
XmlPolicyModule()
          Constructor which retrieves the schema file to validate policies against from the POLICY_SCHEMA_PROPERTY.
XmlPolicyModule(java.io.File schemaFile)
          Constructor that uses the specified input as the schema file to validate policies against.
XmlPolicyModule(java.util.List policies)
          Constructor that specifies a set of initial policy files to use.
 
Method Summary
 boolean addPolicy(java.lang.String policyString)
          Adds a string (containing a policy) to the collection of policy strings (sources) associated with this module.
 void error(org.xml.sax.SAXParseException exception)
          Standard handler routine for the XML parsing.
 void fatalError(org.xml.sax.SAXParseException exception)
          Standard handler routine for the XML parsing.
 com.sun.xacml.finder.PolicyFinderResult findPolicy(com.sun.xacml.EvaluationCtx context)
          Finds a policy based on a request's context.
 java.util.Set getPolicies()
           
 void init(com.sun.xacml.finder.PolicyFinder finder)
          Initializes the FilePolicyModule by loading the policies contained in the collection of files associated with this module.
 boolean isRequestSupported()
          Indicates whether this module supports finding policies based on a request (target matching).
static com.sun.xacml.AbstractPolicy loadPolicy(java.lang.String policySource, com.sun.xacml.finder.PolicyFinder finder)
          Loads a policy from the specified string and uses the specified PolicyFinder to help with instantiating PolicySets.
static com.sun.xacml.AbstractPolicy loadPolicy(java.lang.String policySource, com.sun.xacml.finder.PolicyFinder finder, java.io.File schemaFile, org.xml.sax.ErrorHandler handler)
          Loads a policy from the specified filename, using the specified PolicyFinder to help with instantiating PolicySets, and using the specified input as the schema file to validate policies against.
static com.sun.xacml.AbstractPolicy loadPolicyFromString(java.lang.String policySource, com.sun.xacml.finder.PolicyFinder finder, java.io.File schemaFile, org.xml.sax.ErrorHandler handler)
          Loads a policy from the specified string, using the specified PolicyFinder to help with instantiating PolicySets, and using the specified input as the schema file to validate policies against.
 void warning(org.xml.sax.SAXParseException exception)
          Standard handler routine for the XML parsing.
 
Methods inherited from class com.sun.xacml.finder.PolicyFinderModule
findPolicy, getIdentifier, invalidateCache, isIdReferenceSupported
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POLICY_SCHEMA_PROPERTY

public static final java.lang.String POLICY_SCHEMA_PROPERTY
The property which is used to specify the schema file to validate against (if any)

See Also:
Constant Field Values

JAXP_SCHEMA_LANGUAGE

public static final java.lang.String JAXP_SCHEMA_LANGUAGE
See Also:
Constant Field Values

W3C_XML_SCHEMA

public static final java.lang.String W3C_XML_SCHEMA
See Also:
Constant Field Values

JAXP_SCHEMA_SOURCE

public static final java.lang.String JAXP_SCHEMA_SOURCE
See Also:
Constant Field Values

finder

private com.sun.xacml.finder.PolicyFinder finder

schemaFile

private java.io.File schemaFile

policiesSource

private java.util.Set policiesSource

policies

private java.util.Set policies

logger

private static final java.util.logging.Logger logger
Constructor Detail

XmlPolicyModule

public XmlPolicyModule()
Constructor which retrieves the schema file to validate policies against from the POLICY_SCHEMA_PROPERTY. If the retrieved property is null, then no schema validation will occur.


XmlPolicyModule

public XmlPolicyModule(java.io.File schemaFile)
Constructor that uses the specified input as the schema file to validate policies against. If schema validation is not desired, a null value should be used.

Parameters:
schemaFile - the schema file to validate policies against, or null if schema validation is not desired.

XmlPolicyModule

public XmlPolicyModule(java.util.List policies)
Constructor that specifies a set of initial policy files to use. No schema validation is performed.

Parameters:
fileNames - a List of Strings that policies
Method Detail

isRequestSupported

public boolean isRequestSupported()
Indicates whether this module supports finding policies based on a request (target matching). Since this module does support finding policies based on requests, it returns true.

Overrides:
isRequestSupported in class com.sun.xacml.finder.PolicyFinderModule
Returns:
true, since finding policies based on requests is supported

init

public void init(com.sun.xacml.finder.PolicyFinder finder)
Initializes the FilePolicyModule by loading the policies contained in the collection of files associated with this module. This method also uses the specified PolicyFinder to help in instantiating PolicySets.

Specified by:
init in class com.sun.xacml.finder.PolicyFinderModule
Parameters:
finder - a PolicyFinder used to help in instantiating PolicySets

addPolicy

public boolean addPolicy(java.lang.String policyString)
Adds a string (containing a policy) to the collection of policy strings (sources) associated with this module.

Parameters:
filename - the file to add to this module's collection of files

loadPolicy

public static com.sun.xacml.AbstractPolicy loadPolicy(java.lang.String policySource,
                                                      com.sun.xacml.finder.PolicyFinder finder)
Loads a policy from the specified string and uses the specified PolicyFinder to help with instantiating PolicySets.

Parameters:
policySource - the string to load the policy from
finder - a PolicyFinder used to help in instantiating PolicySets
Returns:
a (potentially schema-validated) policy associated with the specified filename, or null if there was an error

loadPolicyFromString

public static com.sun.xacml.AbstractPolicy loadPolicyFromString(java.lang.String policySource,
                                                                com.sun.xacml.finder.PolicyFinder finder,
                                                                java.io.File schemaFile,
                                                                org.xml.sax.ErrorHandler handler)
Loads a policy from the specified string, using the specified PolicyFinder to help with instantiating PolicySets, and using the specified input as the schema file to validate policies against. If schema validation is not desired, a null value should be used for schemaFile

Parameters:
policySource - the source string to load the policy from
finder - a PolicyFinder used to help in instantiating PolicySets
schemaFile - the schema file to validate policies against, or null if schema validation is not desired
handler - an error handler used to print warnings and errors during parsing
Returns:
a (potentially schema-validated) policy associated with the specified filename, or null if there was an error

loadPolicy

public static com.sun.xacml.AbstractPolicy loadPolicy(java.lang.String policySource,
                                                      com.sun.xacml.finder.PolicyFinder finder,
                                                      java.io.File schemaFile,
                                                      org.xml.sax.ErrorHandler handler)
Loads a policy from the specified filename, using the specified PolicyFinder to help with instantiating PolicySets, and using the specified input as the schema file to validate policies against. If schema validation is not desired, a null value should be used for schemaFile

Parameters:
filename - the file to load the policy from
finder - a PolicyFinder used to help in instantiating PolicySets
schemaFile - the schema file to validate policies against, or null if schema validation is not desired
handler - an error handler used to print warnings and errors during parsing
Returns:
a (potentially schema-validated) policy associated with the specified filename, or null if there was an error

findPolicy

public com.sun.xacml.finder.PolicyFinderResult findPolicy(com.sun.xacml.EvaluationCtx context)
Finds a policy based on a request's context. This may involve using the request data as indexing data to lookup a policy. This will always do a Target match to make sure that the given policy applies. If more than one applicable policy is found, this will return an error. NOTE: this is basically just a subset of the OnlyOneApplicable Policy Combining Alg that skips the evaluation step. See comments in there for details on this algorithm.

Overrides:
findPolicy in class com.sun.xacml.finder.PolicyFinderModule
Parameters:
context - the representation of the request data
Returns:
the result of trying to find an applicable policy

warning

public void warning(org.xml.sax.SAXParseException exception)
             throws org.xml.sax.SAXException
Standard handler routine for the XML parsing.

Specified by:
warning in interface org.xml.sax.ErrorHandler
Parameters:
exception - information on what caused the problem
Throws:
org.xml.sax.SAXException

error

public void error(org.xml.sax.SAXParseException exception)
           throws org.xml.sax.SAXException
Standard handler routine for the XML parsing.

Specified by:
error in interface org.xml.sax.ErrorHandler
Parameters:
exception - information on what caused the problem
Throws:
org.xml.sax.SAXException - always to halt parsing on errors

fatalError

public void fatalError(org.xml.sax.SAXParseException exception)
                throws org.xml.sax.SAXException
Standard handler routine for the XML parsing.

Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Parameters:
exception - information on what caused the problem
Throws:
org.xml.sax.SAXException - always to halt parsing on errors

getPolicies

public java.util.Set getPolicies()