Database Reference
In-Depth Information
Listing 7-7. Method to Call to Build Secret Password Key, makeDESKey()
public static final void makeDESKey(
RAW cryptSecretDESPassPhrase, RAW cryptSecretDESAlgorithm,
RAW cryptSecretDESSalt, RAW cryptSecretDESIterationCount )
{
try {
decryptSessionSecretDESPassPhrase( cryptSecretDESPassPhrase,
cryptSecretDESAlgorithm, cryptSecretDESSalt,
cryptSecretDESIterationCount );
makeSessionSecretDESKey();
} catch( Exception x ) {
x.printStackTrace();
}
}
Within the try block is most of the body of our previous getDecryptData() method, sans the call to
actually decrypt data. This provides us an opportunity to do some refactoring, improving the design of
our code. Because our new method does most of what we did in getDecryptData() , let's rewrite
getDecryptData() to call the new method, as in Listing 7-8.
Listing 7-8. Decrypt Data with the Secret Password Key, getDecryptData()
public static final String getDecryptData( RAW cryptData,
RAW cryptSecretDESPassPhrase, RAW cryptSecretDESAlgorithm,
RAW cryptSecretDESSalt, RAW cryptSecretDESIterationCount )
{
String rtrnString = "getDecryptData() A failed";
try {
if( ( null == sessionSecretDESKey ) || testAsClientAndServer ) {
makeDESKey ( cryptSecretDESPassPhrase, cryptSecretDESAlgorithm,
cryptSecretDESSalt, cryptSecretDESIterationCount );
}
rtrnString = getDecryptData( cryptData );
} catch( Exception x ) {
x.printStackTrace();
}
return rtrnString;
}
The bold text, our call to makeDESKey() , is where we previously had the code that we have moved
into the body of makeDESKey() .
Temporary Method to Reset All Keys
The second method we are adding to OracleJavaSecure is resetKeys() . The resetKeys() method is only
for testing in this chapter (however, we will resurrect it in Chapter 10). Later we will describe several test
scenarios, one of which will emulate starting a new connection/session on the client (by running this
method) and trying to use existing keys on Oracle database. This scenario will fail, but we will do the test
just to demonstrate that scenario.
 
Search WWH ::




Custom Search