I want that hibernate get the encrypted password from C:\jboss-3.2.7\server\default\conf\login-config.xml programatically. Problem is somewhere in step 3. How to tell the Configuration to get the encrypted password from the login-config.xml. I got the following exception
javax.ejb.EJBException: Couldn't create resource The user must supply a JDBC connection
Using the following configuration.
1: in login-config.xml
<application-policy name="EncryptDBPassword">
<authentication>
<login-module code="org.jboss.resource.security.SecureIdentityLoginModule" flag="required">
<module-option name="username">root</module-option>
<module-option name="password">5b11a0839b6fa9be6eaf1b129639c6a8</module-option>
<module-option name="managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=jdbc/dataSource</module-option>
</login-module>
</authentication>
</application-policy>
2: in C:\jboss-3.2.7\server\default\deploy\mysql-ds.xml
<local-tx-datasource>
<jndi-name>jdbc/dataSource</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/test</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<!--user-name>root</user-name>
<password>Nb/U4LQbFbyi9p0Q7LUiJw==</password-->
<security-domain>EncryptDBPassword</security-domain>
<min-pool-size>5</min-pool-size>
<max-pool-size>20</max-pool-size>
<idle-timeout-minutes>5</idle-timeout-minutes>
</local-tx-datasource>
3: In Hibernate Util
Configuration configuration = new Configuration()
.addResource("com/test/hib/Employee.hbm.xml");
configuration.setProperty("hibernate.session_factory_name","jdbc/dataSource");
sessionFactory = configuration.buildSessionFactory();
|