public class AuthletePropertiesConfiguration extends Object implements AuthleteConfiguration
AuthleteConfiguration based 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://authlete.appspot.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.encrypted can be
generated using openssl command like the following.
echo -n "{Sevice-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.encrypted can be
generated by openssl, too.
If you encrypt your service owner API secret and serivce 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 AuthletePropertiesConfiguration
instance needs to be constructed as follows:
String key = "a281ac2de1195e8c91ea383d38d05d1c"; String iv = "b6f5d0f0dd7146b0e3915ebd2dd078f3";AuthleteConfigurationconf = newAuthletePropertiesConfiguration(key, iv);
Constructors without file parameter use "authlete.properties"
as the name of the configuration file and search the file system and then
the classpath for the file.
| Constructor and Description |
|---|
AuthletePropertiesConfiguration(byte[] key,
byte[] iv)
Constructor.
|
AuthletePropertiesConfiguration(String file,
byte[] key,
byte[] iv)
Constructor.
|
AuthletePropertiesConfiguration(String key,
String iv)
Constructor.
|
AuthletePropertiesConfiguration(String file,
String key,
String iv)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getBaseUrl()
Get the base URL.
|
String |
getServiceApiKey()
Get the service API key.
|
String |
getServiceApiSecret()
Get the service API secret.
|
String |
getServiceOwnerApiKey()
Get the service owner API key.
|
String |
getServiceOwnerApiSecret()
Get the service owner API secret.
|
public AuthletePropertiesConfiguration(String key, String iv)
This constructor is an alias of this("authlete.properties", key, iv).
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".IllegalArgumentException - file is null
key is null
iv is null
NumberFormatException - key is not a valid hex string.
iv is not a valid hex string.
public AuthletePropertiesConfiguration(byte[] key,
byte[] iv)
This constructor is an alias of this("authlete.properties", key, iv).
key - The secret key to decode encrypted property values.iv - The initial vector to decode encrypted property values.IllegalArgumentException - key is null
iv is null
public AuthletePropertiesConfiguration(String file, String key, String iv)
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".IllegalArgumentException - file is null
key is null
iv is null
NumberFormatException - key is not a valid hex string.
iv is not a valid hex string.
public AuthletePropertiesConfiguration(String file, byte[] key, byte[] iv)
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.IllegalArgumentException - file is null
key is null
iv is null
public String getBaseUrl()
getBaseUrl in interface AuthleteConfigurationpublic String getServiceOwnerApiKey()
getServiceOwnerApiKey in interface AuthleteConfigurationpublic String getServiceOwnerApiSecret()
getServiceOwnerApiSecret in interface AuthleteConfigurationpublic String getServiceApiKey()
getServiceApiKey in interface AuthleteConfigurationpublic String getServiceApiSecret()
getServiceApiSecret in interface AuthleteConfigurationCopyright © 2015. All rights reserved.