libjwt-1.17.0
|
These functions allow you to add, remove and retrieve grants from a JWT object. More...
Functions | |
const char * | jwt_get_grant (jwt_t *jwt, const char *grant) |
Return the value of a string grant. | |
long | jwt_get_grant_int (jwt_t *jwt, const char *grant) |
Return the value of an integer grant. | |
int | jwt_get_grant_bool (jwt_t *jwt, const char *grant) |
Return the value of an boolean grant. | |
char * | jwt_get_grants_json (jwt_t *jwt, const char *grant) |
Return the value of a grant as JSON encoded object string. | |
int | jwt_add_grant (jwt_t *jwt, const char *grant, const char *val) |
Add a new string grant to this JWT object. | |
int | jwt_add_grant_int (jwt_t *jwt, const char *grant, long val) |
Add a new integer grant to this JWT object. | |
int | jwt_add_grant_bool (jwt_t *jwt, const char *grant, int val) |
Add a new boolean grant to this JWT object. | |
int | jwt_add_grants_json (jwt_t *jwt, const char *json) |
Add grants from a JSON encoded object string. | |
int | jwt_del_grants (jwt_t *jwt, const char *grant) |
Delete a grant from this JWT object. | |
These functions allow you to add, remove and retrieve grants from a JWT object.
int jwt_add_grant | ( | jwt_t * | jwt, |
const char * | grant, | ||
const char * | val ) |
Add a new string grant to this JWT object.
Creates a new grant for this object. The string for grant and val are copied internally, so do not require that the pointer or string remain valid for the lifetime of this object. It is an error if you try to add a grant that already exists.
jwt | Pointer to a JWT object. |
grant | String containing the name of the grant to add. |
val | String containing the value to be saved for grant. Can be an empty string, but cannot be NULL. |
Note, this only allows for string based grants. If you wish to add integer grants, then use jwt_add_grant_int(). If you wish to add more complex grants (e.g. an array), then use jwt_add_grants_json().
int jwt_add_grant_bool | ( | jwt_t * | jwt, |
const char * | grant, | ||
int | val ) |
Add a new boolean grant to this JWT object.
Creates a new grant for this object. The string for grant is copied internally, so do not require that the pointer or string remain valid for the lifetime of this object. It is an error if you try to add a grant that already exists.
jwt | Pointer to a JWT object. |
grant | String containing the name of the grant to add. |
val | boolean containing the value to be saved for grant. |
Note, this only allows for boolean based grants. If you wish to add string grants, then use jwt_add_grant(). If you wish to add more complex grants (e.g. an array), then use jwt_add_grants_json().
int jwt_add_grant_int | ( | jwt_t * | jwt, |
const char * | grant, | ||
long | val ) |
Add a new integer grant to this JWT object.
Creates a new grant for this object. The string for grant is copied internally, so do not require that the pointer or string remain valid for the lifetime of this object. It is an error if you try to add a grant that already exists.
jwt | Pointer to a JWT object. |
grant | String containing the name of the grant to add. |
val | int containing the value to be saved for grant. |
Note, this only allows for integer based grants. If you wish to add string grants, then use jwt_add_grant(). If you wish to add more complex grants (e.g. an array), then use jwt_add_grants_json().
int jwt_add_grants_json | ( | jwt_t * | jwt, |
const char * | json ) |
Add grants from a JSON encoded object string.
Loads a grant from an existing JSON encoded object string. Overwrites existing grant. If grant is NULL, then the JSON encoded string is assumed to be a JSON hash of all grants being added and will be merged into the grant listing.
jwt | Pointer to a JWT object. |
json | String containing a JSON encoded object of grants. |
int jwt_del_grants | ( | jwt_t * | jwt, |
const char * | grant ) |
Delete a grant from this JWT object.
Deletes the named grant from this object. It is not an error if there is no grant matching the passed name. If grant is NULL, then all grants are deleted from this JWT.
jwt | Pointer to a JWT object. |
grant | String containing the name of the grant to delete. If this is NULL, then all grants are deleted. |
const char * jwt_get_grant | ( | jwt_t * | jwt, |
const char * | grant ) |
Return the value of a string grant.
Returns the string value for a grant (e.g. "iss"). If it does not exist, NULL will be returned.
jwt | Pointer to a JWT object. |
grant | String containing the name of the grant to return a value for. |
Note, this will only return grants with JSON string values. Use jwt_get_grants_json() to get the JSON representation of more complex values (e.g. arrays) or use jwt_get_grant_int() to get simple integer values.
int jwt_get_grant_bool | ( | jwt_t * | jwt, |
const char * | grant ) |
Return the value of an boolean grant.
Returns the int value for a grant (e.g. "exp"). If it does not exist, 0 will be returned.
jwt | Pointer to a JWT object. |
grant | String containing the name of the grant to return a value for. |
Note, this will only return grants with JSON boolean values. Use jwt_get_grants_json() to get the JSON representation of more complex values (e.g. arrays) or use jwt_get_grant() to get string values.
long jwt_get_grant_int | ( | jwt_t * | jwt, |
const char * | grant ) |
Return the value of an integer grant.
Returns the int value for a grant (e.g. "exp"). If it does not exist, 0 will be returned.
jwt | Pointer to a JWT object. |
grant | String containing the name of the grant to return a value for. |
Note, this will only return grants with JSON integer values. Use jwt_get_grants_json() to get the JSON representation of more complex values (e.g. arrays) or use jwt_get_grant() to get string values.
char * jwt_get_grants_json | ( | jwt_t * | jwt, |
const char * | grant ) |
Return the value of a grant as JSON encoded object string.
Returns the JSON encoded string value for a grant (e.g. "iss"). If it does not exist, NULL will be returned.
jwt | Pointer to a JWT object. |
grant | String containing the name of the grant to return a value for. If this is NULL, all grants will be returned as a JSON encoded hash. |