MCPcopy Create free account
hub / github.com/Thalhammer/jwt-cpp / header

Class header

include/jwt-cpp/jwt.h:2917–2986  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2915 */
2916 template<typename json_traits>
2917 class header {
2918 protected:
2919 details::map_of_claims<json_traits> header_claims;
2920
2921 public:
2922 using basic_claim_t = basic_claim<json_traits>;
2923 /**
2924 * Check if algorithm is present ("alg")
2925 * \return true if present, false otherwise
2926 */
2927 bool has_algorithm() const noexcept { return has_header_claim("alg"); }
2928 /**
2929 * Check if type is present ("typ")
2930 * \return true if present, false otherwise
2931 */
2932 bool has_type() const noexcept { return has_header_claim("typ"); }
2933 /**
2934 * Check if content type is present ("cty")
2935 * \return true if present, false otherwise
2936 */
2937 bool has_content_type() const noexcept { return has_header_claim("cty"); }
2938 /**
2939 * Check if key id is present ("kid")
2940 * \return true if present, false otherwise
2941 */
2942 bool has_key_id() const noexcept { return has_header_claim("kid"); }
2943 /**
2944 * Get algorithm claim
2945 * \return algorithm as string
2946 * \throw std::runtime_error If claim was not present
2947 * \throw std::bad_cast Claim was present but not a string (Should not happen in a valid token)
2948 */
2949 typename json_traits::string_type get_algorithm() const { return get_header_claim("alg").as_string(); }
2950 /**
2951 * Get type claim
2952 * \return type as a string
2953 * \throw std::runtime_error If claim was not present
2954 * \throw std::bad_cast Claim was present but not a string (Should not happen in a valid token)
2955 */
2956 typename json_traits::string_type get_type() const { return get_header_claim("typ").as_string(); }
2957 /**
2958 * Get content type claim
2959 * \return content type as string
2960 * \throw std::runtime_error If claim was not present
2961 * \throw std::bad_cast Claim was present but not a string (Should not happen in a valid token)
2962 */
2963 typename json_traits::string_type get_content_type() const { return get_header_claim("cty").as_string(); }
2964 /**
2965 * Get key id claim
2966 * \return key id as string
2967 * \throw std::runtime_error If claim was not present
2968 * \throw std::bad_cast Claim was present but not a string (Should not happen in a valid token)
2969 */
2970 typename json_traits::string_type get_key_id() const { return get_header_claim("kid").as_string(); }
2971 /**
2972 * Check if a header claim is present
2973 * \return true if claim was present, false otherwise
2974 */

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected