Commit 3db0271a authored by Simo Sorce's avatar Simo Sorce Committed by Simo Sorce

Make all exception derive from JWException

Fixes #93
Signed-off-by: 's avatarSimo Sorce <simo@redhat.com>
parent 0dab54b0
......@@ -3,6 +3,7 @@
import zlib
from jwcrypto import common
from jwcrypto.common import JWException
from jwcrypto.common import base64url_decode, base64url_encode
from jwcrypto.common import json_decode, json_encode
from jwcrypto.jwa import JWA
......@@ -40,7 +41,7 @@ default_allowed_algs = [
"""Default allowed algorithms"""
class InvalidJWEData(Exception):
class InvalidJWEData(JWException):
"""Invalid JWE Object.
This exception is raised when the JWE Object is invalid and/or
......
......@@ -12,6 +12,7 @@ from cryptography.hazmat.primitives.asymmetric import rsa
from six import iteritems
from jwcrypto.common import JWException
from jwcrypto.common import base64url_decode, base64url_encode
from jwcrypto.common import json_decode, json_encode
......@@ -83,7 +84,7 @@ JWKpycaCurveMap = {'secp256r1': 'P-256',
'secp521r1': 'P-521'}
class InvalidJWKType(Exception):
class InvalidJWKType(JWException):
"""Invalid JWK Type Exception.
This exception is raised when an invalid parameter type is used.
......@@ -98,7 +99,7 @@ class InvalidJWKType(Exception):
self.value, list(JWKTypesRegistry.keys()))
class InvalidJWKUsage(Exception):
class InvalidJWKUsage(JWException):
"""Invalid JWK usage Exception.
This exception is raised when an invalid key usage is requested,
......@@ -123,7 +124,7 @@ class InvalidJWKUsage(Exception):
valid)
class InvalidJWKOperation(Exception):
class InvalidJWKOperation(JWException):
"""Invalid JWK Operation Exception.
This exception is raised when an invalid key operation is requested,
......@@ -150,7 +151,7 @@ class InvalidJWKOperation(Exception):
valid)
class InvalidJWKValue(Exception):
class InvalidJWKValue(JWException):
"""Invalid JWK Value Exception.
This exception is raised when an invalid/unknown value is used in the
......
# Copyright (C) 2015 JWCrypto Project Contributors - see LICENSE file
from jwcrypto.common import JWException
from jwcrypto.common import base64url_decode, base64url_encode
from jwcrypto.common import json_decode, json_encode
from jwcrypto.jwa import JWA
......@@ -30,7 +31,7 @@ default_allowed_algs = [
"""Default allowed algorithms"""
class InvalidJWSSignature(Exception):
class InvalidJWSSignature(JWException):
"""Invalid JWS Signature.
This exception is raised when a signature cannot be validated.
......@@ -47,7 +48,7 @@ class InvalidJWSSignature(Exception):
super(InvalidJWSSignature, self).__init__(msg)
class InvalidJWSObject(Exception):
class InvalidJWSObject(JWException):
"""Invalid JWS Object.
This exception is raised when the JWS Object is invalid and/or
......@@ -63,7 +64,7 @@ class InvalidJWSObject(Exception):
super(InvalidJWSObject, self).__init__(msg)
class InvalidJWSOperation(Exception):
class InvalidJWSOperation(JWException):
"""Invalid JWS Object.
This exception is raised when a requested operation cannot
......
......@@ -5,7 +5,7 @@ import uuid
from six import string_types
from jwcrypto.common import json_decode, json_encode
from jwcrypto.common import JWException, json_decode, json_encode
from jwcrypto.jwe import JWE
from jwcrypto.jwk import JWK, JWKSet
from jwcrypto.jws import JWS
......@@ -22,7 +22,7 @@ JWTClaimsRegistry = {'iss': 'Issuer',
'jti': 'JWT ID'}
class JWTExpired(Exception):
class JWTExpired(JWException):
"""Json Web Token is expired.
This exception is raised when a token is expired accoring to its claims.
......@@ -39,7 +39,7 @@ class JWTExpired(Exception):
super(JWTExpired, self).__init__(msg)
class JWTNotYetValid(Exception):
class JWTNotYetValid(JWException):
"""Json Web Token is not yet valid.
This exception is raised when a token is not valid yet according to its
......@@ -57,7 +57,7 @@ class JWTNotYetValid(Exception):
super(JWTNotYetValid, self).__init__(msg)
class JWTMissingClaim(Exception):
class JWTMissingClaim(JWException):
"""Json Web Token claim is invalid.
This exception is raised when a claim does not match the expected value.
......@@ -74,7 +74,7 @@ class JWTMissingClaim(Exception):
super(JWTMissingClaim, self).__init__(msg)
class JWTInvalidClaimValue(Exception):
class JWTInvalidClaimValue(JWException):
"""Json Web Token claim is invalid.
This exception is raised when a claim does not match the expected value.
......@@ -91,7 +91,7 @@ class JWTInvalidClaimValue(Exception):
super(JWTInvalidClaimValue, self).__init__(msg)
class JWTInvalidClaimFormat(Exception):
class JWTInvalidClaimFormat(JWException):
"""Json Web Token claim format is invalid.
This exception is raised when a claim is not in a valid format.
......@@ -108,7 +108,7 @@ class JWTInvalidClaimFormat(Exception):
super(JWTInvalidClaimFormat, self).__init__(msg)
class JWTMissingKeyID(Exception):
class JWTMissingKeyID(JWException):
"""Json Web Token is missing key id.
This exception is raised when trying to decode a JWT with a key set
......@@ -126,7 +126,7 @@ class JWTMissingKeyID(Exception):
super(JWTMissingKeyID, self).__init__(msg)
class JWTMissingKey(Exception):
class JWTMissingKey(JWException):
"""Json Web Token is using a key not in the key set.
This exception is raised if the key that was used is not available
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment