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

#include <jwt.h>

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

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.
 
template<typename Decode >
 decoded_jwt (const typename json_traits::string_type &token, Decode decode)
 Parses a given token.
 
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
 
json_traits::object_type get_payload_json () const
 
json_traits::object_type get_header_json () 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

json_traits::string_type token
 Unmodified token, as passed to constructor.
 
json_traits::string_type header
 Header part decoded from base64.
 
json_traits::string_type header_base64
 Unmodified header part in base64.
 
json_traits::string_type payload
 Payload part decoded from base64.
 
json_traits::string_type payload_base64
 Unmodified payload part in base64.
 
json_traits::string_type signature
 Signature part decoded from base64.
 
json_traits::string_type signature_base64
 Unmodified signature part in base64.
 
- 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

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

◆ 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 callable, 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

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

◆ 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

◆ 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

◆ get_header_json()

template<typename json_traits >
json_traits::object_type jwt::decoded_jwt< json_traits >::get_header_json ( ) const
inline

Get all header as JSON object

Returns
map of claims

◆ 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

◆ 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

◆ 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

◆ get_payload_json()

template<typename json_traits >
json_traits::object_type jwt::decoded_jwt< json_traits >::get_payload_json ( ) const
inline

Get all payload as JSON object

Returns
map of claims

◆ 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

◆ 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

◆ 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

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