public final class XmlUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
SYSTEM_PROPERTY_IGNORE_XXE_PROTECTION_FAILURES
System property name which allows ignoring failures during enabling the XML External Entity protection.
|
| Modifier and Type | Method and Description |
|---|---|
static String |
format(String input,
int indent)
Formats given XML String with the given indentation used.
|
ErrorListener |
getErrorListener()
Returns ErrorListener implementation which just throws the original error.
|
static SchemaFactory |
getSchemaFactory()
Returns
SchemaFactory with XXE protection enabled. |
static TransformerFactory |
getTransformerFactory()
Returns
TransformerFactory with XXE protection enabled. |
public static final String SYSTEM_PROPERTY_IGNORE_XXE_PROTECTION_FAILURES
XMLConstants.ACCESS_EXTERNAL_DTD and
XMLConstants.ACCESS_EXTERNAL_SCHEMA. These properties are supported in modern XML processors (JAXP 1.5+, Java
8+). Old JAXP implementations on the classpath (e.g. Xerces, Xalan) may miss the support and they throw exception
during enabling the XXE protection. Setting this system property to true suppresses/ignores such Exceptions.public static TransformerFactory getTransformerFactory()
TransformerFactory with XXE protection enabled.public static SchemaFactory getSchemaFactory() throws SAXException
SchemaFactory with XXE protection enabled.SAXExceptionpublic static String format(@Nullable String input, int indent) throws IllegalArgumentException
input XML string is null, or
indent parameter is negative, or XML transformation fails, then the original value is returned unchanged. The
IllegalArgumentException is thrown when indent==0.input - the XML Stringindent - indentation (number of spaces used for one indentation level)IllegalArgumentException - when indentation is equal to zeropublic ErrorListener getErrorListener()
Copyright © 2022 Hazelcast, Inc.. All Rights Reserved.