use of org.apache.cxf.xkms.exception.XKMSException in project cxf by apache.
the class XKMSInvoker method parseValidateXKMSResponse.
protected CertificateValidationResult parseValidateXKMSResponse(ValidateResultType validateResultType, String id) {
XKMSException exception = ExceptionMapper.fromResponse(validateResultType);
if (exception != null) {
throw exception;
}
StatusType status = validateResultType.getKeyBinding().iterator().next().getStatus();
if (KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_VALID != status.getStatusValue()) {
return new CertificateValidationResult(false, XKMS_VALIDATE_ERROR);
}
return new CertificateValidationResult(true, null);
}
use of org.apache.cxf.xkms.exception.XKMSException 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.exception.XKMSException 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.exception.XKMSException in project cxf by apache.
the class LdapSearch method searchSubTree.
// CHECKSTYLE:ON
public NamingEnumeration<SearchResult> searchSubTree(String rootEntry, String filter) throws NamingException {
int retry = 0;
while (true) {
try {
if (this.dirContext == null) {
this.dirContext = createInitialContext();
}
SearchControls ctls = new SearchControls();
ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
return dirContext.search(rootEntry, filter, ctls);
} catch (CommunicationException e) {
LOG.log(Level.WARNING, "Error in ldap search: " + e.getMessage(), e);
this.dirContext = null;
retry++;
if (retry >= numRetries) {
throw new XKMSException(ResultMajorEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_RECEIVER, ResultMinorEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_FAILURE, "Backend failure");
}
}
}
}
Aggregations