use of org.apache.cxf.xkms.model.xkms.UseKeyWithType 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);
}
use of org.apache.cxf.xkms.model.xkms.UseKeyWithType in project cxf by apache.
the class LDAPCertificateRepoTest method testSaveUserCert.
@Test
public void testSaveUserCert() throws Exception {
IMocksControl c = EasyMock.createControl();
LdapSearch ldapSearch = c.createMock(LdapSearch.class);
ldapSearch.bind(EasyMock.eq(EXPECTED_SUBJECT_DN2 + "," + ROOT_DN), EasyMock.anyObject(Attributes.class));
EasyMock.expectLastCall().once();
LdapCertificateRepo ldapCertRepo = new LdapCertificateRepo(ldapSearch, LDAP_CERT_CONFIG, ROOT_DN);
X509Certificate cert = getTestCert();
c.replay();
UseKeyWithType key = new UseKeyWithType();
key.setApplication(Applications.PKIX.getUri());
key.setIdentifier(EXPECTED_SUBJECT_DN2);
ldapCertRepo.saveCertificate(cert, key);
c.verify();
}
use of org.apache.cxf.xkms.model.xkms.UseKeyWithType in project cxf by apache.
the class XKMSServiceTest method testLocatePKIX.
@Test
public void testLocatePKIX() throws URISyntaxException, Exception {
LocateRequestType request = XKMS_OF.createLocateRequestType();
setGenericRequestParams(request);
QueryKeyBindingType queryKeyBindingType = XKMS_OF.createQueryKeyBindingType();
UseKeyWithType useKeyWithType = XKMS_OF.createUseKeyWithType();
useKeyWithType.setIdentifier("CN=Dave, OU=Apache, O=CXF, L=CGN, ST=NRW, C=DE");
useKeyWithType.setApplication(Applications.PKIX.getUri());
locateCertificate(request, queryKeyBindingType, useKeyWithType);
}
use of org.apache.cxf.xkms.model.xkms.UseKeyWithType in project cxf by apache.
the class XKMSServiceTest method testLocateByEndpoint.
@Test
public void testLocateByEndpoint() throws URISyntaxException, Exception {
LocateRequestType request = XKMS_OF.createLocateRequestType();
setGenericRequestParams(request);
QueryKeyBindingType queryKeyBindingType = XKMS_OF.createQueryKeyBindingType();
UseKeyWithType useKeyWithType = XKMS_OF.createUseKeyWithType();
useKeyWithType.setIdentifier("http://localhost:8080/services/TestService");
useKeyWithType.setApplication(Applications.SERVICE_ENDPOINT.getUri());
locateCertificate(request, queryKeyBindingType, useKeyWithType);
}
use of org.apache.cxf.xkms.model.xkms.UseKeyWithType in project cxf by apache.
the class X509Locator method locate.
@Override
public UnverifiedKeyBindingType locate(LocateRequestType request) {
List<UseKeyWithType> keyIDs = parse(request);
X509Certificate cert;
try {
cert = findCertificate(keyIDs);
if (cert == null) {
return null;
}
UnverifiedKeyBindingType result = new UnverifiedKeyBindingType();
result.setKeyInfo(X509Utils.getKeyInfo(cert));
return result;
} catch (CertificateEncodingException e) {
throw new XKMSCertificateException("Cannot encode certificate: " + e.getMessage(), e);
} catch (CertificateException e1) {
throw new XKMSCertificateException(e1.getMessage(), e1);
}
}
Aggregations