Middleware
Application Server
First Publication: 20-Jul-05
Last Update: 16-Jan-06
Author: Frances Zhao
Oracle database supports proxy-authentication which allows a client user to connect to the database through an application server, as a proxy user. The client user authenticates itself with the application server, while the application server authenticates itself as the proxy user with the Oracle database. The client user's name is maintained all the way to the database on any proxy connection opened this way.
OC4J 10g (10.1.3) supports this with Oracle JDBC native data sources. This demo illustrates some of the key steps in configuring and using proxy-authentication with an Oracle JDBC native data source, and tests the proxy connections to the configured Oracle database in JSP code.
This demo requires that the following sofware components are installed and configured correctly:
First, we need to define a native data source that uses Oracle JDBC DataSource implementations. Like in previous OC4J versions, OC4J 10.1.3 data sources are still defined in an appliction's data-sources.xml file. The default data source configuration file for all applications is still located at %ORACLE_HOME%/j2ee/home/config/data-sources.xml.
To define data sources you can edit the data sources configuration file directly or use Enterprise Manager to create, delete, and modify data sources. This How-to uses the first approach only.
Here is the native data source definition, which can be found in the application-embedded data-sources.xml under %HOWTO_HOME%/etc.
<native-data-source
name="OracleNativeDSForProxyDemo"
jndi-name="jdbc/OracleNativeDSForProxyDemo"
description="Native DataSource For Proxy Demo"
data-source-class="oracle.jdbc.pool.OracleDataSource"
user="scott"
password="tiger"
url="jdbc:oracle:thin:@//dbhost:1521/dbservicename">
</native-data-source>
Note that the data-source-class is an Oracle JDBC implementation of javax.sql.DataSource. The user and password attributes define the default user and password, which are not used in this demo.
The next step is to configure the Oracle database to set up the users, database roles, and the proxy mapping. You need to run the provided SQL script %HOWTO_HOME%/etc/setup.sql in SQLPlus with a Oracle DBA account.
Exexute the following command in SQLPlus:There are several groups of operations in the script:
Clicking the associated test button would invoke a JSP that tests proxy connections obtained from the configured native data source. A new page would show the test logs, or if an exception has occurred. There would be a back link on the new page that brings you back to the beginning page.
Here are some important operations in the JSP code relevant to proxy-authentication:
Note that the main purpose of this demo is to illustrate some of the key steps and APIs involved in configuring and using proxy-authentication, like database user setup, connect-through and role grants, openProxySession(), etc. It does not cover all the possible proxy-authentication configuration scenarios supported by Oracle database and Oracle JDBC. Refer to Oracle Database Security Guide 10g and Oracle JDBC Developer's Guide and Reference 10g for more detailed explanation on this subject.
The following instructions are for running this demonstration on a standalone instance of Oracle Containers for J2EE 10g (10.1.3).
Please check to make sure that the following properties are configured correctly in the ant-oracle.properties file located in the root of the sample's distribution (NOTE: Some of these properties will default to the values of corresponding environment variables as noted below. If you have these variables setup in your environment you may not have to alter the values in the file). If necessary, modify these variable to the proper values for you environment:
This demo requires an Oracle database and listener to be running. Note down the hostname, port number, and the service name used -- you need to modify the %HOWTO_HOME%/etc/data-sources.xml with these information.
Stand Alone Installation: %ORACLE_HOME%/bin/oc4j start
Note that the oc4j command expects the JAVA_HOME environment variable to point to a full JDK installation.
OracleAS Managed Installation: %ORACLE_HOME%/opmn/bin/opmnctl startall
In the top-level %HOWTO_HOME% directory, type the command:
You should now have newly created ds_proxy_demo.ear in your %HOWTO_HOME%/dist directory.
This command would also attempt to deploy the application if the build is successful. It will first test whether OC4J is running.
You can also deploy and bind the application separately by using the following command. Make sure the %ORACLE_HOME% environment variable is defined. In the top-level %HOWTO_HOME% directory, type the command:
In a browser window, browse to:
If the website hostname or port number are different, then use those values instead.
Clicking the associated test button would invoke a JSP that tests proxy connections obtained from the configured native data source. A new page would show the test logs, or if an exception has occurred. There would be a back link on the new page that brings you back to the beginning page.
In this document, you should have: