Floating Server V2

LicenseSpring SDKs support both Floating Server v1 and v2. Here we demonstrate how to retrieve and register licenses on Floating Server v2.

In some SDKs you can reuse the same interface for handling licenses on Floating Server v1, with an additional function used for fetching all floating licenses tied to a single product. Each license has its own 64-bit integer license_id, called the server-side license ID in LicenseSpring SDKs.

Certificate and signature verification

Each Floating Server instance has its own private key used for signing response payloads, and you should have received a certificate chain tied to your instance.

To verify the certificate and to verify signatures returned by the Floating Server, you must enter the whole certificate chain into the SDK. You can do it by specifying an absolute or relative path to the chain PEM file, or input the whole chain as a string constant:

#include <LicenseSpring/ExtendedOptions.h>

options.setCertificateChainFromFile("chain.pem");
// or
options.setCertificateChain(R"(...cert...)");
circle-exclamation

Authentication and license registration

Registering and using a license requires users to be logged in to an account created on the Floating Server. The SDK manages token lifetime automatically.

#include <LicenseSpring/FloatingClient.h>
#include <LicenseSpring/ExtendedOptions.h>

// ...

LicenseSpring::ExtendedOptions options;
options.setCertificateChainFromFile("chain.pem");
// or
options.setCertificateChain(R"(...cert...)");
// and other options ...

auto config = LicenseSpring::Configuration::Create(/*...*/);
auto fc = LicenseSpring::FloatingClient::create(config);

// Authenticate the user if it is required
// You should first create the user on the Floating server itself
fc->authenticateUser("user", "pass");

// FloatingClient::getAllLicenses returns one LicenseID for each license tied to the configured product code
std::vector<LicenseSpring::LicenseID> licenseIds = fc->getAllLicenses();

// check if at least one license exists
if (licenseIds.empty())
    return 1;
    
for (const auto &licenseId : licenseIds)
{
    std::cout << "Server-side license ID: " << licenseId.serverId();
    // licenseId.key() will return the license key of the license
}
    
// register the first license, same as on Floating Server v1
auto licenseId = licenseId.front();
std::string username = "John";
auto license = fc->registerLicense(username, licenseId); 
triangle-exclamation

Was this helpful?