TokenService()
TokenService() constructs a TokenService object and starts the Token Service.
TokenService() supports tokenization yielding Unicode (multi-byte character) tokens, and local encryption with symmetric key caching.
This method is overloaded, as follows:
The first entry below supports local encryption with symmetric key caching only, when that functionality is appropriately configured using CADP JCE.
The second entry below is used to specify the path of the IngrianNAE.property file to be used other than the one in
/jre/lib/ext.
Note
If the specified location of the additional IngrianNAE.properties file is invalid, then the default IngrianNAE.properties file (in
Tip
The caching features can improve performance significantly, especially when network latency is high, encryption sizes are small, and local CPU cycles are available. Both require proper configuration and set up using the CADP JCE Provider. Once the keys are cached, your client's crypto operations can continue without access to the server. To configure a caching feature, refer to the information and corresponding instructions provided in the CADP JCE.
Syntax
public TokenService(String naeUser, char[] naePswd, String dbUser, char[] dbPswd) throws TokenException
public TokenService(String naeUser, char[] naePswd, String dbUser, char[] dbPswd, String naePropertyFile) throws TokenException
public TokenService(String naeUser, char[] naePswd, String dbUser, char[] dbPswd, char[] keyStorePassPhrase)
public TokenService(String naeUser, char[] naePswd, String dbUser, char[] dbPswd, char[] keyStorePassPhrase, String naePropertyFile)
Note
The last two TokenService methods are deprecated.
TokenService Constructor with Database Properties
A new constructor is added to TokenService class which accepts DBProperty instance to configure the database. The DBProperty contains database properties such as dbHost, dbPort, and dbName.
TokenService(String naeUser, char[] naePswd, String dbUser, char[] dbPswd, DBProperty dbProperty);
To create the DBProperty instance, use this code snippet:
DBProperty dbProperty = new DBPropertyBuilder("hostName", "port", "databaseName").build();
Note
The database properties specified in this constructor will override the database properties specified in the SafeNetToken.properties file and these properties are supported for MySQL database only.
Request Parameters
Parameters | Data Types | Descriptions |
---|---|---|
naeUser | string | A Key Manager user with access to the AES and HMAC keys. |
naePswd | char[] | A Key Manager user’s password. |
dbUser | string | A database user with access to the token table. Note: The dbUser can also be an AD user. It is applicable for MSSQL. |
dbPswd | char[] | A database user’s password. Note: Use the AD user password, if an AD user is used for the connection. |
naePropertyFile | string | The absolute path of the IngrianNAE.properties file. |
dbProperty | The instance of DBProperty containing database properties such as hostName, port, and databaseName. |
Exception
Throws Exception
if:
Any parameters are missing.
The Token Vault information is missing from the SafeNetToken.properties file.
Example
String naeUser = "KeyManagerUserName";
char[] naePswd = "passwordA".toCharArray();
String dbUser = "DBUserName";
char[] dbPswd = "passwordB".toCharArray();
String naeFile = “.\\IngrianNAE.properties”;
TokenService ts = new TokenService(naeUser, naePswd, dbUser, dbPswd);
or
TokenService ts = new TokenService(naeUser, naePswd, dbUser, dbPswd, naeFile);
Tip
If your application, calls insert(), get(), deleteToken(), or deleteValue() within a loop, make sure that it starts the token service outside of the loop. Otherwise, the application will read the properties files, and authenticate to the Key Manager and the database for every call to the constructor.
!yaml
String naeUser = "KeyManagerUserName"; char[] naePswd = "passwordA".toCharArray(); String dbUser = "DBUserName"; char[] dbPswd = "passwordB".toCharArray(); TokenService ts = new TokenService(naeUser, naePswd, dbUser, dbPswd); String[] data = //an array of plaintext; String tableName = "YOURTOKENVAULT"; for (int i=0; i < dataLength(); i++) { ts.insert(data[i], tableName, TokenService.LAST_FOUR_TOKEN, false); } ts.closeService();
Example to configure database while creating TokenService instance
String tableName = "YOURTOKENVAULT";
DBProperty dbProperty=new DBPropertyBuilder("10.164.xx.xx","3306","tm_test").build();
TokenService ts = new TokenService("naeUser","naePswd".toCharArray(),"dbUser","dbPswd".toCharArray(),dbProperty);
ts.insert("67988226565", tableName, TokenService.LAST_FOUR_TOKEN, false);
ts.closeService();