summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/services/mail/smtpconfig.py
diff options
context:
space:
mode:
authorIvan Alejandro <ivanalejandro0@gmail.com>2013-09-20 17:28:25 -0300
committerIvan Alejandro <ivanalejandro0@gmail.com>2013-09-20 17:28:25 -0300
commit1f0f8efc4cb985c082b3b8fe7b3dc45aed047a47 (patch)
tree8d96c7a374c91699c55fb8c5b609aac222a94e74 /src/leap/bitmask/services/mail/smtpconfig.py
parent9568093138c85212e15d50ade5d5fc7dcec9ff6e (diff)
parent222ce2a1513a3776b3277ded365672d7d43ad2e4 (diff)
Merge branch 'release-0.3.3'0.3.3
Conflicts: pkg/requirements.pip setup.py src/leap/bitmask/config/leapsettings.py
Diffstat (limited to 'src/leap/bitmask/services/mail/smtpconfig.py')
-rw-r--r--src/leap/bitmask/services/mail/smtpconfig.py34
1 files changed, 30 insertions, 4 deletions
diff --git a/src/leap/bitmask/services/mail/smtpconfig.py b/src/leap/bitmask/services/mail/smtpconfig.py
index 20041c30..09f90314 100644
--- a/src/leap/bitmask/services/mail/smtpconfig.py
+++ b/src/leap/bitmask/services/mail/smtpconfig.py
@@ -14,25 +14,29 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
"""
SMTP configuration
"""
import logging
+import os
+from leap.bitmask.config.providerconfig import ProviderConfig
+from leap.bitmask.services import ServiceConfig
from leap.bitmask.services.mail.smtpspec import get_schema
-from leap.common.config.baseconfig import BaseConfig
+from leap.bitmask.util import get_path_prefix
+from leap.common.check import leap_assert, leap_assert_type
logger = logging.getLogger(__name__)
-class SMTPConfig(BaseConfig):
+class SMTPConfig(ServiceConfig):
"""
SMTP configuration abstraction class
"""
+ _service_name = "smtp"
def __init__(self):
- BaseConfig.__init__(self)
+ ServiceConfig.__init__(self)
def _get_schema(self):
"""
@@ -47,3 +51,25 @@ class SMTPConfig(BaseConfig):
def get_locations(self):
return self._safe_get_value("locations")
+
+ def get_client_cert_path(self,
+ providerconfig=None,
+ about_to_download=False):
+ """
+ Returns the path to the certificate used by smtp
+ """
+
+ leap_assert(providerconfig, "We need a provider")
+ leap_assert_type(providerconfig, ProviderConfig)
+
+ cert_path = os.path.join(get_path_prefix(),
+ "leap", "providers",
+ providerconfig.get_domain(),
+ "keys", "client", "smtp.pem")
+
+ if not about_to_download:
+ leap_assert(os.path.exists(cert_path),
+ "You need to download the certificate first")
+ logger.debug("Using SMTP cert %s" % (cert_path,))
+
+ return cert_path