use of org.apache.cxf.xkms.model.xkms.UnverifiedKeyBindingType in project cxf by apache.
the class XKMSService method locate.
@Override
public LocateResultType locate(LocateRequestType request) {
LocateResultType response = XKMSResponseFactory.createResponse(request, new LocateResultType());
try {
validateRequest(request);
// Search
for (Locator locator : locators) {
UnverifiedKeyBindingType keyBinding = locator.locate(request);
if (keyBinding != null) {
response.getUnverifiedKeyBinding().add(keyBinding);
return response;
}
}
// No matches found
response.setResultMinor(ResultMinorEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_NO_MATCH.value());
return response;
} catch (Exception e) {
return handleException("locate", e, response);
}
}
use of org.apache.cxf.xkms.model.xkms.UnverifiedKeyBindingType in project cxf by apache.
the class X509Utils method getUnverifiedKeyBinding.
public static UnverifiedKeyBindingType getUnverifiedKeyBinding(X509Certificate cert) throws CertificateEncodingException {
UnverifiedKeyBindingType unverifiedKeyBinding = new UnverifiedKeyBindingType();
unverifiedKeyBinding.setKeyInfo(getKeyInfo(cert));
return unverifiedKeyBinding;
}
use of org.apache.cxf.xkms.model.xkms.UnverifiedKeyBindingType 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());
}
use of org.apache.cxf.xkms.model.xkms.UnverifiedKeyBindingType in project cxf by apache.
the class XKMSServiceTest method locateCertificate.
private void locateCertificate(LocateRequestType request, QueryKeyBindingType queryKeyBindingType, UseKeyWithType useKeyWithType) {
queryKeyBindingType.getUseKeyWith().add(useKeyWithType);
request.setQueryKeyBinding(queryKeyBindingType);
LocateResultType result = xkmsService.locate(request);
assertSuccess(result);
List<UnverifiedKeyBindingType> keyBinding = result.getUnverifiedKeyBinding();
Assert.assertEquals(1, keyBinding.size());
KeyInfoType keyInfo = keyBinding.get(0).getKeyInfo();
Assert.assertNotNull(keyInfo);
}
use of org.apache.cxf.xkms.model.xkms.UnverifiedKeyBindingType 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