Skip to content

configuration lib

Marten Rebane edited this page Jan 21, 2020 · 1 revision

Central configuration for RIA DigiDoc

Fetch and package default configuration

To fetch and package default configuration, run command:

gradle clean fetchAndPackageDefaultConfiguration app:assemble

The default configuration setup is: Configuration downloaded from: https://id.eesti.ee/ Configuration update interval: 7 (days)

The central configuration options can be overridden with command (replace --args with custom values):

gradle clean fetchAndPackageDefaultConfiguration --args='https://example.com 5' app:assemble

The first argument (URL) is where the configuration is downloaded from. The second argument is interval, where every given number of days, the configuration is updated.

  • The URL argument must contain only the base URL. For example if the specified URL is https://id.eesti.ee/, then the configuration will be downloaded from https://id.eesti.ee/config.json (public key from /config.pub and signature from /config.rsa)

The build will be stopped if configuration validation fails.

Configuration

Get configuration

CachedConfigurationHandler cachedConfHandler = new CachedConfigurationHandler(getCacheDir());

ConfigurationProperties confProperties = new ConfigurationProperties(getAssets());

ConfigurationManager confManager = new ConfigurationManager(this, confProperties, cachedConfHandler, UserAgentUtil.getUserAgent(getApplicationContext()));

confManager.getConfiguration();

Force load default configuration

CachedConfigurationHandler cachedConfHandler = new CachedConfigurationHandler(getCacheDir());

ConfigurationProperties confProperties = new ConfigurationProperties(getAssets());

ConfigurationManager confManager = new ConfigurationManager(this, confProperties, cachedConfHandler, UserAgentUtil.getUserAgent(getApplicationContext()));

confManager.forceLoadDefaultConfiguration();

Force load central configuration

CachedConfigurationHandler cachedConfHandler = new CachedConfigurationHandler(getCacheDir());

ConfigurationProperties confProperties = new ConfigurationProperties(getAssets());

ConfigurationManager confManager = new ConfigurationManager(this, confProperties, cachedConfHandler, UserAgentUtil.getUserAgent(getApplicationContext()));

confManager.forceLoadDefaultConfiguration();

Configuration properties

File: configuration.properties

Get configuration version serial

ConfigurationProperties confProperties = new ConfigurationProperties(getAssets());

confProperties.getConfigurationVersionSerial();

Cached configuration handler

Used to cache and get configuration data

Check if cached configuration exists

CachedConfigurationHandler cachedConfigurationHandler = new CachedConfigurationHandler(getCacheDir());

cachedConfHandler.doesCachedConfigurationExist(); // true or false

Get cached configuration version serial

CachedConfigurationHandler cachedConfigurationHandler = new CachedConfigurationHandler(getCacheDir());

cachedConfHandler.getConfigurationVersionSerial();

Get cached configuration last update check date

CachedConfigurationHandler cachedConfigurationHandler = new CachedConfigurationHandler(getCacheDir());

cachedConfHandler.getConfLastUpdateCheckDate();

Get cached configuration update date

CachedConfigurationHandler cachedConfigurationHandler = new CachedConfigurationHandler(getCacheDir());

cachedConfHandler.getConfUpdateDate();