10Duke Enterprise C++ Client
Loading...
Searching...
No Matches
tenduke::ee Namespace Reference

Detailed Description

Classes, functions and globals of 10Duke Enterprise C++ Client.

This namespace contains classes, functions and globals related to 10Duke Enterprise.

Namespaces

namespace  licensing
 Classes, functions and globals related to 10Duke Enterprise licensing.
 

Classes

class  AbstractClientFactory
 Class template for factories, which create 10Duke client. More...
 
class  APIRequest
 Generic base for API requests. More...
 
class  BrowserBasedClientFactory
 Factory, which creates 10Duke Enterprise client, which authenticates user by opening default OS browser. More...
 
class  CCGClientFactory
 Factory, which creates 10Duke Enterprise client, which authenticates user with OAuth Client Credentials Grant. More...
 
struct  ClientProperties
 Client properties. More...
 
struct  ClientState
 Client state. More...
 
class  DeserializeStateFromJSON
 Service for deserializing client state from JSON. More...
 
class  DeviceAuthenticationClientFactory
 
class  ROPGClientFactory
 Factory, which creates 10Duke Enterprise client, which authenticates user with OAuth Resource Owner Password Credentials Grant. More...
 
class  SerializeStateToJSON
 Serializes client state to JSON. More...
 
struct  TendukeClient
 The 10Duke Enterprise Client. More...
 

Functions

std::unique_ptr<::tenduke::ee::TendukeClientcreateClient (const ::tenduke::TendukeServices &services, const std::shared_ptr<::tenduke::ee::licensing::LicensingConfiguration > &licensingConfiguration, const std::shared_ptr< const ::tenduke::oauth::OAuthConfiguration > &oauthConfiguration, const std::shared_ptr< const ::tenduke::oidc::OIDCConfiguration > &oidcConfiguration, const std::shared_ptr<::tenduke::oidc::OIDCLogin > &oidcLogin, const ::tenduke::oidc::OIDCSessionConfiguration &oidcSessionConfiguration={}, const ::tenduke::ee::ClientState &initialState={})
 Factory function for creating tenduke::ee::TendukeClient.
 
std::unique_ptr<::tenduke::ee::TendukeClientcreateClient (const ::tenduke::TendukeServices &services, const std::shared_ptr<::tenduke::ee::licensing::LicensingConfiguration > &licensingConfiguration, const std::shared_ptr< const ::tenduke::oauth::OAuthConfiguration > &oauthConfiguration, const std::shared_ptr< const ::tenduke::oidc::OIDCConfiguration > &oidcConfiguration, const std::shared_ptr<::tenduke::oidc::OIDCSession > &oidcSession, const ::tenduke::ee::ClientState &initialState={})
 Factory function for creating tenduke::ee::TendukeClient.
 
std::unique_ptr<::tenduke::ee::TendukeClientcreateClientUsingAutodiscovery (const std::string &clientId, const ::tenduke::ee::ClientProperties &clientProperties, const std::string &serviceUrl, const ::tenduke::oidc::osbrowser::BrowserAuthenticationConfig &authenticationConfig, const std::string &initialStateAsJSON={}, const ::tenduke::ServiceConfiguration &serviceConfiguration=::tenduke::ServiceConfiguration())
 Creates client for 10Duke Enterprise, which authenticates user with default operating system browser.
 
std::vector< tenduke::ee::licensing::LeasedeserializeOfflineLicenseTokens (const std::string &serializedLeases)
 Deserializes off-line license tokens.
 
std::unique_ptr<::tenduke::ee::TendukeClientcreateClientForDeviceUsingAutodiscovery (const std::string &clientIdentifier, const ::tenduke::ee::ClientProperties &clientProperties, const std::string &serviceUrl, const ::tenduke::oidc::device::DeviceAuthenticationConfig &authenticationConfig, const std::string &initialStateAsJSON={}, const ::tenduke::ServiceConfiguration &serviceConfiguration=::tenduke::ServiceConfiguration())
 Creates client for 10Duke Enterprise, which authenticates user with OAuth Device Flow.
 
std::unique_ptr<::tenduke::ee::TendukeClientcreateClientForDevice (const std::string &clientIdentifier, const ::tenduke::ee::ClientProperties &clientProperties, const std::string &serviceUrl, const ::tenduke::oauth::OAuthBackendConfiguration &oauthBackendConfiguration, const ::tenduke::oidc::OIDCConfiguration &oidcConfiguration, const ::tenduke::oidc::device::DeviceAuthenticationConfig &authenticationConfig, const std::string &initialStateAsJSON="", const ::tenduke::ServiceConfiguration &serviceConfiguration=::tenduke::ServiceConfiguration())
 Creates client, which authenticates user with OAuth Device Flow.
 

Function Documentation

◆ createClient() [1/2]

std::unique_ptr<::tenduke::ee::TendukeClient > tenduke::ee::createClient ( const ::tenduke::TendukeServices services,
const std::shared_ptr<::tenduke::ee::licensing::LicensingConfiguration > &  licensingConfiguration,
const std::shared_ptr< const ::tenduke::oauth::OAuthConfiguration > &  oauthConfiguration,
const std::shared_ptr< const ::tenduke::oidc::OIDCConfiguration > &  oidcConfiguration,
const std::shared_ptr<::tenduke::oidc::OIDCLogin > &  oidcLogin,
const ::tenduke::oidc::OIDCSessionConfiguration oidcSessionConfiguration = {},
const ::tenduke::ee::ClientState initialState = {} 
)

Factory function for creating tenduke::ee::TendukeClient.

This function is used internally by e.g. tenduke::ee::createClientUsingAutodiscovery(), but can be used by application developers to create client with custom tenduke::oidc::OIDCLogin-service. One reason to do this is to make custom browser-integration, e.g. using embedded browser.

Parameters
services-
licensingConfiguration-
oauthConfiguration-
oidcConfiguration-
oidcLogin-
oidcSessionConfiguration-
initialState-
Returns
-

◆ createClient() [2/2]

std::unique_ptr<::tenduke::ee::TendukeClient > tenduke::ee::createClient ( const ::tenduke::TendukeServices services,
const std::shared_ptr<::tenduke::ee::licensing::LicensingConfiguration > &  licensingConfiguration,
const std::shared_ptr< const ::tenduke::oauth::OAuthConfiguration > &  oauthConfiguration,
const std::shared_ptr< const ::tenduke::oidc::OIDCConfiguration > &  oidcConfiguration,
const std::shared_ptr<::tenduke::oidc::OIDCSession > &  oidcSession,
const ::tenduke::ee::ClientState initialState = {} 
)

Factory function for creating tenduke::ee::TendukeClient.

Parameters
services-
licensingConfiguration-
oauthConfiguration-
oidcConfiguration-
initialState-
oidcSession-
Returns
-

◆ createClientForDevice()

std::unique_ptr<::tenduke::ee::TendukeClient > tenduke::ee::createClientForDevice ( const std::string &  clientIdentifier,
const ::tenduke::ee::ClientProperties clientProperties,
const std::string &  serviceUrl,
const ::tenduke::oauth::OAuthBackendConfiguration oauthBackendConfiguration,
const ::tenduke::oidc::OIDCConfiguration oidcConfiguration,
const ::tenduke::oidc::device::DeviceAuthenticationConfig authenticationConfig,
const std::string &  initialStateAsJSON = "",
const ::tenduke::ServiceConfiguration serviceConfiguration = ::tenduke::ServiceConfiguration() 
)

Creates client, which authenticates user with OAuth Device Flow.

The client is initialized using provided configuration.

See tenduke::ee::createClientForDeviceUsingAutodiscovery(const std::string &,const tenduke::ee::ClientProperties &,const std::string &,const tenduke::oidc::device::DeviceAuthenticationConfig &,const std::string &,const tenduke::ServiceConfiguration &) for more details.

Example:

// Service to parse the validation key into a PublicKey.
#include "crypto/LibcryptoRSAKeyFactory"
// The validation key as PEM:
const std::string = "...";
// Create the client:
"cpp-licensing-demo/0.0.0", // Identifies this client software
::ClientProperties::Builder()
.hardwareId("simulated-hw-id") // Hardware id
.build(),
"https://genco-dev.10duke.net", // URL of the deployment
"https://genco-dev.10duke.net/user/oauth20/authz", // Authorization endpoint URL
"https://genco-dev.10duke.net/user/oauth20/token", // Token endpoint URL
"https://genco-dev.10duke.net/user/oauth20/device-authz" // Device authentication endpoint URL
),
"https://genco-dev.10duke.net", // OIDC issuer
keyFactory.publicKeyFromPEM(KEY), // create the validation key from PEM
::tenduke::crypto::MessageDigest::Algorithm::SHA256, // algorithm
"https://genco-dev.10duke.net/user/info" // OIDC userinfo endpoint URL
),
::DeviceAuthenticationConfig(
"cpp-device-grant", // OAuth client-id, configured in the deployment
*callback // The callback
)
);
Libcrypto implementation of tenduke::crypto::RSAKeyFactory.
Definition LibcryptoRSAKeyFactory.h:16
std::unique_ptr< tenduke::crypto::PublicKey > publicKeyFromPEM(const std::string &publicKeyAsPEM) const override
Creates a tenduke::crypto::PublicKey from PEM.
Definition LibcryptoRSAKeyFactory.cpp:47
Container for OAuth-backend configuration.
Definition OAuthBackendConfiguration.h:17
OIDC-configuration.
Definition OIDCConfiguration.h:17
std::unique_ptr<::tenduke::ee::TendukeClient > createClientForDevice(const std::string &clientIdentifier, const ::tenduke::ee::ClientProperties &clientProperties, const std::string &serviceUrl, const ::tenduke::oauth::OAuthBackendConfiguration &oauthBackendConfiguration, const ::tenduke::oidc::OIDCConfiguration &oidcConfiguration, const ::tenduke::oidc::device::DeviceAuthenticationConfig &authenticationConfig, const std::string &initialStateAsJSON="", const ::tenduke::ServiceConfiguration &serviceConfiguration=::tenduke::ServiceConfiguration())
Creates client, which authenticates user with OAuth Device Flow.
Root for classes, functions and globals of 10Duke C++ Client.
Definition APIRequest.h:4
Parameters
clientIdentifieridentifies the client, used as User-Agent in HTTP-requests
clientPropertiesClient properties
serviceUrlURL of the deployment. Usually something like: https://your-company-name.10duke.com
oauthBackendConfigurationOAuth backend configuration (for user authentication)
oidcConfigurationOIDC configuration (for user authentication)
authenticationConfigConfiguration for device authentication.
initialStateAsJSONInitial client state as JSON. Optional.
serviceConfigurationConfiguration for the underlying services. Optional.
Returns
-

◆ createClientForDeviceUsingAutodiscovery()

std::unique_ptr<::tenduke::ee::TendukeClient > tenduke::ee::createClientForDeviceUsingAutodiscovery ( const std::string &  clientIdentifier,
const ::tenduke::ee::ClientProperties clientProperties,
const std::string &  serviceUrl,
const ::tenduke::oidc::device::DeviceAuthenticationConfig authenticationConfig,
const std::string &  initialStateAsJSON = {},
const ::tenduke::ServiceConfiguration serviceConfiguration = ::tenduke::ServiceConfiguration() 
)

Creates client for 10Duke Enterprise, which authenticates user with OAuth Device Flow.

The client is initialized using OIDC auto-discovery.

The client automatically performs login when the user needs to log in. The login is performed with OAuth Device Flow. In OAuth Device Flow the user is shown a URL and a code. The user uses any browser, which can be on different device, to navigate to the URL, log in and provide the code.

The application developer needs to register a callback (see tenduke::oidc::device::DeviceAuthenticationConfig for details), which is passed the details (URL and code). The application needs to display the details to the user. Once the user has successfully authenticated in the browser, the client continues and acknowledges the successful login.

Example use:

class OnDeviceAuthorizationResponseReceived : public ::tenduke::oauth::device::OAuthDeviceAuthorizationResponseReceived {
public:
void callback(const tenduke::oauth::device::DeviceAuthorizationResponse &response) override {
// display the details from response here
}
};
std::shared_ptr<::OnDeviceAuthorizationResponseReceived> callback(new ::OnDeviceAuthorizationResponseReceived());
"cpp-licensing-demo/0.0.0", // Identifies this client software
::ClientProperties::Builder()
.hardwareId("simulated-hw-id") // Hardware id
.build(),
"https://genco-dev.10duke.net", // URL of the deployment
::DeviceAuthenticationConfig(
"cpp-device-grant", // OAuth client-id, configured in the deployment
*callback
)
);
Device Authorization Response.
Definition DeviceAuthorizationResponse.h:18
A callback to denote that Device Authorization Response has been received.
Definition OAuthDeviceAuthorizationResponseReceived.h:21
std::unique_ptr<::tenduke::ee::TendukeClient > createClientForDeviceUsingAutodiscovery(const std::string &clientIdentifier, const ::tenduke::ee::ClientProperties &clientProperties, const std::string &serviceUrl, const ::tenduke::oidc::device::DeviceAuthenticationConfig &authenticationConfig, const std::string &initialStateAsJSON={}, const ::tenduke::ServiceConfiguration &serviceConfiguration=::tenduke::ServiceConfiguration())
Creates client for 10Duke Enterprise, which authenticates user with OAuth Device Flow.

See also tenduke::ee::createClientUsingAutodiscovery.

Parameters
clientIdentifierIdentifier of the client. Used mainly as HTTP user-agent. This value is very useful when analysing or troubleshooting activity from access logs. We recommend that value is relatively short and contains short application identifier, version and platform identifier. Use "HTTP-friendly"-characters, e.g. [0-9A-Z a-z .-_~/]. Example: the-app/1.0.0/win11
clientPropertiesProperties of the client.
serviceUrlURL of the deployment. Usually something like: https://genco.10duke.com
authenticationConfigConfiguration for device authentication. See the tenduke::oidc::device::DeviceAuthenticationConfig for details.
initialStateAsJSONPreviously stored state, if any. Once the user has successfully logged in, the state can be persisted so that the user does not have to authenticate every time the application is started. If there is no previous state, pass empty string, which forces the user to authenticate on first licensing request. See TendukeClient.serializeState().
serviceConfigurationConfiguration for the underlying services. Optional.
Returns
the client

◆ createClientUsingAutodiscovery()

std::unique_ptr<::tenduke::ee::TendukeClient > tenduke::ee::createClientUsingAutodiscovery ( const std::string &  clientId,
const ::tenduke::ee::ClientProperties clientProperties,
const std::string &  serviceUrl,
const ::tenduke::oidc::osbrowser::BrowserAuthenticationConfig authenticationConfig,
const std::string &  initialStateAsJSON = {},
const ::tenduke::ServiceConfiguration serviceConfiguration = ::tenduke::ServiceConfiguration() 
)

Creates client for 10Duke Enterprise, which authenticates user with default operating system browser.

This factory-function creates client, which automatically opens browser when the user needs to log in. The browser is the default browser provided by operating system.

This factory function performs OIDC/OAuth configuration by reading OIDC discovery document via HTTP request, which simplifies the configuration.

Example use with typical set of parameters (for complete example, see example identity_based_client.cpp):

"cpp-licensing-demo/0.0.0", // Identifies this client software
.hardwareId("simulated-hardware-id") // Identifies this hardware for licensing
.build(),
"https://genco-dev.10duke.net", // URL of the deployment
::BrowserAuthenticationConfig(
"cpp-loopback-redirect", // OAuth client-id, configured in the deployment
"http://localhost/oidc/callback", // OAuth redirect-uri, configured in the deployment
demo::HTTP_MESSAGE_WHEN_LOGIN_SUCCEEDS // HTTP response to show after successful login
),
"" // Initial state (but none provided)
);
Builds the configuration fluently.
Definition ClientProperties.h:105
std::unique_ptr<::tenduke::ee::TendukeClient > createClientUsingAutodiscovery(const std::string &clientId, const ::tenduke::ee::ClientProperties &clientProperties, const std::string &serviceUrl, const ::tenduke::oidc::osbrowser::BrowserAuthenticationConfig &authenticationConfig, const std::string &initialStateAsJSON={}, const ::tenduke::ServiceConfiguration &serviceConfiguration=::tenduke::ServiceConfiguration())
Creates client for 10Duke Enterprise, which authenticates user with default operating system browser.

You can register a listener, which gets notified on OIDC-session events, e.g. when login is starting or complete. Create a class, which inherits from tenduke::oidc::DefaultOIDCSessionEventListener and provide a reference to the instance of the listener to the authenticationConfig parameter. Example:

class CustomListener : public ::tenduke::oidc::DefaultOIDCSessionEventListener {
// Implementation here
}
// Later in code:
auto listener = std::make_shared<CustomListener>();
"cpp-licensing-demo/0.0.0",
.hardwareId("simulated-hardware-id") // Identifies this hardware for licensing
.build(),
"https://genco-dev.10duke.net",
::BrowserAuthenticationConfig(
"cpp-loopback-redirect",
"http://localhost/oidc/callback",
demo::HTTP_MESSAGE_WHEN_LOGIN_SUCCEEDS,
::tenduke::oidc::OIDCSessionConfiguration::Builder() // Fluent OIDCSessionConfiguration
.listenEventsWith(listener) // Register the listener here
.build()
)
);
Default implementation of tenduke::oidc::OIDCSessionEventListener.
Definition DefaultOIDCSessionEventListener.h:14
Builder for the configuration.
Definition OIDCSessionConfiguration.h:53
Parameters
clientIdIdentifier of the client. Used mainly as HTTP user-agent. This value is very useful when analysing or troubleshooting activity from access logs. We recommend that value is relatively short and contains short application identifier, version and platform identifier. Use "HTTP-friendly"-characters, e.g. [0-9A-Z a-z .-_~/]. Example: the-app/1.0.0/win11
clientPropertiesProperties of the client.
serviceUrlURL of the deployment. Usually something like: https://genco.10duke.com
authenticationConfigConfiguration for browser-based authentication. See the tenduke::oidc::osbrowser::BrowserAuthenticationConfig for details.
initialStateAsJSONPreviously stored state, if any. Once the user has successfully logged in, the state can be persisted so that the user does not have to execute every time the application is started. If there is no previous state, pass empty string, which forces the user to execute on first licensing request. See TendukeClient.serializeState().
serviceConfigurationConfiguration for the underlying services. Optional.
Returns
the client

◆ deserializeOfflineLicenseTokens()

std::vector<::Lease > tenduke::ee::deserializeOfflineLicenseTokens ( const std::string &  serializedLeases)

Deserializes off-line license tokens.

This de-serializes license tokens earlier serialized by LicenseTokens::serialize (e.g. TendukeClient::licenseTokens::serialize()). Serialized licenses are usually used to store the leases for offline use.

This function does not need any network connection.

Parameters
serializedLeases-
Returns
-