Search in sources :

Example 1 with CertificateRepo

use of org.apache.cxf.xkms.x509.repo.CertificateRepo in project cxf by apache.

the class LDAPCertificateRepoTest method testSave.

@Test
@Ignore
public void testSave() throws Exception {
    CertificateRepo persistenceManager = createLdapCertificateRepo();
    File certFile = new File("src/test/java/cert1.cer");
    Assert.assertTrue(certFile.exists());
    FileInputStream fis = new FileInputStream(certFile);
    CertificateFactory factory = CertificateFactory.getInstance("X.509");
    X509Certificate cert = (X509Certificate) factory.generateCertificate(fis);
    fis.close();
    UseKeyWithType key = new UseKeyWithType();
    key.setApplication(Applications.PKIX.getUri());
    key.setIdentifier(EXPECTED_SUBJECT_DN);
    persistenceManager.saveCertificate(cert, key);
    testFindBySubjectDnInternal(persistenceManager);
}
Also used : UseKeyWithType(org.apache.cxf.xkms.model.xkms.UseKeyWithType) CertificateRepo(org.apache.cxf.xkms.x509.repo.CertificateRepo) File(java.io.File) CertificateFactory(java.security.cert.CertificateFactory) FileInputStream(java.io.FileInputStream) X509Certificate(java.security.cert.X509Certificate) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with CertificateRepo

use of org.apache.cxf.xkms.x509.repo.CertificateRepo in project cxf by apache.

the class LDAPCertificateRepoTest method testFindUserCert.

@Test
@Ignore
public void testFindUserCert() throws URISyntaxException, NamingException, CertificateException {
    CertificateRepo persistenceManager = createLdapCertificateRepo();
    testFindBySubjectDnInternal(persistenceManager);
}
Also used : CertificateRepo(org.apache.cxf.xkms.x509.repo.CertificateRepo) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with CertificateRepo

use of org.apache.cxf.xkms.x509.repo.CertificateRepo in project cxf by apache.

the class X509LocatorTest method locate.

@Test
public void locate() throws CertificateException {
    CertificateRepo certRepo = EasyMock.createMock(CertificateRepo.class);
    EasyMock.expect(certRepo.findBySubjectDn(EasyMock.eq("alice"))).andReturn(getAliceCert());
    EasyMock.replay(certRepo);
    X509Locator locator = new X509Locator(certRepo);
    LocateRequestType request = prepareLocateXKMSRequest();
    UnverifiedKeyBindingType result = locator.locate(request);
    Assert.assertNotNull(result.getKeyInfo());
}
Also used : CertificateRepo(org.apache.cxf.xkms.x509.repo.CertificateRepo) LocateRequestType(org.apache.cxf.xkms.model.xkms.LocateRequestType) UnverifiedKeyBindingType(org.apache.cxf.xkms.model.xkms.UnverifiedKeyBindingType) Test(org.junit.Test)

Example 4 with CertificateRepo

use of org.apache.cxf.xkms.x509.repo.CertificateRepo in project cxf by apache.

the class LDAPCertificateRepoTest method testFindUserCertViaUID.

@Test
public void testFindUserCertViaUID() throws URISyntaxException, NamingException, CertificateException {
    CertificateRepo persistenceManager = createLdapCertificateRepo();
    X509Certificate cert = persistenceManager.findBySubjectDn("dave");
    assertNotNull(cert);
}
Also used : LdapCertificateRepo(org.apache.cxf.xkms.x509.repo.ldap.LdapCertificateRepo) CertificateRepo(org.apache.cxf.xkms.x509.repo.CertificateRepo) X509Certificate(java.security.cert.X509Certificate) Test(org.junit.Test)

Example 5 with CertificateRepo

use of org.apache.cxf.xkms.x509.repo.CertificateRepo in project cxf by apache.

the class LDAPCertificateRepoTest method createLdapCertificateRepo.

private CertificateRepo createLdapCertificateRepo() throws CertificateException {
    LdapSearch ldapSearch = new LdapSearch("ldap://localhost:" + super.getLdapServer().getPort(), "UID=admin,DC=example,DC=com", "ldap_su", 2);
    LdapSchemaConfig ldapSchemaConfig = new LdapSchemaConfig();
    ldapSchemaConfig.setAttrCrtBinary("userCertificate");
    return new LdapCertificateRepo(ldapSearch, ldapSchemaConfig, ROOT_DN);
}
Also used : LdapSchemaConfig(org.apache.cxf.xkms.x509.repo.ldap.LdapSchemaConfig) LdapSearch(org.apache.cxf.xkms.x509.repo.ldap.LdapSearch) LdapCertificateRepo(org.apache.cxf.xkms.x509.repo.ldap.LdapCertificateRepo)

Aggregations

CertificateRepo (org.apache.cxf.xkms.x509.repo.CertificateRepo)11 Test (org.junit.Test)11 X509Certificate (java.security.cert.X509Certificate)9 LdapCertificateRepo (org.apache.cxf.xkms.x509.repo.ldap.LdapCertificateRepo)7 UseKeyWithType (org.apache.cxf.xkms.model.xkms.UseKeyWithType)5 Ignore (org.junit.Ignore)4 File (java.io.File)3 CertificateFactory (java.security.cert.CertificateFactory)3 URL (java.net.URL)2 FileCertificateRepo (org.apache.cxf.xkms.x509.repo.file.FileCertificateRepo)2 Before (org.junit.Before)2 FileInputStream (java.io.FileInputStream)1 LocateRequestType (org.apache.cxf.xkms.model.xkms.LocateRequestType)1 UnverifiedKeyBindingType (org.apache.cxf.xkms.model.xkms.UnverifiedKeyBindingType)1 LdapSchemaConfig (org.apache.cxf.xkms.x509.repo.ldap.LdapSchemaConfig)1 LdapSearch (org.apache.cxf.xkms.x509.repo.ldap.LdapSearch)1