10Duke Scale SDK for Java
Loading...
Searching...
No Matches
Configuring the 10Duke Scale SDK

The 10Duke Scale SDK for Java defines its configuration as an interface. This interface is called tenduke.scale.api.config.TendukeScaleConfig.

Schema

The following table explains the configuration schema, i.e. what can be configured. Table columns are:

  • Name: The name of the configuration entry as it appears in the Typesafe based out of the box implementation.
  • Purpose: Explains how this field is used and what its meaning is in the SDK.
  • Data type: What kind of data is expected?
Name Purpose Data type
token_path Directory path for storing license data. This configuration entry may be used by applications that do not have access to a database. Applications that have access to a database should consider storing license tokens in the database. Path
public_key_path Directory path for storing public keys. This configuration may be used by applications that do not have access to a database or cache. Applications using a database should consider storing public keys in a cache or in the database. Path
licensing_api_url Scheme and host name for the licensing API URL
licensing_api_authorization_model Method of authorization used for 10Duke Scale API calls. Omit this configuration entry for license key based licensing. enum: [id_token, scale_jwt]
idp_oidc_discovery_url Used to retrieve the details of the Open ID Connect endpoints for the identity provider URL
idp_oauth_authorization_url Endpoint for Authorization Request in Authorization Code or Implicit Grant flows (may be omitted if idp_oidc_discovery_url is present) URL
idp_oauth_device_code_url Endpoint for Device Authorization Request in Device Authorization Grant flow (may be omitted if idp_oidc_discovery_url is present, only required when Device Authorization Grant flow is being used) URL
idp_oauth_token_url Endpoint for Access Token Request or Device Access Token Request (may be omitted if idp_oidc_discovery_url is present) URL
idp_oauth_client_id Application credentials for OAuth/Open ID Connect String
idp_oauth_client_secret Application credentials for OAuth/Open ID Connect. Required for some OAuth flows or for some Identity Providers. String
idp_oauth_scope Scopes to include in the Access and ID tokens requested via Open ID Connect Array (space separated Strings), minimum: "openid", common: "openid profile email"
idp_userinfo_url Endpoint handling the UserInfo Request (may be omitted if idp_oidc_discovery_url is present) URL
token_refresh_leeway_seconds The number of seconds before expiry time that an ID Token or Scale JWT will be automatically refreshed (default: 30 seconds) float (seconds)
idp_jwks_uri URL path to read public key used to verify JWTs received from Authorization Server authenticating Open ID Connect session. URL
auth_redirect_path Path fragment for local redirect URL to use for PKCE Flow Client. This should be the path that the IDP will redirect to for successful authentication during the PKCE flow. Defaults to /login/callback (interpreted as http://localhost/login/callback for the localhost HTTP listener provided for use in desktop scenarios). If this not value is specified here, this default URL must be configured for the application at the IDP. Note This value is ignored if auth_redirect_uri is specified. URL
auth_redirect_port Local port number to list for PKCE Flow redirect. Defaults to a random port. int (tcp port number)
auth_redirect_uri Fully specified URI for redirect_uri in OAuth. This configuration entry is applicable for Java web applications and cases where the 10Duke SDK OAuth client is NOT responsible for the HTTP server. int (tcp port number)
auth_success_message Java resource containing response content for successful login (see 10Duke Core PKCE Flow Client). Resource path
http_timeout_seconds Timeout for HTTP requests (default: 30.0 seconds). float (seconds)
https_proxy Proxy to use for HTTPS requests. URL

Typesafe based implementation

A Typesafe based implementation is provided via an optional dependency. See the installation article for details on how to link the tenduke-scale-sdk-config-typesafe artifact.

Use the class tenduke.scale.config.typesafe.TendukeScaleConfigLoader to bootstrap the configuration:

String configResourceName = ...;
TendukeScaleConfigLoader configLoader = new TendukeScaleConfigLoader();
config = configLoader.loadFrom(configResourceName);

In the resource pointed to by configResourceName, e.g. src/main/resources/tenduke.conf, configure the SDK accordingly if the application requires license key based licensing or identity based licensing.

Configuration example for license key based licensing:

{
token_path="./license-tokens",
public_key_path="./keys",
licensing_api_url="https://...lic-api.scale.10duke.com",
token_refresh_leeway_seconds=30.5,
http_timeout_seconds=15.0
}

A configuration example for identity based based licensing using PKCE flow:

{
token_path="./license-tokens",
public_key_path="./keys",
licensing_api_url="https://...lic-api.scale.10duke.com",
licensing_api_authorization_model="id_token",
idp_oidc_discovery_url="https://your.idp.base.url/.../.well-known/openid-configuration",
idp_oauth_client_id="my-app-client-id",
idp_oauth_client_secret="my-app-client-secret",
idp_oauth_scope="openid profile email",
idp_userinfo_url="https://your.idp.base.url/.../user/info",
token_refresh_leeway_seconds=120.0,
auth_redirect_path="/login/handle-redirect",
auth_redirect_port=8080,
auth_success_message="com/my/app/local_response_content",
http_timeout_seconds=15.0
}

See the example located in examples/cli-with-identity-based-licensing for an identity based licensing application configured to use the Typesafe based configuration implementation.

Programmatic configuration

For applications with an existing configuration implementation it may make more sense to provide a programmatic implementation of the tenduke.scale.api.config.TendukeScaleConfig interface. Such applications may benefit from using the class tenduke.scale.api.config.InMemoryTendukeScaleConfig, which provides a plain old Java object (POJO) implementation of the tenduke.scale.api.config.TendukeScaleConfig interface.

Configuration example for license key based licensing, using the tenduke.scale.api.config.InMemoryTendukeScaleConfig class:

InMemoryTendukeScaleConfig config = new InMemoryTendukeScaleConfig();
config.setHttpTimeoutSeconds(15.0F);
config.setLicensingApiUrl("https://...lic-api.scale.10duke.com");
config.setPublicKeyPath("./public-keys");
config.setTokenPath("./license-tokens");
config.setTokenRefreshLeewaySeconds(42.0F);

Configuration example for identity based licensing, using the InMemoryTendukeScaleConfig class:

InMemoryTendukeScaleConfig config = new InMemoryTendukeScaleConfig();
config.setHttpTimeoutSeconds(30.5F);
config.setIdpJwksUrl("https://your.idp.base.url/...jwks");
config.setIdpOauthAuthorizationUrl("https://your.idp.base.url/.../auth");
config.setIdpOauthClientId("my-app-client-id");
config.setIdpOauthScope("openid");
config.setIdpOauthTokenUrl("https://your.idp.base.url/.../token");
config.setIdpUserinfoUrl("https://your.idp.base.url/.../userinfo");
config.setAuthSuccessMessage("com/my/app/local_response_content");
config.setAuthRedirectPort(8080);
config.setAuthRedirectPath("/login/callback");
config.setAuthRedirectUri("http://localhost:32793/login/callback");
config.setLicensingApiAuthorizationModel("id_token");
config.setLicensingApiUrl("https://...lic-api.scale.10duke.com");
config.setPublicKeyPath("./public-keys");
config.setTokenPath("./license-tokens");
config.setTokenRefreshLeewaySeconds(42.0F);