org.fcrepo.server.security.xacml.pdp.finder.policy
Class PolicyReader

java.lang.Object
  extended by org.fcrepo.server.security.xacml.pdp.finder.policy.PolicyReader
All Implemented Interfaces:
ErrorHandler

public class PolicyReader
extends Object
implements ErrorHandler

This class is provided as a utility for reading policies from common, simple sources: InputStreams, Files, and URL s. It can optionally schema validate the policies.

Note: some of this functionality was previously provided in com.sun.xacml.finder.impl.FilePolicyModule, but as of the 2.0 release, that class has been removed. This new PolicyReader class provides much better functionality for loading policies.

Since:
2.0
Author:
Seth Proctor

Field Summary
static String POLICY_SCHEMA_PROPERTY
          The property which is used to specify the schema file to validate against (if any).
 
Constructor Summary
PolicyReader()
          Creates a PolicyReader that does not schema-validate policies.
PolicyReader(File schemaFile)
          Creates a PolicyReader that may schema-validate policies.
 
Method Summary
 void error(SAXParseException exception)
          Standard handler routine for the XML parsing.
 void fatalError(SAXParseException exception)
          Standard handler routine for the XML parsing.
 Document readPolicy(byte[] input)
           
 Document readPolicy(File file)
          Tries to read an XACML policy or policy set from the given file.
 Document readPolicy(InputStream input)
          Tries to read an XACML policy or policy set from the given stream.
 Document readPolicy(URL url)
          Tries to read an XACML policy or policy set based on the given URL.
 void warning(SAXParseException exception)
          Standard handler routine for the XML parsing.
 
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 String POLICY_SCHEMA_PROPERTY
The property which is used to specify the schema file to validate against (if any). Note that this isn't used directly by PolicyReader , but is referenced by many classes that use this class to load policies.

See Also:
Constant Field Values
Constructor Detail

PolicyReader

public PolicyReader()
Creates a PolicyReader that does not schema-validate policies.

Parameters:
finder - a PolicyFinder that is used by policy sets, which may be null only if no references are used

PolicyReader

public PolicyReader(File schemaFile)
Creates a PolicyReader that may schema-validate policies.

Parameters:
schemaFile - the schema file used to validate policies, or null if schema validation is not desired
Method Detail

readPolicy

public Document readPolicy(File file)
                    throws com.sun.xacml.ParsingException
Tries to read an XACML policy or policy set from the given file.

Parameters:
file - the file containing the policy to read
Returns:
a (potentially schema-validated) policy loaded from the given file
Throws:
com.sun.xacml.ParsingException - if an error occurs while reading or parsing the policy

readPolicy

public Document readPolicy(InputStream input)
                    throws com.sun.xacml.ParsingException
Tries to read an XACML policy or policy set from the given stream.

Parameters:
input - the stream containing the policy to read
Returns:
a (potentially schema-validated) policy loaded from the given file
Throws:
com.sun.xacml.ParsingException - if an error occurs while reading or parsing the policy

readPolicy

public Document readPolicy(byte[] input)
                    throws com.sun.xacml.ParsingException
Throws:
com.sun.xacml.ParsingException

readPolicy

public Document readPolicy(URL url)
                    throws com.sun.xacml.ParsingException
Tries to read an XACML policy or policy set based on the given URL. This may be any resolvable URL, like a file or http pointer.

Parameters:
url - a URL pointing to the policy to read
Returns:
a (potentially schema-validated) policy loaded from the given file
Throws:
com.sun.xacml.ParsingException - if an error occurs while reading or parsing the policy, or if the URL can't be resolved

warning

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

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

error

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

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

fatalError

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

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


Copyright © 2012 DuraSpace. All Rights Reserved.