Package g4ds :: Module messagewrapper :: Class MessageWrapper
[show private | hide private]
[frames | no frames]

Class MessageWrapper

GenericWrapper --+
                 |
                MessageWrapper


Integrates all functions for wrapping and unwrapping data with XML elements.
Method Summary
  __init__(self)
Yet empty Constructor.
String, String, String unwrapControlMessage(self, message)
Unwraps a control message and returns the data as to be passed to the service.
String; String unwrapForDecryption(self, message)
Extracts the cipher text and the name of the algorithm from an encrypted G4DS message chunk.
String; String; String; String; String unwrapForValidation(self, message)
Extracts the message, the signature and the name of the algorithm from a G4DS signature message chunk.
String, xml.dom.Node unwrapG4dsMessage(self, message)
Processes a G4DS XML message and extracts and returns its content.
  unwrapG4dsPlain(self, message)
Processes a G4DS XML plain message and extracts and returns its content.
String, String, String unwrapServiceMessage(self, message)
Unwraps a service message and returns the data as to be passed to the service.
String wrapControlMessage(self, subsystemid, subsystemname, message)
Wraps a message (String of any type (not only XML)) into a G4DS Control message.
String; xml.dom.Document; xml.dom.Element wrapForEncryption(self, message, algName)
Wraps an encrypted message chunk into a valid XML node.
String; xml.dom.Document; xml.dom.Element wrapForSigning(self, message, signature, algName, senderid, communityid)
Wraps the message together with the signature into a signed G4DS message chunk.
String; xml.dom.Document wrapG4dsMessage(self, node)
Creates a new XML document, which is a valid G4DS message, containing the data given by node.
  wrapG4dsPlain(self, xmltext, messageid, senderid, referenceid)
Creates a new G4DS plain message.
String wrapServiceMessage(self, appid, appname, message)
Wraps a message (String of any type (not only XML)) into a G4DS Service message.
Inherited from GenericWrapper: unwrapActionAndData, unwrapArgsAndDatas, wrapActionAndData, wrapArgsAndDatas, _decodeHex, _encodeHex, _replaceCdata, _unReplaceCdata

Method Details

__init__(self)
(Constructor)

Yet empty Constructor.
Overrides:
g4ds.messagewrapper.GenericWrapper.__init__

unwrapControlMessage(self, message)

Unwraps a control message and returns the data as to be passed to the service.
Parameters:
message - XML String of the message containing control data.
           (type=String)
Returns:
Sub system ID, Sub system name and Control message; None, None, None if any of them was not found or the given message is not a g4ds control message
           (type=String, String, String)

unwrapForDecryption(self, message)

Extracts the cipher text and the name of the algorithm from an encrypted G4DS message chunk.

Inverse function to wrapForEncryption. Extracts the algorithm name and the cipher text from the message given.
Parameters:
message - XML String of the G4DS encrypted message chunk
           (type=String)
Returns:
Name of the algorithm and the cipher text
           (type=String; String)

Note: The decryption itself is not performed here. Only the information required for the decryption is gained.

unwrapForValidation(self, message)

Extracts the message, the signature and the name of the algorithm from a G4DS signature message chunk.

Inverse function to wrapForSigning.
Parameters:
message - XML String of the G4DS signed message chunk
           (type=String)
Returns:
Name of the algorithm, unique id of the sender, unique id of the community, the message and the signature
           (type=String; String; String; String; String)

unwrapG4dsMessage(self, message)

Processes a G4DS XML message and extracts and returns its content.
Parameters:
message - XML String - G4DS message to be processed.
           (type=String)
Returns:
All the stuff underneath the G4DS node both as XML String and as DOM Tree Node, None, None if no G4DS message was found
           (type=String, xml.dom.Node)

unwrapG4dsPlain(self, message)

Processes a G4DS XML plain message and extracts and returns its content.

unwrapServiceMessage(self, message)

Unwraps a service message and returns the data as to be passed to the service.

The format of the message must be exactly the one as assembled the the function wrapServiceMessage. Parameters for serive id and name are taken as text values from the corresponding nodes; the data itself is extracted from the CDATA section.
Parameters:
message - XML String of the message, the service information shall be extracted from
           (type=String)
Returns:
Service ID, Serice name and Service message
           (type=String, String, String)

wrapControlMessage(self, subsystemid, subsystemname, message)

Wraps a message (String of any type (not only XML)) into a G4DS Control message.
Parameters:
subsystemid - ID of the g4ds control subsystem
           (type=String)
subsystemname - Name of the g4ds control subsystem
           (type=String)
message - Message from the control subsystem to be wrapped (XML or plain text)
           (type=String)
Returns:
String representation of the XML stream, in which the data is encapsulated in a CDATA section
           (type=String)

wrapForEncryption(self, message, algName)

Wraps an encrypted message chunk into a valid XML node.

Encrypted message chunks have to be wrapped into a node named "enc". The name of the encryption algorithm has to be provided in the message itself too, sothat the receiver may choose the appropriate algorithm on its side. The cipher text itself (given as message) is stored into a CDATA section.
Parameters:
message - Cipher text to be wrapped into a encrypted G4DS field
           (type=String)
algName - Name of the encryption algorithm to be used for decryption
           (type=String)
Returns:
The result as String and as Dom tree and as root element of the dom tree
           (type=String; xml.dom.Document; xml.dom.Element)

wrapForSigning(self, message, signature, algName, senderid, communityid)

Wraps the message together with the signature into a signed G4DS message chunk.
Parameters:
message - Message which was signed and is to be wrapped into a G4DS signed message chunk
           (type=String)
signature - The signature which was processed beforehand
           (type=String)
algName - Name of the encryption algorithm to be used for signing
           (type=String)
senderid - G4DS unique id of the sender
           (type=String)
communityid - G4DS unique id of the community
           (type=String)
Returns:
The result as String and as Dom tree and as root element of the dom tree
           (type=String; xml.dom.Document; xml.dom.Element)

wrapG4dsMessage(self, node)

Creates a new XML document, which is a valid G4DS message, containing the data given by node.
Parameters:
node - Content of the XML document to be appended underneath the G4DS root element.
           (type=xml.dom.Node)
Returns:
XML String containing the G4DS message, and the XML DOM document
           (type=String; xml.dom.Document)

wrapG4dsPlain(self, xmltext, messageid, senderid, referenceid=None)

Creates a new G4DS plain message.

wrapServiceMessage(self, appid, appname, message)

Wraps a message (String of any type (not only XML)) into a G4DS Service message.

The message is put into a CDATA section. This way it might of of any format; and not exclusively XML data. The XML message will look the following way:

<service>

<serviceid>$appid</serviceid>

<servicename>$appname</servicename>

<data> <[!CDATA[$message]]> </data>

</service>
Parameters:
appid - G4DS wide unique ID of the service
           (type=String)
appname - Name of the service
           (type=String)
message - Payload of the service, either XML or plain text
           (type=String)
Returns:
XML String of the service part of a G4DS message containing the service data
           (type=String)

Generated by Epydoc 2.0 on Sat Oct 22 22:52:47 2005 http://epydoc.sf.net