如何解密jboss login-config.xml中的密码?

dur*_*sun 4 java jboss password-encryption

是否有jboss提供的API可以用来访问login-config.xml并解密加密的密码?

Mar*_*ger 6

"jaas就是这种方式"至少对于较旧的jboss版本(4.x)来说是默认键.你可以尝试这样的东西来解码编码的字节.

    public static String decode( String secret ) {
    String retString = "";
    try {
        byte[] kbytes = "jaas is the way".getBytes();
        SecretKeySpec key = new SecretKeySpec( kbytes, "Blowfish" );

        BigInteger n = new BigInteger( secret, 16 );
        byte[] encoding = n.toByteArray();

        Cipher cipher = Cipher.getInstance( "Blowfish" );
        cipher.init( Cipher.DECRYPT_MODE, key );
        byte[] decode = cipher.doFinal( encoding );
        retString = new String( decode );
    } catch (Exception ignore) {
        ignore.printStackTrace();
    }

    return retString;
}
Run Code Online (Sandbox Code Playgroud)

一些额外的信息

https://docs.jboss.org/jbossas/javadoc/4.0.2/org/jboss/resource/security/SecureIdentityLoginModule.java.html

http://www.docjar.com/html/api/org/jboss/resource/security/SecureIdentityLoginModule.java.html