public interface Compiler
PolicyExpression tree. The compiler consumes
the parsed expressions and generates an ordered vector of Opcode objects that are specific to a particular ExecutionEngine.
The resulting vector is then fed to the engine to evaluate the boolean result of the expression.
By default, the compile operation throws a PolicyRequiredException exception if a required attribute is missing in the provided certificate. This
halts the evaluation process immediately at the point the first missing required field is encountered. However, there are use cases, such as a policy
validation tool, where a generating a complete list of missing fields may be useful. In addition, it may desired to process the certificate through the
execution engine even though it is known that required fields are missing. Obviously this is not the most efficient operating mode when executing inside
of an environment where the only result of interest is the simple binary decision of policy compliance.
To enable the ability to retrieve a list of all known missing fields (or other compilation errors), the compiler supports a report mode that can
be enabled by calling the setReportModeEnabled(boolean) method. When reporting mode is turned on, the compiler will no longer throw an exception
when a required attribute is missing. After compilation is complete, a collection of all compilation issues can be retrieved by calling
the getCompilationReport() method.
| Modifier and Type | Method and Description |
|---|---|
Vector<Opcode> |
compile(X509Certificate cert,
PolicyExpression expression)
Compiles the given certificate and a parsed
PolicyExpression tree in a series of executables Opcode objects. |
Collection<String> |
getCompilationReport()
Gets a collection of compilation issues.
|
boolean |
isReportModeEnabled()
Indicates whether or not the compiler is in report mode.
|
void |
setReportModeEnabled(boolean reportMode)
Sets or removes the compiler from report mode.
|
Vector<Opcode> compile(X509Certificate cert, PolicyExpression expression) throws PolicyProcessException
PolicyExpression tree in a series of executables Opcode objects.
Implementations should be thread same meaning multiple expressions can be compiled concurrently with the same compiler.
cert - The certificate that will be evaluated for policy compliance.expression - The parsed expression tree.Opcode objects that are fed into an ExecutionEngine for final evaluation of policy compliance.PolicyProcessException - Thrown if a required certificate attribute does not exist in the given certification. However, this exception
is suppressed if the compiler is placed into report model.void setReportModeEnabled(boolean reportMode)
reportMode - true if the compiler is to be set into report mode. false otherwiseboolean isReportModeEnabled()
Collection<String> getCompilationReport()
The collection is reset each time a compilation occurs. For concurrent compilation, the generated report is specific to the thread that compilation process was executed on.
Copyright © 2010-2016 The Direct Project. All Rights Reserved.