diff options
Diffstat (limited to 'otp2289/server.py')
| -rw-r--r-- | otp2289/server.py | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/otp2289/server.py b/otp2289/server.py index fca3f06..119fbff 100644 --- a/otp2289/server.py +++ b/otp2289/server.py | |||
| @@ -71,7 +71,7 @@ class OTPState: | |||
| 71 | :param hash_algo: The hash algo, defaults to OTP_ALGO_MD5 | 71 | :param hash_algo: The hash algo, defaults to OTP_ALGO_MD5 |
| 72 | :type hash_algo: int or str | 72 | :type hash_algo: int or str |
| 73 | 73 | ||
| 74 | :raises OTPStateException: In case the input does not validate | 74 | :raises otp2289.OTPStateException: If the input does not validate |
| 75 | """ | 75 | """ |
| 76 | # enforce the rfc2289 constraints | 76 | # enforce the rfc2289 constraints |
| 77 | try: | 77 | try: |
| @@ -126,7 +126,7 @@ class OTPState: | |||
| 126 | :type dict_obj: dict | 126 | :type dict_obj: dict |
| 127 | 127 | ||
| 128 | :return: A new OTPState object | 128 | :return: A new OTPState object |
| 129 | :rtype: OTPStore | 129 | :rtype: otp2289.OTPStore |
| 130 | """ | 130 | """ |
| 131 | return cls(**dict_obj) | 131 | return cls(**dict_obj) |
| 132 | 132 | ||
| @@ -144,8 +144,9 @@ class OTPState: | |||
| 144 | :param response: The response to this state (its challenge) | 144 | :param response: The response to this state (its challenge) |
| 145 | :type response: str | 145 | :type response: str |
| 146 | 146 | ||
| 147 | :raises OTPInvalidResponse: If the response is corrupt / illegal, | 147 | :raises otp2289.OTPInvalidResponse: If the response is corrupt/illegal, |
| 148 | but not if it simply does not validate | 148 | but not if it simply does not |
| 149 | validate | ||
| 149 | 150 | ||
| 150 | :return: The bytes representation of response (if any) | 151 | :return: The bytes representation of response (if any) |
| 151 | :rtype: bytes | 152 | :rtype: bytes |
| @@ -168,7 +169,7 @@ class OTPState: | |||
| 168 | :param ot_hex: The one-time hex to validate | 169 | :param ot_hex: The one-time hex to validate |
| 169 | :type ot_hex: str | 170 | :type ot_hex: str |
| 170 | 171 | ||
| 171 | :raises OTPStateException: In case hex does not validate | 172 | :raises otp2289.OTPStateException: If hex does not validate |
| 172 | 173 | ||
| 173 | :return: The validated hex (without leading 0x) converted to bytes | 174 | :return: The validated hex (without leading 0x) converted to bytes |
| 174 | :rtype: bytes | 175 | :rtype: bytes |
| @@ -194,7 +195,7 @@ class OTPState: | |||
| 194 | where step -= 1 and ot_hex = self._new_digest_hex | 195 | where step -= 1 and ot_hex = self._new_digest_hex |
| 195 | 196 | ||
| 196 | :return: The next OTPState if validated, None otherwise | 197 | :return: The next OTPState if validated, None otherwise |
| 197 | :rtype: OTPState or None | 198 | :rtype: otp2289.OTPState or None |
| 198 | """ | 199 | """ |
| 199 | if self._new_digest_hex is None: | 200 | if self._new_digest_hex is None: |
| 200 | return None | 201 | return None |
| @@ -213,7 +214,8 @@ class OTPState: | |||
| 213 | :param store_valid_response: Should a valid response be stored | 214 | :param store_valid_response: Should a valid response be stored |
| 214 | :type store_valid_response: bool | 215 | :type store_valid_response: bool |
| 215 | 216 | ||
| 216 | :raises OTPInvalidResponse: If the response does not match this state | 217 | :raises otp2289.OTPInvalidResponse: If the response does not match |
| 218 | this state | ||
| 217 | 219 | ||
| 218 | :return: Returns True if response validates, False otherwise | 220 | :return: Returns True if response validates, False otherwise |
| 219 | :rtype: bool | 221 | :rtype: bool |
| @@ -328,9 +330,9 @@ class OTPStore: | |||
| 328 | :type key: str | 330 | :type key: str |
| 329 | 331 | ||
| 330 | :param state: The OTPState object | 332 | :param state: The OTPState object |
| 331 | :type state: OTPState | 333 | :type state: otp2289.OTPState |
| 332 | 334 | ||
| 333 | :raises OTPStoreException: On failure | 335 | :raises otp2289.OTPStoreException: On failure |
| 334 | """ | 336 | """ |
| 335 | if not isinstance(key, str): | 337 | if not isinstance(key, str): |
| 336 | raise OTPStoreException('key must be a str') | 338 | raise OTPStoreException('key must be a str') |
| @@ -356,10 +358,10 @@ class OTPStore: | |||
| 356 | 358 | ||
| 357 | :raises KeyError: If key does not exist | 359 | :raises KeyError: If key does not exist |
| 358 | 360 | ||
| 359 | :raises OTPStoreException: On failure | 361 | :raises otp2289.OTPStoreException: On failure |
| 360 | 362 | ||
| 361 | :return: The state corresponding to the key | 363 | :return: The state corresponding to the key |
| 362 | :rtype: OTPState | 364 | :rtype: otp2289.OTPState |
| 363 | """ | 365 | """ |
| 364 | if not isinstance(key, str): | 366 | if not isinstance(key, str): |
| 365 | raise OTPStoreException('key must be a str') | 367 | raise OTPStoreException('key must be a str') |
| @@ -387,7 +389,8 @@ class OTPStore: | |||
| 387 | 389 | ||
| 388 | :raises KeyError: If the key is not present | 390 | :raises KeyError: If the key is not present |
| 389 | 391 | ||
| 390 | :raises OTPInvalidResponse: If the response does not match this state | 392 | :raises otp2289.OTPInvalidResponse: If the response does not match |
| 393 | this state | ||
| 391 | 394 | ||
| 392 | :return: Returns True if response validates, False otherwise | 395 | :return: Returns True if response validates, False otherwise |
| 393 | :rtype: bool | 396 | :rtype: bool |
