Class SecureSchemaFactory
SchemaFactory instances.
Beyond the three universal guarantees on org.apache.commons.xml.secure:
xs:import,xs:includeandxs:redefineschemaLocation URIs are not resolved during schema compilation,xsi:schemaLocation/xsi:noNamespaceSchemaLocationhints in instance documents are not resolved during validation, and- the content model a schema expands into is bounded, on every implementation offering a limit for it. A loader expands a repeated particle while building
the DFA, so a compact schema carrying a large
maxOccurswould otherwise exhaust memory or CPU (see Xerces' security manager, which caps that expansion at 3,000 nodes).
The same guarantees apply to Validator and ValidatorHandler instances produced from the resulting
Schema.
This class is not itself a SchemaFactory, so it inherits none of the static JAXP factory methods. A caller therefore cannot obtain an unsecured
factory through this class by calling a method such as newDefaultInstance(). The secure factories are instances of a nested, non-public wrapper
class.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic SchemaFactoryReturns a new, secureSchemaFactoryof the system-default implementation, supporting W3C XML Schema 1.0.static SchemaFactorynewInstance(String schemaLanguage) Returns a new, secureSchemaFactoryfor the given schema language.static SchemaFactorynewInstance(String schemaLanguage, String factoryClassName, ClassLoader classLoader) Returns a new, secureSchemaFactoryof the given implementation class.
-
Method Details
-
newDefaultInstance
Returns a new, secureSchemaFactoryof the system-default implementation, supporting W3C XML Schema 1.0.Obtained from
SchemaFactory.newDefaultInstance()where the platform provides it (Java 9 or later), by instantiating the JDK's built-in implementation directly on Java 8, and by the standardnewInstance(String)lookup where the platform provides neither (for example Android, whose lookup falls back to exactly the Xerces implementation this library recognizes).- Returns:
- A secure factory.
- Throws:
IllegalStateException- Thrown if a required secure setting cannot be applied to the underlying implementation.IllegalArgumentException- Thrown from thenewInstance(String)lookup this method falls back to on a platform that provides neithernewDefaultInstance()nor the JDK's built-in implementation (for example Android).
-
newInstance
Returns a new, secureSchemaFactoryfor the given schema language.- Parameters:
schemaLanguage- The schema language, as accepted bySchemaFactory.newInstance(String).- Returns:
- A secure factory.
- Throws:
IllegalArgumentException- Thrown if no implementation of the schema language is available.NullPointerException- Thrown ifschemaLanguageisnull.SchemaFactoryConfigurationError- Thrown if a configuration error is encountered.
-
newInstance
public static SchemaFactory newInstance(String schemaLanguage, String factoryClassName, ClassLoader classLoader) Returns a new, secureSchemaFactoryof the given implementation class.- Parameters:
schemaLanguage- The schema language, as accepted bySchemaFactory.newInstance(String).factoryClassName- The fully qualified class name of theSchemaFactoryimplementation.classLoader- The class loader used to load the factory class;nullmeans the current thread's context class loader.- Returns:
- A secure factory.
- Throws:
IllegalArgumentException- Thrown iffactoryClassNameisnull, or if the factory class cannot be loaded or instantiated, or does not supportschemaLanguage.NullPointerException- Thrown ifschemaLanguageisnull.
-