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


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值