Пример #1
0
        static void Main(string[] args)
        {
            Func <ICardContext, ICardChannel> createCardChannel;
            Action processCommands;

            if (args.Length == 2)
            {
                switch (args[1])
                {
                case "applet":
                    createCardChannel = (context) => new CardChannel(context, context.Readers.Last(), new JavaCardApplet());
                    processCommands   = ProcessTb100FakeCardCommands;
                    break;

                case "javacard":
                default:
                    createCardChannel = (context) => new CardChannel(context, context.Readers.Last(), new JavaCardT0ForTB100Adapter(new JavaCardApplet()));
                    processCommands   = ProcessJavaCardTb100FakeCardCommands;
                    break;
                }
            }
            else
            {
                createCardChannel = (context) => new CardChannel(context, context.Readers.Last(), new JavaCardT0ForTB100Adapter(new JavaCardApplet()));
                processCommands   = ProcessJavaCardTb100FakeCardCommands;
            }

            // Connect to Fake PC/SC
            var context = new CardContext();

            context.Establish();

            // Get installed readers
            context.ListReaderGroups();
            context.ListReaders("");

            PrintReadersAndReaderGroups(context);

            // Connect to an ISO7816-4 card in the last reader found
            var rawChannel = createCardChannel(context);

            channel = new CardChannelIso7816(rawChannel);
            channel.Connect(ShareMode.Exclusive, Protocol.Any);

            PrintAttribute(Attrib.AtrString);
            PrintAttribute(Attrib.DeviceFriendlyName);

            processCommands();

            // Unpower the card
            channel.Disconnect(Disposition.UnpowerCard);

            // Disconnect from Fake PC/SC
            context.Release();
        }
Пример #2
0
        /// <inheritdoc />
        public ErrorCode Connect(ShareMode shareMode, Protocol preferedProtocol)
        {
            BeforeConnectEvent.Raise(this, new BeforeConnectEventArgs {
                ShareMode = shareMode, PreferedProtocol = preferedProtocol
            });

            var ret = channel.Connect(shareMode, preferedProtocol);

            AfterConnectEvent.Raise(this, new AfterConnectEventArgs {
                ShareMode = shareMode, PreferedProtocol = preferedProtocol, ReturnValue = ret
            });

            return(ret);
        }
Пример #3
0
        /// <inheritdoc />
        public ErrorCode Connect(ShareMode shareMode, Protocol preferedProtocol)
        {
            var ret = _cardChannel.Connect(shareMode, preferedProtocol);

            return(ret);
        }
Пример #4
0
 /// <inheritdoc/>
 public ErrorCode Connect(ShareMode shareMode, Protocol preferedProtocol)
 {
     return(cardChannel.Connect(shareMode, preferedProtocol));
 }