Jasypt Encrypting the database password in hibernate.cfg.xml
2014-03-17 08:02
309 查看
For those applications that define datasources in Hibernate's hibernate.cfg.xml file, Jasypt provides two Connection Provider (org.hibernate.connection.ConnectionProvider) implementations which let the user declare the datasource
parameters (driver, url, username and password) in an encrypted manner:
org.jasypt.hibernate3|hibernate4.connectionprovider.EncryptedPasswordDriverManagerConnectionProvider, which extends Hibernate's Driver Manager connection provider (a very simplistic pool implementation).
org.jasypt.hibernate3|hibernate4.connectionprovider.EncryptedPasswordC3P0ConnectionProvider, which extends Hibernate's C3P0-based connection provider.
They are used like this in hibernate.cfg.xml:
In this configuration, Hibernate is told to use Jasypt's DriverManager-based connection provider and is passed a set of configuration parameters which contain an encrypted value, the connection.password property. Then, Hibernate is also told about
which is the encryptor object to be used for decrypting the encrypted parameters (connection.encryptor_registered_name).
This encryptor object should have been registered beforehand as a Hibernate Encryptor, as explained in the 'Transparent data encryption' section.
注:本文转载自:http://www.jasypt.org/hibernate.html
parameters (driver, url, username and password) in an encrypted manner:
org.jasypt.hibernate3|hibernate4.connectionprovider.EncryptedPasswordDriverManagerConnectionProvider, which extends Hibernate's Driver Manager connection provider (a very simplistic pool implementation).
org.jasypt.hibernate3|hibernate4.connectionprovider.EncryptedPasswordC3P0ConnectionProvider, which extends Hibernate's C3P0-based connection provider.
They are used like this in hibernate.cfg.xml:
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="connection.provider_class"> org.jasypt.hibernate4.connectionprovider.EncryptedPasswordDriverManagerConnectionProvider </property> <property name="connection.encryptor_registered_name"> configurationHibernateEncryptor </property> <property name="connection.url">jdbc:mysql://localhost/reportsdb</property> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.username">reportsUser</property> <property name="connection.password">ENC(G6N718UuyPE5bHyWKyuLQSm02auQPUtm)</property> <property name="connection.pool_size">12</property> <property name="show_sql">true</property> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <!-- Mappings etc... --> </session-factory> </hibernate-configuration>
In this configuration, Hibernate is told to use Jasypt's DriverManager-based connection provider and is passed a set of configuration parameters which contain an encrypted value, the connection.password property. Then, Hibernate is also told about
which is the encryptor object to be used for decrypting the encrypted parameters (connection.encryptor_registered_name).
This encryptor object should have been registered beforehand as a Hibernate Encryptor, as explained in the 'Transparent data encryption' section.
注:本文转载自:http://www.jasypt.org/hibernate.html
相关文章推荐
- 关于在配置hibernate.cfg.xml时弹出的错误Unable to access java.sql.DatabaseMetaData to determine appropriate Dial
- web 项目中 打开 hibernate.cfg.xml 文件时 提示:The project is not a myEclipse hibernate project
- (转)hibernate.cfg.xml:The file cannot be validated as there was a connection problem
- web 项目中打开 hibernate.cfg.xml 文件时 提示:The project is not a myEclipse hibernate project
- 35.You executed the command to create a password file in the database server:
- Encrypting columns in a database using jasypt
- using JS to control two select(html),the data can be loaded from database and XML,and show in the select
- hibernate.cfg.xml出错:The content of element type "property" must match "(meta*,(column|formula)*
- hibernate.cfg.xml出错:The content of element type "property" must match "(meta*,(column|formula)*
- Hibernate框架 主配置文件 Hibernate.cfg.xml 映射配置 说明
- Hibernate.cfg.xml配置文件解析
- Spring对hibernate配置文件hibernate.cfg.xml的集成,来取代hibernate.cfg.xml的配置
- Enabling the Oozie Web Console and use MySQL Database in Cloudera Manager 5.2
- 3.测试持久化对象的状态:hibernate.cfg.xml
- Hibernate异常:query specified join fetching, but the owner of the fetched association was not present in the select list
- Hibernate的配置文件hibernate.cfg.xml
- Understanding Caching in Hibernate – Part Two : The Query Cache
- hibernate.cfg.xml配置
- Error: mysql error: mysql: [Warning] Using a password on the command line interface can be insecure
- 3.多对多单向关联(用户对角色) hibernate.cfg.xml