Java program with Oracle JDBC thin driver and encryption
Java program with Oracle JDBC thin driver and encryption
I wrote sample java program with Oracle JDBC thin driver and encryption,
as shown at (
http://otn.oracle.com/sample_code/deploy/security/files/secure_thin_driver/readme.html
)
It works well;
But i want use jdbc pool and encryption, I dont know how to write it; can
you help me? May you give me some samples;
My product will run in Oracle 10g + Oracle9i DB,
how can I configure "oracle.net.encryption_client" and other
properties when CREATE jdbc datasource in Oracle10g?
I've tried add properties to data-sources.xml file, but my connection still
is not secured.
There will be my data-sources.xml and conn.java:
data-sources.xml:
<data-sources>
<data-source
class="oracle.jdbc.pool.OracleDataSource"
name="OracleDS"
location="jdbc/OracleCoreDS"
xa-location="jdbc/xa/OracleXADS"
ejb-location="jdbc/OracleDS"
connection-driver="oracle.jdbc.driver.OracleDriver"
username="login"
password="pass"
url="jdbc:oracle:thin:@bill.dati.lv:1521:gates"
inactivity-timeout="30"
>
<property name="oracle.net.encryption_client" value="REQUIRED" />
<property name="oracle.net.encryption_types_client" value="( DES40C )" />
<property name="oracle.net.crypto_checksum_client" value="REQUIRED" />
<property name="oracle.net.crypto_checksum_types_client" value="( MD5 )" />
</data-source>
</data-sources>
and conn.java:
//This code gets secured connection and works fine.
String str_conn="jdbc:oracle:thin:@bill.dati.lv:1521:gates";
Properties l_prop = new Properties();
Class.forName("oracle.jdbc.driver.OracleDriver");
l_prop.put("user", "login");
l_prop.put("password", "password");
l_prop.put("oracle.net.encryption_client", "REQUIRED");
l_prop.put("oracle.net.encryption_types_client", "( DES40C )");
l_prop.put("oracle.net.crypto_checksum_client", "REQUIRED");
l_prop.put("oracle.net.crypto_checksum_types_client", "( MD5 )");
Connection con = DriverManager.getConnection(str_conn, l_prop);
//If I use DataSource object I can't get secured connection
Context ic = new InitialContext(par);
DataSource ds = (DataSource) ic.lookup("jdbc/OracleDS");
Connection con = ds.getConnection();