Top Description Fields Constructors Methods
org.glassfish.jaxb.core.v2.util

public Class XmlFactory

extends Object
Class Inheritance
Imports
org.glassfish.jaxb.core.v2.Messages, java.lang.ref.SoftReference, java.security.AccessController, .PrivilegedAction, java.util.Collections, .Map, .WeakHashMap, java.util.logging.Level, .Logger, javax.xml.XMLConstants, javax.xml.parsers.DocumentBuilderFactory, .ParserConfigurationException, .SAXParserFactory, javax.xml.transform.TransformerConfigurationException, .TransformerFactory, javax.xml.validation.SchemaFactory, javax.xml.xpath.XPathFactory, .XPathFactoryConfigurationException, org.xml.sax.SAXException, .SAXNotRecognizedException, .SAXNotSupportedException

Provides helper methods for creating properly configured XML parser factory instances with namespace support turned on and configured for security.
Author
snajper

Field Summary

Modifier and TypeField and Description
private static final String
DISABLE_XML_SECURITY

If true XML security features when parsing XML documents will be disabled.

private static final Logger
private static final Map<Boolean, SoftReference<TransformerFactory>>
private static final boolean

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static TransformerFactory

Returns:

TransformerFactory new instance
_createTransformerFactory
(boolean
disable secure processing in TransformerFactory
disableSecureProcessing
)

Internal method: returns properly configured (e.g., security features) factory - securityProcessing == is set based on security processing property, default is true

public static SchemaFactory
allowExternalAccess(SchemaFactory sf, String value, boolean disableSecureProcessing)

public static SchemaFactory
allowExternalDTDAccess(SchemaFactory sf, String value, boolean disableSecureProcessing)

public static DocumentBuilderFactory
createDocumentBuilderFactory(boolean disableSecureProcessing)

Returns properly configured (e.g. security features) factory - namespaceAware == true - securityProcessing == is set based on security processing property, default is true

public static SAXParserFactory
createParserFactory(boolean disableSecureProcessing)

Returns properly configured (e.g. security features) parser factory - namespaceAware == true - securityProcessing == is set based on security processing property, default is true

public static SchemaFactory
createSchemaFactory(final String language, boolean disableSecureProcessing)

Returns properly configured (e.g. security features) schema factory - namespaceAware == true - securityProcessing == is set based on security processing property, default is true

public static TransformerFactory

Returns:

TransformerFactory new instance
createTransformerFactory
(boolean
disable secure processing in TransformerFactory
disableSecureProcessing
)

Returns properly configured (e.g., security features) factory - securityProcessing == is set based on security processing property, default is true

public static TransformerFactory

Returns:

TransformerFactory new instance or cached one if useCache is true and found in cache
createTransformerFactory
(boolean
disable secure processing in TransformerFactory
disableSecureProcessing
,
boolean
use cached instances of TransformerFactory, false will always create new ones
useCache
)

Returns properly configured (e.g., security features) factory - securityProcessing == is set based on security processing property, default is true

public static XPathFactory
createXPathFactory(boolean disableSecureProcessing)

Returns properly configured (e.g. security features) factory - securityProcessing == is set based on security processing property, default is true

private static boolean
isXMLSecurityDisabled(boolean runtimeSetting)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DISABLE_XML_SECURITYback to summary
private static final String DISABLE_XML_SECURITY

If true XML security features when parsing XML documents will be disabled. The default value is false. Boolean

Since
2.2.6
LOGGERback to summary
private static final Logger LOGGER
transformerFactoryCacheback to summary
private static final Map<Boolean, SoftReference<TransformerFactory>> transformerFactoryCache
XML_SECURITY_DISABLEDback to summary
private static final boolean XML_SECURITY_DISABLED

Constructor Detail

XmlFactoryback to summary
private XmlFactory()

Method Detail

_createTransformerFactoryback to summary
private static TransformerFactory _createTransformerFactory(boolean disableSecureProcessing) throws IllegalStateException

Internal method: returns properly configured (e.g., security features) factory - securityProcessing == is set based on security processing property, default is true

Parameters
disableSecureProcessing:boolean

disable secure processing in TransformerFactory

Returns:TransformerFactory

TransformerFactory new instance

Exceptions
IllegalStateException:
error on configuring TransformerFactory
allowExternalAccessback to summary
public static SchemaFactory allowExternalAccess(SchemaFactory sf, String value, boolean disableSecureProcessing)
allowExternalDTDAccessback to summary
public static SchemaFactory allowExternalDTDAccess(SchemaFactory sf, String value, boolean disableSecureProcessing)
createDocumentBuilderFactoryback to summary
public static DocumentBuilderFactory createDocumentBuilderFactory(boolean disableSecureProcessing) throws IllegalStateException

Returns properly configured (e.g. security features) factory - namespaceAware == true - securityProcessing == is set based on security processing property, default is true

createParserFactoryback to summary
public static SAXParserFactory createParserFactory(boolean disableSecureProcessing) throws IllegalStateException

Returns properly configured (e.g. security features) parser factory - namespaceAware == true - securityProcessing == is set based on security processing property, default is true

createSchemaFactoryback to summary
public static SchemaFactory createSchemaFactory(final String language, boolean disableSecureProcessing) throws IllegalStateException

Returns properly configured (e.g. security features) schema factory - namespaceAware == true - securityProcessing == is set based on security processing property, default is true

createTransformerFactoryback to summary
public static TransformerFactory createTransformerFactory(boolean disableSecureProcessing) throws IllegalStateException

Returns properly configured (e.g., security features) factory - securityProcessing == is set based on security processing property, default is true

Parameters
disableSecureProcessing:boolean

disable secure processing in TransformerFactory

Returns:TransformerFactory

TransformerFactory new instance

Exceptions
IllegalStateException:
error on configuring TransformerFactory
createTransformerFactoryback to summary
public static TransformerFactory createTransformerFactory(boolean disableSecureProcessing, boolean useCache) throws IllegalStateException

Returns properly configured (e.g., security features) factory - securityProcessing == is set based on security processing property, default is true

Parameters
disableSecureProcessing:boolean

disable secure processing in TransformerFactory

useCache:boolean

use cached instances of TransformerFactory, false will always create new ones

Returns:TransformerFactory

TransformerFactory new instance or cached one if useCache is true and found in cache

Exceptions
IllegalStateException:
error on configuring TransformerFactory
createXPathFactoryback to summary
public static XPathFactory createXPathFactory(boolean disableSecureProcessing) throws IllegalStateException

Returns properly configured (e.g. security features) factory - securityProcessing == is set based on security processing property, default is true

isXMLSecurityDisabledback to summary
private static boolean isXMLSecurityDisabled(boolean runtimeSetting)