Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Proxy Authentication with JDBC Datasource instead of JDBC URL?

696639Feb 23 2010 — edited Jun 14 2010
Hello,

A requirement for my current project (ADF 10g) is that a user should be able to log in with his regular database account. For the moment, this is implemented using Proxy Authentication, as described in the following article:

http://blogs.oracle.com/jheadstart/2008/01/using_proxy_authentication.html

For now, we are using a JDBC URL defined in the application module config for the BC. In short: a ProxyAuthConnectionPoolManager class was created that overrides the default ConnectionPoolManagerImpl. The getConnection method has been overridden to create a standard connection (with the username/pw defined on the AM), and additionally, create a proxy connection within this connection with the specific user credentials. The (simplified) code:
    public Connection getConnection(String key, String url, Properties props, String username, String pwd) {
        // first fetch a default connection from the pool through the superclass
        Connection connection = super.getConnection(key, url, props, username, pwd);
        // cast into an OracleConnection
        OracleConnection oraConnection = (OracleConnection) connection;
        ...
            // close any proxy sessions that would still exist on the connection
            if (oraConnection.isProxySession()) oraConnection.close(OracleConnection.PROXY_SESSION);
            // get a handle on the session scope
            Map sessionScope = ADFContext.getCurrent().getSessionScope();
            if (sessionScope != null) {
                // find the user object in the session (the account the user logs in with)
                ProxyAuthUser user = (ProxyAuthUser) sessionScope.get(ProxyAuthUser.JHS_USER_KEY);
                if (user != null) {
                    // create a property map with the end user credentials
                    Properties proxyProps = new Properties();
                    proxyProps.put(OracleConnection.PROXY_USER_NAME, user.getDbUsername() + "/" + user.getDbPassword());
                    proxyProps.put(OracleConnection.PROXY_USER_PASSWORD, user.getDbPassword());
                    
                    // open the proxy session
                    oraConnection.openProxySession(OracleConnection.PROXYTYPE_USER_NAME, proxyProps);
                } 
            }
            return oraConnection;  
    }
Now, this works perfectly when using a JDBC URL. But when I switch the JDBC Datasource the ProxyAuthConnectionPoolManager class is not called anymore. This is all done in code in the Application Server. While using a JDBC Datasource is actually necessary: otherwise for each environment (dev, test, production,...) a different WAR file is needed.

What class can I override with code similar to the piece above, to open a proxy connection inside the existing connection, when using a JDBC Datasource?

Your help would be greatly appreciated!

Chris
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 12 2010
Added on Feb 23 2010
10 comments
6,628 views