Search in sources :

Example 6 with LdapCertificateStoreProvider

use of org.nhindirect.stagent.cert.impl.provider.LdapCertificateStoreProvider in project nhin-d by DirectProject.

the class LdapCertificateStoreTest method testLdapSearch_MultipleX509Certificates.

public void testLdapSearch_MultipleX509Certificates() throws Exception {
    addCertificatesToLdap(new String[] { "certs/bob.der", "certs/cacert.der" });
    int port = configuration.getLdapPort();
    String url = "ldap://localhost:" + port + "/" + "cn=lookupTest";
    LdapStoreConfiguration ldapStoreConfiguration = new LdapStoreConfiguration(new String[] { url }, "", "email", "privKeyStore", "X509");
    LdapCertificateStoreProvider provider = new LdapCertificateStoreProvider(ldapStoreConfiguration, null, null);
    LDAPCertificateStore certificateResolver = (LDAPCertificateStore) provider.get();
    certificateResolver.flush(true);
    Collection<X509Certificate> certs = certificateResolver.getCertificates("gm2552@cerner.com");
    assertEquals(2, certs.size());
    Iterator<X509Certificate> iterator = certs.iterator();
    X509Certificate cert = iterator.next();
    assertFalse(cert instanceof X509CertificateEx);
    assertTrue(cert.getSubjectX500Principal().toString().contains("bob@nhind.hsgincubator.com"));
    cert = iterator.next();
    assertFalse(cert instanceof X509CertificateEx);
    assertTrue(cert.getSubjectX500Principal().toString().contains("gmeyer@cerner.com"));
}
Also used : X509CertificateEx(org.nhindirect.stagent.cert.X509CertificateEx) PublicLdapCertificateStoreProvider(org.nhindirect.stagent.cert.impl.provider.PublicLdapCertificateStoreProvider) LdapCertificateStoreProvider(org.nhindirect.stagent.cert.impl.provider.LdapCertificateStoreProvider) X509Certificate(java.security.cert.X509Certificate)

Example 7 with LdapCertificateStoreProvider

use of org.nhindirect.stagent.cert.impl.provider.LdapCertificateStoreProvider in project nhin-d by DirectProject.

the class LdapCertificateStoreTest method testLdapSearch_X509Certificate.

public void testLdapSearch_X509Certificate() throws Exception {
    addCertificatesToLdap(new String[] { "certs/bob.der" });
    int port = configuration.getLdapPort();
    String url = "ldap://localhost:" + port + "/" + "cn=lookupTest";
    LdapStoreConfiguration ldapStoreConfiguration = new LdapStoreConfiguration(new String[] { url }, "", "email", "privKeyStore", "X509");
    LdapCertificateStoreProvider provider = new LdapCertificateStoreProvider(ldapStoreConfiguration, null, null);
    LDAPCertificateStore certificateResolver = (LDAPCertificateStore) provider.get();
    Collection<X509Certificate> certs = certificateResolver.getCertificates("gm2552@cerner.com");
    assertEquals(1, certs.size());
    X509Certificate cert = certs.iterator().next();
    assertFalse(cert instanceof X509CertificateEx);
    assertTrue(cert.getSubjectX500Principal().toString().contains("bob@nhind.hsgincubator.com"));
}
Also used : X509CertificateEx(org.nhindirect.stagent.cert.X509CertificateEx) PublicLdapCertificateStoreProvider(org.nhindirect.stagent.cert.impl.provider.PublicLdapCertificateStoreProvider) LdapCertificateStoreProvider(org.nhindirect.stagent.cert.impl.provider.LdapCertificateStoreProvider) X509Certificate(java.security.cert.X509Certificate)

Example 8 with LdapCertificateStoreProvider

use of org.nhindirect.stagent.cert.impl.provider.LdapCertificateStoreProvider in project nhin-d by DirectProject.

the class LdapCertificateStoreTest method testLdapSearch_LdapProviderSupportsMultipleURLs.

public void testLdapSearch_LdapProviderSupportsMultipleURLs() throws Exception {
    addCertificatesToLdap(new String[] { "certs/bob.der" });
    int port = configuration.getLdapPort();
    String url = "ldap://localhost:" + port + "/" + "cn=lookupTest";
    port = port + 10;
    String fakeUrl = "ldap://localhost:" + port + "/" + "cn=lookupTest";
    LdapStoreConfiguration ldapStoreConfiguration = new LdapStoreConfiguration(new String[] { fakeUrl, url }, "", "email", "privKeyStore", "X509");
    LdapCertificateStoreProvider provider = new LdapCertificateStoreProvider(ldapStoreConfiguration, null, null);
    LDAPCertificateStore certificateResolver = (LDAPCertificateStore) provider.get();
    Collection<X509Certificate> certs = certificateResolver.getCertificates("gm2552@cerner.com");
    assertEquals(1, certs.size());
    X509Certificate cert = certs.iterator().next();
    assertFalse(cert instanceof X509CertificateEx);
    assertTrue(cert.getSubjectX500Principal().toString().contains("bob@nhind.hsgincubator.com"));
}
Also used : X509CertificateEx(org.nhindirect.stagent.cert.X509CertificateEx) PublicLdapCertificateStoreProvider(org.nhindirect.stagent.cert.impl.provider.PublicLdapCertificateStoreProvider) LdapCertificateStoreProvider(org.nhindirect.stagent.cert.impl.provider.LdapCertificateStoreProvider) X509Certificate(java.security.cert.X509Certificate)

Aggregations

LdapCertificateStoreProvider (org.nhindirect.stagent.cert.impl.provider.LdapCertificateStoreProvider)8 PublicLdapCertificateStoreProvider (org.nhindirect.stagent.cert.impl.provider.PublicLdapCertificateStoreProvider)6 X509Certificate (java.security.cert.X509Certificate)5 X509CertificateEx (org.nhindirect.stagent.cert.X509CertificateEx)5 LdapStoreConfiguration (org.nhindirect.stagent.cert.impl.LdapStoreConfiguration)4 SmtpAgentException (org.nhindirect.gateway.smtp.SmtpAgentException)3 EmployLdapAuthInformation (org.nhindirect.stagent.cert.impl.EmployLdapAuthInformation)3 LDAPCertificateStore (org.nhindirect.stagent.cert.impl.LDAPCertificateStore)3 AddressException (javax.mail.internet.AddressException)2 PolicyParseException (org.nhindirect.policy.PolicyParseException)2 IOException (java.io.IOException)1 CertificateException (java.security.cert.CertificateException)1 Hashtable (java.util.Hashtable)1 InitialContext (javax.naming.InitialContext)1 NamingEnumeration (javax.naming.NamingEnumeration)1 Attribute (javax.naming.directory.Attribute)1 Attributes (javax.naming.directory.Attributes)1 BasicAttribute (javax.naming.directory.BasicAttribute)1 BasicAttributes (javax.naming.directory.BasicAttributes)1 DirContext (javax.naming.directory.DirContext)1