Ditto  1.0.8
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
ditto::Identity Struct Reference

The various identity configurations that you can use when initializing a Ditto instance. More...

Classes

struct  DevelopmentIdentity
 An identity to be used while in development when you want to control either or both of the app name and the site ID of the peer. More...
 
struct  ProductionIdentity
 The identity to use when in production. This accepts a certificate bundle, which includes identity information, as a base64-encoded string. More...
 
struct  SharedKeyIdentity
 An identity where every device knows the same secret key. This is a simplistic authentication mode which is normally only suitable for private apps where all the users and devices are trusted. More...
 

Public Types

enum  { DEVELOPMENT, SHAREDKEY, PRODUCTION }
 

Public Member Functions

 Identity (std::string app_name="", uint64_t site_id=0, std::string persistence_dir="")
 Construct a new DevelopmentIdentity. More...
 
 Identity (std::string app_name, std::string shared_key, uint64_t site_id=0, std::string persistence_dir="")
 Construct a new SharedKeyIdentity. More...
 
 Identity (std::string certificate_config)
 Construct a new ProductionIdentity. More...
 
 Identity (Identity const &other)
 

Public Attributes

std::shared_ptr< CAuthClient_t > auth_client
 
enum ditto::Identity:: { ... }  type
 
union {
   struct DevelopmentIdentity   dev
 
   struct SharedKeyIdentity   shared_key
 
   struct ProductionIdentity   prod
 
}; 
 

Detailed Description

The various identity configurations that you can use when initializing a Ditto instance.

The different supported identities are as follows:

Constructor & Destructor Documentation

◆ Identity() [1/3]

ditto::Identity::Identity ( std::string  app_name = "",
uint64_t  site_id = 0,
std::string  persistence_dir = "" 
)
explicit

Construct a new DevelopmentIdentity.

Parameters
app_namethe name of the app. Use this to ensure that connections between devices are only established if they share the same app name.
site_idthe site ID for the device. Use this to identity different users or devices. Site IDs are persisted between sessions when using a development identity. Site IDs should be unique and not reused by different users or devices.
[in]persistence_dirthe directory to be used to cache identity-related data.

◆ Identity() [2/3]

ditto::Identity::Identity ( std::string  app_name,
std::string  shared_key,
uint64_t  site_id = 0,
std::string  persistence_dir = "" 
)
explicit

Construct a new SharedKeyIdentity.

Parameters
[in]app_namethe name of the app, specified in domain format, e.g. "app.ditto.live". All peers must use the same app name to communicate.
[in]shared_keya base64-encoded DER private key. Refer to Ditto documentation for details about generating shared keys.
[in]site_idthe site ID for the device. For shared key mode, this can be left unspecified to choose a random number.
[in]persistence_dirthe directory to be used to cache identity-related data.

◆ Identity() [3/3]

ditto::Identity::Identity ( std::string  certificate_config)
explicit

Construct a new ProductionIdentity.

Parameters
configa base64-encoded string representation of a certificate bundle.