1#ifndef DITTO_IDENTITY_H
2#define DITTO_IDENTITY_H
4#include "AuthenticationCallback.hpp"
23 ONLINE_WITH_AUTHENTICATION,
59 friend class ManualIdentity;
60 friend class OfflinePlaygroundIdentity;
61 friend class OnlineWithAuthenticationIdentity;
62 friend class OnlinePlaygroundIdentity;
63 friend class SharedKeyIdentity;
76 static std::shared_ptr<OfflinePlaygroundIdentity>
93 static std::shared_ptr<OfflinePlaygroundIdentity> DITTO_DEPRECATED_BECAUSE(
94 "Use the OfflinePlayground() function that does not specify a `site_id` "
95 "instead. Use `peer_key` to uniquely identify a peer")
109 static std::shared_ptr<OnlineWithAuthenticationIdentity>
112 bool enable_ditto_cloud_sync = true,
113 std::
string custom_auth_url =
"");
128 static std::shared_ptr<OnlinePlaygroundIdentity>
130 bool enable_ditto_cloud_sync = true,
131 std::
string custom_auth_url =
"");
140 static std::shared_ptr<SharedKeyIdentity>
SharedKey(std::
string app_id,
141 std::
string shared_key);
157 static std::shared_ptr<SharedKeyIdentity> DITTO_DEPRECATED_BECAUSE(
158 "Use the SharedKey() function that does not specify a `site_id` "
159 "instead. Use `peer_key` to uniquely identify a peer")
160 SharedKey(std::
string app_id, std::
string shared_key, uint64_t site_id);
168 static std::shared_ptr<ManualIdentity>
Manual(std::
string certificate_config);
171 virtual std::
string get_app_id() const;
172 virtual
bool get_enable_ditto_cloud_sync() const;
173 virtual
bool requires_offline_license_token() const;
178 virtual CIdentityConfig_t *build_identity_config() = 0;
186class OfflinePlaygroundIdentity : public Identity {
187 friend class Identity;
195 DITTO_DEPRECATED_BECAUSE(
"Use `peer_key` instead to uniquely identify a peer")
199 OfflinePlaygroundIdentity(std::
string app_id);
206 DITTO_DEPRECATED_BECAUSE(
207 "Use the OfflinePlaygroundIdentity constructor that does not specify a "
208 "`site_id`. Use `peer_key` instead to uniquely identify a peer.")
209 OfflinePlaygroundIdentity(std::
string app_id, uint64_t
site_id);
212 std::
string get_app_id() const override;
213 bool requires_offline_license_token() const override;
214 CIdentityConfig_t *build_identity_config() override;
237class OnlineWithAuthenticationIdentity : public Identity {
239 friend class Identity;
256 OnlineWithAuthenticationIdentity(
257 std::string app_id, std::shared_ptr<AuthenticationCallback> callback,
261 std::shared_ptr<AuthenticationCallback> callback;
262 std::string get_app_id()
const override;
263 bool get_enable_ditto_cloud_sync()
const override;
264 bool requires_offline_license_token()
const override;
265 CIdentityConfig_t *build_identity_config()
override;
273class OnlinePlaygroundIdentity :
public Identity {
274 friend class Identity;
298 OnlinePlaygroundIdentity(std::string app_id, std::string
token,
303 std::string get_app_id()
const override;
304 std::string get_token()
const;
305 bool get_enable_ditto_cloud_sync()
const override;
306 bool requires_offline_license_token()
const override;
307 CIdentityConfig_t *build_identity_config()
override;
316class SharedKeyIdentity :
public Identity {
317 friend class Identity;
331 DITTO_DEPRECATED_BECAUSE(
332 "Use `peer_key` instead to uniquely identify a peer.")
336 SharedKeyIdentity(std::
string app_id, std::
string shared_key);
342 DITTO_DEPRECATED_BECAUSE(
343 "Use the @ref SharedKeyIdentity constructor that does not specify a "
344 "`site_id` instead. Use `peer_key` to uniquely identify a peer.")
345 SharedKeyIdentity(std::
string app_id, std::
string shared_key,
349 std::
string get_app_id() const override;
350 bool requires_offline_license_token() const override;
351 CIdentityConfig_t *build_identity_config() override;
358class ManualIdentity : public Identity {
359 friend class Identity;
370 bool requires_offline_license_token()
const override;
371 CIdentityConfig_t *build_identity_config()
override;
Provides feedback to the developer about Ditto authentication status.
Definition AuthenticationCallback.hpp:13
The various identity configurations that you can use when initializing a Ditto instance.
Definition Identity.hpp:57
static std::shared_ptr< ManualIdentity > Manual(std::string certificate_config)
Construct a new ManualIdentity.
static std::shared_ptr< OnlineWithAuthenticationIdentity > OnlineWithAuthentication(std::string app_id, std::shared_ptr< AuthenticationCallback > callback, bool enable_ditto_cloud_sync=true, std::string custom_auth_url="")
Construct a new OnlineWithAuthenticationIdentity.
static std::shared_ptr< OfflinePlaygroundIdentity > OfflinePlayground(std::string app_id="")
Construct a new OfflinePlaygroundIdentity.
static std::shared_ptr< SharedKeyIdentity > SharedKey(std::string app_id, std::string shared_key)
Construct a new SharedKeyIdentity.
static std::shared_ptr< OnlinePlaygroundIdentity > OnlinePlayground(std::string app_id, std::string token, bool enable_ditto_cloud_sync=true, std::string custom_auth_url="")
Construct a new OnlinePlaygroundIdentity.
A manually-provided certificate identity. This accepts a base64-encoded bundle.
Definition Identity.hpp:358
std::string certificate_config
Definition Identity.hpp:366
Develop peer-to-peer apps with no cloud connection. This mode offers no security and must only be use...
Definition Identity.hpp:186
uint64_t site_id
Definition Identity.hpp:196
Test a Ditto Cloud app with weak shared token authentication ("Playground mode"). This is not secure ...
Definition Identity.hpp:273
std::string custom_auth_url
Definition Identity.hpp:295
std::string token
Definition Identity.hpp:282
bool enable_ditto_cloud_sync
Definition Identity.hpp:288
Run Ditto in secure production mode, logging on to Ditto Cloud or on on-premises authentication serve...
Definition Identity.hpp:237
std::string custom_auth_url
Definition Identity.hpp:253
bool enable_ditto_cloud_sync
Definition Identity.hpp:246
A mode where any device is trusted provided they know the secret key. This is a simplistic authentica...
Definition Identity.hpp:316
std::string shared_key
Definition Identity.hpp:324
uint64_t site_id
Definition Identity.hpp:333
Namespace for the Ditto C++ SDK types and functions.
Definition AbstractDocumentPath.hpp:19
IdentityType
The different types of Identity that can be used with Ditto.
Definition Identity.hpp:21
std::string default_auth_url(std::string app_id)
Helper function to compute the default auth URL.