Class Jwt
java.lang.Object
com.codename1.backend.Jwt
HS256 JSON Web Tokens: issue one, and verify one you are handed.
Only HS256 is accepted, deliberately. A verifier that reads the algorithm out of the token it is checking is the classic JWT hole - "alg":"none" then verifies anything, and "alg":"HS256" against an RSA public key turns a public value into the signing secret. The algorithm is a property of THIS verifier, not of the token, so the header's alg is checked for agreement and never used to select anything.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classThrown for any token that is not valid and current. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringPulls the token out of an "Authorization: Bearer ..." header.static Stringclaims: the payload; "iat" and "exp" are set here and overwrite anything the caller put there
static MapReturns the claims of a token that is well-formed, correctly signed and not expired.
-
Method Details
-
issue
claims: the payload; "iat" and "exp" are set here and overwrite anything the caller put therettlSeconds: how long the token is good for
- Throws:
IOException
-
verify
Returns the claims of a token that is well-formed, correctly signed and not expired. Throws otherwise; there is no "valid but expired" return.- Throws:
IOException
-
bearer
-