use of org.apache.cxf.xkms.model.xmldsig.KeyInfoType in project cxf by apache.
the class XKMSInvoker method prepareValidateXKMSRequest.
protected ValidateRequestType prepareValidateXKMSRequest(X509Certificate cert) {
JAXBElement<byte[]> x509Cert;
try {
x509Cert = DSIG_OF.createX509DataTypeX509Certificate(cert.getEncoded());
} catch (CertificateEncodingException e) {
throw new IllegalArgumentException(e);
}
X509DataType x509DataType = DSIG_OF.createX509DataType();
x509DataType.getX509IssuerSerialOrX509SKIOrX509SubjectName().add(x509Cert);
JAXBElement<X509DataType> x509Data = DSIG_OF.createX509Data(x509DataType);
KeyInfoType keyInfoType = DSIG_OF.createKeyInfoType();
keyInfoType.getContent().add(x509Data);
QueryKeyBindingType queryKeyBindingType = XKMS_OF.createQueryKeyBindingType();
queryKeyBindingType.setKeyInfo(keyInfoType);
ValidateRequestType validateRequestType = XKMS_OF.createValidateRequestType();
setGenericRequestParams(validateRequestType);
validateRequestType.setQueryKeyBinding(queryKeyBindingType);
// temporary
validateRequestType.setId(cert.getSubjectDN().toString());
return validateRequestType;
}
use of org.apache.cxf.xkms.model.xmldsig.KeyInfoType in project cxf by apache.
the class XKMSInvoker method parseLocateXKMSResponse.
@SuppressWarnings("unchecked")
protected X509Certificate parseLocateXKMSResponse(LocateResultType locateResultType, List<X509AppId> ids) {
XKMSException exception = ExceptionMapper.fromResponse(locateResultType);
if (exception != null) {
throw exception;
}
if (!locateResultType.getUnverifiedKeyBinding().iterator().hasNext()) {
LOG.warn("X509Certificate is not found in XKMS for id: " + ids);
return null;
}
KeyInfoType keyInfo = locateResultType.getUnverifiedKeyBinding().iterator().next().getKeyInfo();
if (!keyInfo.getContent().iterator().hasNext()) {
LOG.warn("X509Certificate is not found in XKMS for id: " + ids);
return null;
}
JAXBElement<X509DataType> x509Data = (JAXBElement<X509DataType>) keyInfo.getContent().iterator().next();
JAXBElement<byte[]> certificate = (JAXBElement<byte[]>) x509Data.getValue().getX509IssuerSerialOrX509SKIOrX509SubjectName().iterator().next();
try {
CertificateFactory cf = CertificateFactory.getInstance("X.509");
return (X509Certificate) cf.generateCertificate(new ByteArrayInputStream(certificate.getValue()));
} catch (CertificateException e) {
throw new XKMSLocateException(XKMS_LOCATE_INVALID_CERTIFICATE, e);
}
}
use of org.apache.cxf.xkms.model.xmldsig.KeyInfoType 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.xmldsig.KeyInfoType in project cxf by apache.
the class XKMSServiceTest method testRegisterWithoutKey.
@Test
public void testRegisterWithoutKey() throws URISyntaxException, Exception {
RegisterRequestType request = new RegisterRequestType();
setGenericRequestParams(request);
PrototypeKeyBindingType binding = new PrototypeKeyBindingType();
KeyInfoType keyInfo = new KeyInfoType();
binding.setKeyInfo(keyInfo);
request.setPrototypeKeyBinding(binding);
RegisterResultType result = xkmsService.register(request);
Assert.assertEquals(ResultMajorEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_SENDER.value(), result.getResultMajor());
Assert.assertEquals(ResultMinorEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_FAILURE.value(), result.getResultMinor());
}
Aggregations