Package com.verisign.epp.util
Class EPPSchemaCachingParser
- java.lang.Object
-
- javax.xml.parsers.DocumentBuilder
-
- com.verisign.epp.util.EPPSchemaCachingParser
-
- All Implemented Interfaces:
EPPSchemaCacher
- Direct Known Subclasses:
EPPStrictContactParser,EPPXMLSignatureSchemaCachingParser
public class EPPSchemaCachingParser extends javax.xml.parsers.DocumentBuilder implements EPPSchemaCacher
XML Parser that pre-caches the XML schemas from the XML schemas registered in theEPPFactoryfor improved XML parsing performance.
-
-
Field Summary
Fields Modifier and Type Field Description static intBIG_PRIMEA default prime number to use for the SymbolTable size.static java.lang.StringCREATE_ENTITY_REF_NODESCreate EntityReference nodes in the DOM tree.static java.lang.StringDEFER_NODE_EXPANSIONConstant for setting the defer node expansion parser feature.static java.lang.StringDISALLOW_DOCTYPE_DECLIf DTDs (doctypes) are disallowed, almost all XML entity attacks are preventedstatic java.lang.StringEXTERNAL_GENERAL_ENTITIESIf DTDs (doctypes) are disallowed, almost all XML entity attacks are preventedstatic java.lang.StringEXTERNAL_PARAMETER_ENTITIESInclude external parameter entities and the external DTD subset.static java.lang.StringINCLUDE_IGNORABLE_WHITE_SPACEInclude text nodes that can be considered "ignorable whitespace" in the DOM tree.static java.lang.StringLOAD_DTD_GRAMMARLoad the DTD and use it to add default attributes and set attribute types when parsing.static java.lang.StringLOAD_EXTERNAL_DTDApache constant for loading external DTD's when they are seen in the instance documentstatic java.lang.StringNAMESPACES_FEATURE_IDNamespaces feature id (http://xml.org/sax/features/namespaces).static java.lang.StringNORMALIZE_DATAattempt to normalize data in an entity reference or CDATA section.static java.lang.StringPOOLName of the EPP XML Parser Pool managed byGenericPoolManagerstatic java.lang.StringSCHEMA_FULL_CHECKING_FEATURE_IDSchema full checking feature id (http://apache.org/xml/features/validation/schema-full-checking).static java.lang.StringSCHEMA_VALIDATION_FEATURE_IDSchema validation feature id (http://apache.org/xml/features/validation/schema).protected static java.lang.StringSYMBOL_TABLEProperty identifier: The symbol table featurestatic java.lang.StringVALIDATION_FEATURE_IDValidation feature id (http://xml.org/sax/features/validation).static java.lang.StringXMLGRAMMAR_POOLProperty identifier: The XML Grammar pool feature
-
Constructor Summary
Constructors Constructor Description EPPSchemaCachingParser()Create a new instance of EPPSchemaCachingParser.EPPSchemaCachingParser(int aSymbolTableSize)Creates an EPPSchemaCachingParser instance with the specified symbol table size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSchemaToCache(org.apache.xerces.xni.parser.XMLInputSource aSchema)Addes the XMLInputSource instance to the current cache of schemas.org.w3c.dom.DOMImplementationgetDOMImplementation()Returns the DOM implementationbooleangetFeature(java.lang.String aFeatureId)Query the state of a feature.java.lang.ObjectgetProperty(java.lang.String aPropertyId)Query the value of a property.intgetSymbolTableSize()Gets the symbol table sizeprotected java.util.Set<java.lang.String>getXmlSchemas()Gets the XML schemas to pre-load into the XML parser.protected voidinit()Helper method to initialize this instance ofEPPSchemaCachingParser.booleanisNamespaceAware()Returns true if the parser is setup to be Namespace aware, false otherwise.booleanisValidating()Returns true if this parser is setup to validate XML instances, false otherwiseorg.w3c.dom.DocumentnewDocument()Non-preferred: use the getDOMImplementation() method instead of this one to get a DOM Level 2 DOMImplementation object and then use DOM Level 2 methods to create a DOM Document object.org.w3c.dom.Documentparse(java.io.File aFile)Parse a file to a DOM Document.org.w3c.dom.Documentparse(java.io.InputStream aInputStream)Implemented as part of standard Document Builder API.org.w3c.dom.Documentparse(java.io.InputStream aInputStream, java.lang.String aSystemId)Implemented as part of standard Document Builder API.org.w3c.dom.Documentparse(java.lang.String aUri)Implemented as part of standard Document Builder API.org.w3c.dom.Documentparse(org.xml.sax.InputSource aXmlInstance)Parses the InputSource passed in which should be an XML instance.protected voidpreloadSchemas()Pre-load the XML schemas into the parser based on theEPPFactoryXML schemas.voidsetEntityResolver(org.xml.sax.EntityResolver aEntityResolver)Sets the EntityResolver of this DocumentBuildervoidsetErrorHandler(org.xml.sax.ErrorHandler aErrorHandler)Sets the ErrorHandler this DocumentBuilder instance.voidsetFeature(java.lang.String aFeatureId, boolean aBoolean)Set the state of any feature in a SAX2 parser.voidsetLockSchemaCache(boolean aBoolean)Lock the schema cache.voidsetProperty(java.lang.String aProperty, java.lang.Object aObject)Set the state of any property in a SAX2 parser.voidsetSymbolTableSize(int aSymbolTableSize)Sets the symbol table size.
-
-
-
Field Detail
-
POOL
public static final java.lang.String POOL
Name of the EPP XML Parser Pool managed byGenericPoolManager- See Also:
- Constant Field Values
-
BIG_PRIME
public static final int BIG_PRIME
A default prime number to use for the SymbolTable size. Some other sample big primes: 1299709 1299721 1299743 1299763 1299791 1299811 1299817 1299821 1299827- See Also:
- Constant Field Values
-
NAMESPACES_FEATURE_ID
public static final java.lang.String NAMESPACES_FEATURE_ID
Namespaces feature id (http://xml.org/sax/features/namespaces). \- See Also:
- Constant Field Values
-
VALIDATION_FEATURE_ID
public static final java.lang.String VALIDATION_FEATURE_ID
Validation feature id (http://xml.org/sax/features/validation).- See Also:
- Constant Field Values
-
SCHEMA_VALIDATION_FEATURE_ID
public static final java.lang.String SCHEMA_VALIDATION_FEATURE_ID
Schema validation feature id (http://apache.org/xml/features/validation/schema).- See Also:
- Constant Field Values
-
SCHEMA_FULL_CHECKING_FEATURE_ID
public static final java.lang.String SCHEMA_FULL_CHECKING_FEATURE_ID
Schema full checking feature id (http://apache.org/xml/features/validation/schema-full-checking). Enable full schema grammar constraint checking, including checking which may be time-consuming or memory intensive. Currently, particle unique attribution constraint checking and particle derivation resriction checking are controlled by this option.- See Also:
- Constant Field Values
-
XMLGRAMMAR_POOL
public static final java.lang.String XMLGRAMMAR_POOL
Property identifier: The XML Grammar pool feature- See Also:
- Constant Field Values
-
SYMBOL_TABLE
protected static final java.lang.String SYMBOL_TABLE
Property identifier: The symbol table feature- See Also:
- Constant Field Values
-
DEFER_NODE_EXPANSION
public static final java.lang.String DEFER_NODE_EXPANSION
Constant for setting the defer node expansion parser feature. The recommendation is to set this to false for EPP packets since the are not large documents.- See Also:
- Constant Field Values
-
LOAD_EXTERNAL_DTD
public static final java.lang.String LOAD_EXTERNAL_DTD
Apache constant for loading external DTD's when they are seen in the instance document- See Also:
- Constant Field Values
-
LOAD_DTD_GRAMMAR
public static final java.lang.String LOAD_DTD_GRAMMAR
Load the DTD and use it to add default attributes and set attribute types when parsing. False: Build the grammar but do not use the default attributes and attribute types information it contains.- See Also:
- Constant Field Values
-
CREATE_ENTITY_REF_NODES
public static final java.lang.String CREATE_ENTITY_REF_NODES
Create EntityReference nodes in the DOM tree. The EntityReference nodes and their child nodes will be read-only. False: Do not create EntityReference nodes in the DOM tree. No EntityReference nodes will be created, only the nodes corresponding to their fully expanded substitution text will be created- See Also:
- Constant Field Values
-
INCLUDE_IGNORABLE_WHITE_SPACE
public static final java.lang.String INCLUDE_IGNORABLE_WHITE_SPACE
Include text nodes that can be considered "ignorable whitespace" in the DOM tree. False: Do not include ignorable whitespace in the DOM tree.- See Also:
- Constant Field Values
-
EXTERNAL_GENERAL_ENTITIES
public static final java.lang.String EXTERNAL_GENERAL_ENTITIES
If DTDs (doctypes) are disallowed, almost all XML entity attacks are prevented- See Also:
- Constant Field Values
-
EXTERNAL_PARAMETER_ENTITIES
public static final java.lang.String EXTERNAL_PARAMETER_ENTITIES
Include external parameter entities and the external DTD subset. False: Do not include external parameter entities or the external DTD subset.- See Also:
- Constant Field Values
-
NORMALIZE_DATA
public static final java.lang.String NORMALIZE_DATA
attempt to normalize data in an entity reference or CDATA section. To preserve character data within entity references and CDATA sections, turn off http://apache.org/xml/features/validation/schema/normalized-value feature.- See Also:
- Constant Field Values
-
DISALLOW_DOCTYPE_DECL
public static final java.lang.String DISALLOW_DOCTYPE_DECL
If DTDs (doctypes) are disallowed, almost all XML entity attacks are prevented- See Also:
- Constant Field Values
-
-
Constructor Detail
-
EPPSchemaCachingParser
public EPPSchemaCachingParser()
Create a new instance of EPPSchemaCachingParser. Defaults are: Namespace aware: true Validation: true Schema Validation: true Full Schema checking: true
-
EPPSchemaCachingParser
public EPPSchemaCachingParser(int aSymbolTableSize)
Creates an EPPSchemaCachingParser instance with the specified symbol table size.- Parameters:
aSymbolTableSize- Size of the symbol table
-
-
Method Detail
-
init
protected void init() throws EPPParserExceptionHelper method to initialize this instance ofEPPSchemaCachingParser.- Throws:
EPPParserException- Error initializingEPPSchemaCachingParser
-
getXmlSchemas
protected java.util.Set<java.lang.String> getXmlSchemas()
Gets the XML schemas to pre-load into the XML parser. Derived classes can override this method to pre-load a custom set of XML schemas.- Returns:
- XML schema names to pre-load
-
preloadSchemas
protected void preloadSchemas() throws EPPParserExceptionPre-load the XML schemas into the parser based on theEPPFactoryXML schemas. A derived class can customize what XML schemas to pre-load.- Throws:
EPPParserException- Error loading the XML schemas into the parser
-
setLockSchemaCache
public void setLockSchemaCache(boolean aBoolean)
Lock the schema cache. True param locks it, false unlocks it- Specified by:
setLockSchemaCachein interfaceEPPSchemaCacher- Parameters:
aBoolean- True param locks it, false unlocks it
-
addSchemaToCache
public void addSchemaToCache(org.apache.xerces.xni.parser.XMLInputSource aSchema) throws EPPParserExceptionAddes the XMLInputSource instance to the current cache of schemas. Only addes the schema to the cache if it isn't already in the cache.- Specified by:
addSchemaToCachein interfaceEPPSchemaCacher- Parameters:
aSchema- The schema instance to be cached- Throws:
EPPParserException- Error adding schema to the cache
-
isNamespaceAware
public boolean isNamespaceAware()
Returns true if the parser is setup to be Namespace aware, false otherwise.- Specified by:
isNamespaceAwarein classjavax.xml.parsers.DocumentBuilder- Returns:
- true if the parser is setup to be Namespace aware, false otherwise.
- Throws:
java.lang.IllegalStateException- Parser is not in a state to query it's properties
-
setEntityResolver
public void setEntityResolver(org.xml.sax.EntityResolver aEntityResolver)
Sets the EntityResolver of this DocumentBuilder- Specified by:
setEntityResolverin classjavax.xml.parsers.DocumentBuilder- Parameters:
aEntityResolver- The EntityResolver instance that this DocumentBuilder will use when parsing.
-
getDOMImplementation
public org.w3c.dom.DOMImplementation getDOMImplementation()
Returns the DOM implementation- Specified by:
getDOMImplementationin classjavax.xml.parsers.DocumentBuilder- Returns:
- the DOM implementation
-
newDocument
public org.w3c.dom.Document newDocument()
Non-preferred: use the getDOMImplementation() method instead of this one to get a DOM Level 2 DOMImplementation object and then use DOM Level 2 methods to create a DOM Document object.- Specified by:
newDocumentin classjavax.xml.parsers.DocumentBuilder- Returns:
- DOM Document
-
parse
public org.w3c.dom.Document parse(org.xml.sax.InputSource aXmlInstance) throws org.xml.sax.SAXException, java.io.IOExceptionParses the InputSource passed in which should be an XML instance. Returns a DOM document.- Specified by:
parsein classjavax.xml.parsers.DocumentBuilder- Parameters:
aXmlInstance- The XML instance to parse- Returns:
- The DOM Document that represents the XML instance
- Throws:
org.xml.sax.SAXException- Thrown if any errors occurjava.io.IOException- Thrown if any errors occurjava.lang.IllegalArgumentException- DOCUMENT ME!
-
parse
public org.w3c.dom.Document parse(java.io.InputStream aInputStream, java.lang.String aSystemId) throws org.xml.sax.SAXException, java.io.IOExceptionImplemented as part of standard Document Builder API. Delegates to DOMParser- Overrides:
parsein classjavax.xml.parsers.DocumentBuilder- Parameters:
aInputStream- The InputStream instance to parseaSystemId- XML System Id- Returns:
- The DOM Document created after the parsing episode
- Throws:
org.xml.sax.SAXException- Error parsing XMLjava.io.IOException- Error processing input
-
parse
public org.w3c.dom.Document parse(java.lang.String aUri) throws org.xml.sax.SAXException, java.io.IOExceptionImplemented as part of standard Document Builder API. Delegates to DOMParser- Overrides:
parsein classjavax.xml.parsers.DocumentBuilder- Parameters:
aUri- The URI to parse- Returns:
- The DOM Document created after the parsing episode
- Throws:
org.xml.sax.SAXException- Error parsing XMLjava.io.IOException- Error processing input
-
parse
public org.w3c.dom.Document parse(java.io.InputStream aInputStream) throws org.xml.sax.SAXException, java.io.IOExceptionImplemented as part of standard Document Builder API. Delegates to DOMParser- Overrides:
parsein classjavax.xml.parsers.DocumentBuilder- Parameters:
aInputStream- The InputStream to parse- Returns:
- The DOM Document created after parsing the stream
- Throws:
org.xml.sax.SAXException- Error parsing XMLjava.io.IOException- Error processing input
-
parse
public org.w3c.dom.Document parse(java.io.File aFile) throws org.xml.sax.SAXException, java.io.IOExceptionParse a file to a DOM Document.- Overrides:
parsein classjavax.xml.parsers.DocumentBuilder- Parameters:
aFile- XML file to parse to a DOM Document- Returns:
- The DOM Document created after parsing the file
- Throws:
java.io.IOException- Error opening XML fileorg.xml.sax.SAXException- Error parsing XML file
-
setErrorHandler
public void setErrorHandler(org.xml.sax.ErrorHandler aErrorHandler)
Sets the ErrorHandler this DocumentBuilder instance.- Specified by:
setErrorHandlerin classjavax.xml.parsers.DocumentBuilder- Parameters:
aErrorHandler- The ErrorHandler instance to use
-
isValidating
public boolean isValidating()
Returns true if this parser is setup to validate XML instances, false otherwise- Specified by:
isValidatingin classjavax.xml.parsers.DocumentBuilder- Returns:
- Returns true if this parser is setup to validate XML instances, false otherwise
- Throws:
java.lang.IllegalStateException- Error setting the validation feature
-
getSymbolTableSize
public int getSymbolTableSize()
Gets the symbol table size- Returns:
- the symbol table size
-
setSymbolTableSize
public void setSymbolTableSize(int aSymbolTableSize) throws EPPParserExceptionSets the symbol table size. If set to 0 then the symbol table size will use the default provided with the ParserConfiguration.- Parameters:
aSymbolTableSize- The new value of the symbol table size- Throws:
EPPParserException- Error setting the symbol table size
-
setFeature
public void setFeature(java.lang.String aFeatureId, boolean aBoolean) throws org.xml.sax.SAXNotSupportedException, org.xml.sax.SAXNotRecognizedExceptionSet the state of any feature in a SAX2 parser. The parser might not recognize the feature, and if it does recognize it, it might not be able to fulfill the request.- Parameters:
aFeatureId- The unique identifier (URI) of the feature.aBoolean- The requested state of the feature (true or false).- Throws:
org.xml.sax.SAXNotSupportedException- If the requested feature is known, but the requested state is not supported.org.xml.sax.SAXNotRecognizedException- If the requested feature is not known.
-
setProperty
public void setProperty(java.lang.String aProperty, java.lang.Object aObject) throws org.xml.sax.SAXNotSupportedException, org.xml.sax.SAXNotRecognizedExceptionSet the state of any property in a SAX2 parser. The parser might not recognize the feature, and if it does recognize it, it might not be able to fulfill the request.- Parameters:
aProperty- The unique identifier (URI) of the feature.aObject- The requested state of the feature (true or false).- Throws:
org.xml.sax.SAXNotSupportedException- If the requested feature is known, but the requested state is not supported.org.xml.sax.SAXNotRecognizedException- If the requested feature is not known.
-
getFeature
public boolean getFeature(java.lang.String aFeatureId) throws org.xml.sax.SAXNotSupportedException, org.xml.sax.SAXNotRecognizedExceptionQuery the state of a feature. Query the current state of any feature in a SAX2 parser. The parser might not recognize the feature.- Parameters:
aFeatureId- The unique identifier (URI) of the feature being set.- Returns:
- The current state of the feature.
- Throws:
org.xml.sax.SAXNotSupportedException- If the requested feature is known but not supported.org.xml.sax.SAXNotRecognizedException- If the requested feature is not known.
-
getProperty
public java.lang.Object getProperty(java.lang.String aPropertyId) throws org.xml.sax.SAXNotSupportedException, org.xml.sax.SAXNotRecognizedExceptionQuery the value of a property. Return the current value of a property in a SAX2 parser. The parser might not recognize the property.- Parameters:
aPropertyId- The unique identifier (URI) of the property being set.- Returns:
- The current value of the property.
- Throws:
org.xml.sax.SAXNotSupportedException- If the requested property is known but not supported.org.xml.sax.SAXNotRecognizedException- If the requested property is not known.
-
-