如何让javax.crypto类(如javax.crypto.Cipher)在jboss的servlet上工作? [英] How do I get javax.crypto classes such as javax.crypto.Cipher to work on a servlet with jboss?

查看:255
本文介绍了如何让javax.crypto类(如javax.crypto.Cipher)在jboss的servlet上工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序验证许可证文件,以使其正常工作。它通过调用javax.crypto.Cipher.getInstance(DES,SunJCE)来解密许可证密钥文件。

My application validates a license file in order for it to work. It does this by calling javax.crypto.Cipher.getInstance("DES","SunJCE") inorder to decipher the license key file.

当我在本地运行我的应用程序时一切工作正常,但是当我使用jboss部署我的应用程序,并到达我想验证servlet上的许可证文件的时候,我收到以下错误:

When I run my application locally everything works fine but when I deploy my application with jboss and get to the point where I want to validate the license file on the servlet, I get the following error:

java.lang.SecurityException: JCE cannot authenticate the provider SunJCE
  at javax.crypto.Cipher.getInstance(DashoA13*..)
  at javax.crypto.Cipher.getInstance(DashoA13*..)

像我说的,它在命令提示符和eclipse中工作正常,但不是作为jboss上的servlet。有人有什么想法我需要做什么?我正在使用jdk 1.6和jboss作为7。

Like I said, it works fine from command prompt and eclipse, but not as a servlet on jboss. Does anybody have any idea what I need to do? I am using jdk 1.6 and jboss as 7.

谢谢

推荐答案

I figured out what was wrong with my code. Earlier in the code for some reason someone did the following:

if (SunJCEinProviders) 
{
Security.removeProvider("SunJCE");
}   

int i = Security.insertProviderAt(new  com.sun.crypto.provider.SunJCE(),1);

所以由于某些原因我们删除了最初的SunJCE提供程序,然后添加了一个新的,未能通过认证。

So for some reason we were removing javas initial SunJCE provider then adding a new one and this new one was failing to be authenticated.

这篇关于如何让javax.crypto类(如javax.crypto.Cipher)在jboss的servlet上工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆