Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions jose/jwk.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def get_key(algorithm):

def register_key(algorithm, key_class):
if not issubclass(key_class, Key):
raise TypeError("Key class not a subclass of jwk.Key")
raise TypeError("Key class is not a subclass of jwk.Key")
ALGORITHMS.KEYS[algorithm] = key_class
ALGORITHMS.SUPPORTED.add(algorithm)
return True
Expand All @@ -53,11 +53,11 @@ def construct(key_data, algorithm=None):
algorithm = key_data.get('alg', None)

if not algorithm:
raise JWKError('Unable to find a algorithm for key: %s' % key_data)
raise JWKError('Unable to find an algorithm for key: %s' % key_data)

key_class = get_key(algorithm)
if not key_class:
raise JWKError('Unable to find a algorithm for key: %s' % key_data)
raise JWKError('Unable to find an algorithm for key: %s' % key_data)
return key_class(key_data, algorithm)


Expand Down Expand Up @@ -119,8 +119,11 @@ def __init__(self, key, algorithm):

def _process_jwk(self, jwk_dict):
if not jwk_dict.get('kty') == 'oct':
raise JWKError("Incorrect key type. Expected: 'oct', Received: %s" % jwk_dict.get('kty'))

raise JWKError("Incorrect key type. Expected: 'oct', Received: %s" % jwk_dict.get('kty'))


k = jwk_dict.get('k')
k = k.encode('utf-8')
k = bytes(k)
Expand Down