pdk.util.JWT
functions to operate with JSON web tokens
Functions
generateToken
Actually builds the JWT and serializes it to a compact, URL-safe string according to the JWT Compact Serialization rules. HS512 is using to sign.
Arguments:
user :: pdk.jwt.JwtUser
term :: pdk.core.Integer - used to calculate expiration date. Value in seconds.
secret :: pdk.core.String - constant used to sign the token
Result:
output :: pdk.core.String - serialized JWT.
Possible exceptions
NullPointerException - throws if the user, term or secret argument is
NULL
validateToken
Verify the token belongs to the input JwtUser.
Arguments:
user :: pdk.jwt.JwtUser
token :: pdk.core.String - serialized JWT.
secret :: pdk.core.String - constant used to sign the token.
Result:
output :: pdk.core.Boolean
Possible exceptions
NullPointerException - throws if the user, token or secret argument is
NULL
isTokenExpired
Verify the token has been expired.
Arguments:
token :: pdk.core.String - serialized JWT.
secret :: pdk.core.String - constant used to sign the token.
Result:
output :: pdk.core.Boolean
Possible exceptions
NullPointerException - throws if the token or secret argument is
NULL
getUserIdFromToken
Returns the userId attribute from the serialized jwt token.
Arguments:
token :: pdk.core.String - serialized JWT.
secret :: pdk.core.String - constant used to sign the token.
Result:
output :: pdk.core.String - userId
Possible exceptions
NullPointerException - throws if the token or secret argument is
NULL
getUserFromToken
Returns the user as an object from the serialized jwt token.
Arguments:
token :: pdk.core.String - serialized JWT.
secret :: pdk.core.String - constant used to sign the token.
Result:
output :: pdk.jwt.JwtUser
Possible exceptions
NullPointerException - throws if the token or secret argument is
NULL
getExpirationDateFromToken
Returns the expiration date from the serialized jwt token.
Arguments:
token :: pdk.core.String - serialized JWT.
secret :: pdk.core.String - constant used to sign the token.
Result:
output :: pdk.core.Date
Possible exceptions
NullPointerException - throws if the token or secret argument is
NULL
Last updated