如何配置Hibernate使用SSL与数据库服务器通信? [英] How can I configure Hibernate to use SSL to talk to the DB server?

查看:538
本文介绍了如何配置Hibernate使用SSL与数据库服务器通信?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个现有的java webapp使用Hibernate的持久性。我被告知,我必须与数据库加密谈 - 所以我的第一个想法是设置它通过SSL进行通信 - 并经过了解如何设置Oracle侦听基于SSL的JDBC -

I have an existing java webapp that uses Hibernate for it's persistence. I've been told that I have to have to talk to the DB encrypted - so my first thought is to set it up to do the communication via SSL - and went through figured out how to set up Oracle to listen for JDBC over SSL -

http://www.oracle.com/technology/tech/java/sqlj_jdbc/pdf/wp-oracle-jdbc_thin_ssl_2007.pdf

写了一个快速测试类来验证它是否已经安装和工作(通过标准JDBC连接)。这让我讨论配置Hibernate的问题 - 不幸的是我不知道hibernate如何支持它?

And wrote a quick test class to verify that it was setup and working (connecting via standard JDBC). That left me with the issue of configuring Hibernate - unfortunately I don't see how hibernate supports it?

推荐答案

Hibernate使用标准JDBC数据源,因此不需要Hibernate特定的配置。

Hibernate works with standard JDBC data sources, so there is no need for Hibernate-specific configuration.

这是一个快速的例子,应该工作时配置Hibernate与Spring:

Here's an quick example that should work when configuring Hibernate with Spring:

<bean id="dataSource" class="oracle.jdbc.pool.OracleDataSource">
    <property name="URL"><value><!-- JDBC URL that specifies SSL connection --></value></property>
    <!-- other relevant properties, like user and password -->
    <property name="connectionProperties>
        <value>
            oracle.net.ssl_cipher_suites: (ssl_rsa_export_with_rc4_40_md5, ssl_rsa_export_with_des40_cbc_sha)
            oracle.net.ssl_client_authentication: false
            oracle.net.ssl_version: 3.0
            oracle.net.encryption_client: REJECTED 
            oracle.net.crypto_checksum_client: REJECTED
        </value>
    </property>
</bean>

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <!-- classes etc -->
</bean>

这篇关于如何配置Hibernate使用SSL与数据库服务器通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆