Hello, i think the filenotfoundexception is throwen, when the service is not supported for the card!! I gues i read this in javadocumentation.
Best Regards. Daniel Beyer -----Urspr�ngliche Nachricht----- Von: Tammy M Blaser [mailto:[EMAIL PROTECTED]] Gesendet am: Montag, 19. August 2002 16:09 An: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Betreff: [OCF] KeyGenerationCardService ClassNotFoundException Hello, I can't seem to get rid of this ClassNotFoundException error. I know that the KeyGenerationCardService class exists inside C:\Gemplus\OCF\Lib\base-opt.jar but something is still not correct in my configuration. Any suggestions out there? (See below 1) Included is the source code OCFGenKey.java (See below 2) Also included is the opencard.properties file I am using. Here is a snapshot of my run: C:\Tammys Code>java OCFGenKey -------------------------------------------------------------------------- Start use case: get already inserted card or a new card and store PKA keys Gemplus Card Terminal Version: 4.01.003 Date: December 10, 1999 Uses Polling thread techniques Sleeptime: 500 got a SmartCard object! =============== Creating KeyGenerationCardService... ClassNotFoundException: CardService implementing interface opencard.opt.signature.KeyGenerationCardService Finished use case: get already inserted card or a new card and store PKA keys Here is the CLASSPATH output: C:\Tammys Code>echo %CLASSPATH% C:\Gemplus\GemXpresso.rad3\lib\gsecardservice.jar;C:\Gemplus\GemXpresso.rad3 \lib \vopcardservice.jar;C:\Gemplus\GemXpresso.rad3\lib\gemplus-rad-terminals.jar ;C:\ Gemplus\GemXpresso.rad3\lib\gemplus-terminals.jar;C:\Gemplus\GemXpresso.rad3 \lib \gemxpresso.jar;C:\Gemplus\OCF\Lib\pcsc_wrapper.jar;C:\Gemplus\OCF\Lib\base- core .jar;C:\Gemplus\OCF\Lib\base-opt.jar;C:\Gemplus\OCF\Lib\reference-services.j ar;C :\jdk1.2.2\lib\ext\gemplus-service-0.3.jar;C:\jdk1.2.2\lib\ext\gemplus-termi nals -4.1.jar;. Here is the PATH output: C:\Tammys Code>path PATH=C:\WINNT\system32;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\ Gemp lus\GemXpresso.rad3\bin;C:\Gemplus\GEMXPR~1.RAD\bin;C:\Program Files\Hummingbird \Connectivity\7.10\Accessories\;C:\Gemplus\GemXpresso.rad3\bin;C:\Gemplus\Ge mXpr esso.rad3\bin;C:\Gemplus\GEMXPR~1.RAD\bin;C:\jdk1.2.2\bin;. (1) Filename="OCFGenKey.java" import opencard.core.service.CardRequest; import opencard.core.service.SmartCard; import opencard.core.service.CardServiceException; import opencard.core.terminal.CardTerminalException; import opencard.core.util.OpenCardPropertyLoadingException; import opencard.opt.signature.KeyGenerationCardService; import opencard.opt.security.PublicKeyFile; import opencard.opt.security.PrivateKeyFile; import opencard.opt.iso.fs.CardFilePath; /** * OpenCard Framework (OCF) code for a smart card that is inserted already * or just the next one being inserted. Followed by the generation (if needed) * and smart card storage of a public/private key pair. * * Written by: Tammy M. Blaser * Date: August 12, 2002 **/ public class OCFGenKey { private static final String NAME = "get already inserted card or a new card and store PKA keys"; public static String separator = System.getProperty("file.separator"); private static final String OCPROPDIR = "C:" + separator + "Gemplus" + separator + "GemXpresso.rad3" + separator + "conf"; private static final String JAVAHOMEDIR = "C:" + separator + "jdk1.2.2" + separator + "jre"; private SmartCard sc = null; // Constructor public OCFGenKey(SmartCard sc) throws CardServiceException, ClassNotFoundException { this.sc = sc; // Instanciate file CardServices System.out.println("\n===============\nCreating KeyGenerationCardService...\n"); try { KeyGenerationCardService kgcs = null; kgcs = (KeyGenerationCardService) sc.getCardService(KeyGenerationCardService.class, true); // create the key references for the keys to be generated // REMINDER: See if private and public key reference formats compatible with CORBASec HSS CardFilePath path = new CardFilePath(":3F00:C110"); PrivateKeyFile privKey = new PrivateKeyFile(path,0); PublicKeyFile pubKey = new PublicKeyFile(path,1); kgcs.generateKeyPair(privKey, pubKey, 512, "RSA"); // read the public key from the card java.security.PublicKey rsaPublic = kgcs.readPublicKey(pubKey, "RSA"); } catch (java.security.InvalidKeyException ike) { System.out.println ("InvalidKeyException: "); System.out.println (ike.getMessage () ); } catch (CardServiceException cse) { System.out.println ("CardServiceException: "); System.out.println (cse.getMessage () ); } catch (CardTerminalException cte) { System.out.println ("CardTerminalException: "); System.out.println (cte.getMessage () ); } } public static void main (String [] args) { System.out.println ("-------------------------------------------------------------------------- "); System.out.println ("Start use case: " + NAME); System.out.println (""); try { // set needed properties System.setProperty("user.dir", OCPROPDIR); System.setProperty("java.home", JAVAHOMEDIR); java.util.Properties p = System.getProperties(); SmartCard.start (); CardRequest cr = new CardRequest (CardRequest.ANYCARD,null,null); // Wait for smart card insertion SmartCard card = SmartCard.waitForCard (cr); if (card != null) { System.out.println ("got a SmartCard object!\n"); } else System.out.println ("did not get a SmartCard object!\n"); // Start KeyGenerationCardService and generate PKA Keys on the smart card OCFGenKey ocfgk = new OCFGenKey(card); SmartCard.shutdown (); } catch (OpenCardPropertyLoadingException plfe) { System.out.println ("OpenCardPropertyLoadingException: "); System.out.println (plfe.getMessage () ); } catch (ClassNotFoundException cnfe) { System.out.println ("ClassNotFoundException: "); System.out.println (cnfe.getMessage () ); } catch (CardServiceException cse) { System.out.println ("CardServiceException: "); System.out.println (cse.getMessage () ); } catch (CardTerminalException cte) { System.out.println ("CardTerminalException: "); System.out.println (cte.getMessage () ); } System.out.println (""); System.out.println ("Finished use case: " + NAME); System.out.println ("-------------------------------------------------------------------------- ---"); } // main } // OCFGenKey.java // end of OCFGenKey.java ------------------------------------------------------- (2) Filename="opencard.properties" ############################################################################ # Copyright (c) 1998-1999 GEMPLUS group. All Rights Reserved. # #--------------------------------------------------------------------------# # GemXpresso RAD 211 Environment # # # # An OCF configuration file to use Simulator CardTerminal and CardService. # # # ############################################################################ ############################### # - Services configuration - # ############################### OpenCard.services =3D \ com.gemplus.opencard.service.op.vop.vop211.CardServiceVOP211Factory \ opencard.opt.util.PassThruCardServiceFactory \ com.gemplus.opencard.service.gse.GSECardServiceFactory ############################### # - Terminals configuration - # ############################### OpenCard.terminals =3D \ com.gemplus.opencard.terminal.GemplusRadCardTerminalFactory|Simulator|SOCKET = JC21SIMULATOR|127.0.0.1:5000 \ com.gemplus.opencard.terminal.GemplusCardTerminalFactory|gempc410_com2|GemPC = 410|COM2 #com.gemplus.opencard.terminal.GemplusCardTerminalFactory|my_gcr_410P|GCR410 = P|COM2 #com.gemplus.opencard.terminal.GemplusCardTerminalFactory|gempc410_com2|GemP = C410|COM2 #com.ibm.opencard.terminal.pcsc10.Pcsc10CardTerminalFactory #/////////////////////////////////////////////////////////////////////////// = // # _ _ _ __ # |_\/ /\ |\/||_)| |_(_ # |_/\/--\| || |_|___) # configurations for Gemplus Readers # #/////////////////////////////////////////////////////////////////////////// = // # # 0-Using socket Simulator (Gemplus Simulator Environment) # -------------------------------------------------------- # This combine a reader and a card, all in one simulator, accessible = via a=20 # socket. The GemXpresso RAD III provides a particular OCF driver for such= with # the following configuration syntax: #= com.gemplus.opencard.terminal.GemplusRadCardTerminalFactory|<Sbn>|<ST>|<AD> # where: # <Sbn> is a zero spaced string that is displayed in the = JCARDMANAGER # terminal selection list box (symbolic name). Default config = is # "Simulator" word. # # <ST> is the socket driver type: currently only= SOCKETJC21SIMULATOR # # <AD> The IP address and port of the running simulator: default = is # local machine on port 5000 : 127.0.0.1:5000 # Note : if you change the simulator port within the GSE_GUI= tool # you need to add the corresponding line with matching port= here! # # 1-Using the PC/SC wrapper # ------------------------- # #= com.ibm.opencard.terminal.pcsc10.Pcsc10CardTerminalFactory|<Sbn>|<Psn>|<Sh> # where # <Sbn> is a zero spaced string that is displayed in the= JCARDMANAGER # terminal selection list box (symbolic name) # # <Psn> is the name extracted from the string returned by the = PC/SC=20 # service. This string has the following syntax:=20 # "<CARD_MANUFACTURER> <Psn> <POSITION>" # Note that <CARD_MANUFACTURER> must be exactly one = word,=20 # <POSITION> is either 0..255 # !!! <Psn> is case sensitive!!! # # <Sh> is either SHARED or EXLCUSIVE keywords (any other = is=20 # considered as SHARED) # # Note1: if your none Gemplus PC/SC reader does not return a correct = string # change the name within registry database. Please have a look = in=20 # <RAD_HOME>/readme.txt at =A72.8 # # Note2: if you don't know the reader name, a generic solution can be used= by=20 # using empty arguments for <Sbn> <Psn> <Sh> and pipes removed. The # available reader will be automaticaly detected.=20 # # Here are gemplus common readers configurations with PC/SC # = ___________________________________________________________________________= _____________________________________ # : Reader Name : Port : config to paste in your OpenCard.terminals= property : #= :_____________:__________:_________________________________________________= ______________________________________: # : GCR 430 : USB := com.ibm.opencard.terminal.pcsc10.Pcsc10CardTerminalFactory|my_gcr_430|GemPC= 430|SHARED : # : GCR 410P : SERIAL := com.ibm.opencard.terminal.pcsc10.Pcsc10CardTerminalFactory|my_gcr_410P|GCR4= 10P|SHARED : # : GPR 400 : PCMCIA := com.ibm.opencard.terminal.pcsc10.Pcsc10CardTerminalFactory|my_gpr_400|GPR40= 0|SHARED : # : UNKNOWN : UNKNOWN := com.ibm.opencard.terminal.pcsc10.Pcsc10CardTerminalFactory = : #= :__________________________________________________________________________= ______________________________________: # # 2-Using the OCF Readers # ----------------------- # # com.gemplus.opencard.terminal.GemplusCardTerminalFactory|<Sbn>|<Rn>|<PORT> # where: # <Sbn> is a zero spaced string that is displayed in the= JCARDMANAGER # terminal selection list box (symbolic name) # # <PORT> for Windows users is either COM1 COM2 COM3 COM4 LPT1 LPT2 # for Linux users is /dev/ttyS0 /dev/ttyS1 ... # for Solaris users is /dev/term/a /dev/term/b ... # # # <Rn> is the Gemplus reader name and is one of following list: # EPAD500 # EPAD500-MS0 # EPAD500-MS2 # GCR400 # GCR410 # GCR410P # GCR500 # GCR500-ECM # GCR500-MS0 # GCR500-MS2 # GCR500-MS4 # GCR700 # GCR700-MUB # GCR700-MS0 # GCR700-MS2 # GCR700-MS4 # GCR800 # GCR800-MS0 # GCR800-MS2 # GCR800-MS4 # GCI400 # GCI410 # GCI500 # GCI500-MS0 # GCI500-MS2 # GCI500-MS4 # GCI400-MS0 # GemPC410 # GemSelf500 # GemSelf500-ECM # GemSelf500-MS0 # GemSelf500-MS2 # GemSelf500-MS4 # GemSelf700 # GemSelf700-MUB # GemSelf700-MS0 # GemSelf700-MS2 # GemSelf700-MS4 # GemSelf800 # GemSelf800-MS0 # GemSelf800-MS2 # GemSelf800-MS4 # GemPC430 # GemSelf430 # GCR415 # # Here are gemplus common readers configurations with OCF # = ___________________________________________________________________________= ____________________________________ # : Reader Name : Port : config to paste in your OpenCard.terminals= property : #= :_____________:_________:__________________________________________________= _____________________________________: # : GCR 410 : COM1 := com.gemplus.opencard.terminal.GemplusCardTerminalFactory|my_gcr_410|GCR410|= COM1 : # : GCR 410P : COM2 := com.gemplus.opencard.terminal.GemplusCardTerminalFactory|my_gcr_410P|GCR410= P|COM2 : # : and an alternative := com.gemplus.opencard.terminal.GemplusCardTerminalFactory|my_gcr_410P|GemPC4= 10|COM2 : # : GCR 500 : COM1 := com.gemplus.opencard.terminal.GemplusCardTerminalFactory|my_gcr_500|GCR500|= COM1 : # : GRC 500 : COM1 : = : # : Security module 1 := com.gemplus.opencard.terminal.GemplusCardTerminalFactory|my_gcr_500|GCR500-= MS0|COM1 : #= :__________________________________________________________________________= _____________________________________: #/////////////////////////////////////////////////////////////////////////// = // #################################### # - Only for Gemplus Card Terminal # # # #################################### Uses_Standard_ISO_TPDU =3D false ############################### # - TRACE configuration - # ############################### ############################################################# # - Do NOT remove entry com.gemplus.tools.gemxpresso.pilot:6, # it is necessary to obtain an APDU trace in the JCardManager. ############################################################# OpenCard.trace.eventsOnly =3D true OpenCard.trace =3D com.gemplus.tools.gemxpresso.pilot:6 # opencard:4 com.gemplus.opencard:4= com.gemplus.opencard.service.op:8 ================================================== Tammy M. Blaser NASA John H. Glenn Research Center Flight Software Engineering Organization 7750 Mail stop 86-11 216-433-2699 (office) 216-433-8269 (fax) [EMAIL PROTECTED] ================================================== --- > Visit the OpenCard web site at http://www.opencard.org/ for more > information on OpenCard---binaries, source code, documents. > This list is being archived at http://www.opencard.org/archive/opencard/ ! To unsubscribe from the [EMAIL PROTECTED] mailing list send an email ! to ! [EMAIL PROTECTED] ! containing the word ! unsubscribe ! in the body. --- > Visit the OpenCard web site at http://www.opencard.org/ for more > information on OpenCard---binaries, source code, documents. > This list is being archived at http://www.opencard.org/archive/opencard/ ! To unsubscribe from the [EMAIL PROTECTED] mailing list send an email ! to ! [EMAIL PROTECTED] ! containing the word ! unsubscribe ! in the body.
