-->
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.  [ 1 post ] 
Author Message
 Post subject: encrypting password with jasypt causes error in QuartzDataSo
PostPosted: Mon May 04, 2009 6:54 pm 
Newbie

Joined: Mon May 04, 2009 6:37 pm
Posts: 1
HI ,
I have encryptyed the database password using jasypt and followed the steps mentioned in the jasypt doc. I see the password being decrypted in the logs and am able to get the connection to retrieve other hibernate objects however in the QuartzDataSource configuration when I inject the same sessionFactory it cannot get the connection to the database and throws this error.

java.sql.SQLException: Can't allocate JDBC connection
QuartzDataSource.getConnection(QuartzDataSource.java:101)
at org.quartz.utils.DBConnectionManager.getConnection(DBConnectionManager.java:111)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.getConnection(JobStoreSupport.java:553)
at org.quartz.impl.jdbcjobstore.JobStoreTX.acquireNextTrigger(JobStoreTX.java:1169)
at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:233)

Here is my configuration:
db-cfg.xml
<hibernate-configuration>
<session-factory name="hibernateSessionFactory">

<property name="connection.provider_class">
org.jasypt.hibernate.connectionprovider.EncryptedPasswordDriverManagerConnectionProvider
</property>

<property name="connection.encryptor_registered_name">myHibernateEncryptor</property>
<property name="hibernate.connection.username">admin</property>
<property name="hibernate.connection.password">ENC(M8ieDrGgEWj8x7a6X00baA==)</property>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">jdbc:postgresql://127.0.0.1/cemdb</property>
</session-factory>
</hibernate-configuration>



data-objects.xml
<bean id="hibernateStringEncryptor" class="org.jasypt.hibernate.encryptor.HibernatePBEStringEncryptor">
<property name="registeredName">
<value>myHibernateEncryptor</value>
</property>
<property name="algorithm">
<value>PBEWithMD5AndDES</value>
</property>
<property name="password">
<value>pwdkey</value>
</property>
</bean>

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocations">
<list>
<value>classpath:hibernate.cfg.xml</value>
</list>
</property>
</bean>

jsayptHibernateTypes.hbm.xml
<hibernate-mapping>

<!-- VARCHAR, CLOB, TEXT based types -->
<typedef name="encryptedString" class="org.jasypt.hibernate.type.EncryptedStringType">
<param name="encryptorRegisteredName">myHibernateEncryptor</param>
</typedef>
</hibernate-mapping>

mapping in hibernate.cfg.xml

<mapping resource="jasyptHibernateTypes.hbm.xml "/>

NOTE: When I remove the encryption quartz is able to obtain a connection to the database.

Here is the snippet of the code that gets the connection. Remember that sessionFactory is injected in here....

public Connection getConnection() throws SQLException
{
Connection conn = null;

synchronized (sessions)
{
if (stopping) throw new SQLException("Tess terminating");

// clean up sessions with closed connections
cleanupSessions();

// allocate a new session/connection
for (int i = 0; i < sessions.length; ++i)
{
if (sessions[i] == null)
{
if (sessionFactory != null)
{
sessions[i] = (SessionImpl) sessionFactory.openSession();
conn = sessions[i].getJDBCContext().getConnectionManager().getConnection();
}
break;
}
}
}

Any ideas/suggestions as to whats going on .

Thanks in advance.
Noel.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.