Custom Encryption/Decryption Handler

RTView supports a Custom File Crypto Handler for encrypting and decrypting .rtv, .properties, and .ini files. The Custom File Crypto Handler class extends the functionality of RTView by allowing you to write Java code that is called when .rtv, .ini, and .properties files are read, and when .rtv and .ini files are written. RTView does not write .properties files so you are responsible for encrypting them in such a way that they can be decrypted by the Custom Crypto Handler.

To implement your own Java Custom File Crypto Handler, create a Java class named MyFileCryptoHandler.java that extends GmsCustomFileCryptoHandler. See docs/javadocs for more information on the GmsCustomFileCryptoHandler.
In MyFileCryptoHandler.java, define the following methods:

/**

* Check if a file should be handled by the custom encoder. This is

* called immediately before a call to <code>encryptString</code>

* or <code>decryptString</code>. If <code>true</code> is returned, then

* the custom handler will be used to invoke <code>encryptString</code>

* or <code>decryptString</code>.

* @param filename the name of the file to be checked

* @return true if the custom handler will handle this file

*/

 

public boolean isFileHandled (String filename)

 

/**

* Encrypt the string before it is saved to the specified filename. This is only called if

* isFileHandled returned true for the filename.

* @param filename the name of the file being saved

* @param stringToEncrypt the string value to encrypt. This will be the contents of the saved file.

* @return the encrypted string value

*/

 

public String encryptString (String filename, String stringToEncrypt)

 

/**

* Decrypt the string after it is read in from the specified filename before it is processed by

* RTView. This is only called if isFileHandled returned true for the filename.

* @param filename the name of the file being opened

* @param stringToDecrypt the string value to decrypt. This will be the contents of the file.

* @return the decrypted string value

*/

 

public String decryptString (String filename, String stringToDecrypt)

 

Every time a .rtv, .ini, or .properties file is read or written by RTView, the isFileHandled method will be called. If it returns true for the specified file, the encryptString (if the file is being saved) or decryptString (if the file is being written) will be called. Add the gmsjrtview.jar file, located in the lib directory (found in your installation directory) to your classpath when you compile your Custom File Crypto Handler. The compiled Custom File Crypto Handler class must be included in the RTView classpath by adding it to the definition for the RTV_USERPATH environment variable. To specify a different Custom File Crypto Handler class name, add the following to RTV_JAVAOPTS:

-Dcom.sl.rtview.customCryptoClassName=FullyQualifiedClassName.

A sample Custom File Crypto Handler that uses the javax.crypto.Crypto class is included in the RTView installation under custom\rtvfilecrypto. To build it, run make_demo (.bat or .sh). When you run from that directory, all .rtv and .ini files will be saved using the encryption defined in the MyFileCryptoHandler class and all .rtv, .ini, and .properties files will be decrypted using the same encryption. You can also encrypt and decrypt files in the command line using the encrypt_file (.bat or .sh) script.

To encrypt:

encrypt_file fileName

To decrypt, run

encrypt_file fileName -decrypt