Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 6c177cca authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

[EDELIVERY-13369] add scheme validation for the sample extension

parent 70979e12
No related tags found
No related merge requests found
Pipeline #208727 failed
...@@ -67,11 +67,8 @@ public abstract class AbstractHandler implements ResourceHandlerSpi { ...@@ -67,11 +67,8 @@ public abstract class AbstractHandler implements ResourceHandlerSpi {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true); factory.setNamespaceAware(true);
factory.setValidating(true); factory.setValidating(true);
try { enableFeature(factory, DISALLOW_DOCTYPE_FEATURE);
factory.setFeature(DISALLOW_DOCTYPE_FEATURE, true); enableFeature(factory, XMLConstants.FEATURE_SECURE_PROCESSING);
} catch (ParserConfigurationException e) {
LOG.warn("DocumentBuilderFactory initialization error. The feature [{}] is not supported by current factory. The feature is ignored.", DISALLOW_DOCTYPE_FEATURE);
}
try { try {
return factory.newDocumentBuilder(); return factory.newDocumentBuilder();
...@@ -80,6 +77,16 @@ public abstract class AbstractHandler implements ResourceHandlerSpi { ...@@ -80,6 +77,16 @@ public abstract class AbstractHandler implements ResourceHandlerSpi {
} }
} }
private static boolean enableFeature(DocumentBuilderFactory factory, String feature) {
try {
factory.setFeature(feature, true);
return true;
} catch (ParserConfigurationException e) {
LOG.warn("DocumentBuilderFactory initialization error. The feature [{}] is not supported by current factory. The feature is ignored.", feature);
return false;
}
}
private static final ThreadLocal<Unmarshaller> jaxbUnmarshaller = ThreadLocal.withInitial(() -> { private static final ThreadLocal<Unmarshaller> jaxbUnmarshaller = ThreadLocal.withInitial(() -> {
try { try {
JAXBContext jaxbContext = JAXBContext.newInstance(CPP.class); JAXBContext jaxbContext = JAXBContext.newInstance(CPP.class);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment