Goby3  3.1.4
2024.02.22
jwt::payload< json_traits > Class Template Reference

#include <goby/util/thirdparty/jwt-cpp/jwt.h>

Inheritance diagram for jwt::payload< json_traits >:
jwt::decoded_jwt< json_traits >

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.

Definition at line 2709 of file jwt.h.

Member Typedef Documentation

◆ basic_claim_t

template<typename json_traits >
using jwt::payload< json_traits >::basic_claim_t = basic_claim<json_traits>

Definition at line 2715 of file jwt.h.

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)

Definition at line 2778 of file jwt.h.

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

Definition at line 2792 of file jwt.h.

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

Definition at line 2813 of file jwt.h.

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

Definition at line 2806 of file jwt.h.

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

Definition at line 2758 of file jwt.h.

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

Definition at line 2799 of file jwt.h.

◆ 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

Definition at line 2830 of file jwt.h.

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

Definition at line 2768 of file jwt.h.

◆ 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

Definition at line 2731 of file jwt.h.

◆ 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

Definition at line 2736 of file jwt.h.

◆ 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

Definition at line 2751 of file jwt.h.

◆ 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

Definition at line 2746 of file jwt.h.

◆ 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

Definition at line 2721 of file jwt.h.

◆ 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

Definition at line 2741 of file jwt.h.

◆ 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

Definition at line 2821 of file jwt.h.

◆ 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

Definition at line 2726 of file jwt.h.

Member Data Documentation

◆ payload_claims

template<typename json_traits >
details::map_of_claims<json_traits> jwt::payload< json_traits >::payload_claims
protected

Definition at line 2712 of file jwt.h.


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