Optimize the MigrateEncryptedInfo utility

MigrateEncryptedInfo is a utility used for re-encrypting sensitive data that is stored in the database. It executes two tasks within this utility and each of the tasks is controlled by a separate configuration file. The MigrateEncryptedInfo script is in the following directory:

When you open up the MigrateEncryptedInfo script, we can see that there are two calls to MKChangeApp. Each of these calls represents a distinct task that the script performs.

Task one

The first task enforces that the sensitive data in the database is consistent with the PDIEncrypt flag specified in the instance configuration file. If this task detects that the data and the PDIEncrypt flag are out of sync, it migrates the data to the current merchant key. By default, this task is commented out.

If the PDIEncrypt flag value is changed, it means we want to encrypt the data from plain text or decrypt the data to plain text. You can manually enable this part in the MigrateEncryptedInfo script. The default value of PDIEncrypt flag is on.

For example, if the data in the database is in plain text, but we want it to be encrypted, change the PDIEncrypt setting in the instance configuration file to "on". Then, enable this part in MigrateEncrytedInfo script and run this task. Once the PDIEncrypt flag is enabled, any subsequent data that is entered into the database is also encrypted. Alternatively, if the data in the database is encrypted, but we want it to be in plain text, change the PDIEncrypt setting in the instance configuration file to "off". Then, enable this part in MigrateEncryptedInfo script, and run this task to decrypt the existing data. Any subsequent data that is entered into the database is also decrypted.

LinuxThe following sections of the MigrateEncryptedInfo script need to be enabled:

This task is controlled by the following configuration file:

This configuration file contains one action item, called SyncCreditCardsEncryption, which provides an implementation class name to process the data and the database tables that it runs this action against. In the configuration file, we can see that by default it checks the following tables to see whether encryption or decryption is required:

Task two

The second task that is performed by the MigrateEncryptedInfo utility re-encrypts sensitive data in the database with the new merchant key. This task is controlled by the following configuration file:

When you examine this configuration file, it contains five action items:

Minimizing the running time of the MigrateEncryptedInfo utility by eliminating unnecessary actions

The MigrateEncryptedInfo utility reads database data first before it checks whether re-encryption needs to be performed against the retrieved data for each action. If you know ahead of time certain tasks do not apply to your site configuration, we can customize the script such that these tasks are not performed. Customizing the script saves some time in reading and processing the data. This is especially valuable if you have a large data set. The following sections describe situations where unnecessary actions can be removed from the utility script.

Note: Certain of these situations are not necessarily recommended (for example, we recommend the use of password history), but are included for completeness. LDAP is in use as the user repository

If your site uses LDAP as the user repository, the user's current and previous passwords are not kept in the USERREG and USERPWDHST tables. This means that the action items that re-encrypt the user's current and previous passwords become unnecessary. In this situation, the following action items can be removed from the configuration file of the second task, DBUpdate.txt:

Previous passwords (password history) are not stored in the database

If you do not configure your password policy to store the user's previous passwords, then we can disable the ReEncryptUserPasswordHistory action that processes the data in the
USERPWDHST table. Remove the following action item from the DBUpdate.txt configuration file:

The PDIEncrypt flag is set to "off"If credit card data is not encrypted or not stored in the WebSphere Commerce database, the highlighted action item that re-encrypts the data in PATTRVALUE, ORDPAYINFO and ORDPAYMTHD tables can be removed from the DBUpdate.txt configuration file.