Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

JCE Problem...( help me asap )

 
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,
I am developing applications in OC4J.
But I have problem when implement JCE in OC4J
this is a part of my code...
stKeystoreFile = CryptConstant.stKeystoreFile;
stKeystorePass = CryptConstant.stKeystorePass;
stKeyAlias = CryptConstant.stKeyAlias;
stKeyPass = CryptConstant.stKeyPass;

Security.addProvider(new SunJCE());

char cKeystorePass[] = new char[stKeystorePass.length()];
stKeystorePass.getChars(0, stKeystorePass.length(), cKeystorePass, 0);

char cKeyPass[] = new char[stKeyPass.length()];
stKeyPass.getChars(0, stKeyPass.length(), cKeyPass, 0);

KeyStore objKeystore = KeyStore.getInstance("JKS");

File objFile = new File(stKeystoreFile);

if(objFile.exists()) {
objKeystore.load(new FileInputStream(stKeystoreFile), cKeystorePass);
}
else {
objKeystore.load(null, cKeystorePass);
}

if(!objKeystore.containsAlias(stKeyAlias))
{

PBEKeySpec pbekeyspec = new PBEKeySpec(cKeyPass);

SecretKeyFactory secretkeyfactory = SecretKeyFactory.getInstance("PBEWithMD5AndDES");

objpbeKey = secretkeyfactory.generateSecret(pbekeyspec);

objKeystore.setKeyEntry(stKeyAlias, objpbeKey, cKeyPass, null);

objKeystore.store(new FileOutputStream(stKeystoreFile), cKeystorePass);

} else
{

objpbeKey = (SecretKey) objKeystore.getKey(stKeyAlias, cKeyPass);

}
And i have error this ...
500 Internal Server Error
java.lang.SecurityException: The JCE framework is invalid
at com.sun.crypto.provider.SunJCE.b(DashoA6275)
at com.sun.crypto.provider.SunJCE.a(DashoA6275)
at com.sun.crypto.provider.PBEKeyFactory.<init>(DashoA6275)
at java.lang.Class.newInstance0(Native Method)
at java.lang.Class.newInstance(Class.java:237)
at javax.crypto.SunJCE_b.a(DashoA6275)
at javax.crypto.SunJCE_b.a(DashoA6275)
at javax.crypto.SecretKeyFactory.getInstance(DashoA6275)
at acc.itparameter.sys004.controller.Crypt.<init>(Unknown Source)
at _pages._admin__light._main._Login._jspService(_Login.java:49)
[SRC:/pages/Admin_Light/main/Login.jsp:5]
at com.orionserver[Oracle9iAS (9.0.3.0.0) Containers for J2EE].http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
at oracle.jsp.runtimev2.JspPageTable.compileAndServe(JspPageTable.java:537)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:272)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:721)
at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:797)
at java.lang.Thread.run(Thread.java:484)
Can you help me please
regards
daniel
 
Run away! Run away! Here, take this tiny ad with you:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!