Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402]
Custom XML parser for signed and/or encrypted XML Docs
Author: | Donal McMullan donal@catalyst.net.nz |
License: | http://www.gnu.org/copyleft/gpl.html GNU Public License |
Version: | 0.0.1 |
File Size: | 357 lines (12 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
mnet_encxml_parser:: (2 methods):
__construct()
mnet_encxml_parser()
name:: (13 methods):
initialise()
parse()
free_resource()
start_element()
parse_timestamp()
parse_cipher()
parse_wwwroot()
parse_digest()
parse_signature()
parse_object()
discard_data()
parse_fault()
end_element()
Class: mnet_encxml_parser - X-Ref
Custom XML parser class for signed and/or encrypted XML Docs__construct() X-Ref |
Constructor creates and initialises parser resource and calls initialise return: bool True |
mnet_encxml_parser() X-Ref |
Old syntax of class constructor. Deprecated in PHP7. |
initialise() X-Ref |
Set default element handlers and initialise properties to empty. return: bool True |
parse($data) X-Ref |
Parse a block of XML text The XML Text will be an XML-RPC request which is wrapped in an XML doc with a signature from the sender. This envelope may be encrypted and delivered within another XML envelope with a symmetric key. The parser should first decrypt this XML, and then place the XML-RPC request into the data_object property, and the signature into the signature property. See the W3C's {@link http://www.w3.org/TR/xmlenc-core/ XML Encryption Syntax and Processing} and {@link http://www.w3.org/TR/2001/PR-xmldsig-core-20010820/ XML-Signature Syntax and Processing} guidelines for more detail on the XML. -----XML-Envelope--------------------------------- | | | Symmetric-key-------------------------- | | |_____________________________________| | | | | Encrypted data------------------------- | | | | | | | -XML-Envelope------------------ | | | | | | | | | | | --Signature------------- | | | | | | |______________________| | | | | | | | | | | | | --Signed-Payload-------- | | | | | | | | | | | | | | | XML-RPC Request | | | | | | | |______________________| | | | | | | | | | | | |_____________________________| | | | |_____________________________________| | | | |________________________________________________| param: string $data The XML that you want to parse return: bool True on success - false on failure |
free_resource() X-Ref |
Destroy the parser and free up any related resource. |
start_element($parser, $name, $attrs) X-Ref |
Set the character-data handler to the right function for each element For each tag (element) name, this function switches the character-data handler to the function that handles that element. Note that character data is referred to the handler in blocks of 1024 bytes. param: mixed $parser The XML parser param: string $name The name of the tag, e.g. method_call param: array $attrs The tag's attributes (if any exist). return: bool True |
parse_timestamp($parser, $data) X-Ref |
Add the next chunk of character data to the remote_timestamp string param: mixed $parser The XML parser param: string $data The content of the current tag (1024 byte chunk) return: bool True |
parse_cipher($parser, $data) X-Ref |
Add the next chunk of character data to the cipher string for that tag The XML parser calls the character-data handler with 1024-character chunks of data. This means that the handler may be called several times for a single tag, so we use the concatenate operator (.) to build the tag content into a string. We should not encounter more than one of each tag type, except for the cipher tag. We will often see two of those. We prevent the content of these two tags being concatenated together by counting each tag, and using its 'number' as the key to an array of ciphers. param: mixed $parser The XML parser param: string $data The content of the current tag (1024 byte chunk) return: bool True |
parse_wwwroot($parser, $data) X-Ref |
Add the next chunk of character data to the remote_wwwroot string param: mixed $parser The XML parser param: string $data The content of the current tag (1024 byte chunk) return: bool True |
parse_digest($parser, $data) X-Ref |
Add the next chunk of character data to the digest string param: mixed $parser The XML parser param: string $data The content of the current tag (1024 byte chunk) return: bool True |
parse_signature($parser, $data) X-Ref |
Add the next chunk of character data to the signature string param: mixed $parser The XML parser param: string $data The content of the current tag (1024 byte chunk) return: bool True |
parse_object($parser, $data) X-Ref |
Add the next chunk of character data to the data_object string param: mixed $parser The XML parser param: string $data The content of the current tag (1024 byte chunk) return: bool True |
discard_data($parser, $data) X-Ref |
Discard the next chunk of character data This is used for tags that we're not interested in. param: mixed $parser The XML parser param: string $data The content of the current tag (1024 byte chunk) return: bool True |
parse_fault($parser, $data) X-Ref |
No description |
end_element($parser, $name) X-Ref |
Switch the character-data handler to ignore the next chunk of data param: mixed $parser The XML parser param: string $name The name of the tag, e.g. method_call return: bool True |