1 Reply Latest reply on Oct 21, 2011 3:42 PM by stevemaring

    JAAS LoginModule as source of DB conn creds?

    stevemaring

      Normally, we develop apps that use a single set of credentials to create database connections within the pool.

       

      We specifiy those in the login.xml using SecureIdentityLoginModule

       

      Now, I'm developing an application that is for support personel.  They are granted specific write permission to the production database for short periods of time while they make specific modifications.  They connect with their own set of credentials.

       

      So, I would like to prompt the user for their database credentials and use those as a basis for creating connections.

       

      I know I could declare <application-managed-security/> in the datasource config, and then do a DataSource.getConnection(username,password) in my DAOs to get a connection, but I don't want to do straight JDBC.  I have a nice set of JPA entities and a whole bunch of criteria queries.

       

      Is there a way to have more control over the connection process, using a specific set of credentials at runtime, and still make use of EntityManager?

       

      Thanks for your thoughts.

       

      -Steve Maring

      Tampa, FL

        • 1. Re: JAAS LoginModule as source of DB conn creds?
          stevemaring

          I tried this ....

           

          @PersistenceUnit(name="myPU")

          private EntityManagerFactory emf;

           

          Properties map = new Properties();

          map.put("hibernate.connection.username", "myuser");

          map.put("hibernate.connection.password", "mypass");

           

          EntityManager entityManager = emf.createEntityManager(map);

           

           

          but I got a runtime error of ...

           

          java.sql.SQLException: Invalid Oracle URL specified

          which makes me think that it is now ignoring my xa-datasource