Enable trusted context for DB2 databases
Enable trusted context in the applications to improve how the appserver interacts with DB2 database servers. Use trusted connections to preserve the identity records of clients that are connecting to a DB2 database through the applications; trusted connections can provide a more secure environment by granting access based on the identity of those users.
Verify the following prerequisites are met before enabling trusted connections:
- we are using a database server that is running DB2 V9.5 or later for AIX, HP-UX, Linux, Solaris, or Windows operating systems or DB2 V9.1 or later for z/OS. See the list of list of supported software for the appserver for more support information.
- You do not need to be connected to the database to configure trusted context in the appserver.
- Trusted context is enabled for the DB2 database.
- Global security is enabled. See the topic, Setting up, enabling and migrating security, for more information on configuring security.
New feature: With trusted connections we can:
- Access the DB2 database with the caller identity, obviating the need to create a new connection for every user.
- Preserve the identity of the end-user when the appserver is interacting with the database.
- Strengthen database security by avoiding granting all of the privileges to a single user.
- Improve performance, as compared to the existing model of using the resetConnection() method to take advantage of identity propagation.
Supported configurations: Non-trusted connections cannot be used as trusted connections. If the connection pool contains only non-trusted connections and a request comes in for a trusted connection, a new request will be sent to the database for the trusted connection.
Enable trusted context for the applications.
- Enable trusted context when we are installing a new application.
- Perform a typical installation for the application until you reach Step 7: Map resource references to resources in the installation wizard.
- In Step 7: Map resource references to resources, select Use trusted connections (one-to-one mapping) in the Specify authentication method section.
- Select an authentication alias from the list that matches an alias that is already defined in the DB2 data source. If we do not have an alias defined that is suitable, continue with the installation, and enable trusted context after the application is installed.
Supported configurations: You can specify a default user (UNAUTHENTICATED) to be used if no client identity is available, but that default ID (UNAUTHENTICATED) must also exist in the DB2 database. If the com.ibm.mapping.unauthenticatedUser is set to null or an empty string, then the appserver will use the default user (UNAUTHENTICATED). Read the topic, Setting the com.ibm.mapping.unauthenticatedUser property, for more information on this property.
- Select a data source from the table that has trusted context enabled.
- Click Apply.
- Edit the properties of the custom login configuration. Read the topic, Setting the security properties for trusted connections.
- Finish the installation wizard.
- Enable trusted context on an application that is already installed.
For transitioning users: Remove the propagateClientIdentityUsingTrustedContext custom property for the DB2 data source, if it is present. If the propagateClientIdentityUsingTrustedContext is enabled, the appserver will issue the following warning at run time:
IDENTITY_PROPAGATION_PROP_WARNING=DSRA7029W: The propagateClientIdentityUsingTrustedContext custom property for the Datasource is no longer used, value will be ignored.The appserver will determine at run time if the request is using trusted context, and the appserver will enable trusted context based on that information. Therefore, the same data source in the appserver can be used for both trusted and non-trusted access.trns
- Click Websphere enterprise apps > application_name.
- Click Resource references from the Resources heading.
- Select Use trusted connections (one-to-one mapping) in the Specify authentication method section.
- Select an authentication alias from the list that matches an alias that is already defined in the DB2 data source. If we do not have an alias defined that is suitable, define a new alias.
- Click JDBC > Data sources > data_source_name.
- Click JAAS - J2C authentication data from the Related Items heading.
- Click New.
- Define the properties for the alias in General properties.
- Click OK.
Supported configurations: You can specify a default user (UNAUTHENTICATED) to be used if no client identity is available, but that default ID (UNAUTHENTICATED) must also exist in the DB2 database. If the com.ibm.mapping.unauthenticatedUser is set to null or an empty string, then the appserver will use the default user (UNAUTHENTICATED). Read the topic, Setting the com.ibm.mapping.unauthenticatedUser property, for more information on this property.
- Select a data source from the table that has trusted context enabled.
- Click Apply.
- Edit the properties of the custom login configuration. Read the topic, Setting the security properties for trusted connections.
Next steps
Be aware of the following error conditions that can occur if trusted context is not configured properly:
- The appserver will issue a warning if we use the TrustedConnectionMapping login configuration and the database server does not support trusted context. The appserver will then return a normal, non-trusted connection. For a DB2 database for the database server, and it doesn't support trusted connections, then the DB2 database server will throw an exception.
- The appserver will throw the following exception if we use the TrustedConnectionMapping login configuration and ThreadIdentity is specified:
IDENTITY_PROPAGATION_CONFLICT2_ERROR=DSRA7028E: We cannot use the TrustedConnectionMapping login configuration when the ThreadIdentity property is enabled.- The appserver will throw the following exception if we use the TrustedConnectionMapping login configuration and reauthentication is specified:
IDENTITY_PROPAGATION_CONFLICT1_ERROR=DSRA7025E: The reauthentication custom property for the Datasource cannot be enabled when we are using the TrustedConnectionMapping login configuration.
Set the security properties for trusted connections
Trusted connections with DB2
Enable trusted context with authentication 
Related concepts
Data sources
JDBC providers
Related tasks
Use the DB2 Universal JDBC Driver to access DB2 for z/OS
Set a JDBC provider and data source
Set up, enabling and migrating security