在数据源中使用身份验证别名有什么好处?

时间:2015-06-26 20:49:59

标签: authentication encryption encoding datasource websphere-liberty

当我在WebSphere Liberty中的user

中添加包含passwordserver.xml属性的数据源时

示例:

<dataSource jdbcDriverRef="db2-driver" type="javax.sql.DataSource">
  <properties.db2.jcc user="MyUser" password="MyPassword"
                databaseName="dbName" serverName="localhost" portNumber="50000"/>
</dataSource>

我在日志中收到以下警告:

J2CA8050I: An authentication alias should be used instead of defining a user name 
           and password on dataSource[default-0].

Configuring authentication aliases for the Liberty profile中查看如何执行此操作我看到他们将userpassword放在另一个名为authData的元素中,如下所示:

<authData id="auth1" user="MyUser" password="MyPassword"/>

我不知道将用户名和密码从dataSource元素移动到authData元素给我带来了什么好处。在这两种情况下,密码都以server.xml文件中的纯文本显示。

2 个答案:

答案 0 :(得分:2)

WebSphere Liberty使用适配器来管理它的数据库连接。通过指定身份验证别名,适配器使用的密码将被加密。如果不使用auth别名,则将在不对加密器属性进行加密的情况下存储用户标识和密码。

此外,别名提供了另一层抽象,因为别名本身就是一种资源。这样做的好处是,如果需要更改数据库用户/密码并且配置了许多数据源,则可以单独配置别名,它们都可以指向相同的身份验证数据。

使用wlp / bin目录中的securityUtility encode命令对server.xml中的密码进行编码。

答案 1 :(得分:2)

如果您通过WebSphere Developer Tools(WDT)添加身份验证数据,则在设置密码期间将提示您对其进行编码(xor)/加密(aes)。它将保存在server.xml中,例如:

<authData user="user" password="{xor}Lz4sLCgwLTs="></authData>