Goby3  3.1.5a
2024.05.23
jwt::decoded_jwt< json_traits > Class Template Reference

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

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

Public Types

using basic_claim_t = basic_claim< json_traits >
 
- Public Types inherited from jwt::header< json_traits >
using basic_claim_t = basic_claim< json_traits >
 
- Public Types inherited from jwt::payload< json_traits >
using basic_claim_t = basic_claim< json_traits >
 

Public Member Functions

JWT_CLAIM_EXPLICIT decoded_jwt (const typename json_traits::string_type &token)
 Parses a given token. More...
 
template<typename Decode >
 decoded_jwt (const typename json_traits::string_type &token, Decode decode)
 Parses a given token. More...
 
const json_traits::string_type & get_token () const noexcept
 
const json_traits::string_type & get_header () const noexcept
 
const json_traits::string_type & get_payload () const noexcept
 
const json_traits::string_type & get_signature () const noexcept
 
const json_traits::string_type & get_header_base64 () const noexcept
 
const json_traits::string_type & get_payload_base64 () const noexcept
 
const json_traits::string_type & get_signature_base64 () const noexcept
 
std::unordered_map< typename json_traits::string_type, basic_claim_tget_payload_claims () const
 
std::unordered_map< typename json_traits::string_type, basic_claim_tget_header_claims () const
 
basic_claim_t get_payload_claim (const typename json_traits::string_type &name) const
 
basic_claim_t get_header_claim (const typename json_traits::string_type &name) const
 
- Public Member Functions inherited from jwt::header< json_traits >
bool has_algorithm () const noexcept
 
bool has_type () const noexcept
 
bool has_content_type () const noexcept
 
bool has_key_id () const noexcept
 
json_traits::string_type get_algorithm () const
 
json_traits::string_type get_type () const
 
json_traits::string_type get_content_type () const
 
json_traits::string_type get_key_id () const
 
bool has_header_claim (const typename json_traits::string_type &name) const noexcept
 
basic_claim_t get_header_claim (const typename json_traits::string_type &name) const
 
- Public Member Functions inherited from jwt::payload< json_traits >
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

const json_traits::string_type token
 Unmodifed token, as passed to constructor. More...
 
json_traits::string_type header
 Header part decoded from base64. More...
 
json_traits::string_type header_base64
 Unmodified header part in base64. More...
 
json_traits::string_type payload
 Payload part decoded from base64. More...
 
json_traits::string_type payload_base64
 Unmodified payload part in base64. More...
 
json_traits::string_type signature
 Signature part decoded from base64. More...
 
json_traits::string_type signature_base64
 Unmodified signature part in base64. More...
 
- Protected Attributes inherited from jwt::header< json_traits >
details::map_of_claims< json_traits > header_claims
 
- Protected Attributes inherited from jwt::payload< json_traits >
details::map_of_claims< json_traits > payload_claims
 

Detailed Description

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

Class containing all information about a decoded token

Definition at line 2930 of file jwt.h.

Member Typedef Documentation

◆ basic_claim_t

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

Definition at line 2949 of file jwt.h.

Constructor & Destructor Documentation

◆ decoded_jwt() [1/2]

template<typename json_traits >
JWT_CLAIM_EXPLICIT jwt::decoded_jwt< json_traits >::decoded_jwt ( const typename json_traits::string_type &  token)
inline

Parses a given token.

Note
Decodes using the jwt::base64url which supports an std::string
Parameters
tokenThe token to parse
Exceptions
std::invalid_argumentToken is not in correct format
std::runtime_errorBase64 decoding failed or invalid json

Definition at line 2960 of file jwt.h.

◆ decoded_jwt() [2/2]

template<typename json_traits >
template<typename Decode >
jwt::decoded_jwt< json_traits >::decoded_jwt ( const typename json_traits::string_type &  token,
Decode  decode 
)
inline

Parses a given token.

Template Parameters
Decodeis callabled, taking a string_type and returns a string_type. It should ensure the padding of the input and then base64url decode and return the results.
Parameters
tokenThe token to parse
decodeThe function to decode the token
Exceptions
std::invalid_argumentToken is not in correct format
std::runtime_errorBase64 decoding failed or invalid json

Definition at line 2979 of file jwt.h.

Member Function Documentation

◆ get_header()

template<typename json_traits >
const json_traits::string_type& jwt::decoded_jwt< json_traits >::get_header ( ) const
inlinenoexcept

Get header part as json string

Returns
header part after base64 decoding

Definition at line 3008 of file jwt.h.

◆ get_header_base64()

template<typename json_traits >
const json_traits::string_type& jwt::decoded_jwt< json_traits >::get_header_base64 ( ) const
inlinenoexcept

Get header part as base64 string

Returns
header part before base64 decoding

Definition at line 3023 of file jwt.h.

◆ get_header_claim()

template<typename json_traits >
basic_claim_t jwt::decoded_jwt< json_traits >::get_header_claim ( const typename json_traits::string_type &  name) const
inline

Get a header claim by name

Parameters
namethe name of the desired claim
Returns
Requested claim
Exceptions
jwt::error::claim_not_present_exceptionif the claim was not present

Definition at line 3077 of file jwt.h.

◆ get_header_claims()

template<typename json_traits >
std::unordered_map<typename json_traits::string_type, basic_claim_t> jwt::decoded_jwt< json_traits >::get_header_claims ( ) const
inline

Get all header claims

Returns
map of claims

Definition at line 3055 of file jwt.h.

◆ get_payload()

template<typename json_traits >
const json_traits::string_type& jwt::decoded_jwt< json_traits >::get_payload ( ) const
inlinenoexcept

Get payload part as json string

Returns
payload part after base64 decoding

Definition at line 3013 of file jwt.h.

◆ get_payload_base64()

template<typename json_traits >
const json_traits::string_type& jwt::decoded_jwt< json_traits >::get_payload_base64 ( ) const
inlinenoexcept

Get payload part as base64 string

Returns
payload part before base64 decoding

Definition at line 3031 of file jwt.h.

◆ get_payload_claim()

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

Get a payload claim by name

Parameters
namethe name of the desired claim
Returns
Requested claim
Exceptions
jwt::error::claim_not_present_exceptionif the claim was not present

Definition at line 3066 of file jwt.h.

◆ get_payload_claims()

template<typename json_traits >
std::unordered_map<typename json_traits::string_type, basic_claim_t> jwt::decoded_jwt< json_traits >::get_payload_claims ( ) const
inline

Get all payload claims

Returns
map of claims

Definition at line 3047 of file jwt.h.

◆ get_signature()

template<typename json_traits >
const json_traits::string_type& jwt::decoded_jwt< json_traits >::get_signature ( ) const
inlinenoexcept

Get signature part as json string

Returns
signature part after base64 decoding

Definition at line 3018 of file jwt.h.

◆ get_signature_base64()

template<typename json_traits >
const json_traits::string_type& jwt::decoded_jwt< json_traits >::get_signature_base64 ( ) const
inlinenoexcept

Get signature part as base64 string

Returns
signature part before base64 decoding

Definition at line 3039 of file jwt.h.

◆ get_token()

template<typename json_traits >
const json_traits::string_type& jwt::decoded_jwt< json_traits >::get_token ( ) const
inlinenoexcept

Get token string, as passed to constructor

Returns
token as passed to constructor

Definition at line 3003 of file jwt.h.

Member Data Documentation

◆ header

template<typename json_traits >
json_traits::string_type jwt::decoded_jwt< json_traits >::header
protected

Header part decoded from base64.

Definition at line 2936 of file jwt.h.

◆ header_base64

template<typename json_traits >
json_traits::string_type jwt::decoded_jwt< json_traits >::header_base64
protected

Unmodified header part in base64.

Definition at line 2938 of file jwt.h.

◆ payload

template<typename json_traits >
json_traits::string_type jwt::decoded_jwt< json_traits >::payload
protected

Payload part decoded from base64.

Definition at line 2940 of file jwt.h.

◆ payload_base64

template<typename json_traits >
json_traits::string_type jwt::decoded_jwt< json_traits >::payload_base64
protected

Unmodified payload part in base64.

Definition at line 2942 of file jwt.h.

◆ signature

template<typename json_traits >
json_traits::string_type jwt::decoded_jwt< json_traits >::signature
protected

Signature part decoded from base64.

Definition at line 2944 of file jwt.h.

◆ signature_base64

template<typename json_traits >
json_traits::string_type jwt::decoded_jwt< json_traits >::signature_base64
protected

Unmodified signature part in base64.

Definition at line 2946 of file jwt.h.

◆ token

template<typename json_traits >
const json_traits::string_type jwt::decoded_jwt< json_traits >::token
protected

Unmodifed token, as passed to constructor.

Definition at line 2934 of file jwt.h.


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