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

JSON Web Key. More...

#include <jwt.h>

Public Member Functions

JWT_CLAIM_EXPLICIT jwk (const typename json_traits::string_type &str)
 
JWT_CLAIM_EXPLICIT jwk (const typename json_traits::value_type &json)
 
json_traits::string_type get_key_type () const
 
json_traits::string_type get_use () const
 
basic_claim_t::set_t get_key_operations () const
 
json_traits::string_type get_algorithm () const
 
json_traits::string_type get_key_id () const
 
json_traits::string_type get_curve () const
 Get curve claim.
 
json_traits::array_type get_x5c () const
 
json_traits::string_type get_x5u () const
 
json_traits::string_type get_x5t () const
 
json_traits::string_type get_x5t_sha256 () const
 
json_traits::string_type get_x5c_key_value () const
 
bool has_key_type () const noexcept
 
bool has_use () const noexcept
 
bool has_key_operations () const noexcept
 
bool has_algorithm () const noexcept
 
bool has_curve () const noexcept
 
bool has_key_id () const noexcept
 
bool has_x5u () const noexcept
 
bool has_x5c () const noexcept
 
bool has_x5t () const noexcept
 
bool has_x5t_sha256 () const noexcept
 
bool has_jwk_claim (const typename json_traits::string_type &name) const noexcept
 
basic_claim_t get_jwk_claim (const typename json_traits::string_type &name) const
 
bool empty () const noexcept
 
json_traits::object_type get_claims () const
 

Detailed Description

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

JSON Web Key.

https://tools.ietf.org/html/rfc7517

A JSON object that represents a cryptographic key. The members of the object represent properties of the key, including its value.

Member Function Documentation

◆ empty()

template<typename json_traits >
bool jwt::jwk< json_traits >::empty ( ) const
inlinenoexcept

Check if the jwk has any claims

Returns
true is any claim is present

◆ get_algorithm()

template<typename json_traits >
json_traits::string_type jwt::jwk< 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_claims()

template<typename json_traits >
json_traits::object_type jwt::jwk< json_traits >::get_claims ( ) const
inline

Get all jwk claims

Returns
Map of claims

◆ get_curve()

template<typename json_traits >
json_traits::string_type jwt::jwk< json_traits >::get_curve ( ) const
inline

Get curve claim.

https://www.rfc-editor.org/rfc/rfc7518.html#section-6.2.1.1 https://www.iana.org/assignments/jose/jose.xhtml#table-web-key-elliptic-curve

Returns
curve 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_jwk_claim()

template<typename json_traits >
basic_claim_t jwt::jwk< json_traits >::get_jwk_claim ( const typename json_traits::string_type & name) const
inline

Get jwk claim by name

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

◆ get_key_id()

template<typename json_traits >
json_traits::string_type jwt::jwk< 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_key_operations()

template<typename json_traits >
basic_claim_t::set_t jwt::jwk< json_traits >::get_key_operations ( ) const
inline

Get key operation types claim

Returns
key operation types as a set of strings
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_key_type()

template<typename json_traits >
json_traits::string_type jwt::jwk< json_traits >::get_key_type ( ) const
inline

Get key type claim

This returns the general type (e.g. RSA or EC), not a specific algorithm value.

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

template<typename json_traits >
json_traits::string_type jwt::jwk< json_traits >::get_use ( ) const
inline

Get public key usage claim

Returns
usage parameter 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_x5c()

template<typename json_traits >
json_traits::array_type jwt::jwk< json_traits >::get_x5c ( ) const
inline

Get x5c claim

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

◆ get_x5c_key_value()

template<typename json_traits >
json_traits::string_type jwt::jwk< json_traits >::get_x5c_key_value ( ) const
inline

Get x5c claim as a string

Returns
x5c as an 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_x5t()

template<typename json_traits >
json_traits::string_type jwt::jwk< json_traits >::get_x5t ( ) const
inline

Get X509 thumbprint claim

Returns
x5t 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_x5t_sha256()

template<typename json_traits >
json_traits::string_type jwt::jwk< json_traits >::get_x5t_sha256 ( ) const
inline

Get X509 SHA256 thumbprint claim

Returns
x5t::S256 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_x5u()

template<typename json_traits >
json_traits::string_type jwt::jwk< json_traits >::get_x5u ( ) const
inline

Get X509 URL claim

Returns
x5u 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_algorithm()

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

Check if algorithm is present ("alg")

Returns
true if present, false otherwise

◆ has_curve()

template<typename json_traits >
bool jwt::jwk< json_traits >::has_curve ( ) const
inlinenoexcept

Check if curve is present ("crv")

Returns
true if present, false otherwise

◆ has_jwk_claim()

template<typename json_traits >
bool jwt::jwk< json_traits >::has_jwk_claim ( const typename json_traits::string_type & name) const
inlinenoexcept

Check if a jwk claim is present

Returns
true if claim was present, false otherwise

◆ has_key_id()

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

Check if key id is present ("kid")

Returns
true if present, false otherwise

◆ has_key_operations()

template<typename json_traits >
bool jwt::jwk< json_traits >::has_key_operations ( ) const
inlinenoexcept

Check if a key operations parameter is present ("key_ops")

Returns
true if present, false otherwise

◆ has_key_type()

template<typename json_traits >
bool jwt::jwk< json_traits >::has_key_type ( ) const
inlinenoexcept

Check if a key type is present ("kty")

Returns
true if present, false otherwise

◆ has_use()

template<typename json_traits >
bool jwt::jwk< json_traits >::has_use ( ) const
inlinenoexcept

Check if a public key usage indication is present ("use")

Returns
true if present, false otherwise

◆ has_x5c()

template<typename json_traits >
bool jwt::jwk< json_traits >::has_x5c ( ) const
inlinenoexcept

Check if X509 Chain is present ("x5c")

Returns
true if present, false otherwise

◆ has_x5t()

template<typename json_traits >
bool jwt::jwk< json_traits >::has_x5t ( ) const
inlinenoexcept

Check if a X509 thumbprint is present ("x5t")

Returns
true if present, false otherwise

◆ has_x5t_sha256()

template<typename json_traits >
bool jwt::jwk< json_traits >::has_x5t_sha256 ( ) const
inlinenoexcept

Check if a X509 SHA256 thumbprint is present ("x5t#S256")

Returns
true if present, false otherwise

◆ has_x5u()

template<typename json_traits >
bool jwt::jwk< json_traits >::has_x5u ( ) const
inlinenoexcept

Check if X509 URL is present ("x5u")

Returns
true if present, false otherwise

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