use of org.apache.camel.processor.validation.ValidatorErrorHandler in project camel by apache.
the class XmlSignerProcessor method getMessageBodyNode.
protected Node getMessageBodyNode(Message message) throws Exception {
//NOPMD
InputStream is = message.getMandatoryBody(InputStream.class);
Boolean isPlainText = isPlainText(message);
Node node;
if (isPlainText != null && isPlainText) {
node = getTextNode(message, is);
} else {
ValidatorErrorHandler errorHandler = new DefaultValidationErrorHandler();
Schema schema = getSchemaForSigner(message, errorHandler);
Document doc = parseInput(is, getConfiguration().getDisallowDoctypeDecl(), schema, errorHandler);
// throws ValidationException
errorHandler.handleErrors(message.getExchange(), schema, null);
node = doc.getDocumentElement();
LOG.debug("Root element of document to be signed: {}", node);
}
return node;
}
use of org.apache.camel.processor.validation.ValidatorErrorHandler in project camel by apache.
the class XmlVerifierProcessor method parseInput.
protected Document parseInput(InputStream is, Message message) throws Exception {
//NOPMD
try {
ValidatorErrorHandler errorHandler = new DefaultValidationErrorHandler();
Schema schema = getSchema(message);
DocumentBuilder db = XmlSignatureHelper.newDocumentBuilder(getConfiguration().getDisallowDoctypeDecl(), schema);
db.setErrorHandler(errorHandler);
Document doc = db.parse(is);
// throws ValidationException
errorHandler.handleErrors(message.getExchange(), schema, null);
return doc;
} catch (SAXException e) {
throw new XmlSignatureFormatException("Message has wrong format, it is not a XML signature document. Check the sent message.", e);
}
}
Aggregations