Forum Stats

  • 3,769,513 Users
  • 2,252,970 Discussions
  • 7,875,068 Comments

Discussions

Facing issue with kerberos Authentication with JDBC

Hello All,

I am facing following exception when trying to connect to Oracle using Kerberos authentication with JDBC in Ubuntu.

<span class="pln">java</span><span class="pun">.</span><span class="pln">sql</span><span class="pun">.</span><span class="typ">SQLException</span><span class="pun">:</span><span class="pln"> </span><span class="typ">The</span><span class="pln"> service </span><span class="kwd">in</span><span class="pln"> process </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> supported</span><span class="pun">.</span><span class="pln"> </span><span class="typ">Unable</span><span class="pln"> to obtain </span><span class="typ">Principal</span><span class="pln"> </span><span class="typ">Name</span><span class="pln"> </span><span class="kwd">for</span><span class="pln"> authentication<br/>  at oracle</span><span class="pun">.</span><span class="pln">jdbc</span><span class="pun">.</span><span class="pln">driver</span><span class="pun">.</span><span class="typ">SQLStateMapping</span><span class="pun">.</span><span class="pln">newSQLException</span><span class="pun">(</span><span class="typ">SQLStateMapping</span><span class="pun">.</span><span class="pln">java</span><span class="pun">:</span><span class="lit">70</span><span class="pun">)</span><span class="pln"><br/>  at oracle</span><span class="pun">.</span><span class="pln">jdbc</span><span class="pun">.</span><span class="pln">driver</span><span class="pun">.</span><span class="typ">DatabaseError</span><span class="pun">.</span><span class="pln">newSQLException</span><span class="pun">(</span><span class="typ">DatabaseError</span><span class="pun">.</span><span class="pln">java</span><span class="pun">:</span><span class="lit">133</span><span class="pun">)</span><span class="pln"><br/>  at oracle</span><span class="pun">.</span><span class="pln">jdbc</span><span class="pun">.</span><span class="pln">driver</span><span class="pun">.</span><span class="typ">DatabaseError</span><span class="pun">.</span><span class="pln">throwSqlException</span><span class="pun">(</span><span class="typ">DatabaseError</span><span class="pun">.</span><span class="pln">java</span><span class="pun">:</span><span class="lit">199</span><span class="pun">)</span><span class="pln"><br/>  at oracle</span><span class="pun">.</span><span class="pln">jdbc</span><span class="pun">.</span><span class="pln">driver</span><span class="pun">.</span><span class="typ">DatabaseError</span><span class="pun">.</span><span class="pln">throwSqlException</span><span class="pun">(</span><span class="typ">DatabaseError</span><span class="pun">.</span><span class="pln">java</span><span class="pun">:</span><span class="lit">480</span><span class="pun">)</span><span class="pln"><br/>  at oracle</span><span class="pun">.</span><span class="pln">jdbc</span><span class="pun">.</span><span class="pln">driver</span><span class="pun">.</span><span class="pln">T4CConnection</span><span class="pun">.</span><span class="pln">logon</span><span class="pun">(</span><span class="pln">T4CConnection</span><span class="pun">.</span><span class="pln">java</span><span class="pun">:</span><span class="lit">413</span><span class="pun">)</span><span class="pln"><br/>  at oracle</span><span class="pun">.</span><span class="pln">jdbc</span><span class="pun">.</span><span class="pln">driver</span><span class="pun">.</span><span class="typ">PhysicalConnection</span><span class="pun">.<</span><span class="pln">init</span><span class="pun">>(</span><span class="typ">PhysicalConnection</span><span class="pun">.</span><span class="pln">java</span><span class="pun">:</span><span class="lit">508</span><span class="pun">)</span><span class="pln"><br/>  at oracle</span><span class="pun">.</span><span class="pln">jdbc</span><span class="pun">.</span><span class="pln">driver</span><span class="pun">.</span><span class="pln">T4CConnection</span><span class="pun">.<</span><span class="pln">init</span><span class="pun">>(</span><span class="pln">T4CConnection</span><span class="pun">.</span><span class="pln">java</span><span class="pun">:</span><span class="lit">203</span><span class="pun">)</span><span class="pln"><br/>  at oracle</span><span class="pun">.</span><span class="pln">jdbc</span><span class="pun">.</span><span class="pln">driver</span><span class="pun">.</span><span class="pln">T4CDriverExtension</span><span class="pun">.</span><span class="pln">getConnection</span><span class="pun">(</span><span class="pln">T4CDriverExtension</span><span class="pun">.</span><span class="pln">java</span><span class="pun">:</span><span class="lit">33</span><span class="pun">)</span><span class="pln"><br/>  at oracle</span><span class="pun">.</span><span class="pln">jdbc</span><span class="pun">.</span><span class="pln">driver</span><span class="pun">.</span><span class="typ">OracleDriver</span><span class="pun">.</span><span class="pln">connect</span><span class="pun">(</span><span class="typ">OracleDriver</span><span class="pun">.</span><span class="pln">java</span><span class="pun">:</span><span class="lit">510</span><span class="pun">)</span><span class="pln"><br/>  at java</span><span class="pun">.</span><span class="pln">sql</span><span class="pun">.</span><span class="typ">DriverManager</span><span class="pun">.</span><span class="pln">getConnection</span><span class="pun">(</span><span class="typ">DriverManager</span><span class="pun">.</span><span class="pln">java</span><span class="pun">:</span><span class="lit">664</span><span class="pun">)</span><span class="pln"><br/>  at java</span><span class="pun">.</span><span class="pln">sql</span><span class="pun">.</span><span class="typ">DriverManager</span><span class="pun">.</span><span class="pln">getConnection</span><span class="pun">(</span><span class="typ">DriverManager</span><span class="pun">.</span><span class="pln">java</span><span class="pun">:</span><span class="lit">208</span><span class="pun">)</span><span class="pln"><br/>  at talendtest</span><span class="pun">.</span><span class="pln">tbillingops_0_1</span><span class="pun">.</span><span class="pln">tBillingOPS</span><span class="pun">.</span><span class="pln">tOracleConnection_1Process</span><span class="pun">(</span><span class="pln">tBillingOPS</span><span class="pun">.</span><span class="pln">java</span><span class="pun">:</span><span class="lit">614</span><span class="pun">)</span><span class="pln"><br/>  at talendtest</span><span class="pun">.</span><span class="pln">tbillingops_0_1</span><span class="pun">.</span><span class="pln">tBillingOPS</span><span class="pun">.</span><span class="pln">runJobInTOS</span><span class="pun">(</span><span class="pln">tBillingOPS</span><span class="pun">.</span><span class="pln">java</span><span class="pun">:</span><span class="lit">6515</span><span class="pun">)</span><span class="pln"><br/>  at talendtest</span><span class="pun">.</span><span class="pln">tbillingops_0_1</span><span class="pun">.</span><span class="pln">tBillingOPS</span><span class="pun">.</span><span class="pln">main</span><span class="pun">(</span><span class="pln">tBillingOPS</span><span class="pun">.</span><span class="pln">java</span><span class="pun">:</span><span class="lit">6333</span><span class="pun">)</span><span class="pln"><br/></span><span class="typ">Caused</span><span class="pln"> </span><span class="kwd">by</span><span class="pun">:</span><span class="pln"> oracle</span><span class="pun">.</span><span class="pln">net</span><span class="pun">.</span><span class="pln">ns</span><span class="pun">.</span><span class="typ">NetException</span><span class="pun">:</span><span class="pln"> </span><span class="typ">The</span><span class="pln"> service </span><span class="kwd">in</span><span class="pln"> process </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> supported</span><span class="pun">.</span><span class="pln"> </span><span class="typ">Unable</span><span class="pln"> to obtain </span><span class="typ">Principal</span><span class="pln"> </span><span class="typ">Name</span><span class="pln"> </span><span class="kwd">for</span><span class="pln"> authentication<br/>  at oracle</span><span class="pun">.</span><span class="pln">net</span><span class="pun">.</span><span class="pln">ano</span><span class="pun">.</span><span class="typ">AuthenticationService</span><span class="pun">.</span><span class="pln">h</span><span class="pun">(</span><span class="typ">Unknown</span><span class="pln"> </span><span class="typ">Source</span><span class="pun">)</span><span class="pln"><br/>  at oracle</span><span class="pun">.</span><span class="pln">net</span><span class="pun">.</span><span class="pln">ano</span><span class="pun">.</span><span class="typ">Ano</span><span class="pun">.</span><span class="pln">negotiation</span><span class="pun">(</span><span class="typ">Unknown</span><span class="pln"> </span><span class="typ">Source</span><span class="pun">)</span><span class="pln"><br/>  at oracle</span><span class="pun">.</span><span class="pln">net</span><span class="pun">.</span><span class="pln">ns</span><span class="pun">.</span><span class="typ">NSProtocol</span><span class="pun">.</span><span class="pln">connect</span><span class="pun">(</span><span class="typ">NSProtocol</span><span class="pun">.</span><span class="pln">java</span><span class="pun">:</span><span class="lit">405</span><span class="pun">)</span><span class="pln"><br/>  at oracle</span><span class="pun">.</span><span class="pln">jdbc</span><span class="pun">.</span><span class="pln">driver</span><span class="pun">.</span><span class="pln">T4CConnection</span><span class="pun">.</span><span class="pln">connect</span><span class="pun">(</span><span class="pln">T4CConnection</span><span class="pun">.</span><span class="pln">java</span><span class="pun">:</span><span class="lit">966</span><span class="pun">)</span><span class="pln"><br/>  at oracle</span><span class="pun">.</span><span class="pln">jdbc</span><span class="pun">.</span><span class="pln">driver</span><span class="pun">.</span><span class="pln">T4CConnection</span><span class="pun">.</span><span class="pln">logon</span><span class="pun">(</span><span class="pln">T4CConnection</span><span class="pun">.</span><span class="pln">java</span><span class="pun">:</span><span class="lit">292</span><span class="pun">)</span><span class="pln"><br/>   </span><span class="pun">...</span><span class="pln"> </span><span class="lit">9</span><span class="pln"> more</span>

<span class="typ">Output</span><span class="pln"> of klist</span><span class="pun">:</span><span class="pln"><br/>[email protected]</span><span class="pun">:~/></span><span class="pln"> klist<br/></span><span class="typ">Ticket</span><span class="pln"> cache</span><span class="pun">:</span><span class="pln"> FILE</span><span class="pun">:</span><span class="str">/tmp/</span><span class="pln">krb5cc_8483390<br/></span><span class="typ">Default</span><span class="pln"> principal</span><span class="pun">:</span><span class="pln"> [email protected]</span><span class="pun">.</span><span class="pln">zzzzzz</span><span class="pun">.</span><span class="pln">NET<br/></span><span class="typ">Valid</span><span class="pln"> starting  </span><span class="typ">Expires</span><span class="pln">   </span><span class="typ">Service</span><span class="pln"> principal<br/></span><span class="lit">10</span><span class="pun">/</span><span class="lit">10</span><span class="pun">/</span><span class="lit">17</span><span class="pln"> </span><span class="lit">13</span><span class="pun">:</span><span class="lit">28</span><span class="pun">:</span><span class="lit">23</span><span class="pln">  </span><span class="lit">10</span><span class="pun">/</span><span class="lit">10</span><span class="pun">/</span><span class="lit">17</span><span class="pln"> </span><span class="lit">23</span><span class="pun">:</span><span class="lit">28</span><span class="pun">:</span><span class="lit">23</span><span class="pln">  krbtgt</span><span class="pun">/</span><span class="pln">xxxx</span><span class="pun">.</span><span class="pln">yyyyyyy</span><span class="pun">.</span><span class="pln">[email protected]</span><span class="pun">.</span><span class="pln">yyy</span><span class="pun">.</span><span class="pln">NET<br/>  renew </span><span class="kwd">until</span><span class="pln"> </span><span class="lit">10</span><span class="pun">/</span><span class="lit">11</span><span class="pun">/</span><span class="lit">17</span><span class="pln"> </span><span class="lit">13</span><span class="pun">:</span><span class="lit">28</span><span class="pun">:</span><span class="lit">23</span><span class="pln"><br/></span><span class="typ">Kerberos</span><span class="pln"> </span><span class="lit">4</span><span class="pln"> ticket cache</span><span class="pun">:</span><span class="pln"> </span><span class="str">/tmp/</span><span class="pln">tkt8483390<br/>klist</span><span class="pun">:</span><span class="pln"> </span><span class="typ">You</span><span class="pln"> have </span><span class="kwd">no</span><span class="pln"> tickets cached</span>

Following is my code snippet:

<span class="pln">java</span><span class="pun">.</span><span class="pln">util</span><span class="pun">.</span><span class="typ">Properties</span><span class="pln"> prop </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> java</span><span class="pun">.</span><span class="pln">util</span><span class="pun">.</span><span class="typ">Properties</span><span class="pun">();</span><span class="pln"><br/>prop</span><span class="pun">.</span><span class="pln">setProperty</span><span class="pun">(</span><span class="pln">oracle</span><span class="pun">.</span><span class="pln">jdbc</span><span class="pun">.</span><span class="typ">OracleConnection</span><span class="pun">.</span><span class="pln">CONNECTION_PROPERTY_THIN_NET_AUTHENTICATION_SERVICES</span><span class="pun">,</span><span class="str">"("</span><span class="pun">+</span><span class="pln">oracle</span><span class="pun">.</span><span class="pln">net</span><span class="pun">.</span><span class="pln">ano</span><span class="pun">.</span><span class="typ">AnoServices</span><span class="pun">.</span><span class="pln">AUTHENTICATION_KERBEROS5</span><span class="pun">+</span><span class="str">")"</span><span class="pun">);</span><span class="pln"><br/>prop</span><span class="pun">.</span><span class="pln">setProperty</span><span class="pun">(</span><span class="pln">oracle</span><span class="pun">.</span><span class="pln">jdbc</span><span class="pun">.</span><span class="typ">OracleConnection</span><span class="pun">.</span><span class="pln">CONNECTION_PROPERTY_THIN_NET_AUTHENTICATION_KRB5_MUTUAL</span><span class="pun">,</span><span class="str">"true"</span><span class="pun">);</span><span class="pln"><br/> prop</span><span class="pun">.</span><span class="pln">setProperty</span><span class="pun">(</span><span class="pln">oracle</span><span class="pun">.</span><span class="pln">jdbc</span><span class="pun">.</span><span class="typ">OracleConnection</span><span class="pun">.</span><span class="pln">CONNECTION_PROPERTY_THIN_NET_AUTHENTICATION_KRB5_CC_NAME</span><span class="pun">,</span><span class="str">"/tmp/krb5cc_8483390"</span><span class="pun">);</span><span class="pln"><br/></span><span class="typ">System</span><span class="pun">.</span><span class="pln">setProperty</span><span class="pun">(</span><span class="str">"java.security.krb5.conf"</span><span class="pun">,</span><span class="str">"/home/pagupta/krb5.conf"</span><span class="pun">);</span><span class="pln"><br/></span><span class="typ">String</span><span class="pln"> url_tOracleConnection_1 </span><span class="pun">=</span><span class="pln"> </span><span class="str">"jdbc:oracle:thin:@(description=(address=(protocol=tcp)(host="</span><span class="pun">+</span><span class="pln"> context</span><span class="pun">.</span><span class="pln">DB_HOST</span><span class="pun">+</span><span class="pln"> </span><span class="str">")(port="</span><span class="pun">+</span><span class="pln"> context</span><span class="pun">.</span><span class="pln">DB_PORT</span><span class="pun">+</span><span class="pln"> </span><span class="str">"))(connect_data=(service_name="</span><span class="pun">+</span><span class="pln"> context</span><span class="pun">.</span><span class="pln">DB_SRV</span><span class="pun">+</span><span class="pln"> </span><span class="str">")))"</span><span class="pun">;</span><span class="pln"><br/>java</span><span class="pun">.</span><span class="pln">sql</span><span class="pun">.</span><span class="typ">DriverManager</span><span class="pun">.</span><span class="pln">registerDriver</span><span class="pun">(</span><span class="kwd">new</span><span class="pln"> oracle</span><span class="pun">.</span><span class="pln">jdbc</span><span class="pun">.</span><span class="typ">OracleDriver</span><span class="pun">());</span><span class="pln"><br/>oracle</span><span class="pun">.</span><span class="pln">jdbc</span><span class="pun">.</span><span class="typ">OracleDriver</span><span class="pln"> dri</span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> oracle</span><span class="pun">.</span><span class="pln">jdbc</span><span class="pun">.</span><span class="typ">OracleDriver</span><span class="pun">();</span><span class="pln"><br/>conn_tOracleConnection_1 </span><span class="pun">=</span><span class="pln"> java</span><span class="pun">.</span><span class="pln">sql</span><span class="pun">.</span><span class="typ">DriverManager</span><span class="pun">.</span><span class="pln">getConnection</span><span class="pun">(</span><span class="pln">url_tOracleConnection_1</span><span class="pun">,</span><span class="pln">prop</span><span class="pun">);</span><span class="pln"><br/></span><span class="typ">System</span><span class="pun">.</span><span class="kwd">out</span><span class="pun">.</span><span class="kwd">print</span><span class="pun">(</span><span class="str">"Connected"</span><span class="pun">);</span>

Can anyone help me to get it resolved, Will be a great help.

Regards,

Ankur

This discussion has been closed.