Class XmlSupport
java.lang.Object
org.jboss.resteasy.util.XmlSupport
A utility for creating secure XML serialization and deserialization resources.
- Author:
- James R. Perkins
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidconfigureParserFactory(SAXParserFactory factory, ResteasyConfiguration config) Configures the factory for secure processing.static TransformerFactoryCreates a newTransformerFactoryand configures it for secure processing.static TransformerFactoryCreates a newTransformerFactoryand configures it for secure processing.static XMLReaderCreates a newXMLReaderfrom the defaultSAXParserFactory.static XMLReadernewXmlReader(ResteasyConfiguration config) Creates a newXMLReaderfrom the defaultSAXParserFactory.
-
Method Details
-
configureParserFactory
public static void configureParserFactory(SAXParserFactory factory, ResteasyConfiguration config) throws SAXNotSupportedException, SAXNotRecognizedException, ParserConfigurationException Configures the factory for secure processing. If the configuration is notnull, the following properties are looked up to determine which features are enabled/disabled:ResteasyContextParameters.RESTEASY_EXPAND_ENTITY_REFERENCES: Determines whether to enable or disablehttp://xml.org/sax/features/external-general-entitiesandhttp://xml.org/sax/features/external-parameter-entities. Defaults tofalse.ResteasyContextParameters.RESTEASY_SECURE_PROCESSING_FEATURE: Determines whether to enable or disableXMLConstants.FEATURE_SECURE_PROCESSING. Defaults totrue.ResteasyContextParameters.RESTEASY_DISABLE_DTDS: Determines whether to enable or disablehttp://apache.org/xml/features/disallow-doctype-decl. Defaults totrue.
If any of these properties are not supported by the
SAXParserFactoryimplementation, aSAXNotSupportedExceptionwill be thrown.- Parameters:
factory- the factory to be configuredconfig- the configuration to be used to override the default values- Throws:
SAXNotSupportedException- if the property is not supported by the underlying implementationSAXNotRecognizedException- if the property is not recognized by the underlying implementationParserConfigurationException- if there is an error configuring the parser- See Also:
-
newXmlReader
Creates a newXMLReaderfrom the defaultSAXParserFactory. TheSAXParserFactoryis configured via theconfigureParserFactory(SAXParserFactory, ResteasyConfiguration).The configuration is looked up in the current context.
- Returns:
- a new XMLReader
- Throws:
ParserConfigurationException- if the configuration for theSAXParserFactoryfailsSAXException- if there is a general failure creating the reader- See Also:
-
newXmlReader
public static XMLReader newXmlReader(ResteasyConfiguration config) throws ParserConfigurationException, SAXException Creates a newXMLReaderfrom the defaultSAXParserFactory. TheSAXParserFactoryis configured via theconfigureParserFactory(SAXParserFactory, ResteasyConfiguration).- Parameters:
config- the optional configuration to use- Returns:
- a new XMLReader
- Throws:
ParserConfigurationException- if the configuration for theSAXParserFactoryfailsSAXException- if there is a general failure creating the reader- See Also:
-
newTransformerFactory
Creates a newTransformerFactoryand configures it for secure processing.The configuration is looked up in the current context.
- Returns:
- a newly configured transformer factory
- Throws:
TransformerConfigurationException- if an error occurs configuring the transformer factory
-
newTransformerFactory
public static TransformerFactory newTransformerFactory(ResteasyConfiguration config) throws TransformerConfigurationException Creates a newTransformerFactoryand configures it for secure processing.The
ResteasyContextParameters.RESTEASY_SECURE_PROCESSING_FEATURE: Determines whether to enable or disableXMLConstants.FEATURE_SECURE_PROCESSING. Defaults totrue.This also attempts to set two attributes which are not configurable:
Both attributes are set to empty string values if they are supported by the underlying implementation. If they are not supported, a warning will be logged once indicating the attribute is not supported.- Parameters:
config- the optional configuration to check for theResteasyContextParameters.RESTEASY_SECURE_PROCESSING_FEATURE- Returns:
- a newly configured transformer factory
- Throws:
TransformerConfigurationException- if an error occurs configuring the transformer factory
-