|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opensaml.XML.ParserPool
Nested class that provides XML parsers as a pooled resource
Field Summary | |
protected SAMLConfig |
config
OpenSAML configuration |
Constructor Summary | |
XML.ParserPool()
Constructor for the ParserPool object |
Method Summary | |
void |
error(SAXParseException e)
Called by parser if an error is detected, currently just throws e |
void |
fatalError(SAXParseException e)
Called by parser if a fatal error is detected, does nothing |
DocumentBuilder |
get()
Get a DocumentBuilder for the default Schema |
DocumentBuilder |
get(Schema schema)
Get a DOM parser suitable for our task |
Schema |
getDefaultSchema()
|
Schema |
getSchemaSAML10()
|
Schema |
getSchemaSAML11()
|
Document |
newDocument()
Builds a new DOM document |
Document |
parse(InputSource in,
Schema schema)
Parses a document using a pooled parser with the proper settings |
Document |
parse(InputStream in)
Short form of parse to support legacy callers |
Document |
parse(String systemId)
Legacy version of parse where the default Schema is implied |
Document |
parse(String systemId,
Schema schema)
Parses a document using a pooled parser with the proper settings |
void |
put(DocumentBuilder p)
Return a parser to the pool |
void |
registerSchemas(Map exts)
Registers one or more extension schemas in the default schema set. |
InputSource |
resolveEntity(String publicId,
String systemId)
|
void |
setDefaultSchema(Schema schema)
Deprecated. |
void |
setDefaultSchemas(Schema schema10,
Schema schema11)
Directly installs a custom schema. |
void |
warning(SAXParseException e)
Called by parser if a warning is issued, currently logs the condition |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected SAMLConfig config
Constructor Detail |
public XML.ParserPool()
To demonstrate the technology, the current version of this code creates both 1.0 and 1.1 Schema objects. However, it then selects only one of the two to use. Future code could refine this and maintain two pools of parsers.
Method Detail |
public void setDefaultSchema(Schema schema)
schema
- public void setDefaultSchemas(Schema schema10, Schema schema11)
schema10
- The schemas to use when handling SAML 1.0schema11
- The schemas to use when handling SAML 1.1public Schema getDefaultSchema()
public Schema getSchemaSAML10()
public Schema getSchemaSAML11()
public void registerSchemas(Map exts)
Note that you must insure that any dependencies are specified ahead of the schemas that require them, because they must be loaded by the SchemaFactory before they are required.
exts
- A map of EntityResolver interfaces keyed by "systemId" to
enable the SAML runtime to obtain the schema instances anytime requiredpublic DocumentBuilder get(Schema schema) throws SAMLException
schema
- JAXP 1.3 Schema object (or null for no XSD)
SAMLException
- Raised if a system error prevents a parser
from being createdpublic DocumentBuilder get() throws SAMLException
Note: This uses the default (probably SAML 1.1) Schema. To get an non-schema-validating parser, call "get(null)".
SAMLException
- can't create a DocumentBuilderpublic Document parse(InputSource in, Schema schema) throws SAMLException, SAXException, IOException
in
- A stream containing the content to
be parsedschema
- Schema object or null
SAMLException
- Raised if a parser is unavailable
SAXException
- Raised if a parsing error occurs
IOException
- Raised if an I/O error occurspublic Document parse(InputStream in) throws SAMLException, SAXException, IOException
This version is not preferred. If the caller converts the InputStream to an InputSource, then it can append a file name as the systemId. Here we only get the InputStream and create an InputSource with no identifier to be used in logging or generating error messages.
in
- InputStream of XML to be parsed
SAMLException
- Raised if a parser is unavailable
SAXException
- Raised if a parsing error occurs
IOException
- Raised if an I/O error occurspublic Document parse(String systemId, Schema schema) throws SAMLException, SAXException, IOException
systemId
- The URI to parse
SAMLException
- Raised if a parser is unavailable
SAXException
- Raised if a parsing error occurs
IOException
- Raised if an I/O error occurspublic Document parse(String systemId) throws SAMLException, SAXException, IOException
systemId
- URI to be parsed, becomes systemId of InputSource
SAMLException
- Raised if a parser is unavailable
SAXException
- Raised if a parsing error occurs
IOException
- Raised if an I/O error occurspublic Document newDocument()
In JAXP, you get a new empty DOM document from a DocumentBuilder. There is no evidence that the Schema is attached to the DOM, so it doesn't matter what pool to use.
public void put(DocumentBuilder p)
p
- Description of Parameterpublic void fatalError(SAXParseException e) throws SAXException
fatalError
in interface ErrorHandler
SAXException
- Can be raised to indicate an explicit errorpublic void error(SAXParseException e) throws SAXParseException
error
in interface ErrorHandler
e
- Description of Parameter
SAXParseException
- Can be raised to indicate an explicit
errorpublic void warning(SAXParseException e) throws SAXParseException
warning
in interface ErrorHandler
e
- Describes the warning
SAXParseException
- Can be raised to indicate an explicit
errorpublic InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
resolveEntity
in interface EntityResolver
SAXException
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |