summaryrefslogtreecommitdiff
path: root/src/leap/crypto/srpauth.py
diff options
context:
space:
mode:
authorTomas Touceda <chiiph@leap.se>2013-05-10 17:01:11 -0300
committerkali <kali@leap.se>2013-05-11 21:59:59 +0900
commit4e201329042d43c8d281c5737d3d5f6f8e2bf67f (patch)
tree3cf5dea6f0d1e2800932ae23340ded46d0df1659 /src/leap/crypto/srpauth.py
parentc533900a43f5006e6b4cb9d070b4bd30fb67f0b5 (diff)
Add support for requests<1.0.0
Diffstat (limited to 'src/leap/crypto/srpauth.py')
-rw-r--r--src/leap/crypto/srpauth.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/leap/crypto/srpauth.py b/src/leap/crypto/srpauth.py
index 26bd0295..dbaac01b 100644
--- a/src/leap/crypto/srpauth.py
+++ b/src/leap/crypto/srpauth.py
@@ -20,12 +20,14 @@ import logging
import requests
import srp
+import json
from PySide import QtCore, QtGui
from leap.common.check import leap_assert
from leap.config.providerconfig import ProviderConfig
from leap.util.checkerthread import CheckerThread
+from leap.util.request_helpers import get_content
from leap.common.events import signal as events_signal
from leap.common.events import events_pb2 as proto
@@ -159,14 +161,18 @@ class SRPAuth(QtCore.QObject):
raise SRPAuthenticationError("Unknown error: %r" %
(e,))
+ content, mtime = get_content(init_session)
+
if init_session.status_code not in (200,):
logger.error("No valid response (salt): "
"Status code = %r. Content: %r" %
- (init_session.status_code, init_session.content))
+ (init_session.status_code, content))
if init_session.status_code == 422:
raise SRPAuthenticationError(self.tr("Unknown user"))
- salt = init_session.json().get("salt", None)
- B = init_session.json().get("B", None)
+
+ json_content = json.loads(content)
+ salt = json_content.get("salt", None)
+ B = json_content.get("B", None)
if salt is None:
logger.error("No salt parameter sent")
@@ -226,22 +232,25 @@ class SRPAuth(QtCore.QObject):
raise SRPAuthenticationError(self.tr("Could not connect to "
"the server"))
+ content, mtime = get_content(auth_result)
+
if auth_result.status_code == 422:
logger.error("[%s] Wrong password (HAMK): [%s]" %
(auth_result.status_code,
- auth_result.json().
+ content.
get("errors", "")))
raise SRPAuthenticationError(self.tr("Wrong password"))
if auth_result.status_code not in (200,):
logger.error("No valid response (HAMK): "
"Status code = %s. Content = %r" %
- (auth_result.status_code, auth_result.content))
+ (auth_result.status_code, content))
raise SRPAuthenticationError(self.tr("Unknown error (%s)") %
(auth_result.status_code,))
- M2 = auth_result.json().get("M2", None)
- uid = auth_result.json().get("id", None)
+ json_content = json.loads(content)
+ M2 = json_content.get("M2", None)
+ uid = json_content.get("id", None)
token = auth_result.json().get("token", None)
events_signal(proto.CLIENT_UID, content=uid)
@@ -251,7 +260,7 @@ class SRPAuth(QtCore.QObject):
if M2 is None or self.get_uid() is None:
logger.error("Something went wrong. Content = %r" %
- (auth_result.content,))
+ (content,))
raise SRPAuthenticationError(self.tr("Problem getting data "
"from server"))