Using Reauthentication
- Last Updated: June 4, 2024
- 2 minute read
- DataDirect Connectors
- JDBC
- Aha! 6.0
- Amazon Redshift 6.0
- Apache Cassandra 6.0
- Apache Hive 6.0
- Apache Spark SQL 6.0
- Atlassian Jira 6.0
- Autonomous REST Connector 6.0
- Cloudera Impala 5.1
- + 24
Typically, you can configure a connection pool to provide scalability for connections. In addition, to help minimize the number of connections required in a connection pool, you can switch the user associated with a connection to another user, a process known as reauthentication.
For example, suppose you are using Kerberos authentication to authenticate users using their operating system user name and password. To reduce the number of connections that must be created and managed, you can use reauthentication to switch the user associated with a connection to multiple users. For example, suppose your connection pool contains a connection, Conn, which was established by the user ALLUSERS. That connection can service multiple users (User A, B, and C) by switching the user associated with the connection Conn to User A, B, and C.
Not all databases support reauthentication. For databases that do, the user performing the switch must have been granted specific database permissions.
The following table shows the support for reauthentication and lists the required database permissions. Refer to your database documentation for information about granting permissions.
| Driver | Database | Database Permissions |
|---|---|---|
| Oracle | Oracle8i R2 and higher 1 | CONNECT THROUGH |
| Db2 | Db2 for Linux/UNIX/Windows | SETSESSIONUSER and SYSADM |
| Oracle | Oracle8i R2 and higher 2 | CONNECT THROUGH |
| SQL Server | Microsoft SQL Server 2005 and higher 3, 4 | IMPERSONATE |
To perform reauthentication on a connection explicitly, call the
setCurrentUser() method in the ExtConnection interface located in the
com.ddtek.jdbc.extensions package. For example, the following code switches the user on the
connection from the user that created the connection (TEST)
to a new user (SMITH). In addition, it sets options that
switch the current schema and current database path to the schema and database path of the new
user.
import com.ddtek.jdbc.extensions.*
// Get Database Connection
Connection con = DriverManager.getConnection(
"jdbc:datadirect:db2://server1:50000;DatabaseName=jdbc", "TEST", "secret");
ExtConnection extCon = (ExtConnection)con
Properties props = new Properties();
props.put("CURRENT_SCHEMA", "SCHEMA");
props.put("CURRENT_PATH", "PATH");
ExtCon.setCurrentUser("SMITH", props);
...
For supported options, refer to the user's guide for your driver.
If you are using the DataDirect Connection Pool Manager for connection pooling, you can enable reauthentication in the Pool Manager. See "Using Reauthentication with the Pool Manager" for details.