summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/keymanager
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/bitmask/keymanager')
-rw-r--r--src/leap/bitmask/keymanager/__init__.py6
-rw-r--r--src/leap/bitmask/keymanager/nicknym.py6
2 files changed, 8 insertions, 4 deletions
diff --git a/src/leap/bitmask/keymanager/__init__.py b/src/leap/bitmask/keymanager/__init__.py
index ed3726ad..f0f82676 100644
--- a/src/leap/bitmask/keymanager/__init__.py
+++ b/src/leap/bitmask/keymanager/__init__.py
@@ -90,7 +90,6 @@ class KeyManager(object):
self.api_uri = api_uri
self.api_version = api_version
self.uid = uid
- self._openpgp = OpenPGPScheme(soledad, gpgbinary=gpgbinary)
create = self._create_combined_bundle_file
try:
self._combined_ca_bundle = combined_ca_bundle or create()
@@ -102,11 +101,15 @@ class KeyManager(object):
self._nicknym = Nicknym(self._nickserver_uri,
self._ca_cert_path, self._token)
self.refresher = None
+ self._init_gpg(soledad, gpgbinary)
#
# utilities
#
+ def _init_gpg(self, soledad, gpgbinary):
+ self._openpgp = OpenPGPScheme(soledad, gpgbinary=gpgbinary)
+
def start_refresher(self):
self.refresher = RandomRefreshPublicKey(self._openpgp, self)
self.refresher.start()
@@ -376,6 +379,7 @@ class KeyManager(object):
def _set_token(self, token):
self._token = token
+ self._nicknym.token = token
token = property(
_get_token, _set_token, doc='The session token.')
diff --git a/src/leap/bitmask/keymanager/nicknym.py b/src/leap/bitmask/keymanager/nicknym.py
index 5fe99925..7c738da0 100644
--- a/src/leap/bitmask/keymanager/nicknym.py
+++ b/src/leap/bitmask/keymanager/nicknym.py
@@ -43,7 +43,7 @@ class Nicknym(object):
def __init__(self, nickserver_uri, ca_cert_path, token):
self._nickserver_uri = nickserver_uri
self._async_client_pinned = HTTPClient(ca_cert_path)
- self._token = token
+ self.token = token
@defer.inlineCallbacks
def put_key(self, uid, key_data, api_uri, api_version):
@@ -72,11 +72,11 @@ class Nicknym(object):
uid)
leap_assert(
- self._token is not None,
+ self.token is not None,
'We need a token to interact with webapp!')
if type(data) == dict:
data = urllib.urlencode(data)
- headers = {'Authorization': [str('Token token=%s' % self._token)]}
+ headers = {'Authorization': [str('Token token=%s' % self.token)]}
headers['Content-Type'] = ['application/x-www-form-urlencoded']
try:
res = yield self._async_client_pinned.request(str(uri), 'PUT',