10Duke Scale C++ Client
|
#include <JWT.h>
Very simple JWT implementation.
This will likely be heavily modified in the future.
Public Member Functions | |
JWT (std::map< std::string, std::string > claims) | |
Constructs new JWT instance from given claims. | |
JWT (const std::map< std::string, std::string > &claims, const std::map< std::string, std::string > &headerParameters) | |
Constructs new JWT instance from given claims and header parameters. | |
JWT (const JWT ©) | |
Copy-constructs new JWT instance. | |
bool | hasClaim (const std::string &name) const |
Checks if the JWT has given claim. | |
const std::string * | claim (const std::string &name) const |
Returns a JWT-claim by given name. | |
const std::map< std::string, std::string > & | getClaims () const |
Returns all claims as a map. | |
const std::string & | getStringClaim (const std::string &claimName) const |
Returns a claim value as string. | |
std::int64_t | getIntClaim (const std::string &claimName) const |
Returns claim value as std::int64_t . | |
const std::string & | getJWTID () const |
Returns "JWT ID", "jti"-claim. | |
const std::string & | getIssuer () const |
Returns "Issuer", "iss"-claim. | |
const std::string & | getSubject () const |
Returns "Subject", "sub"-claim. | |
const std::string & | getAudience () const |
Returns "Audience", "aud"-claim. | |
std::int64_t | getExpirationTime () const |
Returns "Expiration time", "exp"-claim. | |
std::int64_t | getIssuedAt () const |
Returns "Issued at", "iat"-claim. | |
std::string | getHeaderParameterKID () const |
Returns header-parameter KeyId ("kid"-parameter). | |
std::map< std::string, std::string > | getHeaderParameters () const |
Returns header parameters. | |
bool | isInfinite () const |
Returns true if token does expire. | |
Static Public Attributes | |
static const std::int64_t | NUMBER_NOT_PRESENT = INT64_MIN |
Magic value to indicate that numeric claim is not present. | |
Protected Attributes | |
std::map< std::string, std::string > | claims |
Claims. | |
std::map< std::string, std::string > | headerParameters |
Header parameters. | |
|
explicit |
Constructs new JWT instance from given claims.
claims | - |
tenduke::jwt::JWT::JWT | ( | const std::map< std::string, std::string > & | claims, |
const std::map< std::string, std::string > & | headerParameters | ||
) |
Constructs new JWT instance from given claims and header parameters.
claims | - |
headerParameters | - |
const std::string * tenduke::jwt::JWT::claim | ( | const std::string & | name | ) | const |
Returns a JWT-claim by given name.
name | name of the claim |
nullptr
if no such claim const std::string & tenduke::jwt::JWT::getAudience | ( | ) | const |
Returns "Audience", "aud"-claim.
|
inline |
Returns all claims as a map.
std::int64_t tenduke::jwt::JWT::getExpirationTime | ( | ) | const |
Returns "Expiration time", "exp"-claim.
std::string tenduke::jwt::JWT::getHeaderParameterKID | ( | ) | const |
Returns header-parameter KeyId ("kid"-parameter).
std::map< std::string, std::string > tenduke::jwt::JWT::getHeaderParameters | ( | ) | const |
Returns header parameters.
std::int64_t tenduke::jwt::JWT::getIntClaim | ( | const std::string & | claimName | ) | const |
Returns claim value as std::int64_t
.
claimName | - |
std::int64_t tenduke::jwt::JWT::getIssuedAt | ( | ) | const |
Returns "Issued at", "iat"-claim.
const std::string & tenduke::jwt::JWT::getIssuer | ( | ) | const |
Returns "Issuer", "iss"-claim.
const std::string & tenduke::jwt::JWT::getJWTID | ( | ) | const |
Returns "JWT ID", "jti"-claim.
const std::string & tenduke::jwt::JWT::getStringClaim | ( | const std::string & | claimName | ) | const |
Returns a claim value as string.
claimName | name of the claim |
const std::string & tenduke::jwt::JWT::getSubject | ( | ) | const |
Returns "Subject", "sub"-claim.
bool tenduke::jwt::JWT::hasClaim | ( | const std::string & | name | ) | const |
bool tenduke::jwt::JWT::isInfinite | ( | ) | const |
Returns true
if token does expire.
This is based on "exp"-claim, returns true if the claim is missing.