Search in sources :

Example 16 with PolicyResolver

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

the class DefaultNHINDAgent_filterCertificateByPolicyTest method testFilterCertificateByPolicy_requiredFieldMissing_assertNoCertsFiltered.

public void testFilterCertificateByPolicy_requiredFieldMissing_assertNoCertsFiltered() throws Exception {
    final PolicyFilter filter = mock(PolicyFilter.class);
    doThrow(new PolicyRequiredException("Just Passing Through")).when(filter).isCompliant((X509Certificate) any(), (PolicyExpression) any());
    final PolicyExpression expression = mock(PolicyExpression.class);
    final X509Certificate cert = mock(X509Certificate.class);
    final Collection<X509Certificate> certs = Arrays.asList(cert);
    final PolicyResolver resolver = mock(PolicyResolver.class);
    when(resolver.getIncomingPolicy((InternetAddress) any())).thenReturn(Arrays.asList(expression));
    final DefaultNHINDAgent agent = new DefaultNHINDAgent("", mock(CertificateResolver.class), mock(CertificateResolver.class), mock(TrustAnchorResolver.class));
    agent.setPolicyFilter(filter);
    Collection<X509Certificate> filteredCerts = agent.filterCertificatesByPolicy(new InternetAddress("me@you.com"), resolver, certs, true);
    assertEquals(0, filteredCerts.size());
}
Also used : PolicyRequiredException(org.nhindirect.policy.PolicyRequiredException) InternetAddress(javax.mail.internet.InternetAddress) TrustAnchorResolver(org.nhindirect.stagent.trust.TrustAnchorResolver) PolicyFilter(org.nhindirect.policy.PolicyFilter) PolicyResolver(org.nhindirect.stagent.policy.PolicyResolver) PolicyExpression(org.nhindirect.policy.PolicyExpression) CertificateResolver(org.nhindirect.stagent.cert.CertificateResolver) X509Certificate(java.security.cert.X509Certificate)

Aggregations

X509Certificate (java.security.cert.X509Certificate)16 InternetAddress (javax.mail.internet.InternetAddress)16 PolicyResolver (org.nhindirect.stagent.policy.PolicyResolver)16 PolicyExpression (org.nhindirect.policy.PolicyExpression)12 CertificateResolver (org.nhindirect.stagent.cert.CertificateResolver)11 TrustAnchorResolver (org.nhindirect.stagent.trust.TrustAnchorResolver)11 PolicyFilter (org.nhindirect.policy.PolicyFilter)9 Collection (java.util.Collection)4 PolicyProcessException (org.nhindirect.policy.PolicyProcessException)2 PolicyRequiredException (org.nhindirect.policy.PolicyRequiredException)2 AgentException (org.nhindirect.stagent.AgentException)1