class CardConnection(Observable):
Known subclasses: smartcard.CardConnectionDecorator.CardConnectionDecorator
, smartcard.pcsc.PCSCCardConnection.PCSCCardConnection
Constructor: CardConnection(reader)
Card connection abstract class.
Method | __del__ |
Connect to card. |
Method | __enter__ |
Enter the runtime context. |
Method | __exit__ |
Exit the runtime context trying to disconnect. |
Method | __init__ |
Construct a new card connection. |
Method | add |
Add a CardConnection observer. |
Method | add |
Add a status word exception class to be filtered. |
Method | connect |
Connect to card. |
Method | control |
Send a control command and buffer. Internally calls doControl() class method and notify observers upon command/response events. Subclasses must override the doControl() class method. |
Method | delete |
Remove a CardConnection observer. |
Method | disconnect |
Disconnect from card. |
Method | do |
Performs the command control. |
Method | do |
Performs the command get attrib. |
Method | do |
Performs the command APDU transmission. |
Method | get |
Return card ATR |
Method | get |
return the requested attribute |
Method | get |
Return bit mask for the protocol of connection, or None if no protocol set. The return value is a bit mask of CardConnection.T0_protocol , CardConnection.T1_protocol , CardConnection.RAW_protocol , CardConnection.T15_protocol ... |
Method | get |
Return card connection reader |
Method | reconnect |
Reconnect to card. |
Method | set |
Add an error checking chain. |
Method | set |
Set protocol for card connection. |
Method | transmit |
Transmit an apdu. Internally calls doTransmit() class method and notify observers upon command/response APDU events. Subclasses must override the doTransmit() class method. |
Class Variable |
|
protocol RAW (direct access to the reader) |
Class Variable |
|
protocol T=0 |
Class Variable |
|
protocol T=15 |
Class Variable |
|
protocol T=1 |
Instance Variable | defaultprotocol |
see setProtocol and getProtocol |
Instance Variable | errorcheckingchain |
see setErrorCheckingChain |
Instance Variable | reader |
reader name |
Inherited from Observable
:
Method | clear |
Undocumented |
Method | count |
Undocumented |
Method | delete |
Undocumented |
Method | has |
Undocumented |
Method | notify |
If 'changed' indicates that this object has changed, notify all its observers, then call clearChanged(). Each observer has its update() called with two arguments: this observable object and the generic 'arg'. |
Method | set |
Undocumented |
Instance Variable | changed |
Undocumented |
Instance Variable | obs |
Undocumented |
Inherited from Synchronization
(via Observable
):
Instance Variable | mutex |
Undocumented |
smartcard.Observer.Observable.__init__
smartcard.CardConnectionDecorator.CardConnectionDecorator
, smartcard.pcsc.PCSCCardConnection.PCSCCardConnection
Construct a new card connection.
Parameters | |
reader | name of the reader in which the smartcard to connect to is located. |
Add a status word exception class to be filtered.
Parameters | |
ex | the class to filter, e.g. Filtered exceptions will not be raised when encountered in the error checking chain. |
smartcard.CardConnectionDecorator.CardConnectionDecorator
, smartcard.pcsc.PCSCCardConnection.PCSCCardConnection
Connect to card.
Parameters | |
protocol | a bit mask of the protocols to use, from CardConnection.T0_protocol , CardConnection.T1_protocol , CardConnection.RAW_protocol , CardConnection.T15_protocol |
mode | smartcard.scard.SCARD_SHARE_SHARED (default), smartcard.scard.SCARD_SHARE_EXCLUSIVE or smartcard.scard.SCARD_SHARE_DIRECT |
disposition | smartcard.scard.SCARD_LEAVE_CARD (default), smartcard.scard.SCARD_RESET_CARD, smartcard.scard.SCARD_UNPOWER_CARD or smartcard.scard.SCARD_EJECT_CARD |
Send a control command and buffer. Internally calls doControl()
class method and notify observers upon command/response events. Subclasses must override the doControl()
class method.
Parameters | |
control | command code |
command | list of bytes to transmit |
smartcard.CardConnectionDecorator.CardConnectionDecorator
, smartcard.pcsc.PCSCCardConnection.PCSCCardConnection
Disconnect from card.
smartcard.pcsc.PCSCCardConnection.PCSCCardConnection
Performs the command control.
Subclasses must override this method for implementing control.
smartcard.pcsc.PCSCCardConnection.PCSCCardConnection
Performs the command get attrib.
Subclasses must override this method for implementing get attrib.
smartcard.pcsc.PCSCCardConnection.PCSCCardConnection
Performs the command APDU transmission.
Subclasses must override this method for implementing apdu transmission.
smartcard.CardConnectionDecorator.CardConnectionDecorator
, smartcard.pcsc.PCSCCardConnection.PCSCCardConnection
Return card ATR
return the requested attribute
Parameters | |
attrib | attribute id like smartcard.scard.SCARD_ATTR_VENDOR_NAME |
Return bit mask for the protocol of connection, or None if no protocol set. The return value is a bit mask of CardConnection.T0_protocol
, CardConnection.T1_protocol
, CardConnection.RAW_protocol
, CardConnection.T15_protocol
smartcard.CardConnectionDecorator.CardConnectionDecorator
, smartcard.pcsc.PCSCCardConnection.PCSCCardConnection
Reconnect to card.
Parameters | |
protocol | a bit mask of the protocols to use, from CardConnection.T0_protocol , CardConnection.T1_protocol , CardConnection.RAW_protocol , CardConnection.T15_protocol |
mode | smartcard.scard.SCARD_SHARE_SHARED (default), smartcard.scard.SCARD_SHARE_EXCLUSIVE or smartcard.scard.SCARD_SHARE_DIRECT |
disposition | smartcard.scard.SCARD_LEAVE_CARD, smartcard.scard.SCARD_RESET_CARD (default), smartcard.scard.SCARD_UNPOWER_CARD or smartcard.scard.SCARD_EJECT_CARD |
Add an error checking chain.
Parameters | |
errorcheckingchain | a smartcard.sw.ErrorCheckingChain object The error checking strategies in errorchecking chain will be tested with each received response APDU, and a smartcard.sw.SWExceptions.SWException will be raised upon error. |
Set protocol for card connection.
Parameters | |
protocol | a bit mask of
>>> setProtocol(CardConnection.T1_protocol | CardConnection.T0_protocol) |
Transmit an apdu. Internally calls doTransmit()
class method and notify observers upon command/response APDU events. Subclasses must override the doTransmit()
class method.
Parameters | |
command | list of bytes to transmit |
protocol | the transmission protocol, from CardConnection.T0_protocol , CardConnection.T1_protocol , or CardConnection.RAW_protocol |