Código PHP:
http://www.jasypt.org/hibernate.html
http://java-rd.blogspot.mx/2012/07/encrypting-hibernate-configuration-file.html
Código PHP:
<property name="connection.provider_class">org.jasypt.hibernate4.connectionprovider.EncryptedPasswordDriverManagerConnectionProvider</property>
<property name="connection.encryptor_registered_name">configurationHibernateEncryptor</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/aprendiendojsf?autoReconnect=true</property>
<property name="connection.username">root</property>
<property name="connection.password">ENC(lhFCMXdRkAw7Cz5JU17lvg==)</property>
<property name="show_sql">true</property>
<property name="current_session_context_class">thread</property>
Código PHP:
public class HibernateUtil {
private static SessionFactory sessionFactory = null;
static {
try {
// Create the SessionFactory from standard (hibernate.cfg.xml)
// config file.
sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
encryptor.setAlgorithm("PBEWithMD5AndDES");
encryptor.setPassword("clave");
HibernatePBEEncryptorRegistry registry = HibernatePBEEncryptorRegistry.getInstance();
registry.registerPBEStringEncryptor("configurationHibernateEncryptor", encryptor);
} catch (Throwable ex) {
// Log the exception.
System.err.println("Initial SessionFactory creation failed." + ex);
ex.printStackTrace();
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}
Código PHP:
INFO: HHH000046: Connection properties: {user=root, encryptor_registered_name=configurationHibernateEncryptor, password=****}
WARN: HHH000342: Could not obtain connection to query metadata : Could not create connection to database server. Attempted reconnect 3 times. Giving up.
Alguien que tenga experiencia y me pueda echar la mano,
Gracias