| 3125 | */ |
| 3126 | template<typename Clock, typename json_traits> |
| 3127 | class builder { |
| 3128 | typename json_traits::object_type header_claims; |
| 3129 | typename json_traits::object_type payload_claims; |
| 3130 | |
| 3131 | /// Instance of clock type |
| 3132 | Clock clock; |
| 3133 | |
| 3134 | public: |
| 3135 | /** |
| 3136 | * Constructor for building a new builder instance |
| 3137 | * \param c Clock instance |
| 3138 | */ |
| 3139 | JWT_CLAIM_EXPLICIT builder(Clock c) : clock(c) {} |
| 3140 | /** |
| 3141 | * Set a header claim. |
| 3142 | * \param id Name of the claim |
| 3143 | * \param c Claim to add |
| 3144 | * \return *this to allow for method chaining |
| 3145 | */ |
| 3146 | builder& set_header_claim(const typename json_traits::string_type& id, typename json_traits::value_type c) { |
| 3147 | header_claims[id] = std::move(c); |
| 3148 | return *this; |
| 3149 | } |
| 3150 | |
| 3151 | /** |
| 3152 | * Set a header claim. |
| 3153 | * \param id Name of the claim |
| 3154 | * \param c Claim to add |
| 3155 | * \return *this to allow for method chaining |
| 3156 | */ |
| 3157 | builder& set_header_claim(const typename json_traits::string_type& id, basic_claim<json_traits> c) { |
| 3158 | header_claims[id] = c.to_json(); |
| 3159 | return *this; |
| 3160 | } |
| 3161 | /** |
| 3162 | * Set a payload claim. |
| 3163 | * \param id Name of the claim |
| 3164 | * \param c Claim to add |
| 3165 | * \return *this to allow for method chaining |
| 3166 | */ |
| 3167 | builder& set_payload_claim(const typename json_traits::string_type& id, typename json_traits::value_type c) { |
| 3168 | payload_claims[id] = std::move(c); |
| 3169 | return *this; |
| 3170 | } |
| 3171 | /** |
| 3172 | * Set a payload claim. |
| 3173 | * \param id Name of the claim |
| 3174 | * \param c Claim to add |
| 3175 | * \return *this to allow for method chaining |
| 3176 | */ |
| 3177 | builder& set_payload_claim(const typename json_traits::string_type& id, basic_claim<json_traits> c) { |
| 3178 | payload_claims[id] = c.to_json(); |
| 3179 | return *this; |
| 3180 | } |
| 3181 | /** |
| 3182 | * \brief Set algorithm claim |
| 3183 | * You normally don't need to do this, as the algorithm is automatically set if you don't change it. |
| 3184 | * |