-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 33 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Using Oracle Proxy Authentication
PostPosted: Tue Jul 08, 2008 8:24 am 
Newbie

Joined: Fri Jul 04, 2008 7:52 am
Posts: 8
Is there any limitation for using Oracle Proxy Authentication (OracleConnection.openProxySesion(...)) ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 08, 2008 9:57 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
I have used it many ways in several projects and haven't run into any problems. Is there a problem you might be anticipating? A certain usage scenario perhaps?

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 08, 2008 10:24 am 
Newbie

Joined: Fri Jul 04, 2008 7:52 am
Posts: 8
Hi Cameron, thanks a lot. It was only a question for the first approach. Regards, Michel


Top
 Profile  
 
 Post subject: Oracle Proy Authentication
PostPosted: Tue Jul 08, 2008 10:24 am 
Newbie

Joined: Fri Jul 04, 2008 7:52 am
Posts: 8
Hi Cameron, thanks a lot. It was only a question for the first approach. Regards, Michel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 08, 2008 10:24 am 
Newbie

Joined: Fri Jul 04, 2008 7:52 am
Posts: 8
Hi Cameron, thanks a lot. It was only a question for the first approach. Regards, Michel


Top
 Profile  
 
 Post subject: Oracle Proxy Authentication
PostPosted: Tue Jul 08, 2008 10:24 am 
Newbie

Joined: Fri Jul 04, 2008 7:52 am
Posts: 8
hm,... php...


Top
 Profile  
 
 Post subject: Oracle Proxy Athentication
PostPosted: Wed Jul 09, 2008 8:00 am 
Newbie

Joined: Fri Jul 04, 2008 7:52 am
Posts: 8
How to write code for Oracle Proxy Authentication with Hibernate ?

In Oracle Documentation:

//obtain connection from a cache enabled DataSource
OracleConnection conn = ds.getConnection("scott",tiger");
conn.openProxySession(proxyType, proxyProps);

I checked hibernate_reference, Hibernate API but without success. Please advise me. Thanks a lot in advance,

Michel


Top
 Profile  
 
 Post subject: Re: Using Oracle Proxy Authentication
PostPosted: Wed Aug 12, 2009 11:51 am 
Newbie

Joined: Mon Jan 15, 2007 10:40 am
Posts: 2
Location: Winnipeg, MB
I am also trying to use a oracle proxy user with hibernate. Cameron, could you provide some code on how to do this?

_________________
There are only 10 types of people in this world, those who understand binary and those that don't.


Top
 Profile  
 
 Post subject: Re: Using Oracle Proxy Authentication
PostPosted: Fri Aug 14, 2009 8:52 am 
Newbie

Joined: Thu Feb 05, 2009 3:37 pm
Posts: 13
Kind of late, but I've succesfully implemented proxy authentication. What you need is to implement your own connection provider, and when the framework asks for the connection, you use oracle's apis in order to to the proxy.

hope it helps, if you need some code let me know


cheers


Top
 Profile  
 
 Post subject: Re: Using Oracle Proxy Authentication
PostPosted: Tue Sep 01, 2009 4:22 am 
Newbie

Joined: Tue Sep 01, 2009 4:17 am
Posts: 2
julianda wrote:
Kind of late, but I've succesfully implemented proxy authentication. What you need is to implement your own connection provider, and when the framework asks for the connection, you use oracle's apis in order to to the proxy.

hope it helps, if you need some code let me know


cheers


Hi julianda,
We are working on proxy authentication with hibernate, too. Can you share the any code on how to implement the proxy authentication?
Thanks,
Engin


Top
 Profile  
 
 Post subject: Re: Using Oracle Proxy Authentication
PostPosted: Wed Sep 16, 2009 10:53 am 
Newbie

Joined: Thu Feb 05, 2009 3:37 pm
Posts: 13
Engin

What version and brand of appserver are you using? What version of Oracle Database are you using? you can contactme directly if you prefere to julian.deanquin at gmail dot com

cheers


Top
 Profile  
 
 Post subject: Re: Using Oracle Proxy Authentication
PostPosted: Thu Sep 17, 2009 1:43 pm 
Newbie

Joined: Thu Sep 17, 2009 1:13 pm
Posts: 1
julianda - I'd really be interested in seeing your solution as well. We're currently on Oracle App Server 10.1.3.4 / Oracle Database 10.2.0.4 but looking to move off of OAS onto JBoss 4.3 but still using Oracle Database. We have a legacy framework that is heavily invested in proxy authentication so it's a requirement for us to still be able to leverage it within the new application server (hopefully JBoss). I'll send you an email directly as well. Thanks!


Top
 Profile  
 
 Post subject: Re: Using Oracle Proxy Authentication
PostPosted: Thu Sep 17, 2009 2:23 pm 
Newbie

Joined: Thu Feb 05, 2009 3:37 pm
Posts: 13
This is the connection provider i've implemented

Code:
import java.sql.Connection;
import java.sql.SQLException;

import java.util.Enumeration;
import java.util.Properties;


import javax.naming.InitialContext;
import javax.naming.NamingException;

import javax.sql.DataSource;


import oracle.jdbc.OracleConnection;

import org.hibernate.HibernateException;
import org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider;


import org.hibernate.util.NamingHelper;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
*/
/**
* Clase que provee conexion via el connection Provider
InyectedDataSourceConnectionProvider
* dicha conexion es proxy de otro usuario, para implementar proxy
authentication de oracle
* Para especificar que se utilice esta clase, hay que hacerlo via la propiedad
* hibernate.connection.provider_class del archivo persistence.xml
* @author Julian de Anquin
*/
public class ProxyAuthenticationConnectionProviderImpl extends
InjectedDataSourceConnectionProvider {
   private final Logger log =
       LoggerFactory.getLogger(ProxyAuthenticationConnectionProviderImpl.class);

   public ProxyAuthenticationConnectionProviderImpl() {
   }

   @Override
   public void setDataSource(DataSource ds) {
       super.setDataSource(ds);

   }


   @Override
   public Connection getConnection() throws SQLException {


       String nombreDeUsuario = UserThreadLocal.getUser();
       if (nombreDeUsuario != null) {
           return setUserForConnection(super.getConnection(),
                                       nombreDeUsuario);
       } else {
           return super.getConnection();
       }

   }

   private Connection setUserForConnection(Connection pConn,
                                           String userName) throws
SQLException {
       try {
           OracleConnection conn = (OracleConnection)pConn;
           Properties prop = new Properties();
           prop.setProperty(OracleConnection.PROXY_USER_NAME, userName);
           System.out.println("seteando autenticacion para " + userName);
           conn.openProxySession(OracleConnection.PROXYTYPE_USER_NAME, prop);

           return conn;
       } catch (SQLException e) {
           e.printStackTrace(System.err);
           throw e;
       }
   }

   /**
    * Verifica que la conexion sea una session proxy, en caso
afirmativo la cierra dicha session.
    * @param pConn
    */
   private void closeProxyConnection(Connection pConn) {
       try {
           OracleConnection conn = (OracleConnection)pConn;

           if (conn.isProxySession()) {
               conn.close(OracleConnection.PROXY_SESSION);
           }
       } catch (Exception e) {
           e.printStackTrace();
       }
   }

   /**
    * Cierra una conexion primero llamando al metodo closeProxyConnection,
    * luego al de la clase padre
    * @param conn
    * @throws SQLException
    */
   @Override
   public void closeConnection(Connection conn) throws SQLException {
        this.closeProxyConnection(conn);

       super.closeConnection(conn);
   }

}


Top
 Profile  
 
 Post subject: Re: Using Oracle Proxy Authentication
PostPosted: Thu Sep 17, 2009 5:38 pm 
Newbie

Joined: Thu Feb 05, 2009 3:37 pm
Posts: 13
Here is my implementation of the threadlocal pattern. If you are using ejb and a security provider you can use identity propagation in order to "see" the user in the ejbcontext. If this is the case you can use an ejb interceptor in order to populate de threadlocal with the user, because the ejbcontext its not accesible from the connectionprovider
Code:
public class UserThreadLocal {
    private static final ThreadLocal currentSession = new ThreadLocal();

    public UserThreadLocal() {
    }

    public static void setUser(String user) {
        currentSession.set(user);
    }

    public static String getUser() {
        return (String)currentSession.get();
    }

}


Top
 Profile  
 
 Post subject: I can't understand how all it works !!! Help!
PostPosted: Thu Oct 22, 2009 7:19 am 
Newbie

Joined: Thu Oct 22, 2009 7:07 am
Posts: 10
Hi!
Does anybody have working sample of how to use oracle proxy authentification with hibernate?
How must be configured hibernate.cfg.xml hibernate to undersand it must use proxy authentification?
Post please your sample hibernate configuration!!!
Thanks in advance


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 33 posts ]  Go to page 1, 2, 3  Next

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.