Search in sources :

Example 1 with Compiler

use of org.nhindirect.policy.Compiler in project nhin-d by DirectProject.

the class DefaultPolicyFilter_isCompliantTest method testIsCompliant_engineReturnsCompliant_assertTrue.

@SuppressWarnings("unchecked")
public void testIsCompliant_engineReturnsCompliant_assertTrue() throws Exception {
    final Compiler compiler = mock(Compiler.class);
    final ExecutionEngine engine = mock(ExecutionEngine.class);
    final PolicyExpression expression = mock(PolicyExpression.class);
    final X509Certificate cert = mock(X509Certificate.class);
    when(engine.evaluate((Vector<Opcode>) any())).thenReturn(true);
    final DefaultPolicyFilter filter = new DefaultPolicyFilter();
    filter.setCompiler(compiler);
    filter.setExecutionEngine(engine);
    assertTrue(filter.isCompliant(cert, expression));
}
Also used : Compiler(org.nhindirect.policy.Compiler) ExecutionEngine(org.nhindirect.policy.ExecutionEngine) Opcode(org.nhindirect.policy.Opcode) PolicyExpression(org.nhindirect.policy.PolicyExpression) X509Certificate(java.security.cert.X509Certificate)

Example 2 with Compiler

use of org.nhindirect.policy.Compiler in project nhin-d by DirectProject.

the class DefaultPolicyFilter_isCompliantTest method testIsCompliant_parse_engineReturnsCompliant_assertTrue.

@SuppressWarnings("unchecked")
public void testIsCompliant_parse_engineReturnsCompliant_assertTrue() throws Exception {
    final InputStream inStream = FileUtils.openInputStream(new File("./src/test/resources/policies/dataEnciphermentOnlyRequired.xml"));
    final Compiler compiler = mock(Compiler.class);
    final ExecutionEngine engine = mock(ExecutionEngine.class);
    final X509Certificate cert = mock(X509Certificate.class);
    when(engine.evaluate((Vector<Opcode>) any())).thenReturn(true);
    final DefaultPolicyFilter filter = new DefaultPolicyFilter();
    filter.setCompiler(compiler);
    filter.setExecutionEngine(engine);
    assertTrue(filter.isCompliant(cert, inStream, PolicyLexicon.XML));
}
Also used : Compiler(org.nhindirect.policy.Compiler) ExecutionEngine(org.nhindirect.policy.ExecutionEngine) InputStream(java.io.InputStream) Opcode(org.nhindirect.policy.Opcode) File(java.io.File) X509Certificate(java.security.cert.X509Certificate)

Example 3 with Compiler

use of org.nhindirect.policy.Compiler in project nhin-d by DirectProject.

the class DefaultPolicyFilter_isCompliantTest method testIsCompliant_engineReturnsNotCompliant_assertFalse.

@SuppressWarnings("unchecked")
public void testIsCompliant_engineReturnsNotCompliant_assertFalse() throws Exception {
    final Compiler compiler = mock(Compiler.class);
    final ExecutionEngine engine = mock(ExecutionEngine.class);
    final PolicyExpression expression = mock(PolicyExpression.class);
    final X509Certificate cert = mock(X509Certificate.class);
    when(engine.evaluate((Vector<Opcode>) any())).thenReturn(false);
    final DefaultPolicyFilter filter = new DefaultPolicyFilter();
    filter.setCompiler(compiler);
    filter.setExecutionEngine(engine);
    assertFalse(filter.isCompliant(cert, expression));
}
Also used : Compiler(org.nhindirect.policy.Compiler) ExecutionEngine(org.nhindirect.policy.ExecutionEngine) Opcode(org.nhindirect.policy.Opcode) PolicyExpression(org.nhindirect.policy.PolicyExpression) X509Certificate(java.security.cert.X509Certificate)

Aggregations

X509Certificate (java.security.cert.X509Certificate)3 Compiler (org.nhindirect.policy.Compiler)3 ExecutionEngine (org.nhindirect.policy.ExecutionEngine)3 Opcode (org.nhindirect.policy.Opcode)3 PolicyExpression (org.nhindirect.policy.PolicyExpression)2 File (java.io.File)1 InputStream (java.io.InputStream)1