programmatically discover java unlimited encryption

会有一股神秘感。 提交于 2019-12-08 02:49:53

问题


I have a Java app that requires JCE Unlimited Strength policy files to be installed in order to generate certificates. However, currently, the system fails silently if the files are not installed, rather than throwing an exception or something.

Is there a programmatic way to check for these files from within the app? thanks.


回答1:


Probably not the cleanest way:

If it is not there your application should throw an Exception, so you could try a small encryption test that is supposed to work and catch that exception. That's what I do with Bounty Castle.

I suppose you could also check the installed libraries (it looks like the Manisfest within the JAR files contains the strength).




回答2:


Turns out, as GregS points out above, that the program was not failing silently, but swallowing the exception. The call to KeyStore.store() was throwing an IOException that I was catching with a generic catch (Exception e) farther below. Once catching the IOException separately, the program now works properly.



来源:https://stackoverflow.com/questions/9331867/programmatically-discover-java-unlimited-encryption

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!