use of org.apache.cxf.xkms.model.xkms.UseKeyWithType in project cxf by apache.
the class X509Locator method parse.
private List<UseKeyWithType> parse(LocateRequestType request) {
List<UseKeyWithType> keyIDs = new ArrayList<>();
if (request == null) {
return keyIDs;
}
QueryKeyBindingType query = request.getQueryKeyBinding();
if (query == null) {
return keyIDs;
}
// http://www.w3.org/TR/xkms2/ [213]
if (query.getTimeInstant() != null) {
throw new XKMSException(ResultMajorEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_RECEIVER, ResultMinorEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_TIME_INSTANT_NOT_SUPPORTED);
}
keyIDs.addAll(parse(query.getKeyInfo()));
List<UseKeyWithType> useKeyList = query.getUseKeyWith();
keyIDs.addAll(useKeyList);
return keyIDs;
}
use of org.apache.cxf.xkms.model.xkms.UseKeyWithType in project cxf by apache.
the class X509Register method register.
@Override
public RegisterResultType register(RegisterRequestType request, RegisterResultType response) {
try {
PrototypeKeyBindingType binding = request.getPrototypeKeyBinding();
X509Utils.assertElementNotNull(binding, PrototypeKeyBindingType.class);
KeyInfoType keyInfo = binding.getKeyInfo();
X509Utils.assertElementNotNull(binding, KeyInfoType.class);
List<UseKeyWithType> useKeyWithList = binding.getUseKeyWith();
if (useKeyWithList == null || useKeyWithList.size() != 1) {
throw new IllegalArgumentException("Exactly one useKeyWith element is supported");
// TODO standard requires support for multiple useKeyWith attributes
}
UseKeyWithType useKeyWith = useKeyWithList.get(0);
List<X509Certificate> certList = getCertsFromKeyInfo(keyInfo);
if (certList.size() != 1) {
throw new IllegalArgumentException("Must provide one X509Certificate");
}
X509Certificate cert = certList.get(0);
certRepo.saveCertificate(cert, useKeyWith);
KeyBindingType responseBinding = prepareResponseBinding(binding);
response.getKeyBinding().add(responseBinding);
return response;
} catch (CertificateException e) {
throw new RuntimeException(e.getMessage(), e);
}
}
use of org.apache.cxf.xkms.model.xkms.UseKeyWithType in project cxf by apache.
the class TrustedAuthorityValidatorCRLTest 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 = certificateWss40Rev.getSubjectX500Principal().getName();
aliceKey.setIdentifier(subjectDN);
certificateRepo.saveCACertificate(certificateWss40Rev, aliceKey);
UseKeyWithType bobKey = new UseKeyWithType();
bobKey.setApplication(Applications.PKIX.getUri());
subjectDN = certificateWss40.getSubjectX500Principal().getName();
bobKey.setIdentifier(subjectDN);
certificateRepo.saveCACertificate(certificateWss40, bobKey);
UseKeyWithType crlKey = new UseKeyWithType();
crlKey.setApplication(Applications.PKIX.getUri());
crlKey.setIdentifier(crl.getIssuerX500Principal().getName());
certificateRepo.saveCRL(crl, crlKey);
}
use of org.apache.cxf.xkms.model.xkms.UseKeyWithType 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