Starting the Token Service Outside of the Loop
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 repeat the authentication request to the Key Manager and the database for every call to the constructor.
Here is a code sample showing how to do this:
static void Test (string[] dataToEncrypt, string dbTable, string naeUser, string naePswd, string dbUser, string dbPswd)
// naeUser = Key Manager user name
// naePswd = Key Manager password
// dbUser = database user name
// dbPswd = database password
TokenService ts = new TokenService (naeUser, naePswd, dbUser, dbPswd);
// string[] dataToEncrypt = an array of plaintext
// dbTable = Your Token Vault
for (int i=0; i < dataToEncrypt.Length; i++)
{
ts.insert(dataToEncrypt[i], dbTable, TokenService.LAST_FOUR_TOKEN, false);
}
ts.closeService();