7 Oracle Driver : Authentication

Authentication
Authentication protects the identity of the user so that user credentials cannot be intercepted by malicious hackers when transmitted over the network. See “Authentication” for an overview.
The Oracle driver supports the following methods of authentication:
■
User ID/password authentication authenticates the user to the database using a database user name and password specified by the application.
■
Kerberos authentication uses Kerberos, a trusted third-party authentication service, to verify user identities. Kerberos authentication can take advantage of the user name and password maintained by the operating system to authenticate users to the database or use another set of user credentials specified by the application.
This method requires knowledge of how to configure your Kerberos environment and supports Windows Active Directory Kerberos and MIT Kerberos.
■
NTLM authentication is a single sign-on OS authentication method. This method provides authentication from Windows clients only and requires minimal configuration.
■
Client authentication uses the user ID of the user logged onto the system on which the driver is running to authenticate the user to the database. The Oracle database server relies on the client to authenticate the user and does not provide additional authentication.
NOTE: Because the database server does not authenticate the user when client authentication is used, use this method of authentication if you can guarantee that only trusted clients can access the database server.
Except for NTLM authentication, which provides authentication for Windows clients only, these authentication methods provide authentication when the driver is running on any supported platform.
The AuthenticationMethod connection property controls which authentication mechanism the driver uses when establishing connections. See “Using the AuthenticationMethod Property” for information about setting the value for this property.
Using the AuthenticationMethod Property
The AuthenticationMethod connection property controls which authentication mechanism the driver uses when establishing connections. When AuthenticationMethod=auto (default), the driver uses user ID/password, Kerberos, or NTLM authentication when establishing a connection based on the following criteria:
■
If a user ID and password is specified, the driver uses user ID/password authentication when establishing a connection. The User property provides the user ID. The Password property provides the password.
■
If a user ID and password is not specified and the driver is not running on a Windows platform, the driver uses Kerberos authentication when establishing a connection.
■
If a user ID and password is not specified and the driver is running on a Windows platform, the driver uses NTLM authentication when establishing a connection if the driver can load the DLL required for NTLM authentication. If the driver cannot load the DLL, the driver uses Kerberos authentication.
When AuthenticationMethod=kerberos, the driver uses Kerberos authentication when establishing a connection. The driver ignores any values specified by the User and Password properties.
When AuthenticationMethod=kerberosUIDPassword, the driver first uses Kerberos when establishing a connection. Next, the driver reauthenticates the user using user ID/password authentication. The User property provides the user ID. The Password property provides the password. If a user ID and password are not specified, the driver throws an exception. If either Kerberos or user ID/password authentication fails, the connection attempt fails and the driver throws an exception.
When AuthenticationMethod=ntlm, the driver uses NTLM authentication when establishing a connection if the driver can load the DLL required for NTLM authentication. If the driver cannot load the DLL, the driver throws an exception. The driver ignores any values specified by the User and Password properties.
When AuthenticationMethod=client, the driver uses client authentication when establishing a connection. The Oracle database server relies on the client to authenticate the user and does not provide additional authentication. The driver ignores any values specified by the User and Password properties.
When AuthenticationMethod=userIdPassword, the driver uses user ID/password authentication when establishing a connection. The User property provides the user ID. The Password property provides the password. If a user ID is not specified, the driver throws an exception.
NOTE: If the NewPassword connection property is specified, its value is used only if user ID/password authentication is enabled explicitly (AuthenticationMethod=userIdPassword) or implicitly (AuthenticationMethod=auto and a user ID and password is supplied); otherwise, the driver throws an exception.
Configuring User ID/Password Authentication
1
2
3
Configuring Kerberos Authentication
This section provides requirements and instructions for configuring Kerberos authentication for the Oracle driver.
Product Requirements
Verify that your environment meets the requirements listed in Table 7-4 before you configure the driver for Kerberos authentication.
Database server
The database server must be administered by the same domain controller that administers the client and must be running one of the following databases:
■
Oracle 11g R1 (11.1) and R2 (11.2)
■
Oracle 10g R1 (10.1) and R2 (10.2)
■
Oracle9i R2 (9.2)
The Kerberos server is the machine where the user IDs for authentication are administered. The Kerberos server is also the location of the Kerberos KDC.
■
Windows Active Directory on one of the following operating systems: Windows Server 2003 or Windows 2000 Server Service Pack 3 or higher
The client must be administered by the same domain controller that administers the database server. In addition, J2SE 5 or higher must be installed.
Configuring the Driver
During installation, the following files required for Kerberos authentication are installed in the /lib subdirectory of your product installation directory:
■
krb5.conf is a Kerberos configuration file containing values for the Kerberos realm and the KDC name for that realm. A generic file is installed that you must modify for your environment.
■
JDBCDriverLogin.conf file is a Java Authentication and Authorization Service (JAAS) login module for Kerberos authentication. This file is configured to load automatically unless the java.security.auth.login.config system property is set to load another configuration file.
NOTE: Do not modify the JDBCDriverLogin.conf file.
To configure the driver:
1
Set the driver’s AuthenticationMethod property to auto (default) or kerberos. See “Using the AuthenticationMethod Property” for more information about setting a value for this property.
2
Modify the krb5.conf file to contain your Kerberos realm name and the KDC name for that Kerberos realm by editing the file with a text editor or by specifying the system properties, java.security.krb5.realm and java.security.krb5.kdc.
NOTE: In Windows Active Directory, the Kerberos realm name is the Windows domain name and the KDC name is the Windows domain controller name.
For example, if your Kerberos realm name is XYZ.COM and your KDC name is kdc1, your krb5.conf file would look like this:
[libdefaults]
   default_realm = XYZ.COM
 
[realms]
   XYZ.COM = {
   kdc = kdc1
   }
If the krb5.conf file does not contain a valid Kerberos realm and KDC name, the following exception is thrown:
Message:[DataDirect][Oracle JDBC Driver]Could not establish a connection using integrated security: No valid credentials provided
The krb5.conf file is configured to load automatically unless the java.security.krb5.conf system property is set to point to another Kerberos configuration file.
3
Specifying User Credentials for Kerberos Authentication (Delegation of Credentials)
By default, when Kerberos authentication is used, the Oracle driver takes advantage of the user name and password maintained by the operating system to authenticate users to the database. By allowing the database to share the user name and password used for the operating system, users with a valid operating system account can log into the database without supplying a user name and password.
Many application servers or Web servers act on behalf of the client user logged on the machine on which the application is running, rather than the server user. If you want the driver to use a set of user credentials other than the operating system user name and password, include code in your application to obtain and pass a jjavax.security.auth.Subject used for authentication as shown in the following example.
import javax.security.auth.Subject;
import javax.security.auth.login.LoginContext;
import java.sql.*;
 
// The following code creates a javax.security.auth.Subject instance
// used for authentication. Refer to the Java Authentication
// and Authorization Service documentation for details on using a
// LoginContext to obtain a Subject.
 
LoginContext lc = null;
Subject subject = null;
 
try {
 
    lc = new LoginContext("JaasSample", new TextCallbackHandler());
    lc.login();
    subject = lc.getSubject();
}
catch (Exception le) {
    ... // display login error
}
 
// This application passes the javax.security.auth.Subject
// to the driver by executing the driver code as the subject
 
Connection con =
   (Connection) Subject.doAs(subject, new PrivilegedExceptionAction() {
   
    public Object run() {
   
       Connection con = null;
    try {
 
         Class.forName("com.ddtek.jdbc.oracle.OracleDriver");
         String url = "jdbc:datadirect:oracle://myServer:1521";
         con = DriverManager.getConnection(url);
       }
    catch (Exception except) {
 
    ... //log the connection error
            Return null;
       }
      
       return con;
    }
});
 
// This application now has a connection that was authenticated with
// the subject. The application can now use the connection.
Statement   stmt = con.createStatement();
String      sql = "SELECT * FROM employee";
ResultSet   rs = stmt.executeQuery(sql);
 
... // do something with the results
Obtaining a Kerberos Ticket Granting Ticket
To use Kerberos authentication, the application user first must obtain a Kerberos Ticket Granting Ticket (TGT) from the Kerberos server. The Kerberos server verifies the identity of the user and controls access to services using the credentials contained in the TGT.
If the application uses Kerberos authentication from a Windows client and the Kerberos authentication is provided by Windows Active Directory, the application user is not required to log onto the Kerberos server and explicitly obtain a TGT. Windows Active Directory automatically obtains a TGT for the user.
The application user must explicitly obtain a TGT in the following cases:
■
■
To explicitly obtain a TGT, the user must log onto the Kerberos server using the kinit command. For example, the following command requests a TGT from the server with a lifetime of 10 hours, which is renewable for 5 days:
kinit -l 10h -r 5d user
where user is the application user.
Refer to your Kerberos documentation for more information about using the kinit command and obtaining TGTs for users.
Configuring NTLM Authentication
This section provides requirements and instructions for configuring NTLM authentication for the Oracle driver.
Product Requirements
Verify that your environment meets the requirements listed in Table 7-5 before you configure the driver for NTLM authentication.
Database server
The database server must be administered by the same domain controller that administers the client and must be running one of the following databases:
■
Oracle 11g R1 (11.1) and R2 (11.2)
■
Oracle 10g R1 (10.1) and R2 (10.2)
■
Oracle9i R1 (9.1) and R2 (9.2)
■
Oracle8i R2 (8.1.6) and R3 (8.1.7)
The domain controller must administer both the database server and the client. Network authentication must be provided by NTLM on one of the following operating systems:
The client must be administered by the same domain controller that administers the database server and must be running on one of the following operating systems:
Configuring the Driver
The product provides the following NTLM authentication DLLs:
■
DDJDBCAuthxx.dll (32-bit)
■
DDJDBC64Authxx.dll (Itanium 64-bit)
■
DDJDBCx64Authxx.dll (AMD64 and Intel EM64T 64-bit)
where xx is a two-digit number.
The DLLs are located in the install_dir/lib directory (where install_dir is your product installation directory). If the application using NTLM authentication is running in a 32-bit JVM, the driver automatically uses DDJDBCAuthxx.dll. Similarly, if the application is running in a 64-bit JVM, the driver uses DDJDBC64Authxx.dll or DDJDBCx64Authxx.dll.
To configure the driver:
1
2
By default, the driver looks for the NTLM authentication DLLs in a directory on the Windows system path defined by the PATH environment variable. If you install the driver in a directory that is not on the Windows system path, perform one of the following actions to ensure the driver can load the DLLs:
■
Add the install_dir/lib directory to the Windows system path, where install_dir is your product installation directory.
■
Copy the NTLM authentication DLLs from install_dir/lib to a directory that is on the Windows system path, where install_dir is your product installation directory.
■
Set the LoadLibraryPath property to specify the location of the NTLM authentication DLLs. For example, if you install the driver in a directory named "DataDirect" that is not on the Windows system path, you can use the LoadLibraryPath property to specify the directory containing the NTLM authentication DLLs:
jdbc:datadirect:oracle://server3:1521;ServiceName=ORCL;
LoadLibraryPath=C:\DataDirect\lib;User=test;Password=secret
3
If using NTLM authentication with a Security Manager on a Java 2 Platform, security permissions must be granted to allow the driver to establish connections. See “Permissions for Establishing Connections” for an example.
Configuring Client Authentication
Set the AuthenticationMethod property to client. See “Using the AuthenticationMethod Property” for more information about setting a value for this property.