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

JWK Set. More...

#include <jwt.h>

Public Types

using jwks_t = jwk<json_traits>
 JWK instance template specialization.
 
using jwks_vector_t = std::vector<jwks_t>
 Type specialization for the vector of JWK.
 
using iterator = typename jwks_vector_t::iterator
 
using const_iterator = typename jwks_vector_t::const_iterator
 

Public Member Functions

 jwks ()=default
 
JWT_CLAIM_EXPLICIT jwks (const typename json_traits::string_type &str)
 
iterator begin ()
 
iterator end ()
 
const_iterator cbegin () const
 
const_iterator cend () const
 
const_iterator begin () const
 
const_iterator end () const
 
bool has_jwk (const typename json_traits::string_type &key_id) const noexcept
 
jwks_t get_jwk (const typename json_traits::string_type &key_id) const
 

Detailed Description

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

JWK Set.

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

A JSON object that represents a set of JWKs. The JSON object MUST have a "keys" member, which is an array of JWKs.

This container takes a JWKs and simplifies it to a vector of JWKs

Constructor & Destructor Documentation

◆ jwks() [1/2]

template<typename json_traits >
jwt::jwks< json_traits >::jwks ( )
default

Default constructor producing an empty object without any keys

◆ jwks() [2/2]

template<typename json_traits >
JWT_CLAIM_EXPLICIT jwt::jwks< json_traits >::jwks ( const typename json_traits::string_type & str)
inline

Parses a string buffer to extract the JWKS.

Parameters
strbuffer containing JSON object representing a JWKS
Exceptions
error::invalid_json_exceptionor underlying JSON implation error if the JSON is invalid with regards to the JWKS specification

Member Function Documentation

◆ get_jwk()

template<typename json_traits >
jwks_t jwt::jwks< json_traits >::get_jwk ( const typename json_traits::string_type & key_id) const
inline

Get jwk

Returns
Requested jwk by key_id
Exceptions
std::runtime_errorIf jwk was not present

◆ has_jwk()

template<typename json_traits >
bool jwt::jwks< json_traits >::has_jwk ( const typename json_traits::string_type & key_id) const
inlinenoexcept

Check if a jwk with the kid is present

Returns
true if jwk was present, false otherwise

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