Dear Opencard Forum,

I have some doubts about OCF architecture and the way to implement it.

1- In OpenCard Framework 1.1 Programmer's Guide is said (page 13):
   "Thus, once an object has obtained a SlotChannel object, no other
    object can gain access to the associated smart card until that
    SlotChannel object has been released."

    i)   How can a CardService gain exclusive access to a SlotChannel
        object?

==>
An application can gain exclusive access to a card by using
SmartCard.beginMutex()
In OCF 1.2 an application will be table to gain exclusive access to a Slot by
calling
CardTerminal.lockSlot()

    ii)  I have one application which interacts with 2 identical cards
        (the same CardService) and 1 CardTerminal with 2 slots. I want to
        send commands for both cards, but the first slot gains exclusive access
        and all the commands are sent to it.
        Here is the code I use:

          // Command for Card in Slot1
          CardRequest cr1 = new CardRequest(ReadPers.class);
          SmartCard sc1 = SmartCard.waitForCard(cr1);
          UrbiReadPers urpers1 =
(UrbiReadPers)sc1.getCardService(ReadPers.class,
true);
          lName1 = urpers1.GetName();


          // Command for Card in Slot2
          CardRequest cr2 = new CardRequest(ReadPers.class);
          SmartCard sc2 = SmartCard.waitForCard(cr2);
          UrbiReadPers urpers2 =
(UrbiReadPers)sc1.getCardService(ReadPers.class,
true);
          lName2 = urpers2.GetName();

        Where is the problem and how can I solve it?
====>
         OCF framework is prepared to handle that case. You simply need a
CardTerminal
         which is able to manage two slots.
         The current PCSC CardTerminal and pure java CardTerminal are single
slot
         implementations.
         So the current restriction is not in the architecture but in the
CardTerminal
         implementations.

2- Obtaining a smartcard from a particular slot from a particular
   CardTerminal:
   In OpenCard Framework 1.1 Programmer's Guide is said (page 35):
   "Applications may have a need for a particular card reader or slot."

    i)   I know the way to obtain a smartcard object from a particular
        CardTerminal, but how can I specify a particular slot of that
        CardTerminal?
        Here is the code I use, to allocate a specific CardTerminal
        to a specific CardService:

          // Allocates (Sets) one CardTerminal for PersCard
          Enumeration terminals =
CardTerminalRegistry.getRegistry().getCardTerminals();
          CardTerminal PersTerminal = null;

          while (terminals.hasMoreElements()) {

               PersTerminal = (CardTerminal) terminals.nextElement();
               if (PersTerminal.getType().equals (PersTerminalType)) {
                    break;
               }
          }

          this.crPers = new CardRequest(ReadPers.class);
          this.crPers.setCardTerminal(PersTerminal);   // Allocates the
PersTerminal,
                                                 // but not the slot
          SmartCard scPers = SmartCard.waitForCard(this.crPers);
          this.uCardPers = (ReadPers)scPers.getCardService(ReadPers.class,
true);

        If my CardTerminal has several Slots, how can I allocate a specific slot
        for this CardService?

==>      Use the OCF event framework to listen for card insertion events
         (your application code should implement opencard.core.event.CTListener,
          then register as a listener (CardTerminalRegistry.addCTListener())
          then filter out events for the particular slot you're interested in:

public void cardInserted(CardTerminalEvent event)
  {
    if (smartcard == null) {
      System.out.println
        ("CARD INSERTED - creating SmartCard");
      try {
        smartslot = event.getSlot();
        if (smartslot ....) {
             smartcard = SmartCard.getSmartCard(event);
        }
      } catch (Exception e) {
        e.printStackTrace(System.err);
      }
    } else {
      System.out.println("card inserted - ignored");
    }
  } // cardInserted


3- Concerning Factories:
    i)   How many CardTerminal Factories and CardService Factories can I
        have at the same time in
        my application? There is any limit?
==> No known limits

    ii)  I don't understand the concept of Primary CardServiceFactory can
        anyone explain it to me?
==> If a CardServiceFactory derives from PrimaryCardServiceFactory then
    its setupSmartCard method is invoked before any other card service can
access the card.
    This allows some card initialization (like e.g. increasing the speed in
communicating with the card).


4- Concerning configuration with opencard.properties:
    i)   I'm using OCF with I.E4.0, where can I put the
        file(opencard.properties) to configure the framework?
==>
       on my system I use c:\winnt\java\lib\opencard.properties
       or
       c:\winnt\profiles\bendel\Desktop\opencard.properties


Thank you in advance for any comments.
Jorge Mendes



---
> 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/






---
> 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/

Reply via email to