org.fcrepo.server.security
Class PolicyParser

java.lang.Object
  extended by org.fcrepo.server.security.PolicyParser

public class PolicyParser
extends Object

A validating parser for XACML policies.

This class also provides a commandline XACML validation utility.

NOTE: Although instances may be re-used, this class is not thread-safe. Use the copy() method to support concurrent parsing.


Nested Class Summary
static class PolicyParser.ThrowAllErrorHandler
          This class is a workaround to some shift in the behavior of anonymous inner classes
 
Constructor Summary
PolicyParser(InputStream schemaStream)
          Creates an instance that will validate according to the given schema.
 
Method Summary
 PolicyParser copy()
          Gets a new instance that uses the same schema as this one.
static void main(String[] args)
          Command-line utility for validating XACML policies.
 com.sun.xacml.AbstractPolicy parse(InputStream policyStream, boolean schemaValidate)
          Parses the given policy and optionally schema validates it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PolicyParser

public PolicyParser(InputStream schemaStream)
             throws IOException,
                    SAXException
Creates an instance that will validate according to the given schema.

Parameters:
schemaStream - the XSD schema to use for schema validation
Throws:
IOException - if the schema can't be read
SAXException - if the schema isn't valid
Method Detail

copy

public PolicyParser copy()
Gets a new instance that uses the same schema as this one.

Returns:
a copy of this instance

parse

public com.sun.xacml.AbstractPolicy parse(InputStream policyStream,
                                          boolean schemaValidate)
                                   throws ValidationException
Parses the given policy and optionally schema validates it.

Parameters:
policyStream - the serialized XACML policy
validate - whether to schema validate
Returns:
the parsed policy.
Throws:
ValidationException - if the given xml is not a valid policy. This will occur if it is not well-formed XML, its root element is not named Policy or PolicySet, it triggers a parse exception in the Sun libraries when constructing an AbstractPolicy from the DOM, or (if validation is true) it is not schema-valid.

main

public static void main(String[] args)
Command-line utility for validating XACML policies.

Accepts a single argument: the path to the policy instance to validate.

Also requires that the com.sun.xacml.PolicySchema system property points to the XACML schema.



Copyright © 2012 DuraSpace. All Rights Reserved.