Package smartcard :: Module CardConnection :: Class CardConnection
[hide private]
[frames] | no frames]

Class CardConnection

source code


Card connection abstract class.

Known subclasses: smartcard.pcsc.PCSCCardConnection

Instance Methods [hide private]
 
__init__(self, reader)
Construct a new card connection.
source code
 
__del__(self)
Connect to card.
source code
 
addSWExceptionToFilter(self, exClass)
Add a status word exception class to be filtered.
source code
 
addObserver(self, observer)
Add a CardConnection observer.
source code
 
deleteObserver(self, observer)
Remove a CardConnection observer.
source code
 
connect(self, protocol=None, mode=None, disposition=None)
Connect to card.
source code
 
disconnect(self)
Disconnect from card.
source code
 
getATR(self)
Return card ATR
source code
 
getProtocol(self)
Return bit mask for the protocol of connection, or None if no protocol set.
source code
 
getReader(self)
Return card connection reader
source code
 
setErrorCheckingChain(self, errorcheckingchain)
Add an error checking chain.
source code
 
setProtocol(self, protocol)
Set protocol for card connection.
source code
 
transmit(self, bytes, protocol=None)
Transmit an apdu.
source code
 
doTransmit(self, bytes, protocol)
Performs the command APDU transmission.
source code
 
control(self, controlCode, bytes=[])
Send a control command and buffer.
source code
 
doControl(self, controlCode, bytes)
Performs the command control.
source code

Inherited from Observer.Observable: clearChanged, countObservers, deleteObservers, hasChanged, notifyObservers, setChanged

Class Variables [hide private]
  T0_protocol = 1
  T1_protocol = 2
  RAW_protocol = 65536
  T15_protocol = 8
Method Details [hide private]

__init__(self, reader)
(Constructor)

source code 

Construct a new card connection.

readerName: name of the reader in which the smartcard to connect to is located.

Overrides: Synchronization.Synchronization.__init__

addSWExceptionToFilter(self, exClass)

source code 

Add a status word exception class to be filtered.

exClass: the class to filter, e.g. smartcard.sw.SWException.WarningProcessingException

Filtered exceptions will not be raised when encountered in the error checking chain.

addObserver(self, observer)

source code 

Add a CardConnection observer.

Overrides: Observer.Observable.addObserver

deleteObserver(self, observer)

source code 

Remove a CardConnection observer.

Overrides: Observer.Observable.deleteObserver

connect(self, protocol=None, mode=None, disposition=None)

source code 

Connect to card. protocol: a bit mask of the protocols to use, from CardConnection.T0_protocol, CardConnection.T1_protocol, CardConnection.RAW_protocol, CardConnection.T15_protocol

mode: passed as-is to the PC/SC layer

getProtocol(self)

source code 

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

setErrorCheckingChain(self, errorcheckingchain)

source code 

Add an error checking chain. 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.SWException.SWException will be raised upon error.

setProtocol(self, protocol)

source code 

Set protocol for card connection. protocol: a bit mask of CardConnection.T0_protocol, CardConnection.T1_protocol, CardConnection.RAW_protocol, CardConnection.T15_protocol e.g. setProtocol(CardConnection.T1_protocol | CardConnection.T0_protocol)

transmit(self, bytes, protocol=None)

source code 
Transmit an apdu. Internally calls doTransmit() class method
and notify observers upon command/response APDU events.
Subclasses must override the doTransmit() class method.

bytes:      list of bytes to transmit

protocol:   the transmission protocol, from
            CardConnection.T0_protocol,
            CardConnection.T1_protocol, or
            CardConnection.RAW_protocol

doTransmit(self, bytes, protocol)

source code 

Performs the command APDU transmission.

Subclasses must override this method for implementing apdu transmission.

control(self, controlCode, bytes=[])

source code 

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.

controlCode: command code

bytes: list of bytes to transmit

doControl(self, controlCode, bytes)

source code 

Performs the command control.

Subclasses must override this method for implementing control.