惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
博客园_首页
H
Help Net Security
WordPress大学
WordPress大学
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
罗磊的独立博客
博客园 - 三生石上(FineUI控件)
B
Blog
I
InfoQ
SecWiki News
SecWiki News
T
Tailwind CSS Blog
Spread Privacy
Spread Privacy
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
Vulnerabilities – Threatpost
N
Netflix TechBlog - Medium
P
Palo Alto Networks Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Vercel News
Vercel News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
K
Kaspersky official blog
M
MIT News - Artificial intelligence
S
Schneier on Security
T
Threat Research - Cisco Blogs
F
Fortinet All Blogs
Cyberwarzone
Cyberwarzone
Scott Helme
Scott Helme
aimingoo的专栏
aimingoo的专栏
Martin Fowler
Martin Fowler
MyScale Blog
MyScale Blog
The Cloudflare Blog
Recent Announcements
Recent Announcements
Security Latest
Security Latest
G
GRAHAM CLULEY
IT之家
IT之家
Y
Y Combinator Blog
The Last Watchdog
The Last Watchdog
腾讯CDC
Google DeepMind News
Google DeepMind News
V
V2EX
S
Securelist
TaoSecurity Blog
TaoSecurity Blog
B
Blog RSS Feed
S
SegmentFault 最新的问题
博客园 - 叶小钗
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
Project Zero
Project Zero
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
F
Full Disclosure

博客园 - Daniel Pang

pcanywhere失去连接的一个解决方法 JS格式化日期字符串 - Daniel Pang - 博客园 [软件共享]将数据库中的数据导出为SQL脚本 对文件下载的补充 - Daniel Pang - 博客园 复制DataTable的一种方法 IBatisNet + Castle 开发相关文章 [IBatisNet]关于返回DataTable的一点问题 深圳电话订票基本步骤及所有的取票点地址电话 Automatic Transaction Management Facility 使用 - Daniel Pang IBatisnet Facility 的几种配置 - Daniel Pang Rational Rose 加载出错的问题 修改Sql server中列的属性脚本 字符串加密方法 ERP术语 英文对照(部分)(参考) 一个关于SQL2005的问题 动态加载TreeNode -- ComponentArt TreeView - Daniel Pang 使用IBatisNet + Castle 开发DotNet软件 JS--屏蔽浏览器右键菜单 Excel的导出操作 - Daniel Pang - 博客园
IBatisNet -- 保护你的配置文件及映射文件信息
Daniel Pang · 2007-01-17 · via 博客园 - Daniel Pang

      通常情况下我们在使用IBatisNet的时候,配置文件和映射文件都是暴露在外的,如果能进入到服务器,那么你的程序的操作数据库的SQL语句,数据库连接字符串等信息都将很轻松的被看到,这样是很危险的。然而IBatisnet自身也没有提供配置文件直接加密的方法,但我们可以用变通的方式来尽可能的保护这些文件中的信息。IBatisnet的映射文件等可以指定为内嵌的资源,利用这个我们可以把一些敏感信息写到另外一个配置文件中,并设置这个配置文件的Build Action为embedded Resource。具体操作如下:

一、假设我们映射文件的路径为 ~@Maps/,我们将所有的映射文件都设置为“内嵌的资源”,SqlMap.config文件直接在根目录下。

二、建立一个properties.config文件,添加一些敏感信息(即不能直接让别人看到的信息)。如下:

<?xml version="1.0" encoding="utf-8" ?>
<settings>
  
<!--   User application and configured property settings go here.-->
  
<!--   Example: <add key="settingName" value="settingValue"/> -->
  
<add key="provider" value="sqlServer1.1" />
  
<add 
        
key="connectionString" 
        value
="server=.;database=DocumentSystem;uid=sa;pwd=" />
  
<add key="root" value="TVSystem.Web._Maps." />
  
<add key="assembly" value="TVSystem.Web" />
</settings>

三、SqlMap.config文件的配置

<?xml version="1.0" encoding="utf-8"?>
<sqlMapConfig 
  
xmlns="http://ibatis.apache.org/dataMapper" 
  xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance">

  
<properties embedded="TVSystem.Web.properties.config" />
  
<settings>
        
<setting useStatementNamespaces="false"/>
    
</settings>

  
<providers resource="providers.config"/>

  
<!-- Database connection information -->
  
<database>
    
<provider name="${provider}"/>
    
<dataSource name="DocumentSystem" connectionString="${connectionString}"/>
  
</database>

    
<sqlMaps>
    
<sqlMap embedded="${root}Department.xml,${assembly}" />
    
<sqlMap embedded="${root}Stream.xml,${assembly}" />
    
<sqlMap embedded="${root}Employees.xml,${assembly}" />
    
<sqlMap embedded="${root}Relations.xml,${assembly}" />
  
</sqlMaps>
    
</sqlMapConfig>

这样发布后的代码中,只能看到SqlMap.config中的内容,映射文件和数据库连接字符串等信息就被编译到DLL中去了。