Results 1 to 15 of 15
- 08-11-2011, 04:43 AM #1
applet can not enforce my command :(
i have 2 classes: Form class and Library class.
in Form class:
in Library class:Java Code:JOptionPane.showMessageDialog(null, "go to 1"); //Get list certificate libStore = new VNPT_CA_Library(); int iCheck = 0; iCheck = libStore.VNPT_CA_Initialize(); if (iCheck != 0) { quitApplet(); } JOptionPane.showMessageDialog(null, "go to 2");
when i embed jar file in html, applet can not show message "go to 1.1", so have a problem with command line: " Method[] methods = PKCS11.class.getMethods();" ?Java Code:public int VNPT_CA_Initialize() { Method[] methods = PKCS11.class.getMethods(); JOptionPane.showMessageDialog(null, "go to 1.1"); Method p11Getinstance = null; for (int i = 0; i < methods.length; i++) { if (methods[i].getName().equals("getInstance")) { p11Getinstance = methods[i]; } }
Sorry about my Eng
-
Sorry, but I don't see enough information here that would allow us to guess at an answer to your question. Please consider providing more information. Please see my second link in my signature below on how to ask smart questions.
- 08-11-2011, 05:19 AM #3
Sorry,
i'm building a applet project about digital certificate. It include two class : form and library.here, i only want to show methods that problem occurs.
in Form class:
and in Library class:Java Code:private VNPT_CA_Library libStore; public int ListCert_Initialize() { try { frame_Sign = new JFrame("VNPT CA - Chương trình ứng dụng PKI"); frame_Sign.setVisible(true); frame_Sign.setLayout(new GridLayout(4, 1)); frame_Sign.setSize(800, 370); frame_Sign.setResizable(false); w = frame_Sign.getWidth(); h = frame_Sign.getHeight(); // pTop = new JPanel(); pBot = new JPanel(); p1 = new JPanel(); p2 = new JPanel(); p3 = new JPanel(); frame_Sign.add(pTop); frame_Sign.add(p1); frame_Sign.add(p2); frame_Sign.add(pBot); pTop.setBackground(Color.white); p1.setBackground(Color.white); p2.setBackground(Color.white); p3.setBackground(Color.white); pBot.setBackground(Color.white); JOptionPane.showMessageDialog(null, "go to 1"); //Get list certificate libStore = new VNPT_CA_Library(); int iCheck = 0; iCheck = libStore.VNPT_CA_Initialize(); if (iCheck != 0) { quitApplet(); } JOptionPane.showMessageDialog(null, "go to 2"); Vector<X509Certificate> Certificates = new Vector<X509Certificate>(); iCheck = libStore.VNPT_CA_ListCertificate(Certificates); if (iCheck != 0) { quitApplet(); } idChoise = 0; // Top Image lbTop = new JLabel(); lbTop.setIcon(new ImageIcon(getClass().getResource("/img/top.jpg"))); pTop.add(lbTop); // Bot Image lbBot = new JLabel(); lbBot.setIcon(new ImageIcon(getClass().getResource("/img/bot.jpg"))); pBot.add(lbBot); // String abc = new String(); X509Certificate CertBuf; int iList = Certificates.size(); Object[][] data = new Object[Certificates.size()][3]; for (int i = 0; i < iList; i++) { CertBuf = Certificates.get(i); data[i][0] = (CertBuf.getSubjectDN().getName()); data[i][1] = CertBuf.getNotBefore().toString(); data[i][2] = CertBuf.getNotAfter().toString(); //abc = CertBuf.getSubjectDN().getName(); } table = new JTable(data, headerName); table.setVisible(true); table.setPreferredScrollableViewportSize(new Dimension(600, 60)); p1.add(table); scroll = new JScrollPane(table); table.setFillsViewportHeight(true); p1.add(scroll); // button btnSign = new JButton("Ký"); btnSign.setLocation(w / 6, h - 50); p2.add(btnSign); btnSign.addActionListener(this); // button btnCancel = new JButton("Xem"); btnCancel.setLocation(w / 6, h - 50); p2.add(btnCancel); btnCancel.addActionListener(this); // button btnView = new JButton("Thoát"); btnView.setLocation(w / 6, h - 50); p2.add(btnView); btnView.addActionListener(this); return 0; } catch (Exception e) { return 1; } }
when i enforce project in IDE, no problem, form class can display anything that i build, but when i embed jar file in html, applet can not display table, button,...so only show panels. i put some command to show place where applet can go to (JOptionPane.showMessageDialog commands), and result, applet can show "go to 1" but cannot show "go to 1.1" and "go to 2"Java Code:public int VNPT_CA_Initialize() { Method[] methods = PKCS11.class.getMethods(); JOptionPane.showMessageDialog(null, "go to 1.1"); Method p11Getinstance = null; for (int i = 0; i < methods.length; i++) { if (methods[i].getName().equals("getInstance")) { p11Getinstance = methods[i]; } } try { String version = System.getProperty("java.version"); if (version.indexOf("1.6") > -1 || version.indexOf("1.7") > -1) { // JRE 1.6 , JRE 1.7 p11 = (PKCS11) p11Getinstance.invoke(null, new Object[]{_pk11LibPath, "C_GetFunctionList", null, false}); } else if (version.indexOf("1.5") > -1) { // JRE 1.5 p11 = (PKCS11) p11Getinstance.invoke(null, new Object[]{_pk11LibPath, null, false}); } else { return 10; } return 0; } catch (Exception e) { return 10; } }
So there is problem with command line : "Method[] methods = PKCS11.class.getMethods()" in library class. i really don't understands.
- 08-11-2011, 02:34 PM #4
Are there any error messages in the browser's java console?when i embed jar file in html, applet can not display table, button,
You could use printlns to print out messages on the java console instead of using JOptionPane.showMessageDialog
- 08-18-2011, 10:18 AM #5
when i start my applet in cmd with appletviewer,throw "java.lang.RuntimePermission accessClassInPackage.sun.security.pkcs11.wrapper"

i was edit java.policy file in (java_home)/jre6/lib/security/ by adding permission:
grant {
.....
.....
permission java.util.PropertyPermission "java.home", "read";
permission java.security.SecurityPermission "authProvider.SunPKCS11-FeitianPKCS";
permission java.lang.RuntimePermission "createClassLoader";
permission java.lang.RuntimePermission "getClassLoader";
}
this code is place exception appear.Java Code:p11Getinstance = PKCS11.class.getMethod("getInstance", String.class, String.class, CK_C_INITIALIZE_ARGS.class, Boolean.TYPE);
help me,pls!
- 08-18-2011, 02:03 PM #6
Does Your console image cut off some of the text?
To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'
Paste here.
I use the policytool to edit my .java.policy file. That file is located in:
C:\Documents and Settings\Owner\.java.policy
The above file is pointed to by the second entry in the .java.security file:
policy.url.1=file:${java.home}/lib/security/java.policy
policy.url.2=file:${user.home}/.java.policy
- 08-19-2011, 06:46 AM #7
this is full of command prompt window.Java Code:Microsoft Windows [Version 6.1.7600] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Users\HoangPTD>cd C:\Program Files\Java\jdk1.6.0_20\bin C:\Program Files\Java\jdk1.6.0_20\bin>appletviewer.exe test1.html java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.security.pkcs11.wrapper) at java.security.AccessControlContext.checkPermission(AccessControlConte xt.java:323) at java.security.AccessController.checkPermission(AccessController.java: 546) at java.lang.SecurityManager.checkPermission(SecurityManager.java:532) at java.lang.SecurityManager.checkPackageAccess(SecurityManager.java:151 2) at sun.applet.AppletSecurity.checkPackageAccess(AppletSecurity.java:266) at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:141) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) at VNPT_CA.SmartCardSigner.VNPT_CA_Lib$1.run(VNPT_CA_Lib.java:74) at java.security.AccessController.doPrivileged(Native Method) at VNPT_CA.SmartCardSigner.VNPT_CA_Lib.VNPT_CA_Initialize(VNPT_CA_Lib.ja va:70) at VNPT_CA.Applet.VNPT_CA_Certificate.ListCert_Initialize(VNPT_CA_Certif icate.java:81) at VNPT_CA.Applet.SmartCardSignerApplet.signSelectedFile(SmartCardSigner Applet.java:64) at VNPT_CA.Applet.SmartCardSignerApplet.access$000(SmartCardSignerApplet .java:20) at VNPT_CA.Applet.SmartCardSignerApplet$1.actionPerformed(SmartCardSigne rApplet.java:40) at java.awt.Button.processActionEvent(Button.java:392) at java.awt.Button.processEvent(Button.java:360) at java.awt.Component.dispatchEventImpl(Component.java:4630) at java.awt.Component.dispatchEvent(Component.java:4460) at java.awt.EventQueue.dispatchEvent(EventQueue.java:599) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre ad.java:269) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread. java:184) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre ad.java:174) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) java.lang.NullPointerException at VNPT_CA.SmartCardSigner.VNPT_CA_Lib.VNPT_CA_Initialize(VNPT_CA_Lib.ja va:92) at VNPT_CA.Applet.VNPT_CA_Certificate.ListCert_Initialize(VNPT_CA_Certif icate.java:81) at VNPT_CA.Applet.SmartCardSignerApplet.signSelectedFile(SmartCardSigner Applet.java:64) at VNPT_CA.Applet.SmartCardSignerApplet.access$000(SmartCardSignerApplet .java:20) at VNPT_CA.Applet.SmartCardSignerApplet$1.actionPerformed(SmartCardSigne rApplet.java:40) at java.awt.Button.processActionEvent(Button.java:392) at java.awt.Button.processEvent(Button.java:360) at java.awt.Component.dispatchEventImpl(Component.java:4630) at java.awt.Component.dispatchEvent(Component.java:4460) at java.awt.EventQueue.dispatchEvent(EventQueue.java:599) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre ad.java:269) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread. java:184) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre ad.java:174) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
i don't really understand your comment. what's name of your tool? i try to find in my computer but i don't see it. could you give me some clear suggestions? thks!
- 08-19-2011, 09:54 AM #8
my program is a application for client, so edit java lib is a end solution. now, i want to edit my code to avoid above exception. i edit my error code as follows:
but my applet does not still run successfully! :(Java Code:AccessController.doPrivileged(new PrivilegedAction() { public Object run() { try { p11Getinstance = PKCS11.class.getMethod("getInstance", String.class, String.class, CK_C_INITIALIZE_ARGS.class, Boolean.TYPE); } catch (Exception ex) { ex.printStackTrace(); } return null; } });
- 08-19-2011, 02:35 PM #9
The policytool.exe program comes with the jre and is in the jre's bin folder.what's name of your tool?
- 08-19-2011, 04:12 PM #10
Have you tried this policy file statement:accessClassInPackage.sun.security.pkcs11.wrapper
java.lang.RuntimePermission "accessClassInPackage.sun.security.pkcs11.wrap per"
- 08-23-2011, 09:25 AM #11
Thanks!
Base on your suggestion, i edit file java.policy with statament: java.lang.RuntimePermission "accessClassInPackage.sun.security.pkcs11.wrapper" , and now i want to edit my source code, not library.
- 08-23-2011, 02:21 PM #12
Is there a problem? Can you explain?now i want to edit my source code,
- 08-24-2011, 11:49 AM #13
i use jarsigned in jdk/bin forder to sign my jar file, and i clear statement java.lang.RuntimePermission "accessClassInPackage.sun.security.pkcs11.wrap per" in java lib, the exception still appear.
i try to edit my code following:
but not success!Java Code:AccessController.doPrivileged(new PrivilegedAction() { @Override public Object run() { try { p11Getinstance = PKCS11.class.getMethod("getInstance", String.class, String.class, CK_C_INITIALIZE_ARGS.class, Boolean.TYPE); } catch (Exception ex) { ex.printStackTrace(); } return null; } });
- 08-24-2011, 01:51 PM #14
Does your code work when you execute it from an application?
- 08-26-2011, 05:55 AM #15
Similar Threads
-
Letting my program command the command prompt
By Smokey. in forum Threads and SynchronizationReplies: 4Last Post: 03-29-2011, 11:34 PM -
How is Java inheritance being used to enforce program requirements?
By Greatwolf in forum New To JavaReplies: 4Last Post: 07-22-2010, 11:22 AM -
Running applet from command prompt
By niteshwar.bhardwaj in forum Java 2DReplies: 1Last Post: 03-12-2009, 08:10 AM -
Unable to execute command line command in java
By LordSM in forum New To JavaReplies: 1Last Post: 08-08-2007, 12:23 AM -
Applet, To center text and To open I engage in a dialog in an Applet
By Marcus in forum Java AppletsReplies: 4Last Post: 06-08-2007, 06:15 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks