Java JBoss AS 7.1-数据源如何加密密码
在JBossAS5中,我在*-ds.xml中定义了一个数据源,但在*-JBoss-beans.xml中放置了用户名/加密密码 现在在JBossAS7.1中,数据源是在standalone.xml或domain.xml中定义的。 AS 7.1中的加密密码放在哪里Java JBoss AS 7.1-数据源如何加密密码,java,security,jboss,password-protection,jboss7.x,Java,Security,Jboss,Password Protection,Jboss7.x,在JBossAS5中,我在*-ds.xml中定义了一个数据源,但在*-JBoss-beans.xml中放置了用户名/加密密码 现在在JBossAS7.1中,数据源是在standalone.xml或domain.xml中定义的。 AS 7.1中的加密密码放在哪里 换句话说,AS 7中的明文密码是如何加密和保护的?在AS7中,您可以使用SecureIdentityLogin模块添加加密的密码域。例如,您可以在standalone.xml或domain.xml中定义安全域: <security-
换句话说,AS 7中的明文密码是如何加密和保护的?在AS7中,您可以使用SecureIdentityLogin模块添加加密的密码域。例如,您可以在standalone.xml或domain.xml中定义安全域:
<security-domain name="EncryptedPassword">
<authentication>
<login-module code="SecureIdentity" flag="required">
<module-option name="username" value="test"/>
<module-option name="password" value="encrypted_password"/>
</login-module>
</authentication>
</security-domain>
. 由于是开源的,您可以在的源代码中看到编码代码是如何工作的。您将在源代码中注意到它使用了河豚进行加密。下面是Jboss AS-7的完整安全域配置:
<security-domains>
<!-- Security Setting's -->
<security-domain name="encryptedSecurity" cache-type="default">
<authentication>
<login-module code="org.picketbox.datasource.security.SecureIdentityLoginModule" flag="required">
<module-option name="username" value="user_name"/>
<module-option name="password" value="encrypted_password"/>
<module-option name="managedConnectionFactoryName" value="jboss.jca:service=LocalTxCM,name=dataSource-1-PoolName,dataSource-2-PoolName"/>
</login-module>
</authentication>
</security-domain>
在CentOS 6.3版JBoss-EAP-6.0.0环境中,这只适用于code=“SecureIdentity”,
使用picketbox-4.0.9.Final-redhat-1.jar进行密码加密
<security-domain name="some-ds-EncryptedPassword">
<authentication>
<login-module code="SecureIdentity" flag="required">
<module-option name="username" value="username"/>
<module-option name="password" value="encrypted_password"/>
</login-module>
</authentication>
</security-domain>
使用JAR创建简单项目(
jboss-logging-3.1.4.GA-redhat-2.jar
picketbox-4.1.1.Final-redhat-1.jar
picketbox-commons-1.0.0.final-redhat-3.jar
picketbox-infinispan-4.1.1.Final-redhat-1.jar)并使用输入参数运行自定义类:
public class Test {
public static void main(String[] args) throws Exception {
new org.picketbox.datasource.security.SecureIdentityLoginModule()
.main(args);
}
}
输出将是:编码密码:3d5bc094c128…,用于有兴趣在windows上运行此功能的用户(在我的例子中,是在JBoss EAP 6.4…)
希望这有帮助,
Matteo另请参见shatk的答案,需要提供ManagedConnectionFactoryRename模块选项。描述这些步骤和完整数据源文件的博客实际上可以为多个数据源提供相同的安全模块吗?我一直在阅读jboss文档,他们只提到一个数据源:jboss.jca:service={type},name={jndiName}。我看到您指定了name=dataSource-1-PoolName,dataSource-2-PoolName
<security-domain name="some-ds-EncryptedPassword">
<authentication>
<login-module code="SecureIdentity" flag="required">
<module-option name="username" value="username"/>
<module-option name="password" value="encrypted_password"/>
</login-module>
</authentication>
</security-domain>
public class Test {
public static void main(String[] args) throws Exception {
new org.picketbox.datasource.security.SecureIdentityLoginModule()
.main(args);
}
}
set JBOSS_HOME=C:\dev\jboss\jboss-eap-6.4
set MYPATH=%JBOSS_HOME%\modules\system\layers\base\org\picketbox\main\picketbox-4.1.1.Final-redhat-1.
jar;%JBOSS_HOME%\modules\system\layers\base\org\jboss\logging\main\jboss-logging-3.1.4.GA-redhat-2.jar;
java -classpath %MYPATH% org.picketbox.datasource.security.SecureIdentityLoginModule SecretPass
Encoded password: 13e0362237c93a9cda89f5b3da271521