Class AuthletePropertiesConfiguration
- java.lang.Object
-
- com.authlete.common.conf.AuthletePropertiesConfiguration
-
- All Implemented Interfaces:
AuthleteConfiguration
public class AuthletePropertiesConfiguration extends Object implements AuthleteConfiguration
Implementation ofAuthleteConfigurationbased on a properties file.This is a utility class to load a configuration file that includes properties related to Authlete. Below is the list of configuration properties.
base_url-
The base URL of Authlete Web API. The default value is
"https://api.authlete.com".
service_owner.api_key-
The service owner API key issued by Authlete.
service_owner.api_secret.encrypted-
The service owner API secret issued by Authlete, encrypted by
"AES/CBC/PKCS5Padding"and encoded in Base64. The secret key and the initial vector of the encryption have to be passed to the constructor of this class.
service_owner.api_secret-
The service owner API secret issued by Authlete. The value
of this configuration property is referred to only when
service_owner.api_secret.encryptedis not found in the configuration file.
service.api_key-
The service API key issued by Authlete.
service.api_secret.encrypted-
The service API secret issued by Authlete, encrypted by
"AES/CBC/PKCS5Padding"and encoded in Base64. The secret key and the initial vector of the encryption have to be passed to the constructor of this class.
service.api_secret-
The service API secret issued by Authlete. The value of
of this configuration property is referred to only when
service.api_secret.encryptedis not found in the configuration file.
The value of
service_owner.api_secret.encryptedcan be generated usingopensslcommand like the following.echo -n "{Service-Owner-API-Secret}" | openssl aes-128-cbc -e -a \ -K "{Your-Secret-Key-in-Hex}" -iv "{Your-Initial-Vector-in-Hex}""{Service-Owner-API-Secret}" is the service owner API secret issued by Authlete. Values of "{Your-Secret-Key-in-Hex}" and "{Your-Initial-Vector-in-Hex}" are 32-letter hex strings which you can determine. The following is an example to generate a random 32-letter hex string.
ruby -e 'puts Random.new.bytes(16).unpack("H*")'Likewise, the value of
service.api_secret.encryptedcan be generated byopenssl, too.If you encrypt your service owner API secret and service API secret as shown below:
// Encrypt service owner API secret. $ echo -n "AF4Sms0cqs3HsTNlVrPbnWz5AXi3GtmMcveOklYKVCc" | openssl aes-128-cbc -e -a \ -K a281ac2de1195e8c91ea383d38d05d1c -iv b6f5d0f0dd7146b0e3915ebd2dd078f3 sKzcMU98a8xA5lwR23Crfkyu23klZnTuQlWApyllARpHFv84IItoZFZXj70OCrnF // Encrypt service API secret. $ echo -n "9La-ZhyyKK6sV6zsteNmcoTizHmC0NEVTFT9FUrIaYs" | openssl aes-128-cbc -e -a \ -K a281ac2de1195e8c91ea383d38d05d1c -iv b6f5d0f0dd7146b0e3915ebd2dd078f3 ERxV45wkpjJWXs+Mg9m6UyGHHGzBG5/2ytX0j0x3qNPuz5oWyciqkWjkBznLTWxb
The configuration file will look like the following.
base_url = https://evaluation-dot-authlete.appspot.com service_owner.api_key = etKXFbM0VumfC5j1XD6qGOk3yhHmsdqOILBFFIkDfmw service_owner.api_secret.encrypted = sKzcMU98a8xA5lwR23Crfkyu23klZnTuQlWApyllARpHFv84IItoZFZXj70OCrnF service.api_key = KNiA4bWqj2Ht0CJTqr4DTBgTIXeCskCHQ_vONBeth6M service.api_secret.encrypted = ERxV45wkpjJWXs+Mg9m6UyGHHGzBG5/2ytX0j0x3qNPuz5oWyciqkWjkBznLTWxb
And to load the configuration file, an
AuthletePropertiesConfigurationinstance needs to be constructed as follows:String key = "a281ac2de1195e8c91ea383d38d05d1c"; String iv = "b6f5d0f0dd7146b0e3915ebd2dd078f3";
AuthleteConfigurationconf = newAuthletePropertiesConfiguration(key, iv);Constructors without
fileparameter use"authlete.properties"as the name of the configuration file and search the file system and then the classpath for the file.
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_FILEThe default value of the name of the configuration file (authlete.properties).static StringDEFAULT_IVThe default value of the initial vector to decode encrypted property values (b6f5d0f0dd7146b0e3915ebd2dd078f3).static StringDEFAULT_KEYThe default value of the secret key to decode encrypted property values (a281ac2de1195e8c91ea383d38d05d1c).static StringSYSTEM_PROPERTY_AUTHLETE_CONFIGURATION_FILEThe system property key to specify the name of an Authlete configuration file (authlete.configuration.file).
-
Constructor Summary
Constructors Constructor Description AuthletePropertiesConfiguration()Constructor with no argument.AuthletePropertiesConfiguration(byte[] key, byte[] iv)Constructor with a pair of secret key and initial vector to decode encrypted property values.AuthletePropertiesConfiguration(String file)Constructor with a configuration file name.AuthletePropertiesConfiguration(String file, byte[] key, byte[] iv)Constructor with a configuration file name and a pair of secret key and initial vector to decode encrypted property values.AuthletePropertiesConfiguration(String key, String iv)Constructor with a pair of secret key and initial vector to decode encrypted property values.AuthletePropertiesConfiguration(String file, String key, String iv)Constructor with a configuration file name and a pair of secret key and initial vector to decode encrypted property values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetApiVersion()Get the Authlete API version.StringgetBaseUrl()Get the base URL.StringgetClientCertificate()Get the certificate used for MTLS bound access tokens in PEM format.StringgetDpopKey()Get the public/private key pair used for DPoP signatures in JWK format.StringgetServiceAccessToken()Get the service API access tokenStringgetServiceApiKey()Get the service API key.StringgetServiceApiSecret()Get the service API secret.StringgetServiceOwnerAccessToken()Get the service owner API access tokenStringgetServiceOwnerApiKey()Get the service owner API key.StringgetServiceOwnerApiSecret()Get the service owner API secret.
-
-
-
Field Detail
-
DEFAULT_KEY
public static final String DEFAULT_KEY
The default value of the secret key to decode encrypted property values (a281ac2de1195e8c91ea383d38d05d1c).- Since:
- 1.24
- See Also:
- Constant Field Values
-
DEFAULT_IV
public static final String DEFAULT_IV
The default value of the initial vector to decode encrypted property values (b6f5d0f0dd7146b0e3915ebd2dd078f3).- Since:
- 1.24
- See Also:
- Constant Field Values
-
DEFAULT_FILE
public static final String DEFAULT_FILE
The default value of the name of the configuration file (authlete.properties).- Since:
- 1.24
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_AUTHLETE_CONFIGURATION_FILE
public static final String SYSTEM_PROPERTY_AUTHLETE_CONFIGURATION_FILE
The system property key to specify the name of an Authlete configuration file (authlete.configuration.file). When this system property has a value, it is used as the name of the configuration file. Otherwise, the default file (authlete.properties) is used.- Since:
- 1.29
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AuthletePropertiesConfiguration
public AuthletePropertiesConfiguration(String key, String iv)
Constructor with a pair of secret key and initial vector to decode encrypted property values.This constructor is an alias of
this(file, key, iv)wherefileis eitherauthlete.propertiesor the value of the system propertyauthlete.configuration.fileif the value is not empty.- Parameters:
key- The secret key to decode encrypted property values in hex. For example,"9543837d590ef25312e7d156a435feda".iv- The initial vector to decode encrypted property values. For example,"e90ce45e6134d37e0aa2c3c870003639".- Throws:
IllegalArgumentException-keyisnullivisnull
NumberFormatException-keyis not a valid hex string.ivis not a valid hex string.
-
AuthletePropertiesConfiguration
public AuthletePropertiesConfiguration(byte[] key, byte[] iv)Constructor with a pair of secret key and initial vector to decode encrypted property values.This constructor is an alias of
this(file, key, iv)wherefileis eitherauthlete.propertiesor the value of the system propertyauthlete.configuration.fileif the value is not empty.- Parameters:
key- The secret key to decode encrypted property values.iv- The initial vector to decode encrypted property values.- Throws:
IllegalArgumentException-keyisnullivisnull
-
AuthletePropertiesConfiguration
public AuthletePropertiesConfiguration(String file, String key, String iv)
Constructor with a configuration file name and a pair of secret key and initial vector to decode encrypted property values.- Parameters:
file- The name of the configuration file. The file system and then the classpath are searched for the file.key- The secret key to decode encrypted property values in hex. For example,"9543837d590ef25312e7d156a435feda".iv- The initial vector to decode encrypted property values. For example,"e90ce45e6134d37e0aa2c3c870003639".- Throws:
IllegalArgumentException-fileisnullkeyisnullivisnull
NumberFormatException-keyis not a valid hex string.ivis not a valid hex string.
-
AuthletePropertiesConfiguration
public AuthletePropertiesConfiguration(String file)
Constructor with a configuration file name.This constructor is an alias of
this(file,DEFAULT_KEY,DEFAULT_IV).- Parameters:
file- The name of the configuration file. The file system and then the classpath are searched for the file.- Throws:
IllegalArgumentException-fileisnull.- Since:
- 1.24
-
AuthletePropertiesConfiguration
public AuthletePropertiesConfiguration()
Constructor with no argument.This constructor is an alias of
this(file,DEFAULT_KEY,DEFAULT_IV)wherefileis eitherauthlete.propertiesor the value of the system propertyauthlete.configuration.fileif the value is not empty.- Since:
- 1.24
-
AuthletePropertiesConfiguration
public AuthletePropertiesConfiguration(String file, byte[] key, byte[] iv)
Constructor with a configuration file name and a pair of secret key and initial vector to decode encrypted property values.- Parameters:
file- The name of the configuration file. The file system and then the classpath are searched for the file.key- The secret key to decode encrypted property values.iv- The initial vector to decode encrypted property values.- Throws:
IllegalArgumentException-fileisnullkeyisnullivisnull
-
-
Method Detail
-
getApiVersion
public String getApiVersion()
Get the Authlete API version.- Specified by:
getApiVersionin interfaceAuthleteConfiguration
-
getBaseUrl
public String getBaseUrl()
Get the base URL.- Specified by:
getBaseUrlin interfaceAuthleteConfiguration
-
getServiceOwnerApiKey
public String getServiceOwnerApiKey()
Get the service owner API key.- Specified by:
getServiceOwnerApiKeyin interfaceAuthleteConfiguration
-
getServiceOwnerApiSecret
public String getServiceOwnerApiSecret()
Get the service owner API secret.- Specified by:
getServiceOwnerApiSecretin interfaceAuthleteConfiguration
-
getServiceOwnerAccessToken
public String getServiceOwnerAccessToken()
Description copied from interface:AuthleteConfigurationGet the service owner API access token- Specified by:
getServiceOwnerAccessTokenin interfaceAuthleteConfiguration
-
getServiceApiKey
public String getServiceApiKey()
Get the service API key.- Specified by:
getServiceApiKeyin interfaceAuthleteConfiguration
-
getServiceApiSecret
public String getServiceApiSecret()
Get the service API secret.- Specified by:
getServiceApiSecretin interfaceAuthleteConfiguration
-
getServiceAccessToken
public String getServiceAccessToken()
Description copied from interface:AuthleteConfigurationGet the service API access token- Specified by:
getServiceAccessTokenin interfaceAuthleteConfiguration
-
getDpopKey
public String getDpopKey()
Description copied from interface:AuthleteConfigurationGet the public/private key pair used for DPoP signatures in JWK format.- Specified by:
getDpopKeyin interfaceAuthleteConfiguration
-
getClientCertificate
public String getClientCertificate()
Description copied from interface:AuthleteConfigurationGet the certificate used for MTLS bound access tokens in PEM format.- Specified by:
getClientCertificatein interfaceAuthleteConfiguration
-
-