SSL 和 StandardPBEStringEncryptor 的 PowerMock 问题
PowerMock issues with ssl & StandardPBEStringEncryptor
正在尝试 运行 Junit 测试
- 下面是密码解密使用org.jasypt.encryption.pbe.StandardPBEStringEncryptor
> Caused by: org.jasypt.exceptions.EncryptionInitializationException:
> java.security.NoSuchAlgorithmException: PBEWithMD5AndDES
> SecretKeyFactory not available
> at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.initialize(StandardPBEByteEncryptor.java:716)
> at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.initialize(StandardPBEStringEncryptor.java:553)
> at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.decrypt(StandardPBEStringEncryptor.java:705)
> at com.optum.pdm.nameaddressstandardizer.PropertyFileLoader.getDecryptedValue(PropertyFileLoader.java:104)
> ... 29 more
> Caused by: java.security.NoSuchAlgorithmException: PBEWithMD5AndDES SecretKeyFactory not available
> at javax.crypto.SecretKeyFactory.<init>(SecretKeyFactory.java:121)
> at javax.crypto.SecretKeyFactory.getInstance(SecretKeyFactory.java:159)
> at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.initialize(StandardPBEByteEncryptor.java:703)
> ... 32 more
- TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm())
Caused by: java.security.NoSuchAlgorithmException: class configured for TrustManagerFactory: sun.security.ssl.TrustManagerFactoryImpl$PKIXFactory not a TrustManagerFactory
at sun.security.jca.GetInstance.checkSuperClass(GetInstance.java:258)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:237)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:164)
at javax.net.ssl.TrustManagerFactory.getInstance(TrustManagerFactory.java:138)
at com.optum.pdm.util.SSLConnectionHelper.getSslSocketFactory(SSLConnectionHelper.java:41)
at com.optum.pdm.util.SSLConnectionHelper.getSSLContext(SSLConnectionHelper.java:31)
... 33 more
- 当我在 Junit 上尝试使用 @PowerMockIgnore ("javax.crypto., javax.net.ssl.") 时,它仍然失败并出现上述密码解密问题
- 当我在 Junit 上使用一个 @PowerMockIgnore ("javax.crypto.*") 时,它因加载 jks 问题而失败
有什么办法可以解决这类问题
需要注释语法修正
语法错误:
@PowerMockIgnore ("javax.crypto.*, javax.net.ssl.*")
包含多项的正确语法:
@PowerMockIgnore({"org.apache.http.conn.ssl.*", "javax.net.ssl.*" , "javax.crypto.*"})
正在尝试 运行 Junit 测试
- 下面是密码解密使用org.jasypt.encryption.pbe.StandardPBEStringEncryptor
> Caused by: org.jasypt.exceptions.EncryptionInitializationException: > java.security.NoSuchAlgorithmException: PBEWithMD5AndDES > SecretKeyFactory not available > at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.initialize(StandardPBEByteEncryptor.java:716) > at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.initialize(StandardPBEStringEncryptor.java:553) > at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.decrypt(StandardPBEStringEncryptor.java:705) > at com.optum.pdm.nameaddressstandardizer.PropertyFileLoader.getDecryptedValue(PropertyFileLoader.java:104) > ... 29 more > Caused by: java.security.NoSuchAlgorithmException: PBEWithMD5AndDES SecretKeyFactory not available > at javax.crypto.SecretKeyFactory.<init>(SecretKeyFactory.java:121) > at javax.crypto.SecretKeyFactory.getInstance(SecretKeyFactory.java:159) > at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.initialize(StandardPBEByteEncryptor.java:703) > ... 32 more
- TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm())
Caused by: java.security.NoSuchAlgorithmException: class configured for TrustManagerFactory: sun.security.ssl.TrustManagerFactoryImpl$PKIXFactory not a TrustManagerFactory
at sun.security.jca.GetInstance.checkSuperClass(GetInstance.java:258)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:237)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:164)
at javax.net.ssl.TrustManagerFactory.getInstance(TrustManagerFactory.java:138)
at com.optum.pdm.util.SSLConnectionHelper.getSslSocketFactory(SSLConnectionHelper.java:41)
at com.optum.pdm.util.SSLConnectionHelper.getSSLContext(SSLConnectionHelper.java:31)
... 33 more
- 当我在 Junit 上尝试使用 @PowerMockIgnore ("javax.crypto., javax.net.ssl.") 时,它仍然失败并出现上述密码解密问题
- 当我在 Junit 上使用一个 @PowerMockIgnore ("javax.crypto.*") 时,它因加载 jks 问题而失败
有什么办法可以解决这类问题
需要注释语法修正
语法错误:
@PowerMockIgnore ("javax.crypto.*, javax.net.ssl.*")
包含多项的正确语法:
@PowerMockIgnore({"org.apache.http.conn.ssl.*", "javax.net.ssl.*" , "javax.crypto.*"})