Beispiel #1
0
        public static SmartCardManager getInstance()
        {
            if (mSCManager == null)
            {
                mSCManager = new SmartCardManager();
                return(mSCManager);
            }
            else
            {
                //Check is there any change
                try
                {
                    //If there is a new card in the system, user will select a smartcard.
                    //Create new SmartCard.
                    if (mSCManager.getSlotCount() < SmartOp.getCardTerminals().Length)
                    {
                        Console.WriteLine("New card pluged in to system");
                        mSCManager = null;
                        return(getInstance());
                    }

                    //If used card is removed, select new card.
                    String availableSerial = null;
                    try
                    {
                        availableSerial = StringUtil.ToString(mSCManager.getBasicSmartCard().getSerial());
                    }
                    catch (SmartCardException ex)
                    {
                        Console.WriteLine("Card removed");
                        mSCManager = null;
                        return(getInstance());
                    }
                    if (!mSCManager.getSelectedSerialNumber().Equals(availableSerial))
                    {
                        Console.WriteLine("Serial number changed. New card is placed to system");
                        mSCManager = null;
                        return(getInstance());
                    }

                    return(mSCManager);
                }
                catch (SmartCardException e)
                {
                    mSCManager = null;
                    throw;
                }
            }
        }
Beispiel #2
0
 public static void reset()
 {
     mSCManager = null;
 }