Thursday, January 10, 2013

SQLDeveloper and the connections.xml file

I am trying to generate the connections.xml file used by SQLDeveloper to contain all connection info. It doesn't seem too difficult, the only trick is to encrypt the password.

<?xml version = '1.0' encoding = 'UTF-8'?>
<References xmlns="http://xmlns.oracle.com/adf/jndi">
   <Reference name="hqblln422.acme.com:1551_TST_OSB_ts1_pippo_gm" className="oracle.jdeveloper.db.adapter.DatabaseProvider" xmlns="">
      <Factory className="oracle.jdeveloper.db.adapter.DatabaseProviderFactory"/>
      <RefAddresses>
         <StringRefAddr addrType="OracleConnectionType">
            <Contents>ADVANCED</Contents>
         </StringRefAddr>
         <StringRefAddr addrType="oraDriverType">
            <Contents>thin</Contents>
         </StringRefAddr>
         <StringRefAddr addrType="user">
            <Contents>ts1_pippo_gm</Contents>
         </StringRefAddr>
         <StringRefAddr addrType="role">
            <Contents/>
         </StringRefAddr>
         <StringRefAddr addrType="NoPasswordConnection">
            <Contents>TRUE</Contents>
         </StringRefAddr>
         <StringRefAddr addrType="subtype">
            <Contents>oraJDBC</Contents>
         </StringRefAddr>
         <StringRefAddr addrType="KERBEROS_AUTHENTICATION">
            <Contents>false</Contents>
         </StringRefAddr>
         <StringRefAddr addrType="OS_AUTHENTICATION">
            <Contents>false</Contents>
         </StringRefAddr>
         <StringRefAddr addrType="RaptorConnectionType">
            <Contents>Oracle</Contents>
         </StringRefAddr>
         <StringRefAddr addrType="ConnName">
            <Contents>hqblln422.acme.com:1551_TST_OSB_ts1_pippo_gm</Contents>
         </StringRefAddr>
         <StringRefAddr addrType="customUrl">
            <Contents>jdbc:oracle:thin:@//hqblln422.acme.com:1551/TST_OSB</Contents>
         </StringRefAddr>
         <StringRefAddr addrType="password">
            <Contents>053F1E4CDCA2D3C78B79D97CC5A0ED93CA39ADBDA8ED2CB2D3</Contents>
         </StringRefAddr>
         <StringRefAddr addrType="SavePassword">
            <Contents>true</Contents>
         </StringRefAddr>
         <StringRefAddr addrType="driver">
            <Contents>oracle.jdbc.OracleDriver</Contents>
         </StringRefAddr>
      </RefAddresses>
   </Reference>
</References>



Here a post telling you how to encrypt:

http://stackoverflow.com/questions/1032721/does-anybody-know-what-encrypting-technique-is-jdeveloper-sql-developer-using-to

and here how to decrypt:

http://jvzoggel.wordpress.com/tag/sqldeveloper/

You need these libraries:

/opt/oracle/fmw11_1_1_5/oracle_common/modules/oracle.adf.model_11.1.1/db-ca.jar

/opt/oracle/fmw11_1_1_5/oracle_common/modules/oracle.ldap_11.1.1/ojmisc.jar

and the code is

import oracle.jdevimpl.db.adapter.DatabaseProviderHelper;


cleartextPassword = DatabaseProviderHelper.comingIn(encryptedPassword)


encryptedPassword = DatabaseProviderHelper.goingOut(cleartextPassword)



No comments: