-/*
- * check whether the token of 'session' is 'token'
- * return 1 if true or 0 otherwise
- */
-int afb_session_check_token (struct afb_session *session, const char *token)
-{
- int r;
-
- session_lock(session);
- r = !session->closed
- && session->expiration >= NOW
- && !(session->token && strcmp(token, afb_session_token(session)));
- session_unlock(session);
- return r;
-}
-
-/* generate a new token and update client context */
-void afb_session_new_token (struct afb_session *session)
-{
- int rc;
- uuid_stringz_t uuid;
- struct afb_token *previous, *next;
- session_lock(session);
- uuid_new_stringz(uuid);
- rc = afb_token_get(&next, uuid);
- if (rc < 0)
- ERROR("can't renew token");
- else {
- previous = session->token;
- session->token = next;
- session_update_expiration(session, NOW);
-#if WITH_AFB_HOOK
- afb_hook_session_renew(session);
-#endif
- afb_token_unref(previous);
- }
- session_unlock(session);
-}
-