public class FilePolicyModule extends PolicyFinderModule implements ErrorHandler
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.
Modifier and Type | Field and Description |
---|---|
static String |
JAXP_SCHEMA_LANGUAGE |
static String |
JAXP_SCHEMA_SOURCE |
static String |
POLICY_SCHEMA_PROPERTY
The property which is used to specify the schema
file to validate against (if any)
|
static String |
W3C_XML_SCHEMA |
Constructor and Description |
---|
FilePolicyModule()
Constructor which retrieves the schema file to validate policies against
from the POLICY_SCHEMA_PROPERTY.
|
FilePolicyModule(File schemaFile)
Constructor that uses the specified input as the schema file to
validate policies against.
|
FilePolicyModule(List fileNames)
Constructor that specifies a set of initial policy files to use.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addPolicy(String filename)
Adds a file (containing a policy) to the collection of filenames
associated with this module.
|
void |
error(SAXParseException exception)
Standard handler routine for the XML parsing.
|
void |
fatalError(SAXParseException exception)
Standard handler routine for the XML parsing.
|
PolicyFinderResult |
findPolicy(EvaluationCtx context)
Finds a policy based on a request's context.
|
void |
init(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 AbstractPolicy |
loadPolicy(String filename,
PolicyFinder finder)
Loads a policy from the specified filename and uses the specified
PolicyFinder to help with instantiating PolicySets. |
static AbstractPolicy |
loadPolicy(String filename,
PolicyFinder finder,
File schemaFile,
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. |
void |
warning(SAXParseException exception)
Standard handler routine for the XML parsing.
|
findPolicy, getIdentifier, invalidateCache, isIdReferenceSupported
public static final String POLICY_SCHEMA_PROPERTY
public static final String JAXP_SCHEMA_LANGUAGE
public static final String W3C_XML_SCHEMA
public static final String JAXP_SCHEMA_SOURCE
public FilePolicyModule()
public FilePolicyModule(File schemaFile)
schemaFile
- the schema file to validate policies against,
or null if schema validation is not desired.public FilePolicyModule(List fileNames)
fileNames
- a List
of String
s that
identify policy filespublic boolean isRequestSupported()
isRequestSupported
in class PolicyFinderModule
public void init(PolicyFinder finder)
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.init
in class PolicyFinderModule
finder
- a PolicyFinder used to help in instantiating PolicySetspublic boolean addPolicy(String filename)
filename
- the file to add to this module's collection of filespublic static AbstractPolicy loadPolicy(String filename, PolicyFinder finder)
PolicyFinder
to help with instantiating PolicySets.filename
- the file to load the policy fromfinder
- a PolicyFinder used to help in instantiating PolicySetspublic static AbstractPolicy loadPolicy(String filename, PolicyFinder finder, File schemaFile, ErrorHandler handler)
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 schemaFilefilename
- the file to load the policy fromfinder
- a PolicyFinder used to help in instantiating PolicySetsschemaFile
- the schema file to validate policies against, or
null if schema validation is not desiredhandler
- an error handler used to print warnings and errors
during parsingpublic PolicyFinderResult findPolicy(EvaluationCtx context)
findPolicy
in class PolicyFinderModule
context
- the representation of the request datapublic void warning(SAXParseException exception) throws SAXException
warning
in interface ErrorHandler
exception
- information on what caused the problemSAXException
public void error(SAXParseException exception) throws SAXException
error
in interface ErrorHandler
exception
- information on what caused the problemSAXException
- always to halt parsing on errorspublic void fatalError(SAXParseException exception) throws SAXException
fatalError
in interface ErrorHandler
exception
- information on what caused the problemSAXException
- always to halt parsing on errorsCopyright © 2023 JBoss by Red Hat. All rights reserved.