use of org.apache.cxf.xkms.x509.repo.CertificateRepo in project cxf by apache.
the class LDAPCertificateRepoTest method testFindUserCertForNonExistentDn.
@Test
public void testFindUserCertForNonExistentDn() throws URISyntaxException, NamingException, CertificateException {
CertificateRepo persistenceManager = createLdapCertificateRepo();
X509Certificate cert = persistenceManager.findBySubjectDn("CN=wrong");
assertNull("Certificate should be null", cert);
}
use of org.apache.cxf.xkms.x509.repo.CertificateRepo in project cxf by apache.
the class LDAPCertificateRepoTest method testSaveServiceCert.
@Test
public void testSaveServiceCert() 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.SERVICE_NAME.getUri());
key.setIdentifier(EXPECTED_SERVICE_URI);
persistenceManager.saveCertificate(cert, key);
// Search by DN
X509Certificate foundCert = persistenceManager.findByServiceName(EXPECTED_SERVICE_URI);
assertNotNull(foundCert);
// Search by UID
foundCert = persistenceManager.findByServiceName(cert.getSubjectX500Principal().getName());
assertNotNull(foundCert);
}
use of org.apache.cxf.xkms.x509.repo.CertificateRepo in project cxf by apache.
the class LDAPCertificateRepoTest method testFindUserCertForNonExistantDn.
@Test
@Ignore
public void testFindUserCertForNonExistantDn() throws URISyntaxException, NamingException, CertificateException {
CertificateRepo persistenceManager = createLdapCertificateRepo();
X509Certificate cert = persistenceManager.findBySubjectDn("CN=wrong");
Assert.assertNull("Certifiacte should be null", cert);
}
use of org.apache.cxf.xkms.x509.repo.CertificateRepo in project cxf by apache.
the class LDAPCertificateRepoTest method testFindServiceCert.
@Test
@Ignore
public void testFindServiceCert() throws URISyntaxException, NamingException, CertificateException {
CertificateRepo persistenceManager = createLdapCertificateRepo();
String serviceUri = "cn=http:\\/\\/myservice.apache.org\\/MyServiceName,ou=services";
X509Certificate cert = persistenceManager.findByServiceName(serviceUri);
Assert.assertEquals(EXPECTED_SUBJECT_DN, cert.getSubjectDN().toString());
}
use of org.apache.cxf.xkms.x509.repo.CertificateRepo in project cxf by apache.
the class TrustedAuthorityValidatorTest 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 = certificateAlice.getSubjectX500Principal().getName();
aliceKey.setIdentifier(subjectDN);
certificateRepo.saveCACertificate(certificateAlice, aliceKey);
}
Aggregations