I need a help on getting database passwod encryption in hibernate.cfg.xml.
I have followed hibernate + jasypt forum/procedure to encrypt hibernate.cfg.xml content (database password) and retrieving through registering the encryptor before creating database session.
1. my hibernate.cfg.xml contains following lines:
<property name=”connection.provider_class”>
org.jasypt.hibernate.connectionprovider.EncryptedPasswordDriverManagerConnectionProvider
</property>
<property name=”connection.encryptor_registered_name”>
configurationHibernateEncryptor
</property>
.
.
.
<property name=”connection.password”>ENC(NIB1ua0P4w2DhJoVjX+Uag==)</property>
2. Added following lines in HiberateSessionFactory.java before getting session (basically registering the jasypt encryptor)
StandardPBEStringEncryptor strongEncryptor = new StandardPBEStringEncryptor();
strongEncryptor.setAlgorithm(“PBEWithMD5AndDES”);
strongEncryptor.setPassword(“mypassword”);
HibernatePBEEncryptorRegistry registry = HibernatePBEEncryptorRegistry.getInstance();
registry.registerPBEStringEncryptor(“configurationHibernateEncryptor”, strongEncryptor);
But after these 2 steps, part of HibernateSessionFactory which gets session
sessionFactory = configuration.buildSessionFactory();
hangs for every. It does not even throws any exception.
Could you please confirm whether these steps are correct or any example code available to implement JASYPT for hiberate.cfg.xml encryption.
Thanks in advance
Manoj.