summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2013-07-30 10:20:30 -0300
committerTomás Touceda <chiiph@leap.se>2013-07-31 17:25:31 -0300
commit6f11db8234a7236f6dce0c4611dffa3068dc5036 (patch)
treedd64e1c2d43b6c59b99a53a8938f769299adecfc /src
parent233622752ee3098a3bee9ed1539573912cde18e3 (diff)
Reintegrate Soledad
Diffstat (limited to 'src')
-rw-r--r--src/leap/gui/mainwindow.py24
-rw-r--r--src/leap/services/soledad/soledadbootstrapper.py48
2 files changed, 44 insertions, 28 deletions
diff --git a/src/leap/gui/mainwindow.py b/src/leap/gui/mainwindow.py
index f333d7ec..1c871aa2 100644
--- a/src/leap/gui/mainwindow.py
+++ b/src/leap/gui/mainwindow.py
@@ -42,8 +42,8 @@ from leap.gui.statuspanel import StatusPanelWidget
from leap.services.eip.eipbootstrapper import EIPBootstrapper
from leap.services.eip.eipconfig import EIPConfig
from leap.services.eip.providerbootstrapper import ProviderBootstrapper
-# XXX: comment out soledad temporarily to avoid problem in Windows, issue #2932
-# from leap.services.soledad.soledadbootstrapper import SoledadBootstrapper
+# XXX: Soledad might not work out of the box in Windows, issue #2932
+from leap.services.soledad.soledadbootstrapper import SoledadBootstrapper
from leap.services.mail.smtpbootstrapper import SMTPBootstrapper
from leap.platform_init import IS_WIN, IS_MAC
from leap.platform_init.initializers import init_platform
@@ -199,11 +199,11 @@ class MainWindow(QtGui.QMainWindow):
self._eip_bootstrapper.download_client_certificate.connect(
self._finish_eip_bootstrap)
- #self._soledad_bootstrapper = SoledadBootstrapper()
- #self._soledad_bootstrapper.download_config.connect(
- #self._soledad_intermediate_stage)
- #self._soledad_bootstrapper.gen_key.connect(
- #self._soledad_bootstrapped_stage)
+ self._soledad_bootstrapper = SoledadBootstrapper()
+ self._soledad_bootstrapper.download_config.connect(
+ self._soledad_intermediate_stage)
+ self._soledad_bootstrapper.gen_key.connect(
+ self._soledad_bootstrapped_stage)
self._smtp_bootstrapper = SMTPBootstrapper()
self._smtp_bootstrapper.download_config.connect(
@@ -867,11 +867,11 @@ class MainWindow(QtGui.QMainWindow):
self.ui.stackedWidget.setCurrentIndex(self.EIP_STATUS_INDEX)
# XXX disabling soledad for now
- #self._soledad_bootstrapper.run_soledad_setup_checks(
- #self._provider_config,
- #self._login_widget.get_user(),
- #self._login_widget.get_password(),
- #download_if_needed=True)
+ self._soledad_bootstrapper.run_soledad_setup_checks(
+ self._provider_config,
+ self._login_widget.get_user(),
+ self._login_widget.get_password(),
+ download_if_needed=True)
self._download_eip_config()
diff --git a/src/leap/services/soledad/soledadbootstrapper.py b/src/leap/services/soledad/soledadbootstrapper.py
index 46e985ad..ac063152 100644
--- a/src/leap/services/soledad/soledadbootstrapper.py
+++ b/src/leap/services/soledad/soledadbootstrapper.py
@@ -86,21 +86,32 @@ class SoledadBootstrapper(AbstractBootstrapper):
secrets_path = "%s/%s.secret" % (prefix, uuid)
local_db_path = "%s/%s.db" % (prefix, uuid)
- # TODO: use the proper URL
- #server_url = 'https://mole.dev.bitmask.net:2424/user-%s' % (uuid,)
- server_url = 'https://gadwall.dev.bitmask.net:1111/user-%s' % (uuid,)
- # server_url = self._soledad_config.get_hosts(...)
-
- cert_file = self._provider_config.get_ca_cert_path()
-
- self._soledad = Soledad(uuid,
- self._password.encode("utf-8"),
- secrets_path=secrets_path,
- local_db_path=local_db_path,
- server_url=server_url,
- cert_file=cert_file,
- auth_token=srp_auth.get_token())
- self._soledad.sync()
+ # TODO: Select server based on timezone (issue #3308)
+ server_dict = self._soledad_config.get_hosts()
+
+ if len(server_dict.keys() > 0):
+ selected_server = server_dict[server_dict.keys()[0]]
+ server_url = "https://%s:%s/user-%s" % (selected_server["hostname"],
+ selected_server["port"],
+ uuid)
+
+ logger.debug("Using soledad server url: %s" % (server_url,))
+
+ cert_file = self._provider_config.get_ca_cert_path()
+
+ # TODO: If selected server fails, retry with another host
+ # (issue #3309)
+ self._soledad = Soledad(uuid,
+ self._password.encode("utf-8"),
+ secrets_path=secrets_path,
+ local_db_path=local_db_path,
+ server_url=server_url,
+ cert_file=cert_file,
+ auth_token=srp_auth.get_token())
+
+ self._soledad.sync()
+ else:
+ raise Exception("No soledad server found")
def _download_config(self):
"""
@@ -148,6 +159,10 @@ class SoledadBootstrapper(AbstractBootstrapper):
# Not modified
if res.status_code == 304:
logger.debug("Soledad definition has not been modified")
+ self._soledad_config.load(os.path.join("leap",
+ "providers",
+ self._provider_config.get_domain(),
+ "soledad-service.json"))
else:
soledad_definition, mtime = get_content(res)
@@ -159,7 +174,7 @@ class SoledadBootstrapper(AbstractBootstrapper):
self._load_and_sync_soledad(srp_auth)
- def _gen_key(self):
+ def _gen_key(self, _):
"""
Generates the key pair if needed, uploads it to the webapp and
nickserver
@@ -188,6 +203,7 @@ class SoledadBootstrapper(AbstractBootstrapper):
except KeyNotFound:
logger.debug("Key not found. Generating key for %s" % (address,))
self._keymanager.gen_key(openpgp.OpenPGPKey)
+ self._keymanager.send_key(openpgp.OpenPGPKey)
logger.debug("Key generated successfully.")
def run_soledad_setup_checks(self,