Database Reference
In-Depth Information
Use Static Class Members to Retain APPVER Connection and Keys
We establish several static class members in Listing 10-42 to retain the appver connection and session-
specific keys. These keys, generated for the session for appver use, will continue to be required when the
application later attempts to decrypt connection strings in connsHash for application use. Those
connection strings were encrypted with the shared password key associated with the appver session.
Listing 10-42. Static Class Members to Retain Application Verification Decryption Keys
private static OracleConnection appVerConn = null;
private static byte[] appAuthSalt;
private static int appAuthIterationCount;
private static char[] appAuthDESPassPhraseChars;
private static AlgorithmParameterSpec appAuthParamSpec;
private static String appAuthSessionSecretDESAlgorithm;
private static SecretKey appAuthSessionSecretDESKey;
private static Cipher appAuthCipherDES;
You may want to refer to Chapter 3 where we discuss objects, static members, pointers, and
references. Because our primary encryption keys and all the artifacts and related members are static ,
we cannot just assign a new member name to refer to and retain them while we point the primary
references at a new instance. We need to set our new static members, those retaining the appver session
data, to a new value, referencing a different place in memory. Within the getAppConnections() method
in Listing 10-43, we set those retainer members to copies or clones of the current key artifacts. We create
new instances where that process is supported.
Listing 10-43. Set Static Class Members for Application Verification Keys
// Cant just set new pointers to existing members
// Since static, updates to one will update both
// Must instantiate, clone or copy values
appAuthSalt = salt.clone() ;
appAuthIterationCount =
( new Integer( iterationCount )).intValue();
appAuthDESPassPhraseChars =
sessionSecretDESPassPhraseChars .clone() ;
appAuthParamSpec = new PBEParameterSpec( appAuthSalt,
appAuthIterationCount );
KeySpec keySpec = new PBEKeySpec( appAuthDESPassPhraseChars,
appAuthSalt, appAuthIterationCount );
appAuthSessionSecretDESAlgorithm =
new String( sessionSecretDESAlgorithm );
appAuthSessionSecretDESKey = SecretKeyFactory. getInstance (
appAuthSessionSecretDESAlgorithm ).generateSecret( keySpec );
appAuthCipherDES = Cipher. getInstance (
appAuthSessionSecretDESKey.getAlgorithm() );
resetKeys() ;
At the end of our effort to retain those members for further use by appver in updating the connsHash
for this application, and for decrypting the connection strings in connsHash , we call the resetKeys()
method, which points all our primary keys and artifacts at null. We first saw resetKeys() in Chapter 7,
where we used it in testing. Here it is identical, with one exception. We do not set the existing
 
Search WWH ::




Custom Search