I am trying to encrypt some secure information in a mobile application being developed using ADF Mobile. I am using "javax.crypto.Cipher". As per my understanding ADF Mobile packs it's own JVM along with the application's apk/ipa for deployment purposes.But during deployment we are facing the following issue
java.lang.ExceptionInInitializerError
at java.lang.Class.runStaticInitializers(Unknown Source)
at javax.crypto.Cipher.a(Unknown Source)
at javax.crypto.Cipher.getInstance(Unknown Source)
Caused by: java.lang.SecurityException: Cannot set up certs for trusted CAs
01-08 16:10:19.758: D/CVM(769): at javax.crypto.SunJCE_b.<clinit>(Unknown Source)
01-08 16:10:19.768: D/CVM(769): ... 14 more
01-08 16:10:19.768: D/CVM(769): Caused by: java.lang.SecurityException: Cannot locate policy or framework files!
01-08 16:10:19.768: D/CVM(769): at javax.crypto.SunJCE_b.g(Unknown Source)
01-08 16:10:19.768: D/CVM(769): at javax.crypto.SunJCE_b.f(Unknown Source)
01-08 16:10:19.768: D/CVM(769): at javax.crypto.SunJCE_t.run(Unknown Source)
at the following line: Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
Where will these policy files be? How to check whether they are present or not?
Any help would be greatly appreciated.Please let me know if you need additional info.
Looks like problem in Sun JCE provider, and doesn't ADF related. I can reproduce in jdk 1.4_2.19 and JCE 1.2.2 by replacing
$JRE_HOME/lib/jce.jar
tojce1_2_2.jar
. In this case a gotAs workaround you can use BouncyCastle provider (with returning original
$JRE_HOME/lib/jce.jar
back and removing all SunJCE related in$JRE_HOME/lib/ext
).