Beispiel #1
0
        if not cert:
            raise Exception(
                "This message has not been signed by the claimed party.")

        ret = {}
        ret['message'] = data
        ret['signedBy'] = ('certificate', cert.as_pem().strip())
        return (ret, "XML data verified as signed by '%s'" %
                cert.get_subject().as_text())


CodecManager.registerCodecClass('soap11.ds', SoapDigitalSignatureCodec)

if __name__ == '__main__':
    CodecManager.alias('ds', 'soap11.ds')

    sampleEnv = """<?xml version="1.0" encoding="utf-8" ?>
<soapenv:Envelope xmlns:ns="http://www.eservglobal.com/homesend/tews/2.0" xmlns:ns1="http://www.eservglobal.com/homesend/types/2.0" xmlns:ns2="http://www.eservglobal.com/homesend/tews/2.1" xmlns:ns3="http://www.eservglobal.com/homesend/types/2.1" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
<library owner="John Smith" administrator="Héléna Utf8 and Mickaël Orangina" xmlns="http://default" xmlns:b="http://base">
	<book isbn="88888-7777788">
		<b:author>Mickaël Orangina</b:author>
		<title locale="fr">Tonnerre sous les tropiques</title>
		<title locale="us">Tropic thunder</title>
		<title locale="es">No <i>habla</i> espagnol</title>
		<b:summary><![CDATA[This is a CDATA section <-> <-- this is a tie fighter]]></b:summary>
	</book>
</library>
   </soapenv:Body>
</soapenv:Envelope>
Beispiel #2
0
		children = []
		for node in element.childNodes:
			if node.nodeType == node.ELEMENT_NODE:
				children.append(self._decode(node))
			# We should return only if these nodes are the first one.. ?
			elif node.nodeType == node.TEXT_NODE and node.nodeValue.strip():
				return (tag, node.nodeValue.strip())
			# Ignore other final node types (cdata, comments, ...)
		
		return (tag, children) 

CodecManager.registerCodecClass('xer.lite', XerLiteCodec)


if __name__ == '__main__':
	CodecManager.alias('xer.noprolog', 'xer.lite', write_prolog = False)
	CodecManager.alias('xer.iso', 'xer.lite', encoding = "iso-8859-1")
	CodecManager.alias('xer.canonical', 'xer.lite', canonical = True)
	
	sample = """<?xml version="1.0"?>
<library>
	<administrator>Héléna Utf8</administrator>
	<book>
		<isbn>89084-89089</isbn>
		<author>Philippe Kendall</author>
		<author>Mickaël Orangina</author>
		<title>Tropic thunder</title>
	</book>
</library>
"""
		
		if not cert:
			raise Exception("This message has not been signed by the claimed party.")

		ret = {}
		ret['message'] = data
		ret['signedBy'] = ('certificate', cert.as_pem().strip())			
		return (ret, "XML data verified as signed by '%s'" % cert.get_subject().as_text())

	

CodecManager.registerCodecClass('soap11.ds', SoapDigitalSignatureCodec)


if __name__ == '__main__':
	CodecManager.alias('ds', 'soap11.ds')
	
	sampleEnv = """<?xml version="1.0" encoding="utf-8" ?>
<soapenv:Envelope xmlns:ns="http://www.eservglobal.com/homesend/tews/2.0" xmlns:ns1="http://www.eservglobal.com/homesend/types/2.0" xmlns:ns2="http://www.eservglobal.com/homesend/tews/2.1" xmlns:ns3="http://www.eservglobal.com/homesend/types/2.1" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
<library owner="John Smith" administrator="Héléna Utf8 and Mickaël Orangina" xmlns="http://default" xmlns:b="http://base">
	<book isbn="88888-7777788">
		<b:author>Mickaël Orangina</b:author>
		<title locale="fr">Tonnerre sous les tropiques</title>
		<title locale="us">Tropic thunder</title>
		<title locale="es">No <i>habla</i> espagnol</title>
		<b:summary><![CDATA[This is a CDATA section <-> <-- this is a tie fighter]]></b:summary>
	</book>
</library>
   </soapenv:Body>
</soapenv:Envelope>
Beispiel #4
0
		children = []
		for node in element.childNodes:
			if node.nodeType == node.ELEMENT_NODE:
				children.append(self._decode(node))
			# We should return only if these nodes are the first one.. ?
			elif node.nodeType == node.TEXT_NODE and node.nodeValue.strip():
				return (tag, node.nodeValue.strip())
			# Ignore other final node types (cdata, comments, ...)
		
		return (tag, children) 

CodecManager.registerCodecClass('xer.lite', XerLiteCodec)


if __name__ == '__main__':
	CodecManager.alias('xer.noprolog', 'xer.lite', write_prolog = False)
	CodecManager.alias('xer.iso', 'xer.lite', encoding = "iso-8859-1")
	CodecManager.alias('xer.canonical', 'xer.lite', canonical = True)
	
	sample = """<?xml version="1.0"?>
<library>
	<administrator>Héléna Utf8</administrator>
	<book>
		<isbn>89084-89089</isbn>
		<author>Philippe Kendall</author>
		<author>Mickaël Orangina</author>
		<title>Tropic thunder</title>
	</book>
</library>
"""
Beispiel #5
0
			# only element children
			d = { 'attributes': attributes, 'children': children }
			if ns: d['ns'] = ns
			return (tag, d)

		# no child, or a single text child
		d = { 'attributes': attributes, 'cdata': cdata, 'value': value }
		if ns: d['ns'] = ns
		return (tag, d)
	

CodecManager.registerCodecClass('xml', XmlCodec)


if __name__ == '__main__':
	CodecManager.alias('xml.noprolog', 'xml', write_prolog = False)
	CodecManager.alias('xml.iso', 'xml', encoding = "iso-8859-1", write_prolog = True)
	CodecManager.alias('xml.pretty', 'xml', prettyprint = True)
	
	sampleNoNs = """<?xml version="1.0" encoding="utf-8" ?>
<library owner="John Smith" administrator="Héléna Utf8 and Mickaël Orangina">
	<book isbn="88888-7777788">
		<author>Mickaël Orangina</author>
		<title locale="fr">Tonnerre sous les tropiques</title>
		<title locale="us">Tropic thunder</title>
		<title locale="es">No <i>habla</i> espagnol</title>
		<summary><![CDATA[This is a CDATA section <-> <-- this is a tie fighter]]></summary>
	</book>
</library>
"""
Beispiel #6
0
        if hasElementChild:
            # only element children
            d = {'attributes': attributes, 'children': children}
            if ns: d['ns'] = ns
            return (tag, d)

        # no child, or a single text child
        d = {'attributes': attributes, 'cdata': cdata, 'value': value}
        if ns: d['ns'] = ns
        return (tag, d)


CodecManager.registerCodecClass('xml', XmlCodec)

if __name__ == '__main__':
    CodecManager.alias('xml.noprolog', 'xml', write_prolog=False)
    CodecManager.alias('xml.iso',
                       'xml',
                       encoding="iso-8859-1",
                       write_prolog=True)
    CodecManager.alias('xml.pretty', 'xml', prettyprint=True)

    sampleNoNs = """<?xml version="1.0" encoding="utf-8" ?>
<library owner="John Smith" administrator="Héléna Utf8 and Mickaël Orangina">
	<book isbn="88888-7777788">
		<author>Mickaël Orangina</author>
		<title locale="fr">Tonnerre sous les tropiques</title>
		<title locale="us">Tropic thunder</title>
		<title locale="es">No <i>habla</i> espagnol</title>
		<summary><![CDATA[This is a CDATA section <-> <-- this is a tie fighter]]></summary>
	</book>