Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if hash_data:
file_tag.addChild(node=hash_data)
pjid = app.get_jid_without_resource(self.session.peerjid)
file_info = {'name' : self.file_props.name,
'file-name' : self.file_props.file_name,
'hash' : self.file_props.hash_,
'size' : self.file_props.size,
'date' : self.file_props.date,
'peerjid' : pjid
}
self.session.connection.get_module('Jingle').set_file_info(file_info)
desc = file_tag.setTag('desc')
if self.file_props.desc:
desc.setData(self.file_props.desc)
if self.use_security:
security = nbxmpp.simplexml.Node(
tag=Namespace.JINGLE_XTLS + ' security')
certpath = os.path.join(
configpaths.get('MY_CERT'), SELF_SIGNED_CERTIFICATE) + '.cert'
cert = load_cert_file(certpath)
if cert:
digest_algo = (cert.get_signature_algorithm()
.decode('utf-8').split('With')[0])
security.addChild('fingerprint').addData(cert.digest(
digest_algo).decode('utf-8'))
for m in ('x509', ): # supported authentication methods
method = nbxmpp.simplexml.Node(tag='method')
method.setAttr('name', m)
security.addChild(node=method)
content.addChild(node=security)
content.addChild(node=description_node)
desc = file_tag.setTag('desc')
if self.file_props.desc:
desc.setData(self.file_props.desc)
if self.use_security:
security = nbxmpp.simplexml.Node(
tag=Namespace.JINGLE_XTLS + ' security')
certpath = os.path.join(
configpaths.get('MY_CERT'), SELF_SIGNED_CERTIFICATE) + '.cert'
cert = load_cert_file(certpath)
if cert:
digest_algo = (cert.get_signature_algorithm()
.decode('utf-8').split('With')[0])
security.addChild('fingerprint').addData(cert.digest(
digest_algo).decode('utf-8'))
for m in ('x509', ): # supported authentication methods
method = nbxmpp.simplexml.Node(tag='method')
method.setAttr('name', m)
security.addChild(node=method)
content.addChild(node=security)
content.addChild(node=description_node)
def _fill_content(self, content):
description_node = nbxmpp.simplexml.Node(
tag=Namespace.JINGLE_FILE_TRANSFER_5 + ' description')
file_tag = description_node.setTag('file')
if self.file_props.name:
node = nbxmpp.simplexml.Node(tag='name')
node.addData(self.file_props.name)
file_tag.addChild(node=node)
if self.file_props.date:
node = nbxmpp.simplexml.Node(tag='date')
node.addData(self.file_props.date)
file_tag.addChild(node=node)
if self.file_props.size:
node = nbxmpp.simplexml.Node(tag='size')
node.addData(self.file_props.size)
file_tag.addChild(node=node)
if self.file_props.type_ == 'r':
if self.file_props.hash_:
file_tag.addChild('hash', attrs={'algo': self.file_props.algo},
namespace=Namespace.HASHES_2,
payload=self.file_props.hash_)
else:
def _fill_content(self, content):
description_node = nbxmpp.simplexml.Node(
tag=Namespace.JINGLE_FILE_TRANSFER_5 + ' description')
file_tag = description_node.setTag('file')
if self.file_props.name:
node = nbxmpp.simplexml.Node(tag='name')
node.addData(self.file_props.name)
file_tag.addChild(node=node)
if self.file_props.date:
node = nbxmpp.simplexml.Node(tag='date')
node.addData(self.file_props.date)
file_tag.addChild(node=node)
if self.file_props.size:
node = nbxmpp.simplexml.Node(tag='size')
node.addData(self.file_props.size)
file_tag.addChild(node=node)
if self.file_props.type_ == 'r':
if self.file_props.hash_:
def _fill_content(self, content):
description_node = nbxmpp.simplexml.Node(
tag=Namespace.JINGLE_FILE_TRANSFER_5 + ' description')
file_tag = description_node.setTag('file')
if self.file_props.name:
node = nbxmpp.simplexml.Node(tag='name')
node.addData(self.file_props.name)
file_tag.addChild(node=node)
if self.file_props.date:
node = nbxmpp.simplexml.Node(tag='date')
node.addData(self.file_props.date)
file_tag.addChild(node=node)
if self.file_props.size:
node = nbxmpp.simplexml.Node(tag='size')
node.addData(self.file_props.size)
file_tag.addChild(node=node)
if self.file_props.type_ == 'r':
if self.file_props.hash_:
file_tag.addChild('hash', attrs={'algo': self.file_props.algo},
namespace=Namespace.HASHES_2,
payload=self.file_props.hash_)
else:
# if the file is less than 10 mb, then it is small
# lets calculate it right away
if self.file_props.size < 10000000 and not self.file_props.hash_:
hash_data = self._compute_hash()