Java SDK

SDK 2.1.1 offline migration: configure trusted tenant public keys independently of cache files. No pins means no cached authorization. Persisted offline helpers use the configured client and re-verify the original signed token on every read. Offline setup and migration.

Device and usage operations in SDK 2.1.1: all clients can request key-only device removal using tenant slug, key and activation ID. HTTP 204 confirms removal; protected portals still require OTP/account customer flows. Usage reporting returns boolean confirmation, supports nested/empty metadata objects and normalizes quantities below 1 to 1. Java/C++ use tryMeter/try_meter for that boolean contract and retain legacy detailed meter results. Neither operation retries automatically or uses offline cache. See this SDK's README for signatures and failure handling.

Floating sessions in SDK 2.1.1: checkout and heartbeat return a failed session without credentials on network/HTTP/parse failure (RequestFailed). Business denial preserves its error code or uses FloatingDenied. Floating never uses offline cache. The new boolean TryCheckin equivalent confirms HTTP 204; legacy checkin is best effort. Method names follow this language's conventions. See the source README and SDK availability matrix before choosing a registry version.

Official SDKs

Java SDK

SDK 2.1.1 request settings

A slow or unavailable license server must not leave your application waiting indefinitely. All eight SDKs default to a 10-second timeout for each attempt and two additional attempts for safe requests. The usual backoff is 250 milliseconds, then 500 milliseconds. This is not a single 10-second deadline for the complete operation: activation also fetches a nonce.

  • License validation, nonce/public-key retrieval and floating heartbeat may retry a network failure or HTTP 5xx response. Set the retry count to zero to disable these retries; the range is 0–5.
  • Floating checkout, activation POST, usage reporting, device removal and checkin are sent once. A lost response can follow a successful server change, so retrying these blindly can duplicate work.
  • HTTP 3xx/4xx responses and malformed successful responses do not retry. SDK-owned transports do not follow redirects, so configure the final HTTPS API address directly.

For validate/activate, branch on the server's error code when available. Otherwise HttpError means an HTTP rejection, InvalidResponse means malformed successful license/nonce evidence and RequestFailed means the network/5xx attempts were exhausted without a usable signed cache. Rejection or malformed successful evidence never becomes cached authorization. A network outage can use only a separately trusted, unexpired proof.

SDKConfiguration
JavaThe extended constructor takes trusted keys, cache path, device ID, Duration.ofSeconds(10), then 2.

Timeout mechanisms follow each runtime: Python uses socket I/O timeouts; Unity delegates to its transport. Caller cancellation is separate from retry policy. Unity's default adapter disables redirects; WebGL needs Unity 2021.3 or later for that protection and fails closed on older versions. Portable .NET tests do not certify an Editor, IL2CPP or browser build. Verify your actual target before shipping.

Install SDK 2.1.1 using the SDK installation references and follow the offline migration guide when upgrading from 1.x.

Pure Java 11+. Uses Java's built-in HttpClient — no Apache HttpClient or OkHttp required. JSON handled by Jackson (pulled automatically by Maven).

Download Java SDK (ZIP)

Installation

The package for this release is dev.permitcore:permitcore-sdk:2.1.1. Add the dependency below to use Maven Central. To build from the optional source ZIP instead:

Terminal
cd SDKs/java
mvn install

Then add to your pom.xml:

pom.xml
<dependency>
  <groupId>dev.permitcore</groupId>
  <artifactId>permitcore-sdk</artifactId>
  <version>2.1.1</version>
</dependency>

Quick start

Java
import dev.permitcore.PermitClient;

PermitClient client = new PermitClient("https://api.permitcore.dev");

PermitClient.ValidateResult result = client.validate("PERMIT-XXXX-XXXX-XXXX-XXXX", null,
    "7f3e9a2b-1c4d-4e8f-9a6b-3d2c1e0f5a8b"); // expectedProductId — optional, reject a key issued for a different product
if (result.isValid) {
    System.out.println("License OK — product: " + result.productName + " (" + result.productId + ")");
    // Unlock features
    if (result.features != null && result.features.contains("export"))
        enableExportMenu();
    if (result.isTrial)
        showTrialBanner(result.trialDaysRemaining + " days remaining");
    if (result.isOffline)
        System.out.println("Running on a cached result — server was unreachable.");
} else if ("WrongProduct".equals(result.errorCode)) {
    showLicenseError("This key is for a different product: " + result.productId);
} else {
    showLicenseError(result.message);
}

validate() and activate() never throw for a network failure — they fall back to the local offline-grace cache automatically and, failing that, return isValid: false with isOffline: true. Only meter() throws PermitException.

Validate with version check

Java
PermitClient.ValidateResult result = client.validate("PERMIT-XXXX-XXXX-XXXX-XXXX", "2.3.1");
if (!result.isValid && result.minVersion != null)
    showError("Please upgrade to v" + result.minVersion + " or newer.");

Activation

Java
var req = new PermitClient.ActivateRequest(
    "PERMIT-XXXX-XXXX-XXXX-XXXX",
    "sha256-of-hardware-fingerprint",  // deviceId
    InetAddress.getLocalHost().getHostName(), // deviceName
    "2.3.1",                            // version
    "7f3e9a2b-1c4d-4e8f-9a6b-3d2c1e0f5a8b" // expectedProductId — optional, reject a key issued for a different product
);
PermitClient.ValidateResult result = client.activate(req);
if (result.isValid)
    saveActivationSuccess();
else if ("WrongProduct".equals(result.errorCode))
    showError("Wrong product: " + result.productId);

Metered billing

Java
// Single event
PermitClient.MeterResult m = client.meter("PERMIT-XXXX-XXXX-XXXX-XXXX", "export");

// Batch — 5 API calls at once
var req = new PermitClient.MeterRequest("PERMIT-XXXX-XXXX-XXXX-XXXX", "api_call", 5, null);
PermitClient.MeterResult m = client.meter(req);

ValidateResult field reference

FieldTypeDescription
isValidbooleantrue if the license is active and all checks pass
productNameStringName of the product this license belongs to
remainingActivationsIntegerHow many more activations are allowed (null = unlimited)
expiresAtOffsetDateTimeLicense expiry in UTC (null = perpetual)
messageStringHuman-readable status message
customFieldsMap<String, String>Arbitrary key/value metadata set by the vendor on this license
vendorWarningStringNon-null if the vendor's PermitCore subscription is lapsing — display a warning to your user
featuresList<String>Feature flags enabled on this license (e.g. ["export","api","premium"])
isTrialbooleantrue if this is a trial license
trialDaysRemainingIntegerDays remaining in the trial (0 when not a trial)
nodeLockedbooleantrue if this license uses HWID node-locking
offlineGraceDaysIntegerDays the software may run without reaching the server
minVersionStringMinimum allowed software version (semver), null if unrestricted
maxVersionStringMaximum allowed software version (semver), null if unrestricted
isOfflinebooleantrue when this result was served from the local offline-grace cache (server unreachable)
productIdStringStable ID of the product this license belongs to. Always present when a license was found, even without passing expectedProductId on the request.

Product scoping: by default, any active key belonging to your tenant validates/activates successfully regardless of which product it was issued for. If you sell more than one product, either check result.getProductId() yourself, or pass expectedProductId (a 5th ActivateRequest constructor arg, or a 3rd validate(licenseKey, version, expectedProductId) overload) and let the server reject a mismatch (result.getErrorCode().equals("WrongProduct")). Find a product's ID in the Admin panel under Products.

Offline grace period (built in)

When offlineGraceDays is set on the license, validate()/activate() cache every successful result to the OS temp directory (java.io.tmpdir). If a later call can't reach the server, the cached result is returned automatically — check isOffline to detect it. Disable with new PermitClient(baseUrl, false).

Error handling

validate() and activate() never throw for a network failure — they fall back to the cache and, failing that, return isValid: false with message: "Cannot reach license server." and isOffline: true. Only meter() throws PermitClient.PermitException (checked exception) on a network error, timeout, or HTTP 429 (rate limited) — usage events aren't cached, since replaying a stale count on reconnect could double-count.

Java
var result = client.validate(key);
if (result.isValid) {
    // proceed — result.isOffline tells you if this came from cache
} else {
    showLicenseDialog(result.message); // key expired, revoked, or unreachable
}

try {
    client.meter(key, "export");
} catch (PermitClient.PermitException e) {
    log.warn("Could not record usage event: " + e.getMessage());
}