diff options
author | Ivan Alejandro <ivanalejandro0@gmail.com> | 2014-03-21 16:56:58 -0300 |
---|---|---|
committer | Ivan Alejandro <ivanalejandro0@gmail.com> | 2014-04-15 15:00:08 -0300 |
commit | 2ad21a720b14a6c58922bf4f026d24ad87ed8acd (patch) | |
tree | f3c8dcad91131363f2c0a764a560d7105a0a1a41 /src/leap/bitmask/crypto/srpauth.py | |
parent | 31162802bb8712a4d0d8e4b007b9ef55e13d3993 (diff) |
Remove PySide as a dependency.
- Use python `object` as a parent class.
- Replace QMutex with a `threading.Lock`
Diffstat (limited to 'src/leap/bitmask/crypto/srpauth.py')
-rw-r--r-- | src/leap/bitmask/crypto/srpauth.py | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/src/leap/bitmask/crypto/srpauth.py b/src/leap/bitmask/crypto/srpauth.py index 26a2d09a..895ab87e 100644 --- a/src/leap/bitmask/crypto/srpauth.py +++ b/src/leap/bitmask/crypto/srpauth.py @@ -17,6 +17,7 @@ import binascii import logging +import threading import sys import requests @@ -28,7 +29,6 @@ from simplejson.decoder import JSONDecodeError from functools import partial from requests.adapters import HTTPAdapter -from PySide import QtCore from twisted.internet import threads from twisted.internet.defer import CancelledError @@ -118,12 +118,12 @@ class SRPAuthNoSessionId(SRPAuthenticationError): pass -class SRPAuth(QtCore.QObject): +class SRPAuth(object): """ SRPAuth singleton """ - class __impl(QtCore.QObject): + class __impl(object): """ Implementation of the SRPAuth interface """ @@ -146,8 +146,6 @@ class SRPAuth(QtCore.QObject): from the backend :type signaler: Signaler """ - QtCore.QObject.__init__(self) - leap_assert(provider_config, "We need a provider config to authenticate") @@ -167,11 +165,11 @@ class SRPAuth(QtCore.QObject): self._reset_session() self._session_id = None - self._session_id_lock = QtCore.QMutex() + self._session_id_lock = threading.Lock() self._uuid = None - self._uuid_lock = QtCore.QMutex() + self._uuid_lock = threading.Lock() self._token = None - self._token_lock = QtCore.QMutex() + self._token_lock = threading.Lock() self._srp_user = None self._srp_a = None @@ -662,32 +660,32 @@ class SRPAuth(QtCore.QObject): self._signaler.signal(self._signaler.SRP_LOGOUT_OK) def set_session_id(self, session_id): - QtCore.QMutexLocker(self._session_id_lock) - self._session_id = session_id + with self._session_id_lock: + self._session_id = session_id def get_session_id(self): - QtCore.QMutexLocker(self._session_id_lock) - return self._session_id + with self._session_id_lock: + return self._session_id def set_uuid(self, uuid): - QtCore.QMutexLocker(self._uuid_lock) - full_uid = "%s@%s" % ( - self._username, self._provider_config.get_domain()) - if uuid is not None: # avoid removing the uuid from settings - self._settings.set_uuid(full_uid, uuid) - self._uuid = uuid + with self._uuid_lock: + full_uid = "%s@%s" % ( + self._username, self._provider_config.get_domain()) + if uuid is not None: # avoid removing the uuid from settings + self._settings.set_uuid(full_uid, uuid) + self._uuid = uuid def get_uuid(self): - QtCore.QMutexLocker(self._uuid_lock) - return self._uuid + with self._uuid_lock: + return self._uuid def set_token(self, token): - QtCore.QMutexLocker(self._token_lock) - self._token = token + with self._token_lock: + self._token = token def get_token(self): - QtCore.QMutexLocker(self._token_lock) - return self._token + with self._token_lock: + return self._token __instance = None @@ -701,8 +699,6 @@ class SRPAuth(QtCore.QObject): from the backend :type signaler: Signaler """ - QtCore.QObject.__init__(self) - # Check whether we already have an instance if SRPAuth.__instance is None: # Create and remember instance |