Class AuthletePropertiesConfiguration
- java.lang.Object
-
- com.authlete.common.conf.AuthletePropertiesConfiguration
-
- All Implemented Interfaces:
AuthleteConfiguration
public class AuthletePropertiesConfiguration extends Object implements AuthleteConfiguration
Implementation ofAuthleteConfiguration
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://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.encrypted
is 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.encrypted
is not found in the configuration file.
The value of
service_owner.api_secret.encrypted
can be generated usingopenssl
command 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.encrypted
can 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
AuthletePropertiesConfiguration
instance needs to be constructed as follows:String key = "a281ac2de1195e8c91ea383d38d05d1c"; String iv = "b6f5d0f0dd7146b0e3915ebd2dd078f3";
AuthleteConfiguration
conf = 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.
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_FILE
The default value of the name of the configuration file (authlete.properties
).static String
DEFAULT_IV
The default value of the initial vector to decode encrypted property values (b6f5d0f0dd7146b0e3915ebd2dd078f3
).static String
DEFAULT_KEY
The default value of the secret key to decode encrypted property values (a281ac2de1195e8c91ea383d38d05d1c
).static String
SYSTEM_PROPERTY_AUTHLETE_CONFIGURATION_FILE
The 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 String
getApiVersion()
Get the Authlete API version.String
getBaseUrl()
Get the base URL.String
getClientCertificate()
Get the certificate used for MTLS bound access tokens in PEM format.String
getDpopKey()
Get the public/private key pair used for DPoP signatures in JWK format.String
getServiceAccessToken()
Get the service API access tokenString
getServiceApiKey()
Get the service API key.String
getServiceApiSecret()
Get the service API secret.String
getServiceOwnerAccessToken()
Get the service owner API access tokenString
getServiceOwnerApiKey()
Get the service owner API key.String
getServiceOwnerApiSecret()
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)
wherefile
is eitherauthlete.properties
or the value of the system propertyauthlete.configuration.file
if 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
-key
isnull
iv
isnull
NumberFormatException
-key
is not a valid hex string.iv
is 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)
wherefile
is eitherauthlete.properties
or the value of the system propertyauthlete.configuration.file
if 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
-key
isnull
iv
isnull
-
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
-file
isnull
key
isnull
iv
isnull
NumberFormatException
-key
is not a valid hex string.iv
is 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
-file
isnull
.- Since:
- 1.24
-
AuthletePropertiesConfiguration
public AuthletePropertiesConfiguration()
Constructor with no argument.This constructor is an alias of
this
(file,
DEFAULT_KEY
,
DEFAULT_IV
)
wherefile
is eitherauthlete.properties
or the value of the system propertyauthlete.configuration.file
if 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
-file
isnull
key
isnull
iv
isnull
-
-
Method Detail
-
getApiVersion
public String getApiVersion()
Get the Authlete API version.- Specified by:
getApiVersion
in interfaceAuthleteConfiguration
-
getBaseUrl
public String getBaseUrl()
Get the base URL.- Specified by:
getBaseUrl
in interfaceAuthleteConfiguration
-
getServiceOwnerApiKey
public String getServiceOwnerApiKey()
Get the service owner API key.- Specified by:
getServiceOwnerApiKey
in interfaceAuthleteConfiguration
-
getServiceOwnerApiSecret
public String getServiceOwnerApiSecret()
Get the service owner API secret.- Specified by:
getServiceOwnerApiSecret
in interfaceAuthleteConfiguration
-
getServiceOwnerAccessToken
public String getServiceOwnerAccessToken()
Description copied from interface:AuthleteConfiguration
Get the service owner API access token- Specified by:
getServiceOwnerAccessToken
in interfaceAuthleteConfiguration
-
getServiceApiKey
public String getServiceApiKey()
Get the service API key.- Specified by:
getServiceApiKey
in interfaceAuthleteConfiguration
-
getServiceApiSecret
public String getServiceApiSecret()
Get the service API secret.- Specified by:
getServiceApiSecret
in interfaceAuthleteConfiguration
-
getServiceAccessToken
public String getServiceAccessToken()
Description copied from interface:AuthleteConfiguration
Get the service API access token- Specified by:
getServiceAccessToken
in interfaceAuthleteConfiguration
-
getDpopKey
public String getDpopKey()
Description copied from interface:AuthleteConfiguration
Get the public/private key pair used for DPoP signatures in JWK format.- Specified by:
getDpopKey
in interfaceAuthleteConfiguration
-
getClientCertificate
public String getClientCertificate()
Description copied from interface:AuthleteConfiguration
Get the certificate used for MTLS bound access tokens in PEM format.- Specified by:
getClientCertificate
in interfaceAuthleteConfiguration
-
-