Jdbc connection string ORACLE , integrated security

active-directoryjdbcoracle

we are trying to configure Spotfire to use JDBC connection to ORACLE. We would like it to use integrated security (I call it Active Directory, TIBCO seems to like integrated security).

Here is the current connection string which required username, pwd

jdbc:oracle:thin:@WARHAWK.conocophillips.net:1521:OWVCORP3

can anyone point me to, or tell me how to modify this to use integrated security.

Best Answer

When you use Kerberos authentication (for example Active Directory) with JDBC, you have to prepare your code for it, and not just simply change the connection string.

The Database JDBC Developer's Guide and Reference covers this topic: http://docs.oracle.com/cd/E11882_01/java.112/e16548/clntsec.htm#JJDBC28344

Essential parts from the example of the above URL:

Example connection string and declarations:

  String url ="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)"+
    "(HOST=oracleserver.mydomain.com)(PORT=5561))(CONNECT_DATA=" +
    "(SERVICE_NAME=mydatabaseinstance)))";

   OracleDriver driver = new OracleDriver();
    Properties prop = new Properties();

Specifying the kerberos specific options:

prop.setProperty(OracleConnection.CONNECTION_PROPERTY_THIN_NET_AUTHENTICATION_SERVICES, "("+AnoServices.AUTHENTICATION_KERBEROS5+")");  
prop.setProperty(OracleConnection.CONNECTION_PROPERTY_THIN_NET_AUTHENTICATION_KRB5_MUTUAL, "true");

Specifying the credential cache location:

prop.setProperty(OracleConnection.CONNECTION_PROPERTY_THIN_NET_AUTHENTICATION_KRB5_CC_NAME, "/tmp/krb5cc_5088");

Finally connecting:

Connection conn  = driver.connect(url,prop);
String auth = ((OracleConnection)conn).getAuthenticationAdaptorName();
System.out.println("Authentication adaptor="+auth);
printUserName(conn);
conn.close();