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"));
}
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"));
}
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"));
}
Aggregations