Search in sources :

Example 11 with PolicyExpression

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

the class UniversalPolicyResolver_constructTest method testConstruct_singleExpression_assertAttributes.

public void testConstruct_singleExpression_assertAttributes() {
    final PolicyExpression expression = mock(PolicyExpression.class);
    final UniversalPolicyResolver resolver = new UniversalPolicyResolver(expression);
    assertNotNull(resolver);
    assertEquals(1, resolver.expressions.size());
    assertEquals(expression, resolver.expressions.iterator().next());
}
Also used : UniversalPolicyResolver(org.nhindirect.stagent.policy.impl.UniversalPolicyResolver) PolicyExpression(org.nhindirect.policy.PolicyExpression)

Example 12 with PolicyExpression

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

the class UniversalPolicyResolver_constructTest method testConstruct_multipleExpressions_assertAttributes.

public void testConstruct_multipleExpressions_assertAttributes() {
    final PolicyExpression expression1 = mock(PolicyExpression.class);
    final PolicyExpression expression2 = mock(PolicyExpression.class);
    final UniversalPolicyResolver resolver = new UniversalPolicyResolver(Arrays.asList(expression1, expression2));
    assertNotNull(resolver);
    assertEquals(2, resolver.expressions.size());
    final Iterator<PolicyExpression> iter = resolver.expressions.iterator();
    assertEquals(expression1, iter.next());
    assertEquals(expression2, iter.next());
}
Also used : UniversalPolicyResolver(org.nhindirect.stagent.policy.impl.UniversalPolicyResolver) PolicyExpression(org.nhindirect.policy.PolicyExpression)

Example 13 with PolicyExpression

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

the class UniversalPolicyResolver_getPolicyTest method testGetOutgoingPolicy_assertPolicyRetrieved.

public void testGetOutgoingPolicy_assertPolicyRetrieved() throws Exception {
    final PolicyExpression expression = mock(PolicyExpression.class);
    final UniversalPolicyResolver resolver = new UniversalPolicyResolver(expression);
    final Collection<PolicyExpression> policies = resolver.getOutgoingPolicy(new InternetAddress("me@you.com"));
    assertEquals(1, policies.size());
    assertEquals(expression, policies.iterator().next());
}
Also used : InternetAddress(javax.mail.internet.InternetAddress) PolicyExpression(org.nhindirect.policy.PolicyExpression)

Example 14 with PolicyExpression

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

the class UniversalPolicyResolver_getPolicyTest method testGetOutgoingPolicy_nullAddress_assertException.

public void testGetOutgoingPolicy_nullAddress_assertException() throws Exception {
    final PolicyExpression expression = mock(PolicyExpression.class);
    final UniversalPolicyResolver resolver = new UniversalPolicyResolver(expression);
    boolean execptionOccured = false;
    try {
        resolver.getOutgoingPolicy(null);
    } catch (IllegalArgumentException e) {
        execptionOccured = true;
    }
    assertTrue(execptionOccured);
}
Also used : PolicyExpression(org.nhindirect.policy.PolicyExpression)

Example 15 with PolicyExpression

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

the class UniversalPolicyResolver_getPolicyTest method testGetIncomingPolicy_nullAddress_assertException.

public void testGetIncomingPolicy_nullAddress_assertException() throws Exception {
    final PolicyExpression expression = mock(PolicyExpression.class);
    final UniversalPolicyResolver resolver = new UniversalPolicyResolver(expression);
    boolean execptionOccured = false;
    try {
        resolver.getIncomingPolicy(null);
    } catch (IllegalArgumentException e) {
        execptionOccured = true;
    }
    assertTrue(execptionOccured);
}
Also used : PolicyExpression(org.nhindirect.policy.PolicyExpression)

Aggregations

PolicyExpression (org.nhindirect.policy.PolicyExpression)54 X509Certificate (java.security.cert.X509Certificate)21 InternetAddress (javax.mail.internet.InternetAddress)18 LiteralPolicyExpression (org.nhindirect.policy.LiteralPolicyExpression)16 OperationPolicyExpression (org.nhindirect.policy.OperationPolicyExpression)16 PolicyResolver (org.nhindirect.stagent.policy.PolicyResolver)12 InputStream (java.io.InputStream)11 PolicyFilter (org.nhindirect.policy.PolicyFilter)10 Vector (java.util.Vector)9 Collection (java.util.Collection)8 HashMap (java.util.HashMap)8 Opcode (org.nhindirect.policy.Opcode)7 KeyUsageExtensionField (org.nhindirect.policy.x509.KeyUsageExtensionField)7 CertificateResolver (org.nhindirect.stagent.cert.CertificateResolver)7 TrustAnchorResolver (org.nhindirect.stagent.trust.TrustAnchorResolver)7 File (java.io.File)6 StackMachineCompiler (org.nhindirect.policy.impl.machine.StackMachineCompiler)6 ExtendedKeyUsageExtensionField (org.nhindirect.policy.x509.ExtendedKeyUsageExtensionField)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5