sg_aps(jboss7)資料來源密碼加密解密
參考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