1#ifndef TENDUKE_OAUTH_OAUTHSTATEIMPL_H
2#define TENDUKE_OAUTH_OAUTHSTATEIMPL_H
4#include "./OAuthState.h"
25 std::string accessToken,
26 std::string refreshToken,
29 std::map<std::string, std::string> additionalProperties
30 ) : accessToken(std::move(accessToken)), refreshToken(std::move(refreshToken)), expiresAt(expiresAt), infinite(infinite),
31 additionalProperties(std::move(additionalProperties))
42 std::string accessToken,
43 std::string refreshToken,
45 std::map<std::string, std::string> additionalProperties
46 ) :
OAuthStateImpl(std::move(accessToken), std::move(refreshToken), expiresAt,
47 (expiresAt ==
tenduke::
oauth::TOKEN_DOES_NOT_EXPIRE), std::move(additionalProperties))
67 return additionalProperties;
72 auto iterator = additionalProperties.find(name);
74 if (iterator == additionalProperties.end()) {
78 return &(iterator->second);
83 auto iterator = additionalProperties.find(name);
85 return !(iterator == additionalProperties.end());
90 return !accessToken.empty();
100 return !refreshToken.empty();
105 this->accessToken = newAccessToken;
110 this->expiresAt = newExpiresAt;
116 this->refreshToken = newRefreshToken;
128 if (! newRefreshToken.empty()) {
135 additionalProperties.erase(propertyName);
139 std::string accessToken;
140 std::string refreshToken;
141 std::int64_t expiresAt;
143 std::map<std::string, std::string> additionalProperties;
Implementation of OAuthState.
Definition OAuthStateImpl.h:14
bool hasAccessToken() const override
Returns true if the state contains an access token.
Definition OAuthStateImpl.h:88
OAuthStateImpl(std::string accessToken, std::string refreshToken, int64_t expiresAt, std::map< std::string, std::string > additionalProperties)
Constructs new instance.
Definition OAuthStateImpl.h:41
void removeAdditionalProperty(const std::string &propertyName) override
Removes given additional property.
Definition OAuthStateImpl.h:133
const std::map< std::string, std::string > & getAdditionalProperties() const override
Returns all additional properties returned by the server.
Definition OAuthStateImpl.h:65
const std::string & getRefreshToken() const override
Returns the refresh token.
Definition OAuthStateImpl.h:55
OAuthStateImpl(std::string accessToken, std::string refreshToken, int64_t expiresAt, bool infinite, std::map< std::string, std::string > additionalProperties)
Constructs new instance.
Definition OAuthStateImpl.h:24
bool isRefreshable() const override
Returns true if the state is refreshable (i.e.
Definition OAuthStateImpl.h:98
void refreshFrom(const OAuthState &state) override
Refreshes the state from another state, This is called after refreshing the state with the service.
Definition OAuthStateImpl.h:119
bool doesExpire() const override
Returns true if the access token expires.
Definition OAuthStateImpl.h:93
std::int64_t getExpiresAt() const override
Returns timestamp (as epoch seconds) when the current access token expires.
Definition OAuthStateImpl.h:60
const std::string & getAccessToken() const override
Returns the access token.
Definition OAuthStateImpl.h:50
bool hasAdditionalProperty(const std::string &name) const override
Checks if the state has additional property.
Definition OAuthStateImpl.h:81
void setExpiresAt(std::int64_t newExpiresAt) override
Set the "expires at".
Definition OAuthStateImpl.h:108
void setRefreshToken(const std::string &newRefreshToken) override
Set the refresh token.
Definition OAuthStateImpl.h:114
const std::string * getAdditionalProperty(const std::string &name) const override
Returns additional property returned by the server.
Definition OAuthStateImpl.h:70
void setAccessToken(const std::string &newAccessToken) override
Set the access token.
Definition OAuthStateImpl.h:103
OAuth session state.
Definition OAuthState.h:17
virtual std::int64_t getExpiresAt() const =0
Returns timestamp (as epoch seconds) when the current access token expires.
virtual const std::string & getAccessToken() const =0
Returns the access token.
virtual const std::string & getRefreshToken() const =0
Returns the refresh token.
OAuth services.
Definition AccessTokenRequestAuthenticator.h:8
const std::int64_t TOKEN_DOES_NOT_EXPIRE
Magic value to denote that the access token does not expire.
Definition OAuthState.h:12
Root for classes, functions and globals of 10Duke C++ Client.
Definition BackendConfiguration.h:7