Configuring Multiple Databases in REST APIs
To configure multiple databases for REST Webservices, a file, named Databases.json (located in the CATALINA_HOME/webapps/tmrest/WEB-INF/lib directory) is used. This file stores the mapping of token vaults and their respective databases. Based on the tablename passed in the API calls, the database node is selected and operation is performed on that database table. This feature is supported for MySQL database only.
Note
The multiple databases feature is not supported for the insertTokenBatchWithMultipleVault API.
For the following APIs, tablename parameter is not part of API requests so, to configure multiple databases feature, following optional parameters are added in the API request: dbHost ,dbPort, and dbName. If these parameters are configured, these values are given precedence over the values specified in the SafeNetToken.properties file.
createTokenFormat
createTokenFormatWithRegEx
createTokenFormatWithRandomTokenLength
createMaskingFormat
Note
If you have made any changes to the Databases.json file, you must restart the server.
Below is the sample of Databases.json file.
{
"Databases": [
{
"Host": "DatabaseHost1",
"Name": "DatabaseName1",
"Port": "3306",
"Vaults": ["TokenVault1","TokenVault2"]
},
{
"Host": "DatabaseHost2",
"Name": "DatabaseName2",
"Port": "3306",
"Vaults": ["TokenVault3","TokenVault4"]
}
]
}
Here, TokenVault1 and TokenVault2 are present in database "DatabaseHost1" whereas, TokenVault3 and TokenVault4 are present in database "DatabaseHost2". All these token vaults are independent.
Note
While configuring the Databases.json file, make sure that the token vaults are independent and must have unique names (one vault name should have only one occurrence in the Databases.json file).