|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.rsa.certj.xml.ParserHandler
This class defines methods for reading and writing XML signatures to
or from an XML document. It processes an XML document by either loading
XMLSignature
objects from a file or by generating the signed
document based on information provided by the XMLSignature
object. After processing, it writes the document.
Field Summary |
|
static String |
DTD_LOCATION
A |
static String |
PRINTWRITER_ENCODING
Default encoding for an XML signature document. |
static String |
PUBLIC_ID
A |
static boolean |
setNameSpaces
A |
static boolean |
setValidation
A |
static String |
SYSTEM_ID
A |
static String |
TEMPLATE_ID
The unique ID attribute value of the signature template
that specifies the template to fill with
|
Constructor Summary |
|
ParserHandler()
|
Method Summary |
|
static org.w3c.dom.Node |
byteArrayToNode(byte[] input,
int inOffset,
int inputLength)
Converts a |
static int |
checkSignatureType(XMLSignature xmlSig)
Checks the signature type of the passed-in
|
static org.w3c.dom.Element |
generateKeyInfo(XMLSignature xmlSignature,
org.w3c.dom.Document document)
Generates a |
static org.w3c.dom.Element |
generateSignatureElement(XMLSignature xmlSignature,
org.w3c.dom.Document document)
Generates a signature element of the particular |
static void |
getStringValue(org.w3c.dom.NodeList nodes,
StringBuffer valueString)
Retrieves the information stored in a |
static void |
getStringValue(org.w3c.dom.Node node,
StringBuffer valueString)
Converts the node-set node
to a |
static byte[] |
nodeToByteArray(org.w3c.dom.Node node,
boolean canonical,
boolean withComments,
String encoding)
Converts a node to a |
static byte[] |
nodeToByteArray(org.w3c.dom.NodeList node,
boolean canonical,
boolean withComments,
String encoding)
Converts a node-set to a |
static void |
parseSignedInfo(XMLSignature xmlSignature,
org.w3c.dom.Element sigEle)
Parses the sigEle, retrieves the signedInfo information and stores in the xmlSignature. |
static org.w3c.dom.Document |
parseXML(org.xml.sax.InputSource inputSource)
Parses input source with a DOM parser configured as specified by the user settings. |
static XMLSignature[] |
read(File file)
Reads data from an XML document containing XML signatures
specified by a |
static XMLSignature[] |
read(InputStream inputStream)
Reads data from an XML document containing XML signatures
specified by an |
static XMLSignature[] |
read(String fileName)
Reads data from an XML document file or URL containing XML signatures specified by the fileName. |
static void |
write(File signedDocument,
XMLSignature xmlSignature)
Writes an |
static void |
write(OutputStream signedDocument,
XMLSignature xmlSignature)
Writes an |
static void |
write(String signedDocument,
XMLSignature xmlSignature)
Writes a list of |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static String PRINTWRITER_ENCODING
public static String TEMPLATE_ID
SignatureValue
and DigestValue
values.
If this value is null
, then the first empty signature
template will be processed.public static String SYSTEM_ID
String
object that defines the system ID when
reading an XML file, to be signed or verified. This variable is
optional. When it is set to null
(the default value), then
any DTD element declarations in the document must be fully qualified.
Otherwise, the value set for this String
can be
used by the parser to help resolve relative URIs in the document.public static String PUBLIC_ID
String
object that defines the public ID when
reading an XML file, to be signed or verified. This variable is
optional. When it is set to null
(the default value),
then any DTD element declarations in the document must be fully
qualified. Otherwise, the value set for this String
can be used by the parser to help resolve relative URIs in the document.public static String DTD_LOCATION
String
object defining the XML signature schema definition
file and its path. It is optional. If it is null
, then the
schema will not be specified in the output file.
Note: XMLException will be thrown if a protocol handler cannot be found.
For instance
ParserHandler.DTD_LOCATION="file:///C:/xmldsig-core-schema.dtd"
or
ParserHandler.DTD_LOCATION="http://location.com/xmldsig-core-schema.dtd"
can be set.public static boolean setValidation
boolean
setting for a parser feature. This sets the
parser feature "http://xml.org/sax/features/validation".
Default value is false.public static boolean setNameSpaces
boolean
setting for a parser feature. This sets the
parser feature "http://xml.org/sax/features/namespaces".
Default value is true.Constructor Detail |
public ParserHandler()
Method Detail |
public static XMLSignature[] read(String fileName) throws XMLException
XMLSignature
objects associated
with this document.
Parameters
fileName | A |
Returns
XMLSignature
objects retreived from the
input XML document.Throws
XMLException
- If an error occurs in reading and
processing this document.public static XMLSignature[] read(File file) throws XMLException
File
object. It parses data from the
file and instantiates a list of XMLSignature
objects associated with this document.
Parameters
file | A |
Returns
XMLSignature
objects retreived from the
input XML document.Throws
XMLException
- If an error occurs in reading and
processing this document.public static XMLSignature[] read(InputStream inputStream) throws XMLException
InputStream
object. It parses data from the
inputStream and instantiates a list of XMLSignature
objects associated with this document.
Parameters
inputStream | An |
Returns
XMLSignature
objects retreived from the
input XML document.Throws
XMLException
- If an error occurs in reading and
processing this document.public static org.w3c.dom.Document parseXML(org.xml.sax.InputSource inputSource) throws XMLException
Parameters
inputSoure | An |
Returns
Document
object.Throws
XMLException
- If an error occurs while creating the
parser or during the actual parsing.public static void parseSignedInfo(XMLSignature xmlSignature, org.w3c.dom.Element sigEle) throws XMLException
Internal method, do not use
public static int checkSignatureType(XMLSignature xmlSig)
XMLSignature
object.
Internal method, do not use
Returns
integer
value specifing the signature type.public static void write(String signedDocument, XMLSignature xmlSignature) throws XMLException
XMLSignature
objects to a file or URL
with the name signedDocument.Parameters
signedDocument | A | ||
xmlSignature | An |
Throws
XMLException
- If an error occurs while writing the
xmlSignature as an XML document.public static void write(File signedDocument, XMLSignature xmlSignature) throws XMLException
XMLSignature
to a File
object.Parameters
signedDocument | A | ||
xmlSignature | An |
Throws
XMLException
- If an error occurs while writing the
xmlSignature out as an XML document.public static void write(OutputStream signedDocument, XMLSignature xmlSignature) throws XMLException
XMLSignature
to an OutputStream
object.Parameters
signedDocument | An | ||
xmlSignature | An |
Throws
XMLException
- If an error occurs while writing the
xmlSignature out as an XML document.public static org.w3c.dom.Element generateSignatureElement(XMLSignature xmlSignature, org.w3c.dom.Document document) throws XMLException
XMLSignature
object.
Internal method, do not useParameters
xmlSignature | An | ||
document | The |
Returns
Element
object.Throws
XMLException
- If an error occurs while generating
the Signature element.public static org.w3c.dom.Element generateKeyInfo(XMLSignature xmlSignature, org.w3c.dom.Document document) throws XMLException
Element
object containing the key information
of xmlSignature. The generated element will be attached to
document.
Internal method, do not use
public static byte[] nodeToByteArray(org.w3c.dom.NodeList node, boolean canonical, boolean withComments, String encoding) throws XMLException
byte
array.Parameters
node | A | ||
canonical | A | ||
withComments | A | ||
encoding | A |
Returns
byte
array storing all the data of the passed-in
NodeList
object.Throws
XMLException
- If an error ocurrs while converting.public static byte[] nodeToByteArray(org.w3c.dom.Node node, boolean canonical, boolean withComments, String encoding) throws XMLException
byte
array.
Parameters
node | A | ||
canonical | A | ||
withComments | A | ||
encoding | A |
Returns
byte
array storing all the data of the passed-in
node
object.Throws
XMLException
- If an error occurrs while converting.public static org.w3c.dom.Node byteArrayToNode(byte[] input, int inOffset, int inputLength) throws XMLException
byte
array to a node.
Parameters
input | A | ||
inOffset | An | ||
inputLength | An |
Throws
XMLException
- If an error occurs while converting.public static void getStringValue(org.w3c.dom.Node node, StringBuffer valueString) throws XMLException
String
value. All data
including start and end tags are converted.
Parameters
node | A | ||
valueString | A |
Throws
XMLException
- If an error occurs while converting
the node to a String
value.public static void getStringValue(org.w3c.dom.NodeList nodes, StringBuffer valueString) throws XMLException
NodeList
object and stores it in a StringBuffer
.
Parameters
nodes | The | ||
valueString | A |
Throws
XMLException
- If an error occurs while converting the node-set
to a String
value.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |