| 3859 | */ |
| 3860 | template<typename json_traits> |
| 3861 | class jwk { |
| 3862 | using basic_claim_t = basic_claim<json_traits>; |
| 3863 | const details::map_of_claims<json_traits> jwk_claims; |
| 3864 | |
| 3865 | public: |
| 3866 | JWT_CLAIM_EXPLICIT jwk(const typename json_traits::string_type& str) |
| 3867 | : jwk_claims(details::map_of_claims<json_traits>::parse_claims(str)) {} |
| 3868 | |
| 3869 | JWT_CLAIM_EXPLICIT jwk(const typename json_traits::value_type& json) |
| 3870 | : jwk_claims(json_traits::as_object(json)) {} |
| 3871 | |
| 3872 | /** |
| 3873 | * Get key type claim |
| 3874 | * |
| 3875 | * This returns the general type (e.g. RSA or EC), not a specific algorithm value. |
| 3876 | * \return key type as string |
| 3877 | * \throw std::runtime_error If claim was not present |
| 3878 | * \throw std::bad_cast Claim was present but not a string (Should not happen in a valid token) |
| 3879 | */ |
| 3880 | typename json_traits::string_type get_key_type() const { return get_jwk_claim("kty").as_string(); } |
| 3881 | |
| 3882 | /** |
| 3883 | * Get public key usage claim |
| 3884 | * \return usage parameter as string |
| 3885 | * \throw std::runtime_error If claim was not present |
| 3886 | * \throw std::bad_cast Claim was present but not a string (Should not happen in a valid token) |
| 3887 | */ |
| 3888 | typename json_traits::string_type get_use() const { return get_jwk_claim("use").as_string(); } |
| 3889 | |
| 3890 | /** |
| 3891 | * Get key operation types claim |
| 3892 | * \return key operation types as a set of strings |
| 3893 | * \throw std::runtime_error If claim was not present |
| 3894 | * \throw std::bad_cast Claim was present but not a string (Should not happen in a valid token) |
| 3895 | */ |
| 3896 | typename basic_claim_t::set_t get_key_operations() const { return get_jwk_claim("key_ops").as_set(); } |
| 3897 | |
| 3898 | /** |
| 3899 | * Get algorithm claim |
| 3900 | * \return algorithm as string |
| 3901 | * \throw std::runtime_error If claim was not present |
| 3902 | * \throw std::bad_cast Claim was present but not a string (Should not happen in a valid token) |
| 3903 | */ |
| 3904 | typename json_traits::string_type get_algorithm() const { return get_jwk_claim("alg").as_string(); } |
| 3905 | |
| 3906 | /** |
| 3907 | * Get key id claim |
| 3908 | * \return key id as string |
| 3909 | * \throw std::runtime_error If claim was not present |
| 3910 | * \throw std::bad_cast Claim was present but not a string (Should not happen in a valid token) |
| 3911 | */ |
| 3912 | typename json_traits::string_type get_key_id() const { return get_jwk_claim("kid").as_string(); } |
| 3913 | |
| 3914 | /** |
| 3915 | * \brief Get curve claim |
| 3916 | * |
| 3917 | * https://www.rfc-editor.org/rfc/rfc7518.html#section-6.2.1.1 |
| 3918 | * https://www.iana.org/assignments/jose/jose.xhtml#table-web-key-elliptic-curve |
nothing calls this directly
no outgoing calls
no test coverage detected