Esempio n. 1
0
    def __init__(self,
                 _data,
                 _subtype='octet-stream; name="encrypted.asc"',
                 _encoder=encoders.encode_noop,
                 **_params):
        """Create an application/octet-stream type MIME document.

        _data is a string containing the raw application data.

        _subtype is the MIME content type subtype, defaulting to
        'octet-stream; name="encrypted.asc"'.

        _encoder is a function which will perform the actual encoding for
        transport of the application data, defaulting to noop encoding.

        Any additional keyword arguments are passed to the base class
        constructor, which turns them into parameters on the Content-Type
        header.
        """
        _params["Content-Description"] = "OpenPGP encrypted message"
        _params["Content-Disposition"] = 'inline; filename="encrypted.asc"'
        MIMEApplication.__init__(self,
                                 _data=_data,
                                 _subtype=_subtype,
                                 _encoder=_encoder,
                                 **_params)
Esempio n. 2
0
    def __init__(self,
                 _data="Version: 1\n",
                 _subtype='pgp-encrypted',
                 _encoder=encoders.encode_noop,
                 **_params):
        """Create an application/pgp-encrypted type MIME document.

        _data is a string containing by default Version: 1\n.

        _subtype is the MIME content type subtype, defaulting to
        'pgp/encrypted'.

        _encoder is a function which will perform the actual encoding for
        transport of the application data, defaulting to noop encoding.

        Any additional keyword arguments are passed to the base class
        constructor, which turns them into parameters on the Content-Type
        header.
        """
        _params["Content-Description"] = "PGP/MIME version identification"
        MIMEApplication.__init__(self,
                                 _data=_data,
                                 _subtype=_subtype,
                                 _encoder=_encoder,
                                 **_params)
Esempio n. 3
0
 def __init__(self, _data, name='signature.asc'):
     MIMEApplication.__init__(self,
                              _data,
                              'pgp-signature',
                              _encoder=lambda x: x,
                              name=name)
     self.add_header('Content-Description', 'OpenPGP Digital Signature')
Esempio n. 4
0
    def __init__(self,
                 _data,
                 _subtype=AC_CT_SETUP,
                 _encoder=encoders.encode_noop,
                 **_params):
        # policy=None,
        """Create an application/autocrypt-setup type MIME document.

        _data is a string containing the raw application data.

        _subtype is the MIME content type subtype, defaulting to
        'autocrypt-setup; name="autocrypt-setup-message.txt"'.

        _encoder is a function which will perform the actual encoding for
        transport of the application data, defaulting to noop encoding.

        Any additional keyword arguments are passed to the base class
        constructor, which turns them into parameters on the Content-Type
        header.
        """
        # NOTE: this is not needed but might be useful to add it.
        # _params["Content-Description"] = "Autocrypt Setup Message key"
        # NOTE: adding Content-Disposition as header to be able to pass
        # filename param without quoting.
        # _params["Content-Disposition"] = \
        #     'attachment; filename="autocrypt-setup-message.html"''
        # policy=policy,
        MIMEApplication.__init__(self, _data, _subtype, _encoder, **_params)
Esempio n. 5
0
 def __init__(self, method, uri, headers, body):
     if isinstance(body, dict):
         body = json.dumps(body)
         headers['Content-Type'] = 'application/json'
         headers['Content-Length'] = len(body)
     if body is None:
         body = ''
     lines = ['%s %s HTTP/1.1' % (method, uri)]
     lines.extend(['%s: %s' % (key, value)
                   for key, value in sorted(headers.items())])
     lines.append('')
     lines.append(body)
     payload = '\r\n'.join(lines)
     if six.PY2:
         # email.message.Message is an old-style class, so we
         # cannot use 'super()'.
         MIMEApplication.__init__(self, payload, 'http', encode_noop)
     else:  # pragma: NO COVER  Python3
         super_init = super(MIMEApplicationHTTP, self).__init__
         super_init(payload, 'http', encode_noop)
Esempio n. 6
0
 def __init__(self, method, uri, headers, body):
     if isinstance(body, dict):
         body = json.dumps(body)
         headers['Content-Type'] = 'application/json'
         headers['Content-Length'] = len(body)
     if body is None:
         body = ''
     lines = ['%s %s HTTP/1.1' % (method, uri)]
     lines.extend(['%s: %s' % (key, value)
                   for key, value in sorted(headers.items())])
     lines.append('')
     lines.append(body)
     payload = '\r\n'.join(lines)
     if six.PY2:  # pragma: NO COVER  Python2
         # Sigh.  email.message.Message is an old-style class, so we
         #        cannot use 'super()'.
         MIMEApplication.__init__(self, payload, 'http', encode_noop)
     else:                        # pragma: NO COVER  Python3
         super_init = super(MIMEApplicationHTTP, self).__init__
         super_init(payload, 'http', encode_noop)
Esempio n. 7
0
 def __init__(self, method, uri, headers, body):
     if isinstance(body, dict):
         body = json.dumps(body)
         headers["Content-Type"] = "application/json"
         headers["Content-Length"] = len(body)
     if body is None:
         body = ""
     lines = ["%s %s HTTP/1.1" % (method, uri)]
     lines.extend([
         "%s: %s" % (key, value) for key, value in sorted(headers.items())
     ])
     lines.append("")
     lines.append(body)
     payload = "\r\n".join(lines)
     if six.PY2:
         # email.message.Message is an old-style class, so we
         # cannot use 'super()'.
         MIMEApplication.__init__(self, payload, "http", encode_noop)
     else:  # pragma: NO COVER  Python3
         super_init = super(MIMEApplicationHTTP, self).__init__
         super_init(payload, "http", encode_noop)
Esempio n. 8
0
 def __init__(self, _data):
     MIMEApplication.__init__(self, _data, 'pgp-keys')
Esempio n. 9
0
 def __init__(self, _data, name='signature.asc'):
     MIMEApplication.__init__(self, _data, 'pgp-signature',
                              _encoder=lambda x: x, name=name)
     self.add_header('Content-Description', 'OpenPGP Digital Signature')
Esempio n. 10
0
 def __init__(self, version=1):
     data = "Version: %d" % version
     MIMEApplication.__init__(self, data, 'pgp-encrypted')
Esempio n. 11
0
 def __init__(self, _data):
     MIMEApplication.__init__(self, _data, 'pgp-keys')
Esempio n. 12
0
 def __init__(self, version=1):
     data = "Version: %d" % version
     MIMEApplication.__init__(self, data, 'pgp-encrypted')
Esempio n. 13
0
 def __init__(self, _data):
     MIMEApplication.__init__(self,
                              _data,
                              'pgp-keys',
                              _encoder=encode_7or8bit)
Esempio n. 14
0
 def __init__(self, version=1):
     data = "Version: %d" % version
     MIMEApplication.__init__(self,
                              data,
                              'pgp-encrypted',
                              _encoder=encode_7or8bit)