Search in sources :

Example 41 with X509CertificateEx

use of org.nhindirect.stagent.cert.X509CertificateEx in project nhin-d by DirectProject.

the class CacheableKeyStoreManagerCertificateStore_containsTest method testContains_existingCert_assertFound.

public void testContains_existingCert_assertFound() throws Exception {
    if (store != null) {
        // add a certificate
        final X509CertificateEx user1 = (X509CertificateEx) TestUtils.getInternalCert("user1");
        store.add(user1);
        assertTrue(store.contains(user1));
    }
}
Also used : X509CertificateEx(org.nhindirect.stagent.cert.X509CertificateEx)

Example 42 with X509CertificateEx

use of org.nhindirect.stagent.cert.X509CertificateEx in project nhin-d by DirectProject.

the class CacheableKeyStoreManagerCertificateStore_getAllCertificateTest method testGetGetAllCertificates_singleCertificatesInstalled_assertCertificateRetrieved.

public void testGetGetAllCertificates_singleCertificatesInstalled_assertCertificateRetrieved() throws Exception {
    if (store != null) {
        // add a certificate
        final X509CertificateEx user1 = (X509CertificateEx) TestUtils.getInternalCert("user1");
        store.add(user1);
        final Collection<X509Certificate> retrievedCerts = store.getAllCertificates();
        assertEquals(1, retrievedCerts.size());
        final X509Certificate retrievedCert = retrievedCerts.iterator().next();
        assertTrue(retrievedCert instanceof X509CertificateEx);
        assertEquals(user1, retrievedCert);
    }
}
Also used : X509CertificateEx(org.nhindirect.stagent.cert.X509CertificateEx) X509Certificate(java.security.cert.X509Certificate)

Example 43 with X509CertificateEx

use of org.nhindirect.stagent.cert.X509CertificateEx in project nhin-d by DirectProject.

the class CacheableKeyStoreManagerCertificateStore_getCertificatesTest method testGetCertificate_existingCertsInStore_findByEmailAddress_assertFound.

public void testGetCertificate_existingCertsInStore_findByEmailAddress_assertFound() throws Exception {
    if (store != null) {
        // add a certificate
        final X509CertificateEx user1 = (X509CertificateEx) TestUtils.getInternalCert("user1");
        store.add(user1);
        final Collection<X509Certificate> retrievedCerts = store.getCertificates(new InternetAddress("user1@cerner.com"));
        assertEquals(1, retrievedCerts.size());
        final X509Certificate retrievedCert = retrievedCerts.iterator().next();
        assertTrue(retrievedCert instanceof X509CertificateEx);
        assertEquals(user1, retrievedCert);
    }
}
Also used : InternetAddress(javax.mail.internet.InternetAddress) X509CertificateEx(org.nhindirect.stagent.cert.X509CertificateEx) X509Certificate(java.security.cert.X509Certificate)

Example 44 with X509CertificateEx

use of org.nhindirect.stagent.cert.X509CertificateEx in project nhin-d by DirectProject.

the class CacheableKeyStoreManagerCertificateStore_getCertificatesTest method testGetCertificate_existingCertsInStore_assertFound.

public void testGetCertificate_existingCertsInStore_assertFound() throws Exception {
    if (store != null) {
        // add a certificate
        final X509CertificateEx user1 = (X509CertificateEx) TestUtils.getInternalCert("user1");
        store.add(user1);
        final Collection<X509Certificate> retrievedCerts = store.getCertificates("user1@cerner.com");
        assertEquals(1, retrievedCerts.size());
        final X509Certificate retrievedCert = retrievedCerts.iterator().next();
        assertTrue(retrievedCert instanceof X509CertificateEx);
        assertEquals(user1, retrievedCert);
    }
}
Also used : X509CertificateEx(org.nhindirect.stagent.cert.X509CertificateEx) X509Certificate(java.security.cert.X509Certificate)

Example 45 with X509CertificateEx

use of org.nhindirect.stagent.cert.X509CertificateEx 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)

Aggregations

X509CertificateEx (org.nhindirect.stagent.cert.X509CertificateEx)51 X509Certificate (java.security.cert.X509Certificate)39 MimeEntity (org.nhindirect.stagent.mail.MimeEntity)18 SMIMECryptographerImpl (org.nhindirect.stagent.cryptography.SMIMECryptographerImpl)13 IOException (java.io.IOException)11 KeyStore (java.security.KeyStore)11 NHINDException (org.nhindirect.stagent.NHINDException)9 ByteArrayInputStream (java.io.ByteArrayInputStream)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 Key (java.security.Key)6 PrivateKey (java.security.PrivateKey)6 File (java.io.File)5 Certificate (java.security.cert.Certificate)5 MimeMultipart (javax.mail.internet.MimeMultipart)5 SMIMEEnveloped (org.bouncycastle.mail.smime.SMIMEEnveloped)5 LdapCertificateStoreProvider (org.nhindirect.stagent.cert.impl.provider.LdapCertificateStoreProvider)5 SignedEntity (org.nhindirect.stagent.cryptography.SignedEntity)5 ArrayList (java.util.ArrayList)4 MessagingException (javax.mail.MessagingException)4 RecipientInformation (org.bouncycastle.cms.RecipientInformation)4