Skip to content

Commit

Permalink
Add class method to deserialize JWS token
Browse files Browse the repository at this point in the history
One shot api to get a JWS token from a serialized json token

Signed-off-by: Simo Sorce <simo@redhat.com>
  • Loading branch information
simo5 committed May 11, 2022
1 parent ccea1c9 commit 7abf382
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions jwcrypto/jws.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,3 +631,17 @@ def jose_header(self):
return jhl
else:
raise InvalidJWSOperation("JOSE Header(s) not available")

@classmethod
def from_jose_token(cls, token):
"""Creates a JWS object from a serialized JWS token.
:param token: A string with the json or compat representation
of the token.
:raises InvalidJWSObject: if the raw object is an invalid JWS token.
"""

obj = cls()
obj.deserialize(token)
return obj

0 comments on commit 7abf382

Please sign in to comment.