Search in sources :

Example 11 with CertificateRepo

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

the class TrustedAuthorityValidatorCRLTest method setUpCertificateRepo.

@Before
public void setUpCertificateRepo() throws CertificateException {
    File storageDir = new File("target/teststore_trusted_authority_validator");
    FileUtils.removeDir(storageDir);
    storageDir.mkdirs();
    certificateRepo = new FileCertificateRepo("target/teststore_trusted_authority_validator");
    UseKeyWithType rootKey = new UseKeyWithType();
    rootKey.setApplication(Applications.PKIX.getUri());
    String subjectDN = certificateRoot.getSubjectX500Principal().getName();
    rootKey.setIdentifier(subjectDN);
    certificateRepo.saveTrustedCACertificate(certificateRoot, rootKey);
    UseKeyWithType aliceKey = new UseKeyWithType();
    aliceKey.setApplication(Applications.PKIX.getUri());
    subjectDN = certificateWss40Rev.getSubjectX500Principal().getName();
    aliceKey.setIdentifier(subjectDN);
    certificateRepo.saveCACertificate(certificateWss40Rev, aliceKey);
    UseKeyWithType bobKey = new UseKeyWithType();
    bobKey.setApplication(Applications.PKIX.getUri());
    subjectDN = certificateWss40.getSubjectX500Principal().getName();
    bobKey.setIdentifier(subjectDN);
    certificateRepo.saveCACertificate(certificateWss40, bobKey);
    UseKeyWithType crlKey = new UseKeyWithType();
    crlKey.setApplication(Applications.PKIX.getUri());
    crlKey.setIdentifier(crl.getIssuerX500Principal().getName());
    certificateRepo.saveCRL(crl, crlKey);
}
Also used : UseKeyWithType(org.apache.cxf.xkms.model.xkms.UseKeyWithType) File(java.io.File) FileCertificateRepo(org.apache.cxf.xkms.x509.repo.file.FileCertificateRepo) Before(org.junit.Before)

Example 12 with CertificateRepo

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

the class LDAPCertificateRepoTest method testSave.

@Test
public void testSave() throws Exception {
    CertificateRepo persistenceManager = createLdapCertificateRepo();
    URL url = this.getClass().getResource("cert1.cer");
    CertificateFactory factory = CertificateFactory.getInstance("X.509");
    X509Certificate cert = (X509Certificate) factory.generateCertificate(url.openStream());
    assertNotNull(cert);
    UseKeyWithType key = new UseKeyWithType();
    key.setApplication(Applications.PKIX.getUri());
    key.setIdentifier(EXPECTED_SUBJECT_DN2);
    persistenceManager.saveCertificate(cert, key);
    X509Certificate foundCert = persistenceManager.findBySubjectDn(EXPECTED_SUBJECT_DN2);
    assertNotNull(foundCert);
}
Also used : UseKeyWithType(org.apache.cxf.xkms.model.xkms.UseKeyWithType) LdapCertificateRepo(org.apache.cxf.xkms.x509.repo.ldap.LdapCertificateRepo) CertificateRepo(org.apache.cxf.xkms.x509.repo.CertificateRepo) CertificateFactory(java.security.cert.CertificateFactory) URL(java.net.URL) X509Certificate(java.security.cert.X509Certificate) Test(org.junit.Test)

Example 13 with CertificateRepo

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

the class LDAPCertificateRepoTest method testFindUserCertViaWrongUID.

@Test
public void testFindUserCertViaWrongUID() throws URISyntaxException, NamingException, CertificateException {
    CertificateRepo persistenceManager = createLdapCertificateRepo();
    X509Certificate cert = persistenceManager.findBySubjectDn("wrong");
    assertNull("Certificate should be null", 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 14 with CertificateRepo

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

the class LDAPCertificateRepoTest method testFindUserCert.

@Test
public void testFindUserCert() throws URISyntaxException, NamingException, CertificateException {
    CertificateRepo persistenceManager = createLdapCertificateRepo();
    X509Certificate cert = persistenceManager.findBySubjectDn(EXPECTED_SUBJECT_DN);
    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)

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