JWT-CPP v0.7.0
A header only library for creating and validating JSON Web Tokens (JWT) in C++
Loading...
Searching...
No Matches
jwt::payload< json_traits > Class Template Reference

#include <jwt.h>

Inheritance diagram for jwt::payload< json_traits >:
[legend]

Public Types

using basic_claim_t = basic_claim<json_traits>
 

Public Member Functions

bool has_issuer () const noexcept
 
bool has_subject () const noexcept
 
bool has_audience () const noexcept
 
bool has_expires_at () const noexcept
 
bool has_not_before () const noexcept
 
bool has_issued_at () const noexcept
 
bool has_id () const noexcept
 
json_traits::string_type get_issuer () const
 
json_traits::string_type get_subject () const
 
basic_claim_t::set_t get_audience () const
 
date get_expires_at () const
 
date get_not_before () const
 
date get_issued_at () const
 
json_traits::string_type get_id () const
 
bool has_payload_claim (const typename json_traits::string_type &name) const noexcept
 
basic_claim_t get_payload_claim (const typename json_traits::string_type &name) const
 

Protected Attributes

details::map_of_claims< json_traits > payload_claims
 

Detailed Description

template<typename json_traits>
class jwt::payload< json_traits >

Base class that represents a token payload. Contains Convenience accessors for common claims.

Member Function Documentation

◆ get_audience()

template<typename json_traits >
basic_claim_t::set_t jwt::payload< json_traits >::get_audience ( ) const
inline

Get audience claim

Returns
audience as a set of strings
Exceptions
std::runtime_errorIf claim was not present
std::bad_castClaim was present but not a set (Should not happen in a valid token)

◆ get_expires_at()

template<typename json_traits >
date jwt::payload< json_traits >::get_expires_at ( ) const
inline

Get expires claim

Returns
expires as a date in utc
Exceptions
std::runtime_errorIf claim was not present
std::bad_castClaim was present but not a date (Should not happen in a valid token)

◆ get_id()

template<typename json_traits >
json_traits::string_type jwt::payload< json_traits >::get_id ( ) const
inline

Get id claim

Returns
id as string
Exceptions
std::runtime_errorIf claim was not present
std::bad_castClaim was present but not a string (Should not happen in a valid token)

◆ get_issued_at()

template<typename json_traits >
date jwt::payload< json_traits >::get_issued_at ( ) const
inline

Get issued at claim

Returns
issued at as date in utc
Exceptions
std::runtime_errorIf claim was not present
std::bad_castClaim was present but not a date (Should not happen in a valid token)

◆ get_issuer()

template<typename json_traits >
json_traits::string_type jwt::payload< json_traits >::get_issuer ( ) const
inline

Get issuer claim

Returns
issuer as string
Exceptions
std::runtime_errorIf claim was not present
std::bad_castClaim was present but not a string (Should not happen in a valid token)

◆ get_not_before()

template<typename json_traits >
date jwt::payload< json_traits >::get_not_before ( ) const
inline

Get not valid before claim

Returns
nbf date in utc
Exceptions
std::runtime_errorIf claim was not present
std::bad_castClaim was present but not a date (Should not happen in a valid token)

◆ get_payload_claim()

template<typename json_traits >
basic_claim_t jwt::payload< json_traits >::get_payload_claim ( const typename json_traits::string_type & name) const
inline

Get payload claim

Returns
Requested claim
Exceptions
std::runtime_errorIf claim was not present

◆ get_subject()

template<typename json_traits >
json_traits::string_type jwt::payload< json_traits >::get_subject ( ) const
inline

Get subject claim

Returns
subject as string
Exceptions
std::runtime_errorIf claim was not present
std::bad_castClaim was present but not a string (Should not happen in a valid token)

◆ has_audience()

template<typename json_traits >
bool jwt::payload< json_traits >::has_audience ( ) const
inlinenoexcept

Check if audience is present ("aud")

Returns
true if present, false otherwise

◆ has_expires_at()

template<typename json_traits >
bool jwt::payload< json_traits >::has_expires_at ( ) const
inlinenoexcept

Check if expires is present ("exp")

Returns
true if present, false otherwise

◆ has_id()

template<typename json_traits >
bool jwt::payload< json_traits >::has_id ( ) const
inlinenoexcept

Check if token id is present ("jti")

Returns
true if present, false otherwise

◆ has_issued_at()

template<typename json_traits >
bool jwt::payload< json_traits >::has_issued_at ( ) const
inlinenoexcept

Check if issued at is present ("iat")

Returns
true if present, false otherwise

◆ has_issuer()

template<typename json_traits >
bool jwt::payload< json_traits >::has_issuer ( ) const
inlinenoexcept

Check if issuer is present ("iss")

Returns
true if present, false otherwise

◆ has_not_before()

template<typename json_traits >
bool jwt::payload< json_traits >::has_not_before ( ) const
inlinenoexcept

Check if not before is present ("nbf")

Returns
true if present, false otherwise

◆ has_payload_claim()

template<typename json_traits >
bool jwt::payload< json_traits >::has_payload_claim ( const typename json_traits::string_type & name) const
inlinenoexcept

Check if a payload claim is present

Returns
true if claim was present, false otherwise

◆ has_subject()

template<typename json_traits >
bool jwt::payload< json_traits >::has_subject ( ) const
inlinenoexcept

Check if subject is present ("sub")

Returns
true if present, false otherwise

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