JWTXX
C++ library for JWT
Loading...
Searching...
No Matches
jwt.h File Reference

Classes, constants and functions to work with JWT. More...

#include "value.h"
#include "error.h"
#include <functional>
#include <string>
#include <vector>
#include <memory>
#include <ctime>

Go to the source code of this file.

Classes

class  JWTXX::Key
 Represents signature algorithm Signs tokens and verifies token signatures. More...
 
class  JWTXX::Key::Error
 Key-specific exception. More...
 
class  JWTXX::ValidationResult
 Represents the result of validation. If validation is successfull an object of this class is equivalent to 'true' boolean value. Otherwise it is equivalent ot 'false' and contains an error message. More...
 
class  JWTXX::JWT
 Main class to work with JWT. More...
 
class  JWTXX::JWT::Error
 JWT-specific exception. More...
 
class  JWTXX::JWT::ParseError
 Indicates problems with JWT structure. More...
 
class  JWTXX::JWT::ValidationError
 Indicates problems with JWT validation (signature and claims). More...
 

Namespaces

namespace  JWTXX
 All classes, functions and constants are here.
 
namespace  JWTXX::Validate
 Validation functions are here.
 

Typedefs

using JWTXX::Validator = std::function<ValidationResult (const Value::Object&)>
 Validation function for claims.
 
using JWTXX::Validators = std::vector<Validator>
 A list of validators.
 

Enumerations

enum class  JWTXX::Algorithm {
  JWTXX::HS256 , JWTXX::HS384 , JWTXX::HS512 , JWTXX::RS256 ,
  JWTXX::RS384 , JWTXX::RS512 , JWTXX::ES256 , JWTXX::ES384 ,
  JWTXX::ES512 , JWTXX::none
}
 JWT signature algorithms. More...
 

Functions

void JWTXX::enableOpenSSLErrors () noexcept
 Enable OpenSSL human-readable error messages. You only need to call it once, in the beginning of your program.
 
std::string JWTXX::algToString (Algorithm alg) noexcept
 Converts algorithm code into a string representation.
 
Algorithm JWTXX::stringToAlg (const std::string &value)
 Converts algorithm name into algorithm code.
 
Validator JWTXX::Validate::exp (std::time_t now=std::time(nullptr)) noexcept
 Constructs validator for 'exp' claim.
 
Validator JWTXX::Validate::nbf (std::time_t now=std::time(nullptr)) noexcept
 Constructs validator for 'nbf' claim.
 
Validator JWTXX::Validate::iat (std::time_t now=std::time(nullptr)) noexcept
 Constructs validator for 'iat' claim.
 
Validator JWTXX::Validate::iss (std::string issuer) noexcept
 Constructs validator for 'iss' claim.
 
Validator JWTXX::Validate::aud (std::string audience) noexcept
 Constructs validator for 'aud' claim.
 
Validator JWTXX::Validate::sub (std::string subject) noexcept
 Constructs validator for 'sub' claim.
 

Detailed Description

Classes, constants and functions to work with JWT.