Joined: Wed Mar 05, 2014 1:16 pm Posts: 4
|
I used Jasypt to encrypt a pw and followed the instruction as below but I have a run time error of "java.lang.ClassNotFoundException: org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider". Did the new API and their implementation break Jasypt? Is there other way to do this? Thanks in advance.
My hibernate.cfg.xml:
<property name="hibernate.connection.encryptor_registered_name">configurationHibernateEncryptor </property> <property name="hibernate.connection.algorithm">PBEWithMD5AndTripleDES</property> <property name="hibernate.connection.password">ENC(E32KfS4Vgl4uCdFb1R3Eq3XQNsDkPyAkl)</property>
My code:
StandardPBEStringEncryptor myEncryptor = new StandardPBEStringEncryptor(); myEncryptor.setPassword("JDBC_PASSWORD"); myEncryptor.setAlgorithm("PBEWithMD5AndTripleDES"); myEncryptor.setKeyObtentionIterations(2000); HibernatePBEEncryptorRegistry registry = HibernatePBEEncryptorRegistry.getInstance(); registry.registerPBEStringEncryptor("configurationHibernateEncryptor", myEncryptor);
Configuration config = new Configuration(); URL url = DbManager.class.getClassLoader().getResource("db/hibernate.cfg.xml");
StandardServiceRegistryBuilder serviceBuilder = new StandardServiceRegistryBuilder();
serviceBuilder.applySettings(config.getProperties()); StandardServiceRegistry serviceReg = serviceBuilder.build(); sessionFactory = config.buildSessionFactory(serviceReg);
|
|