Cleaned some code/gitignore and commented the classes

This commit is contained in:
Felipe Martin 2013-07-21 16:25:58 +02:00
parent 6e8c9130a3
commit 37cc29fad7
2 changed files with 20 additions and 7 deletions

3
.gitignore vendored
View File

@ -1,3 +1,6 @@
.c9revisions/ .c9revisions/
tests.py tests.py
*.pyc *.pyc
build/
dist/
*.egg-info

View File

@ -8,6 +8,10 @@ import requests
class YubicoWS(object): class YubicoWS(object):
"""
Yubico Web Service class that interacts with the Yubico API
"""
register_ws = 'https://upgrade.yubico.com/getapikey/?format=json' register_ws = 'https://upgrade.yubico.com/getapikey/?format=json'
api_ws = None api_ws = None
@ -152,6 +156,10 @@ class YubicoWS(object):
class Yubikey(object): class Yubikey(object):
"""
Yubikey object wrapper
"""
id = None id = None
key = None key = None
prefix = None prefix = None
@ -197,7 +205,11 @@ class Yubikey(object):
self.prefix = str.lower(otp[:-32]) self.prefix = str.lower(otp[:-32])
###
# Custom exceptions
###
class YubicoWSError(Exception): class YubicoWSError(Exception):
"Web service error. Defined by yubico documentation."
def __init__(self, message=None): def __init__(self, message=None):
self.msg = "Web Service responded with an error: %s" % message self.msg = "Web Service responded with an error: %s" % message
@ -206,17 +218,15 @@ class YubicoWSError(Exception):
class YubicoWSInvalidResponse(Exception): class YubicoWSInvalidResponse(Exception):
"Exception if the web service answers without same otp/nonce parameters"
msg = 'Response from the server is invalid' msg = 'Response from the server is invalid'
class WSResponseError(Exception): class YubicoWSResponseBadSignature(Exception):
def __str__(self): "Exception if the web service answers with a invalid signature"
return repr(self.msg) pass
class OTPIncorrectFormat(Exception): class OTPIncorrectFormat(Exception):
pass "Exception raised if the OTP provided is incorrect"
class YubicoWSResponseBadSignature(Exception):
pass pass