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
 
getAttrib(self, attribId)
return the requested attribute
source code
 
doGetAttrib(self, attribId)
Performs the command get attrib.
source code
 
__enter__(self)
Enter the runtime context.
source code
 
__exit__(self, type, value, traceback)
Exit the runtime context trying to disconnect.
source code

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

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

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

Inherited from object: __class__

Method Details [hide private]

__init__(self, reader)
(Constructor)

source code 

Construct a new card connection.

Parameters:
  • reader - name of the reader in which the smartcard to connect to is located.
Overrides: object.__init__

addSWExceptionToFilter(self, exClass)

source code 

Add a status word exception class to be filtered.

Parameters:

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.

Parameters:

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.

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.SWException.SWException will be raised upon error.

setProtocol(self, protocol)

source code 

Set protocol for card connection.

Parameters:
  • 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.

Parameters:
  • 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.

Parameters:
  • 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.

getAttrib(self, attribId)

source code 

return the requested attribute

Parameters:
  • attribId - attribute id like SCARD_ATTR_VENDOR_NAME

doGetAttrib(self, attribId)

source code 

Performs the command get attrib.

Subclasses must override this method for implementing get attrib.