在jdbc代码中加密Oracle-Ds.xml和解密

时间:2013-04-09 05:30:35

标签: encryption jdbc jboss

服务器:JBOSS 5.x. 以下函数写在我的会话bean(ejb3体系结构)

@Remote(OracleDsInteractionRemote.class)
@Local(OracleDsInteractionLocal.class)

@Stateless
@RemoteBinding(jndiBinding="OracleDsInteractionBean/remote")
@LocalBinding(jndiBinding="OracleDsInteractionBean/local")

public class OracleDsInteractionBean implements OracleDsInteractionRemote,OracleDsInteractionLocal
{
@EJB    
@Resource(mappedName="java:/EncryptedDS") 
private DataSource ds1;

 public int getAllValues() throws Exception
{
    System.out.println("************************* ");
    Connection conn = ds1.getConnection();
    Statement st = conn.createStatement();
    String query = "SELECT count(*) FROM DETAILS_DATA";
    ResultSet rs = st.executeQuery(query);
    while (rs.next())
    {
        return rs.getInt(1);
    }
    return -1;

}
}

此函数使用jdbc连接从details_data表中检索行数。 DataSource对象ds1与'EncryptedDS'映射。 “加密DS”的输入在oracle-ds.xml中定义如下。

<?xml version="1.0" encoding="UTF-8"?>
 <!-- ===================================================================== -->
 <!--                                                                       -->
 <!--  JBoss Server Configuration                                           -->
 <datasources>
   <xa-datasource>
     <jndi-name>EncryptedDS</jndi-name>
     <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>

     <xa-datasource-property name="URL">jdbc:oracle:thin:@182.158.93.26:1521:dbSid</xa-datasource-property>

     <xa-datasource-property name="User">Test</xa-datasource-property>
     <xa-datasource-property name="Password">pass123</xa-datasource-property>

     <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>

        <metadata>
           <type-mapping>Oracle11g</type-mapping>
        </metadata>
    </xa-datasource>
   </datasources>

但问题是任何人都可以转到$ JBOSS_HOME / server / default / deploy目录并从oracle-ds.xml中找出'EncryptedDS'配置..(在oracle-ds.xml中,完整的数据库信息是用文本写的( DatabaseServerIP,港口,希德,的SchemaName,SchemaPassword))... 如何在oracle-ds.xml中存储加密的数据库信息?我的java代码将如何解码以进行jdbc连接?

0 个答案:

没有答案