IBM DB2 Manual page 471

Table of Contents

Advertisement

properties.put("kerberosServerPrincipal",
"sample/srvlsj.ibm.com@SRVLSJ.SJ.IBM.COM");
properties.put("securityMechanism",
new String("" +
com.ibm.db2.jcc.DB2BaseDataSource.KERBEROS_SECURITY + ""));
String url = "jdbc:db2://mvs1.sj.ibm.com:5021/san_jose";
Connection con = DriverManager.getConnection(url, properties);
For the DataSource interface: If you create and deploy the DataSource object, set
the Kerberos server and security mechanism by invoking the
DataSource.setKerberosServerPrincipal and DataSource.setSecurityMechanism
methods after you create the DataSource object. For example:
import java.sql.*;
import com.ibm.db2.jcc.*;
...
DB2SimpleDataSource db2ds =
new com.ibm.db2.jcc.DB2SimpleDataSource();
db2ds.setDriverType(4);
db2ds.setDatabaseName("san_jose");
db2ds.setServerName("mvs1.sj.ibm.com");
db2ds.setPortNumber(5021);
db2ds.setKerberosServerPrincipal(
"sample/srvlsj.ibm.com@SRVLSJ.SJ.IBM.COM");
db2ds.setSecurityMechanism(
com.ibm.db2.jcc.DB2BaseDataSource.KERBEROS_SECURITY);
Kerberos security with a delegated credential from another
principal
For this case, you authenticate to the database server using a delegated credential
that another principal passes to you.
You need to set the kerberosServerPrincipal, gssCredential, and
securityMechanism properties. Set the securityMechanism property to
com.ibm.db2.jcc.DB2BaseDataSource.KERBEROS_SECURITY (11).
For the DriverManager interface: Set the Kerberos server, delegated credential, and
security mechanism by setting the kerberosServerPrincipal, and
securityMechanism properties in a Properties object. Then invoke the form of the
getConnection method that includes the Properties object as a parameter. For
example, use code like this to set the Kerberos security mechanism without a user
ID and password:
import java.sql.*;
import com.ibm.db2.jcc.*;
...
Properties properties = new Properties(); // Create a Properties object
properties.put("kerberosServerPrincipal",
"sample/srvlsj.ibm.com@SRVLSJ.SJ.IBM.COM");
properties.put("gssCredential",delegatedCredential);
Chapter 10. Security under the IBM Data Server Driver for JDBC and SQLJ
// Set the Kerberos server
// Set security mechanism to
// Kerberos
// Set URL for the data source
// Create the connection
// JDBC base
// IBM Data Server Driver for JDBC
// and SQLJ implementation of JDBC
// Create the DataSource object
// Set the driver type
// Set the location
// Set the server name
// Set the port number
// Set the Kerberos server
// Set security mechanism to
// Kerberos
// JDBC base
// IBM Data Server Driver for JDBC
// and SQLJ implementation of JDBC
// Set the Kerberos server
455

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents