参考https://blog.csdn.net/heweimingming/article/details/54668803
1,首先将sg-aps下
/home/tyfwfw/uap/sg_aps-V1.0.0/modules/org/picketbox/main/picketbox-4.0.13.Final.jar;/home/tyfwfw/uap/sg_aps-V1.0.0/modules/org/jboss/logging/main/jboss-logging-3.1.2.GA.jar
两个jar包下到本地。如D:\jbosslib下
2,cmd 进入 D:\jbosslib执行
java -cp picketbox-4.0.13.Final.jar;jboss-logging-3.1.2.GA.jar org.picketbox.datasource.security.SecureIdentityLoginModule 123456
3,进入/home/tyfwfw/uap/sg_aps-V1.0.0/standalone/configuration首先备份standalone-sg.xml,然后修改standalone-sg.xml
首先将
<security>
<user-name>root</user-name>
<password>123456</password>
</security>
换成
<security> <security-domain>EncryptedPassword</security-domain>
</security>
然后在<subsystem xmlns="urn:jboss:domain:security:1.2">下 加入
<security-domain name="EncryptedPassword">
<authentication>
<login-module code="SecureIdentity" flag="required">
<module-option name="username" value="root"/>
<module-option name="password" value="64c5fd2979a86168"/>
</login-module>
</authentication>
</security-domain>
4,关于数据源密码解密
通过反编译picketbox-4.0.13.Final.jar下org.picketbox.datasource.security.SecureIdentityLoginModule.class
可以看到加密使用的是: private static String encode(String secret)
自然解密的到是:private static char[] decode(String secret)
在Eclipse下新建包 org.picketbox.datasource.security,新建SecureIdentityLoginModule.java 和PasswordDecoder.java
SecureIdentityLoginModule.java(这个类只是为了能让 PasswordDecoder 编译通过,没有实际意义)
package org.picketbox.datasource.security;
public class SecureIdentityLoginModule {
private static String encode(String secret) {
return secret;
}
private static char[] decode(String secret) {
System.out.println("Input password: " + secret);
return new char[] { '0', '1', '2', '3', '4', '5' };
}
}
package org.picketbox.datasource.security;
import java.lang.reflect.Method;
/**
* Decode the encoded password.
*
* @author 酒樽舞曲
*
*/
public class PasswordDecoder {
public static void main(String args[]) throws Exception {
Class<SecureIdentityLoginModule> cla = SecureIdentityLoginModule.class;
Method m = cla.getDeclaredMethod("decode", String.class);
m.setAccessible(true);
Object obj = m.invoke(null, args[0]);
char[] chars = (char[]) obj;
System.out.println("Decoded password: " + new String(chars));
}
}
java -cp picketbox-4.0.13.Final.jar;jboss-logging-3.1.2.GA.jar org.picketbox.datasource.security.PasswordDecoder 64c5fd2979a86168