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

#include <jwt.h>

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

Public Types

using basic_claim_t = basic_claim<json_traits>
 

Public Member Functions

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
 

Protected Attributes

details::map_of_claims< json_traits > header_claims
 

Detailed Description

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

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

Member Function Documentation

◆ get_algorithm()

template<typename json_traits >
json_traits::string_type jwt::header< json_traits >::get_algorithm ( ) const
inline

Get algorithm claim

Returns
algorithm 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_content_type()

template<typename json_traits >
json_traits::string_type jwt::header< json_traits >::get_content_type ( ) const
inline

Get content type claim

Returns
content type 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_header_claim()

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

Get header claim

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

◆ get_key_id()

template<typename json_traits >
json_traits::string_type jwt::header< json_traits >::get_key_id ( ) const
inline

Get key id claim

Returns
key 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_type()

template<typename json_traits >
json_traits::string_type jwt::header< json_traits >::get_type ( ) const
inline

Get type claim

Returns
type as a 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_algorithm()

template<typename json_traits >
bool jwt::header< json_traits >::has_algorithm ( ) const
inlinenoexcept

Check if algorithm is present ("alg")

Returns
true if present, false otherwise

◆ has_content_type()

template<typename json_traits >
bool jwt::header< json_traits >::has_content_type ( ) const
inlinenoexcept

Check if content type is present ("cty")

Returns
true if present, false otherwise

◆ has_header_claim()

template<typename json_traits >
bool jwt::header< json_traits >::has_header_claim ( const typename json_traits::string_type & name) const
inlinenoexcept

Check if a header claim is present

Returns
true if claim was present, false otherwise

◆ has_key_id()

template<typename json_traits >
bool jwt::header< json_traits >::has_key_id ( ) const
inlinenoexcept

Check if key id is present ("kid")

Returns
true if present, false otherwise

◆ has_type()

template<typename json_traits >
bool jwt::header< json_traits >::has_type ( ) const
inlinenoexcept

Check if type is present ("typ")

Returns
true if present, false otherwise

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