use of org.apache.cxf.xkms.model.xkms.UseKeyWithType in project cxf by apache.
the class XKMSInvoker method prepareLocateXKMSRequest.
protected LocateRequestType prepareLocateXKMSRequest(List<X509AppId> ids) {
QueryKeyBindingType queryKeyBindingType = XKMS_OF.createQueryKeyBindingType();
for (X509AppId id : ids) {
UseKeyWithType useKeyWithType = XKMS_OF.createUseKeyWithType();
useKeyWithType.setIdentifier(id.getId());
useKeyWithType.setApplication(id.getApplication().getUri());
queryKeyBindingType.getUseKeyWith().add(useKeyWithType);
}
LocateRequestType locateRequestType = XKMS_OF.createLocateRequestType();
locateRequestType.setQueryKeyBinding(queryKeyBindingType);
setGenericRequestParams(locateRequestType);
return locateRequestType;
}
use of org.apache.cxf.xkms.model.xkms.UseKeyWithType in project cxf by apache.
the class X509Locator method parse.
private List<UseKeyWithType> parse(KeyInfoType keyInfo) {
List<UseKeyWithType> keyIDs = new ArrayList<>();
if (keyInfo == null) {
return keyIDs;
}
List<Object> content = keyInfo.getContent();
for (Object obj1 : content) {
if (obj1 instanceof JAXBElement) {
JAXBElement<?> keyInfoChild = (JAXBElement<?>) obj1;
if (X509Utils.X509_KEY_NAME.equals(keyInfoChild.getName())) {
UseKeyWithType keyDN = new UseKeyWithType();
keyDN.setApplication(Applications.PKIX.getUri());
keyDN.setIdentifier((String) keyInfoChild.getValue());
keyIDs.add(keyDN);
} else if (X509Utils.X509_DATA.equals(keyInfoChild.getName())) {
X509DataType x509Data = (X509DataType) keyInfoChild.getValue();
List<Object> x509DataContent = x509Data.getX509IssuerSerialOrX509SKIOrX509SubjectName();
for (Object obj2 : x509DataContent) {
if (obj2 instanceof JAXBElement) {
JAXBElement<?> x509DataChild = (JAXBElement<?>) obj2;
if (X509Utils.X509_ISSUER_SERIAL.equals(x509DataChild.getName())) {
X509IssuerSerialType x509IssuerSerial = (X509IssuerSerialType) x509DataChild.getValue();
UseKeyWithType issuer = new UseKeyWithType();
issuer.setApplication(Applications.ISSUER.getUri());
issuer.setIdentifier(x509IssuerSerial.getX509IssuerName());
keyIDs.add(issuer);
UseKeyWithType serial = new UseKeyWithType();
serial.setApplication(Applications.SERIAL.getUri());
serial.setIdentifier(x509IssuerSerial.getX509SerialNumber().toString());
keyIDs.add(serial);
} else if (X509Utils.X509_SUBJECT_NAME.equals(x509DataChild.getName())) {
UseKeyWithType keyDN = new UseKeyWithType();
keyDN.setApplication(Applications.PKIX.getUri());
keyDN.setIdentifier((String) x509DataChild.getValue());
keyIDs.add(keyDN);
}
}
}
}
}
}
return keyIDs;
}
use of org.apache.cxf.xkms.model.xkms.UseKeyWithType in project cxf by apache.
the class X509LocatorTest method prepareLocateXKMSRequest.
private LocateRequestType prepareLocateXKMSRequest() {
QueryKeyBindingType queryKeyBindingType = XKMS_OF.createQueryKeyBindingType();
UseKeyWithType useKeyWithType = XKMS_OF.createUseKeyWithType();
useKeyWithType.setIdentifier("alice");
useKeyWithType.setApplication(Applications.PKIX.getUri());
queryKeyBindingType.getUseKeyWith().add(useKeyWithType);
LocateRequestType locateRequestType = XKMS_OF.createLocateRequestType();
locateRequestType.setQueryKeyBinding(queryKeyBindingType);
setGenericRequestParams(locateRequestType);
return locateRequestType;
}
use of org.apache.cxf.xkms.model.xkms.UseKeyWithType in project cxf by apache.
the class FileCertificateRepoTest method testSaveAndFind.
@Test
public void testSaveAndFind() throws CertificateException, IOException, URISyntaxException {
File storageDir = new File("target/teststore1");
storageDir.mkdirs();
FileCertificateRepo fileRegisterHandler = new FileCertificateRepo("target/teststore1");
InputStream is = this.getClass().getResourceAsStream("/store1/" + EXPECTED_CERT_FILE_NAME);
if (is == null) {
throw new RuntimeException("Can not find path " + is + " in classpath");
}
X509Certificate cert = loadTestCert(is);
UseKeyWithType key = new UseKeyWithType();
key.setApplication(Applications.PKIX.getUri());
key.setIdentifier(EXAMPLE_SUBJECT_DN);
fileRegisterHandler.saveCertificate(cert, key);
File certFile = new File(storageDir, fileRegisterHandler.getCertPath(cert, key));
Assert.assertTrue("Cert file " + certFile + " should exist", certFile.exists());
try (FileInputStream fis = new FileInputStream(certFile)) {
X509Certificate outCert = loadTestCert(fis);
Assert.assertEquals(cert, outCert);
}
X509Certificate resultCert = fileRegisterHandler.findBySubjectDn(EXAMPLE_SUBJECT_DN);
Assert.assertNotNull(resultCert);
}
use of org.apache.cxf.xkms.model.xkms.UseKeyWithType in project cxf by apache.
the class LDAPCertificateRepoTest method testSaveServiceCert.
@Test
public void testSaveServiceCert() throws Exception {
IMocksControl c = EasyMock.createControl();
LdapSearch ldapSearch = c.createMock(LdapSearch.class);
ldapSearch.bind(EasyMock.eq(EXPECTED_DN_FOR_SERVICE + "," + 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.SERVICE_NAME.getUri());
key.setIdentifier(EXPECTED_SERVICE_URI);
ldapCertRepo.saveCertificate(cert, key);
c.verify();
}
Aggregations