A Data Encryption and Integrity Example
Now that we’ve discussed both data encryption and integrity, let’s see them in action. Example 6-1 is a sample application that uses the Thin driver to establish a secure database connection.
First, the program loads the Oracle Thin driver using the
DriverManager.registerDriver( )
method. This method is chosen because
the use of encryption and integrity is definitely an Oracle
extension, and therefore not portable. So why be concerned about
using the Class.forName( ) method, along with the
extra coding that it requires, when portability is no longer a
concern?
Second, the program creates a Properties object
named prop and then adds the required properties.
It adds the user and password
properties because the form of getConnection( )
used with a Properties object does not take them
as separate parameters. The program then adds the
oracle.net.encryption_client and
oracle.net.encryption_types_client properties to
require 40-bit encryption. Next, the program adds
oracle.net.crypto_checksum_client and
oracle.net.crypto_checksum_types_client properties
to require that MD5 message digests be added to each packet.
Third, the program calls the getConnection(String url, Properties info) form of the getConnection( ) method. Then it finishes up in a manner similar to our previous connection examples by querying the database. This is the kind of secured connection you would most likely make for an applet. Alternatively, if you use an application or servlet, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access