10Duke Scale C++ Client
Loading...
Searching...
No Matches
tenduke::jwt::JWT Class Reference

#include <JWT.h>

Detailed Description

Very simple JWT implementation.

This will likely be heavily modified in the future.

Inheritance diagram for tenduke::jwt::JWT:
tenduke::oidc::IdToken

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)
 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.
 

Constructor & Destructor Documentation

◆ JWT() [1/3]

tenduke::jwt::JWT::JWT ( std::map< std::string, std::string >  claims)
explicit

Constructs new JWT instance from given claims.

Parameters
claims-

◆ JWT() [2/3]

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.

Parameters
claims-
headerParameters-

◆ JWT() [3/3]

tenduke::jwt::JWT::JWT ( const JWT copy)

Copy-constructs new JWT instance.

Parameters
copy-

Member Function Documentation

◆ claim()

const std::string * tenduke::jwt::JWT::claim ( const std::string &  name) const

Returns a JWT-claim by given name.

Parameters
namename of the claim
Returns
pointer to the claim, or nullptr if no such claim

◆ getAudience()

const std::string & tenduke::jwt::JWT::getAudience ( ) const

Returns "Audience", "aud"-claim.

Returns
"Audience" or empty string if not present

◆ getClaims()

const std::map< std::string, std::string > & tenduke::jwt::JWT::getClaims ( ) const
inline

Returns all claims as a map.

Returns
-

◆ getExpirationTime()

std::int64_t tenduke::jwt::JWT::getExpirationTime ( ) const

Returns "Expiration time", "exp"-claim.

Returns
"Expiration time" or NUMBER_NOT_PRESENT if not present.

◆ getHeaderParameterKID()

std::string tenduke::jwt::JWT::getHeaderParameterKID ( ) const

Returns header-parameter KeyId ("kid"-parameter).

Returns
"KeyId" or empty string if not present.

◆ getHeaderParameters()

std::map< std::string, std::string > tenduke::jwt::JWT::getHeaderParameters ( ) const

Returns header parameters.

Returns
-

◆ getIntClaim()

std::int64_t tenduke::jwt::JWT::getIntClaim ( const std::string &  claimName) const

Returns claim value as std::int64_t.

Parameters
claimName-
Returns
-

◆ getIssuedAt()

std::int64_t tenduke::jwt::JWT::getIssuedAt ( ) const

Returns "Issued at", "iat"-claim.

Returns
"Issued at" or NUMBER_NOT_PRESENT if not present.

◆ getIssuer()

const std::string & tenduke::jwt::JWT::getIssuer ( ) const

Returns "Issuer", "iss"-claim.

Returns
"Issuer" or empty string if not present

◆ getJWTID()

const std::string & tenduke::jwt::JWT::getJWTID ( ) const

Returns "JWT ID", "jti"-claim.

Returns
"JWT ID" or empty string if not present

◆ getStringClaim()

const std::string & tenduke::jwt::JWT::getStringClaim ( const std::string &  claimName) const

Returns a claim value as string.

Parameters
claimNamename of the claim
Returns
-

◆ getSubject()

const std::string & tenduke::jwt::JWT::getSubject ( ) const

Returns "Subject", "sub"-claim.

Returns
"Subject" or empty string if not present

◆ hasClaim()

bool tenduke::jwt::JWT::hasClaim ( const std::string &  name) const

Checks if the JWT has given claim.

Parameters
namename of the claim
Returns
-

◆ isInfinite()

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.

Returns
-

The documentation for this class was generated from the following files: