| 2797 | */ |
| 2798 | template<typename json_traits> |
| 2799 | class payload { |
| 2800 | protected: |
| 2801 | details::map_of_claims<json_traits> payload_claims; |
| 2802 | |
| 2803 | public: |
| 2804 | using basic_claim_t = basic_claim<json_traits>; |
| 2805 | |
| 2806 | /** |
| 2807 | * Check if issuer is present ("iss") |
| 2808 | * \return true if present, false otherwise |
| 2809 | */ |
| 2810 | bool has_issuer() const noexcept { return has_payload_claim("iss"); } |
| 2811 | /** |
| 2812 | * Check if subject is present ("sub") |
| 2813 | * \return true if present, false otherwise |
| 2814 | */ |
| 2815 | bool has_subject() const noexcept { return has_payload_claim("sub"); } |
| 2816 | /** |
| 2817 | * Check if audience is present ("aud") |
| 2818 | * \return true if present, false otherwise |
| 2819 | */ |
| 2820 | bool has_audience() const noexcept { return has_payload_claim("aud"); } |
| 2821 | /** |
| 2822 | * Check if expires is present ("exp") |
| 2823 | * \return true if present, false otherwise |
| 2824 | */ |
| 2825 | bool has_expires_at() const noexcept { return has_payload_claim("exp"); } |
| 2826 | /** |
| 2827 | * Check if not before is present ("nbf") |
| 2828 | * \return true if present, false otherwise |
| 2829 | */ |
| 2830 | bool has_not_before() const noexcept { return has_payload_claim("nbf"); } |
| 2831 | /** |
| 2832 | * Check if issued at is present ("iat") |
| 2833 | * \return true if present, false otherwise |
| 2834 | */ |
| 2835 | bool has_issued_at() const noexcept { return has_payload_claim("iat"); } |
| 2836 | /** |
| 2837 | * Check if token id is present ("jti") |
| 2838 | * \return true if present, false otherwise |
| 2839 | */ |
| 2840 | bool has_id() const noexcept { return has_payload_claim("jti"); } |
| 2841 | /** |
| 2842 | * Get issuer claim |
| 2843 | * \return issuer as string |
| 2844 | * \throw std::runtime_error If claim was not present |
| 2845 | * \throw std::bad_cast Claim was present but not a string (Should not happen in a valid token) |
| 2846 | */ |
| 2847 | typename json_traits::string_type get_issuer() const { return get_payload_claim("iss").as_string(); } |
| 2848 | /** |
| 2849 | * Get subject claim |
| 2850 | * \return subject as string |
| 2851 | * \throw std::runtime_error If claim was not present |
| 2852 | * \throw std::bad_cast Claim was present but not a string (Should not happen in a valid token) |
| 2853 | */ |
| 2854 | typename json_traits::string_type get_subject() const { return get_payload_claim("sub").as_string(); } |
| 2855 | /** |
| 2856 | * Get audience claim |
nothing calls this directly
no outgoing calls
no test coverage detected