Java security class cast exception

Hi, I'm a beginner of Java security. I encountered the following problems when calling:

Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");

I received an error:

java. lang.ClassCastException:com. sun. crypto. provider. Rsacipher cannot be cast to javax crypto. CipherSpi

There are also five jar files for payment gateway encryption in my war file:

> cryptix-jce-api. jar > cryptix-jce-provider. jar > cryptix-message-api. jar > cryptix-openpgp-provider. jar > cryptix-pki-api. jar

If you don't have these five jar files, cipher GetInstance () works, but it's impossible because I need jars to encrypt payment information

Can anyone there tell me how to overcome this problem?

Solution

Powermockito cannot enhance javax Crypto class, so you can add the following comments at the class level:

@Powermockignore ("javax. Crypto. *") or @ powermockignore ({"javax. Crypto"})

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>