我们有一个db.properties包含数据库访问凭据的属性文件(例如 )。例子:
db.jdbc.user=johndoe 
db.jdbc.password=topsecret
我们有许多 ant 脚本来读取这个文件并执行各种任务。例子:
<!--Initialize the environment-->
<target name="environment">
<!--Read database connection properties-->
    <property file="$../db.properties"/>
    ...
</target>
<target name="dbping"
    description="Test the database connectivity with the current settings."
    depends="environment">
    ...
    <sql driver="oracle.jdbc.OracleDriver"
         url="${db.jdbc.url}"
         userid="${db.jdbc.user}"
         password="${db.jdbc.password}"
         classpathref="classpath.jdbc"
         print="true"
         showheaders="false">
         SELECT 'JDBC connect: successful!' FROM dual;
    </sql>
    ...
</target>
现在客户端希望使用 .jar 文件中提供的加密库对 db.properties 中的密码进行加密,例如:
db.jdbc.user=johndoe
db.jdbc.password.encrypted=true
db.jdbc.password=018Dal0AdnE=|ySHZl0FsnYOvM+114Q1hNA==
我们想要的是通过对大量 ant 文件的最小修改来实现解密。我听说过增强的属性处理Ant 1.8,但我们使用Ant 1.7.1.
什么是最好的解决方案 - 自定义任务,PropertyHelper实例的一些魔力,还有什么?
提前感谢您的提示。