Mutli oralce Datasource Password Encryption in Jboss

284 Views Asked by At

I need to configure encrypted password for Jboss. Right now i have direct username password in oracle-ds.xml.

https://docs.jboss.org/jbosssecurity/docs/6.0/security_guide/html/Encrypting_Data_Source_Passwords.html

After going through above Url, I removed username and password from oracle-ds.xml and added a new policy in login-config.xml and mapped the policy in oralce-ds.xml.

Its working fine, in case of single JNDI-name. (Single datasource)

In another application i have 5 data sources in Oracle-ds.xml.

1) I tried adding different policies in login-config and mapped respective in oracle-ds.xml - But it is not working

2) And I tried adding login-module under single policy, - But failed

Can someone help me on this?

2

There are 2 best solutions below

0
JimCovington On BEST ANSWER

If you simply need to map your Oracle connection to N different JNDI names due to the names stored in your applications' persistence.xml, you can use the concept of aliasing.

<mbean code="org.jboss.naming.NamingAlias" 
   name="jboss.jca:name=jdbc/myFirstDS,service=DataSourceBinding">
<attribute name="ToName">java:jdbc/mySecondDS</attribute>
<attribute name="FromName">java:jdbc/myFirstDS</attribute>
</mbean>
0
Connor McDonald On

I have not tried this explicitly in Jboss, but perhaps easier option is to not have passwords (plain or encrypted) stored in your configuration files, but in an Oracle wallet?

You can create a wallet so that the passwords are stored encrypted in there, and then the connection information would be:

<module-option name="username">/</module-option>
<module-option name="password"></module-option>

You configure the wallet and set it up like this:

mkstore -create -wrl c:\oracle\wallet
mkstore -wrl c:\oracle\wallet -createCredential MYDB scott tiger

where user = scott, password = tiger, for the database "MYDB", with sqlnet.ora pointing to where the wallet is:

SQLNET.WALLET_OVERRIDE=TRUE
WALLET_LOCATION=(SOURCE=(METHOD=FILE)(METHOD_DATA=(DIRECTORY=c:\oracle\wallet)))

You can find a fully worked example here:

https://connor-mcdonald.com/2015/09/21/connection-shortcuts-with-a-wallet/