summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mail/src/leap/mail/outgoing/__init__.py0
-rw-r--r--mail/src/leap/mail/outgoing/service.py (renamed from mail/src/leap/mail/service.py)13
-rw-r--r--mail/src/leap/mail/outgoing/tests/__init__.py0
-rw-r--r--mail/src/leap/mail/outgoing/tests/test_outgoing.py (renamed from mail/src/leap/mail/tests/test_service.py)2
-rw-r--r--mail/src/leap/mail/smtp/__init__.py2
-rw-r--r--mail/src/leap/mail/smtp/gateway.py6
-rw-r--r--mail/src/leap/mail/walk.py64
7 files changed, 45 insertions, 42 deletions
diff --git a/mail/src/leap/mail/outgoing/__init__.py b/mail/src/leap/mail/outgoing/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/mail/src/leap/mail/outgoing/__init__.py
diff --git a/mail/src/leap/mail/service.py b/mail/src/leap/mail/outgoing/service.py
index a99f13a..b70b3b1 100644
--- a/mail/src/leap/mail/service.py
+++ b/mail/src/leap/mail/outgoing/service.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# service.py
-# Copyright (C) 2013 LEAP
+# outgoing/service.py
+# Copyright (C) 2013-2015 LEAP
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -41,6 +41,10 @@ from leap.mail.smtp.rfc3156 import RFC3156CompliantGenerator
from leap.mail.smtp.rfc3156 import PGPSignature
from leap.mail.smtp.rfc3156 import PGPEncrypted
+# TODO
+# [ ] rename this module to something else, service should be the implementor
+# of IService
+
class SSLContextFactory(ssl.ClientContextFactory):
def __init__(self, cert, key):
@@ -48,6 +52,9 @@ class SSLContextFactory(ssl.ClientContextFactory):
self.key = key
def getContext(self):
+ # FIXME -- we should use sslv23 to allow for tlsv1.2
+ # and, if possible, explicitely disable sslv3 clientside.
+ # Servers should avoid sslv3
self.method = SSL.TLSv1_METHOD # SSLv23_METHOD
ctx = ssl.ClientContextFactory.getContext(self)
ctx.use_certificate_file(self.cert)
@@ -57,7 +64,7 @@ class SSLContextFactory(ssl.ClientContextFactory):
class OutgoingMail:
"""
- A service for handling encrypted mail.
+ A service for handling encrypted outgoing mail.
"""
FOOTER_STRING = "I prefer encrypted email"
diff --git a/mail/src/leap/mail/outgoing/tests/__init__.py b/mail/src/leap/mail/outgoing/tests/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/mail/src/leap/mail/outgoing/tests/__init__.py
diff --git a/mail/src/leap/mail/tests/test_service.py b/mail/src/leap/mail/outgoing/tests/test_outgoing.py
index 43f354d..fa50c30 100644
--- a/mail/src/leap/mail/tests/test_service.py
+++ b/mail/src/leap/mail/outgoing/tests/test_outgoing.py
@@ -28,7 +28,7 @@ from twisted.mail.smtp import User
from mock import Mock
from leap.mail.smtp.gateway import SMTPFactory
-from leap.mail.service import OutgoingMail
+from leap.mail.outgoing.service import OutgoingMail
from leap.mail.tests import (
TestCaseWithKeyManager,
ADDRESS,
diff --git a/mail/src/leap/mail/smtp/__init__.py b/mail/src/leap/mail/smtp/__init__.py
index 72b26ed..24402b4 100644
--- a/mail/src/leap/mail/smtp/__init__.py
+++ b/mail/src/leap/mail/smtp/__init__.py
@@ -22,7 +22,7 @@ import logging
from twisted.internet import reactor
from twisted.internet.error import CannotListenError
-from leap.mail.service import OutgoingMail
+from leap.mail.outgoing.service import OutgoingMail
logger = logging.getLogger(__name__)
diff --git a/mail/src/leap/mail/smtp/gateway.py b/mail/src/leap/mail/smtp/gateway.py
index d58c581..222ef3f 100644
--- a/mail/src/leap/mail/smtp/gateway.py
+++ b/mail/src/leap/mail/smtp/gateway.py
@@ -93,7 +93,7 @@ class SMTPFactory(ServerFactory):
mail or not.
:type encrypted_only: bool
:param outgoing_mail: The outgoing mail to send the message
- :type outgoing_mail: leap.mail.service.OutgoingMail
+ :type outgoing_mail: leap.mail.outgoing.service.OutgoingMail
"""
leap_assert_type(encrypted_only, bool)
@@ -141,7 +141,7 @@ class SMTPDelivery(object):
mail or not.
:type encrypted_only: bool
:param outgoing_mail: The outgoing mail to send the message
- :type outgoing_mail: leap.mail.service.OutgoingMail
+ :type outgoing_mail: leap.mail.outgoing.service.OutgoingMail
"""
self._userid = userid
self._outgoing_mail = outgoing_mail
@@ -266,7 +266,7 @@ class EncryptedMessage(object):
:param user: The recipient of this message.
:type user: twisted.mail.smtp.User
:param outgoing_mail: The outgoing mail to send the message
- :type outgoing_mail: leap.mail.service.OutgoingMail
+ :type outgoing_mail: leap.mail.outgoing.service.OutgoingMail
"""
# assert params
leap_assert_type(user, smtp.User)
diff --git a/mail/src/leap/mail/walk.py b/mail/src/leap/mail/walk.py
index f747377..5172837 100644
--- a/mail/src/leap/mail/walk.py
+++ b/mail/src/leap/mail/walk.py
@@ -85,6 +85,35 @@ get_raw_docs = lambda msg, parts: (
for payload, headers in get_payloads(msg)
if not isinstance(payload, list))
+"""
+Groucho Marx: Now pay particular attention to this first clause, because it's
+ most important. There's the party of the first part shall be
+ known in this contract as the party of the first part. How do you
+ like that, that's pretty neat eh?
+
+Chico Marx: No, that's no good.
+Groucho Marx: What's the matter with it?
+
+Chico Marx: I don't know, let's hear it again.
+Groucho Marx: So the party of the first part shall be known in this contract as
+ the party of the first part.
+
+Chico Marx: Well it sounds a little better this time.
+Groucho Marx: Well, it grows on you. Would you like to hear it once more?
+
+Chico Marx: Just the first part.
+Groucho Marx: All right. It says the first part of the party of the first part
+ shall be known in this contract as the first part of the party of
+ the first part, shall be known in this contract - look, why
+ should we quarrel about a thing like this, we'll take it right
+ out, eh?
+
+Chico Marx: Yes, it's too long anyhow. Now what have we got left?
+Groucho Marx: Well I've got about a foot and a half. Now what's the matter?
+
+Chico Marx: I don't like the second party either.
+"""
+
def walk_msg_tree(parts, body_phash=None):
"""
@@ -162,7 +191,7 @@ def walk_msg_tree(parts, body_phash=None):
outer = parts[0]
outer.pop(HEADERS)
- if not PART_MAP in outer:
+ if PART_MAP not in outer:
# we have a multipart with 1 part only, so kind of fix it
# although it would be prettier if I take this special case at
# the beginning of the walk.
@@ -177,36 +206,3 @@ def walk_msg_tree(parts, body_phash=None):
pdoc = outer
pdoc[BODY] = body_phash
return pdoc
-
-"""
-Groucho Marx: Now pay particular attention to this first clause, because it's
- most important. There's the party of the first part shall be
- known in this contract as the party of the first part. How do you
- like that, that's pretty neat eh?
-
-Chico Marx: No, that's no good.
-Groucho Marx: What's the matter with it?
-
-Chico Marx: I don't know, let's hear it again.
-Groucho Marx: So the party of the first part shall be known in this contract as
- the party of the first part.
-
-Chico Marx: Well it sounds a little better this time.
-Groucho Marx: Well, it grows on you. Would you like to hear it once more?
-
-Chico Marx: Just the first part.
-Groucho Marx: All right. It says the first part of the party of the first part
- shall be known in this contract as the first part of the party of
- the first part, shall be known in this contract - look, why
- should we quarrel about a thing like this, we'll take it right
- out, eh?
-
-Chico Marx: Yes, it's too long anyhow. Now what have we got left?
-Groucho Marx: Well I've got about a foot and a half. Now what's the matter?
-
-Chico Marx: I don't like the second party either.
-"""
-
-"""
-I feel you deserved it after reading the above and try to debug your problem ;)
-"""