Database Reference
In-Depth Information
{
...
Set the Application Context
The body of test code resides in the main method. In this case, we are presuming that the client user will
call the application from the command line. After the first call, he will need to call it again, including the
two-factor authentication code on the command line.
See in Listing 10-58 how the application sets the application context in OracleJavaSecure by calling
the setAppContext() method.
Listing 10-58. Set Second Test Application Context
public static void main( String[] args ) {
OracleCallableStatement stmt = null;
Statement mStmt = null;
ResultSet rSet;
try {
// Submit two-factor auth code on command line, once received
String twoFactorAuth = "";
if( args.length != 0 && args[0] != null ) twoFactorAuth = args[0];
String applicationID = "HRVIEW" ;
Object appClass = new AnyNameWeWant() ;
OracleJavaSecure. setAppContext ( applicationID, appClass, twoFactorAuth );
Store the Connection Strings in Oracle
If this is the first time we have run the TestOracleJavaSecure class, both before and after we have a two-
factor authentication code, then we can run a few lines to populate the connsHash list of connection
strings and store them in Oracle, as shown in Listing 10-59.
Listing 10-59. Store Connections for Second Test Application
// Only do these lines once
// If we provided an old twoFactorAuth, will not have connHash -
// null pointer exception here
OracleJavaSecure.getAppConnections();
OracleJavaSecure.putAppConnString( "Orcl", "appusr",
"password", "localhost", String.valueOf( 1521 ) );
OracleJavaSecure.putAppConnections();
After we have succeeded in submitting our application-specific connection strings to Oracle, we can
comment those lines of code and simply use the connection strings that we've stored in and retrieved
from Oracle Database.
Get an Application Connection with Role
For this test, we are going to call our new method, getAAConnRole() , which as you'll recall gets the
application connection and sets the secure application role. This call is shown in Listing 10-60.
 
Search WWH ::




Custom Search