1 """Card service abstract class.
2
3 A card service is a class providings specific smart card functionality,
4 e.g. a GSM file system or an Open Platform loader. CardService is an
5 abstract class from which concrete card services are derived. A concrete
6 card service is almost always smart card operating system specific
7
8 __author__ = "http://www.gemalto.com"
9
10 Copyright 2001-2011 gemalto
11 Author: Jean-Daniel Aussel, mailto:jean-daniel.aussel@gemalto.com
12
13 This file is part of pyscard.
14
15 pyscard is free software; you can redistribute it and/or modify
16 it under the terms of the GNU Lesser General Public License as published by
17 the Free Software Foundation; either version 2.1 of the License, or
18 (at your option) any later version.
19
20 pyscard is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU Lesser General Public License for more details.
24
25 You should have received a copy of the GNU Lesser General Public License
26 along with pyscard; if not, write to the Free Software
27 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 """
29
30 from smartcard import CardService
31
32
34 """Pass-thru card service class."""
35
36 - def __init__(self, connection, cardname=None):
37 """Construct a pass-thru card service.
38
39 connection: the CardConnection used to access the smart card
40 """
41 CardService.CardService.__init__(self, connection, cardname)
42
44 """Returns True if the cardname is supported by the card service.
45 The PassThruCardService supports all cardnames and always
46 returns True."""
47 return True
48
49 supports = staticmethod(supports)
50
51 if __name__ == '__main__':
52 """Small sample illustrating the use of CardService."""
53 SELECT = [0xA0, 0xA4, 0x00, 0x00, 0x02]
54 DF_TELECOM = [0x7F, 0x10]
55 from smartcard.System import readers
56 from smartcard.CardConnection import CardConnection
57 cc = readers()[0].createConnection()
58 cs = PassThruCardService(cc)
59 cs.connection.connect()
60 data, sw1, sw2 = cs.connection.transmit(SELECT + DF_TELECOM)
61 print "%X %X" % (sw1, sw2)
62 cs.connection.disconnect()
63