Пример #1
0
    def xml(self):
        """
        Get xml representation of the object.
        @return: The root node.
        @rtype: L{Element}
        """
        root = Element('UsernameToken', ns=WSSE_NS)
        for p, u in self.nsprefixes.items():
            root.addPrefix(p, u)
        root.append(Attribute('wsu:Id', 'UsernameToken-9'))
        root.append(Attribute('xmlns:wsu', WSU_URI))

        u = Element('Username', ns=WSSE_NS)
        u.setText(self.username)
        root.append(u)
        p = Element('Password', ns=WSSE_NS)
        p.setText(self.password)
        p.append(Attribute('Type', WSU_UN_URI))
        root.append(p)
        if self.nonce is not None:
            n = Element('Nonce', ns=WSSE_NS)
            n.setText(self.nonce)
            root.append(n)
        if self.created is not None:
            n = Element('Created', ns=WSU_NS)
            n.setText(str(UTC(self.created)))
            root.append(n)
        return root
Пример #2
0
 def node(self, content):
     ns = content.type.namespace()
     if content.type.form_qualified:
         node = Element(content.tag, ns=ns)
         node.addPrefix(ns[0], ns[1])
     else:
         node = Element(content.tag)
     self.encode(node, content)
     log.debug('created - node:\n%s', node)
     return node
Пример #3
0
 def xml(self):
     """
     Get xml representation of the object.
     @return: The root node.
     @rtype: L{Element}
     """
     root = Element('Security', ns=WSSE_NS)
     for p, u in self.nsprefixes.items():
         root.addPrefix(p, u)
     root.set('SOAP-ENV:mustUnderstand', self.mustUnderstand)
     for t in self.tokens:
         root.append(t.xml())
     return root
Пример #4
0
 def node(self, content):
     #
     # Create an XML node and namespace qualify as defined
     # by the schema (elementFormDefault).
     #
     ns = content.type.namespace()
     if content.type.form_qualified:
         node = Element(content.tag, ns=ns)
         node.addPrefix(ns[0], ns[1])
     else:
         node = Element(content.tag)
     self.encode(node, content)
     log.debug('created - node:\n%s', node)
     return node
Пример #5
0
 def node(self, content):
     #
     # Create an XML node and namespace qualify as defined
     # by the schema (elementFormDefault).
     #
     ns = content.type.namespace()
     if content.type.form_qualified:
         node = Element(content.tag, ns=ns)
         node.addPrefix(ns[0], ns[1])
     else:
         node = Element(content.tag)
     self.encode(node, content)
     log.debug('created - node:\n%s', node)
     return node
Пример #6
0
 def envelope(self, header, body):
     """
     Build the B{<Envelope/>} for an soap outbound message.
     @param header: The soap message B{header}.
     @type header: L{Element}
     @param body: The soap message B{body}.
     @type body: L{Element}
     @return: The soap envelope containing the body and header.
     @rtype: L{Element}
     """
     env = Element('Envelope', ns=envns)
     env.addPrefix(Namespace.xsins[0], Namespace.xsins[1])
     env.append(header)
     env.append(body)
     return env
Пример #7
0
 def envelope(self, header, body):
     """
     Build the B{<Envelope/>} for a SOAP outbound message.
     @param header: The SOAP message B{header}.
     @type header: L{Element}
     @param body: The SOAP message B{body}.
     @type body: L{Element}
     @return: The SOAP envelope containing the body and header.
     @rtype: L{Element}
     """
     env = Element('Envelope', ns=envns)
     env.addPrefix(Namespace.xsins[0], Namespace.xsins[1])
     env.append(header)
     env.append(body)
     return env
Пример #8
0
    def node(self, content):
        """
        Create an XML node.

        The XML node is namespace qualified as defined by the corresponding
        schema element.

        """
        ns = content.type.namespace()
        if content.type.form_qualified:
            node = Element(content.tag, ns=ns)
            if ns[0]:
                node.addPrefix(ns[0], ns[1])
        else:
            node = Element(content.tag)
        self.encode(node, content)
        log.debug("created - node:\n%s", node)
        return node
Пример #9
0
    def node(self, content):
        """
        Create an XML node.

        The XML node is namespace qualified as defined by the corresponding
        schema element.

        """
        ns = content.type.namespace()
        if content.type.form_qualified:
            node = Element(content.tag, ns=ns)
            if ns[0]:
                node.addPrefix(ns[0], ns[1])
        else:
            node = Element(content.tag)
        self.encode(node, content)
        log.debug("created - node:\n%s", node)
        return node
Пример #10
0
 def node(self, content):
     """
     Create and return an XML node that is qualified
     using the I{type}.  Also, make sure all referenced namespace
     prefixes are declared.
     @param content: The content for which proccessing has ended.
     @type content: L{Object}
     @return: A new node.
     @rtype: L{Element}
     """
     ns = content.type.namespace()
     if content.type.form_qualified:
         node = Element(content.tag, ns=ns)
         node.addPrefix(ns[0], ns[1])
     else:
         node = Element(content.tag)
     self.encode(node, content)
     log.debug('created - node:\n%s', node)
     return node
Пример #11
0
    def _build_security_header(self, username, password):
        """ Alternative method for building security header elements to use
            in the SOAP calls.  This method is *not* being used currently, but
            is left here for reference.
        """
        usernameElement = Element('Username', ns=WSSE_NS)
        usernameElement.setText(username)

        passwordElement = Element('Password', ns=WSSE_NS)
        passwordElement.setText(password)
        passwordElement.append(Attribute('Type', WSU_UN_URI))

        userCreds = Element('UsernameToken', ns=WSSE_NS)
        userCreds.append(Attribute('wsu:Id', 'UsernameToken-9'))
        userCreds.append(Attribute('xmlns:wsu', WSSE_URI))
        userCreds.insert(usernameElement)
        userCreds.insert(passwordElement)

        security = Element('Security', ns=WSSE_NS)
        security.addPrefix(p='SOAP-ENC', u=SOAP_ENC_URI)
        security.append(Attribute('SOAP-ENV:mustUnderstand', '1'))
        security.append(Attribute('xmlns:wsse', WSSE_URI))
        security.insert(userCreds)
        return security