Dealing with different versions of Hibernate libs
I have an existing application using a DB called EXAMPLE, which uses a kind-of-old version of hibernate.
Users' passwords are stored as org.jasypt.hibernate.type.EncryptedStringType
<typedef name="encryptedString" class="org.jasypt.hibernate.type.EncryptedStringType">
<param name="encryptorRegisteredName">jasyptHibernateEncryptor</param>
</typedef>
<property name="password" type="encryptedString">
<column name="pwd" length="254" not-null="true" />
</property>
I don't know if it's always like this but basically, when querying for a user, it automatically decrypts their password so it is in clear text.
开发者_如何学编程Now, on the very same database, there is a new web application running (call it webapp2). This one encrypts passwords differently and in an undecryptable way.
What I was asked to do is migrate the old users to "the new way", and what I did was to create a maven project with 3 modules:
- module1 (aka oldie) should just be able to query the database in the old way (so that for every query on the user table I can have the user's password in clear text)
- module2 (aka newie) should just query the database in the new way.
- module3 should have one dummy class (for now it's a junit thingy) that uses UserService from module1 and UserService from module2 respectively for read users password (clear text) and set it back the new way.
THE ISSUE: What I'm facing is a whole lot of issues with module3 having to deal with different versions of hibernate libs and what not.
On my configuration of module3 (they're all spring applications) I'm autowiring services and daos from both module1 and module2 making a lot of mess which ends up in trouble.
What appears to be happening is that there's a mix of dependencies that makes instantiations of sessionFactories or daos (for now) impossible.
Any help will be appreciated.
I wouldn't try to use both versions of Hibernate at the same time. You could
- extract both encryption/decryption parts in a small utility class, and just use JDBC to decrypt using the old way and encrypt using the new way.
- or just run a first pass with the first module to extract all the passwords in clear text and put them in a file or in a dedicated database table, then run a second pass with the second module to extract the clear text passwords and store them in the entities to encrypt them using the new method.
精彩评论