Skip to content
LICENTIVO / INTEGRATION

Ruby software licensing SDK: activation and protected business blocks

Install the Ruby gem, activate or restore a customer license and protect a real export with a Ruby block. The native core verifies grants, device credentials and policy heartbeats.

Ruby 3.1+Updated

1. Prepare the product and license

Start with a node-locked license and an ordinary export feature. Add metered usage only after the basic authorization flow works.

Device quota counts current activations and is returned on release. Ordinary licenses remain counted while offline; floating licenses also return quota when their leases expire.

  1. Copy the Product ID from Console > Products. Open that product’s Signing public keys and paste every key ID/public key pair into the initialization code, replacing YOUR_PRODUCT_ID, YOUR_KEY_ID and YOUR_PUBLIC_KEY. Quick integration can generate these public code constants. No product configuration file is required; the SDK defaults to https://www.licentivo.com.
  2. In Quick integration, create or select a product. Enable a feature named export in its policy and prepare a test license.

2. Install the SDK

Run the command below in your application project, or add the build dependency, to install SDK 0.11.6. The package manager retrieves the SDK; no source ZIP, manual extraction or local source path is required.

Terminal
gem install licentivo-sdk --version 0.11.6

3. Protect a real export

Move SDK startup into your application’s startup or activation handler. Read the customer key from your activation form, pass your own product ID and trusted keys, and keep the client alive until shutdown. Put RunFeature at the actual business entry point; replace the report writer with your own operation.

Ruby 3.1+ · main.rb
# frozen_string_literal: true
require 'licentivo'

# BEGIN LICENTIVO PRODUCT
# Copy Product ID and all key ID/public key pairs from Console > Products > Signing public keys.
PRODUCT_ID = 'YOUR_PRODUCT_ID'
TRUSTED_KEYS = {'YOUR_KEY_ID' => 'YOUR_PUBLIC_KEY'}.freeze
# END LICENTIVO PRODUCT

def setting(name, fallback)
  value = ENV[name]
  value.nil? || value.empty? ? fallback : value
end

def export_report(path)
  # Replace this write with your existing export operation.
  File.write(path, "A report generated by the licensed application.\n")
end

begin
  # A GUI supplies the activation input. Later starts use an empty key.
  Licentivo::Client.open_product(
    PRODUCT_ID, TRUSTED_KEYS,
    setting('LICENTIVO_LICENSE_KEY', '')
  ) do |client|
    feature = setting('LICENTIVO_FEATURE', 'export')
    path = setting('LICENTIVO_OUTPUT', 'licensed-report.txt')
    if setting('LICENTIVO_METERED', '0') == '1'
      client.run_metered_feature(feature, 1, setting('LICENTIVO_OPERATION_ID', '')) { export_report(path) }
    else
      client.run_feature(feature) { export_report(path) }
    end
    puts "License OK: #{feature} is available\nExport completed: #{path}"
  end # Real app: keep the owning block/client alive until shutdown.
rescue StandardError => error
  warn error.message
  exit 2
end

4. Keep the client alive until shutdown

This command-line example performs one operation and exits. In a desktop application, open one client at startup, invoke the feature callback from the export action, and close the client only when the application exits.

After activation, later starts can leave LICENTIVO_LICENSE_KEY empty and restore the private credential under the same user and cache location. Keep that credential in the user application-data directory. Closing stops heartbeats and returns floating seats; normal exit should not deactivate a node-locked device.

Offline access is available only when the policy permits it and the signed grant remains valid. An expired or denied feature must remain blocked. Metered operations require a network connection.

The open_with_license block owns the client. Keep the application loop inside its lifetime and invoke run_feature for each protected action. Do not close the client from inside a business callback. Ruby exceptions propagate after the SDK handles the failed operation.

5. Run and verify the result

Copy the Product ID from Console > Products. Open that product’s Signing public keys and paste every key ID/public key pair into the initialization code, replacing YOUR_PRODUCT_ID, YOUR_KEY_ID and YOUR_PUBLIC_KEY. Quick integration can generate these public code constants. No product configuration file is required; the SDK defaults to https://www.licentivo.com.

  1. Confirm that a valid license with export access creates licensed-report.txt.
  2. Clear LICENTIVO_LICENSE_KEY and run again using the same user account: the saved credential should restore.
  3. Set LICENTIVO_FEATURE to a feature absent from the license and LICENTIVO_OUTPUT to a fresh filename. The program must report a denial without creating that file.
  4. Test an offline restart only with a permitted, unexpired signed grant. Do not bypass a failed feature check after a background refresh error.
Windows · PowerShell
$env:LICENTIVO_LICENSE_KEY = 'YOUR_LICENSE_KEY'
ruby main.rb
Linux / macOS · Bash
LICENTIVO_LICENSE_KEY=YOUR_LICENSE_KEY ruby main.rb

Common integration problems

Check the product ID, every key ID/public key pair and the customer’s license input. Public verification keys belong to a product; customer licenses and saved device credentials are separate. Do not distribute development test keys or vendor management API keys.

Feature denied, device limit reached or license expired: inspect the license and policy in the console, then show the SDK error to the customer. A failed authorization must not call the export function.

RunFeature checks feature access; the metered variant reserves and settles configured usage. Use a stable operation ID per real business job and inspect its durable result before recovering an interrupted job.

Cannot load licentivo: check that gem installation and program execution use the same Ruby environment. For a source build on Windows, set LICENTIVO_CURL_ROOT and make the matching libcurl DLL available on PATH.