如何配置Hibernate使用SSL与数据库服务器通信?

BZ.*_*BZ. 9 java configuration hibernate

我有一个现有的java webapp,它使用Hibernate来实现它的持久性.我被告知我必须加密与数据库加密 - 所以我的第一个想法是设置它来通过SSL进行通信 - 并通过想出如何设置Oracle来通过SSL监听JDBC -

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

并编写了一个快速测试类来验证它是否已设置并正常工作(通过标准JDBC连接).这让我遇到了配置Hibernate的问题 - 遗憾的是我没看到hibernate如何支持它?

and*_*dri 5

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

这是一个在使用Spring配置Hibernate时应该工作的快速示例:

<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>
Run Code Online (Sandbox Code Playgroud)