JBoss Community

Re: Datasource security

created by Nicolas Davyt in Datasource Configuration - View the full discussion

Maybe you cant try with define 2 or 3 <jndi-name> with diferent username and password with respective privileges defined at the database. (only select, full acces, etc)

 

<local-tx-datasource>
    <jndi-name>TradeTestOracle_ONLY_SELECT_DS</jndi-name>
    <connection-url>jdbc:oracle:thin:@trmpd_pkg.bankers.com:1521:trmpd</connection-url>
    <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
    <max-pool-size>100</max-pool-size>
    <user-name>boatradeONLY_SELECT</user-name>
    <password>test1</password>
    <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
    <metadata>
      <type-mapping>Oracle9i</type-mapping>
    </metadata>
  </local-tx-datasource>

 

<local-tx-datasource>
    <jndi-name>TradeTestOracle_ALL_ACCESS_DS</jndi-name>
    <connection-url>jdbc:oracle:thin:@trmpd_pkg.bankers.com:1521:trmpd</connection-url>
    <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
    <max-pool-size>100</max-pool-size>
    <user-name>boatrade
_ALL_ACCESS_</user-name>
    <password>test1</password>
    <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
    <metadata>
      <type-mapping>Oracle9i</type-mapping>
    </metadata>
  </local-tx-datasource>

 

And in you code like for example:   (in your dataBase Connection class.)

 

public static Connection getConnection( User user)

 

......

if (user.equals("Bob"))

     ds = (DataSource) iniCtx.lookup("TradeTestOracle_ONLY_SELECT_DS");

else if (user.equals("John"))

     ds = (DataSource) iniCtx.lookup("TradeTestOracle_ALL_ACCESS_DS");

.......

Reply to this message by going to Community

Start a new discussion in Datasource Configuration at Community