Search in sources :

Example 1 with Opcode

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

the class StackMachine_evaluateTest method testEvaluate_sizeCollection_singleEntry_assertSize1.

public void testEvaluate_sizeCollection_singleEntry_assertSize1() throws Exception {
    final Vector<Opcode> stuffToProcess = new Vector<Opcode>();
    stuffToProcess.add(new StackMachineEntry(PolicyValueFactory.getInstance(Arrays.asList("Hello"))));
    stuffToProcess.add(new StackMachineEntry(PolicyOperator.SIZE));
    stuffToProcess.add(new StackMachineEntry(PolicyValueFactory.getInstance(1)));
    stuffToProcess.add(new StackMachineEntry(PolicyOperator.EQUALS));
    final StackMachine stMachine = new StackMachine();
    assertTrue(stMachine.evaluate(stuffToProcess));
}
Also used : StackMachine(org.nhindirect.policy.impl.machine.StackMachine) StackMachineEntry(org.nhindirect.policy.impl.machine.StackMachineEntry) Opcode(org.nhindirect.policy.Opcode) Vector(java.util.Vector)

Example 2 with Opcode

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

the class StackMachine_evaluateTest method testEvaluate_equalsDifferentTypeValues_assertTrue.

public void testEvaluate_equalsDifferentTypeValues_assertTrue() throws Exception {
    final Vector<Opcode> stuffToProcess = new Vector<Opcode>();
    stuffToProcess.add(new StackMachineEntry(PolicyValueFactory.getInstance("12345")));
    stuffToProcess.add(new StackMachineEntry(PolicyValueFactory.getInstance(12345)));
    stuffToProcess.add(new StackMachineEntry(PolicyOperator.EQUALS));
    final StackMachine stMachine = new StackMachine();
    assertTrue(stMachine.evaluate(stuffToProcess));
}
Also used : StackMachine(org.nhindirect.policy.impl.machine.StackMachine) StackMachineEntry(org.nhindirect.policy.impl.machine.StackMachineEntry) Opcode(org.nhindirect.policy.Opcode) Vector(java.util.Vector)

Example 3 with Opcode

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

the class StackMachine_evaluateTest method testEvaluate_logicalAndBothTrue_assertTrue.

public void testEvaluate_logicalAndBothTrue_assertTrue() throws Exception {
    final Vector<Opcode> stuffToProcess = new Vector<Opcode>();
    stuffToProcess.add(new StackMachineEntry(PolicyValueFactory.getInstance(true)));
    stuffToProcess.add(new StackMachineEntry(PolicyValueFactory.getInstance(true)));
    stuffToProcess.add(new StackMachineEntry(PolicyOperator.LOGICAL_AND));
    final StackMachine stMachine = new StackMachine();
    assertTrue(stMachine.evaluate(stuffToProcess));
}
Also used : StackMachine(org.nhindirect.policy.impl.machine.StackMachine) StackMachineEntry(org.nhindirect.policy.impl.machine.StackMachineEntry) Opcode(org.nhindirect.policy.Opcode) Vector(java.util.Vector)

Example 4 with Opcode

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

the class StackMachine_evaluateTest method testEvaluate_logicalOrOneTrue_assertTrue.

public void testEvaluate_logicalOrOneTrue_assertTrue() throws Exception {
    Vector<Opcode> stuffToProcess = new Vector<Opcode>();
    stuffToProcess.add(new StackMachineEntry(PolicyValueFactory.getInstance(false)));
    stuffToProcess.add(new StackMachineEntry(PolicyValueFactory.getInstance(true)));
    stuffToProcess.add(new StackMachineEntry(PolicyOperator.LOGICAL_OR));
    StackMachine stMachine = new StackMachine();
    assertTrue(stMachine.evaluate(stuffToProcess));
    stuffToProcess = new Vector<Opcode>();
    stuffToProcess.add(new StackMachineEntry(PolicyValueFactory.getInstance(true)));
    stuffToProcess.add(new StackMachineEntry(PolicyValueFactory.getInstance(false)));
    stuffToProcess.add(new StackMachineEntry(PolicyOperator.LOGICAL_OR));
    stMachine = new StackMachine();
    assertTrue(stMachine.evaluate(stuffToProcess));
}
Also used : StackMachine(org.nhindirect.policy.impl.machine.StackMachine) StackMachineEntry(org.nhindirect.policy.impl.machine.StackMachineEntry) Opcode(org.nhindirect.policy.Opcode) Vector(java.util.Vector)

Example 5 with Opcode

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

the class StackMachine_evaluateTest method testEvaluate_finalStackGreaterThanSingleEntry_assertException.

public void testEvaluate_finalStackGreaterThanSingleEntry_assertException() throws Exception {
    final Vector<Opcode> stuffToProcess = new Vector<Opcode>();
    stuffToProcess.add(new StackMachineEntry(PolicyValueFactory.getInstance(false)));
    stuffToProcess.add(new StackMachineEntry(PolicyValueFactory.getInstance(false)));
    boolean exceptionOccured = false;
    final StackMachine stMachine = new StackMachine();
    try {
        stMachine.evaluate(stuffToProcess);
    } catch (IllegalStateException e) {
        exceptionOccured = true;
    }
    assertTrue(exceptionOccured);
}
Also used : StackMachine(org.nhindirect.policy.impl.machine.StackMachine) StackMachineEntry(org.nhindirect.policy.impl.machine.StackMachineEntry) Opcode(org.nhindirect.policy.Opcode) Vector(java.util.Vector)

Aggregations

Opcode (org.nhindirect.policy.Opcode)47 Vector (java.util.Vector)43 StackMachine (org.nhindirect.policy.impl.machine.StackMachine)43 StackMachineEntry (org.nhindirect.policy.impl.machine.StackMachineEntry)40 PolicyExpression (org.nhindirect.policy.PolicyExpression)7 X509Certificate (java.security.cert.X509Certificate)6 LiteralPolicyExpression (org.nhindirect.policy.LiteralPolicyExpression)5 OperationPolicyExpression (org.nhindirect.policy.OperationPolicyExpression)5 StackMachineCompiler (org.nhindirect.policy.impl.machine.StackMachineCompiler)5 Compiler (org.nhindirect.policy.Compiler)3 ExecutionEngine (org.nhindirect.policy.ExecutionEngine)3 ExtendedKeyUsageExtensionField (org.nhindirect.policy.x509.ExtendedKeyUsageExtensionField)3 KeyUsageExtensionField (org.nhindirect.policy.x509.KeyUsageExtensionField)3 File (java.io.File)1 InputStream (java.io.InputStream)1 PolicyOperatorExecutor (org.nhindirect.policy.PolicyOperatorExecutor)1