JMRTD 0.4.5

net.sourceforge.scuba.smartcards
Class CardService

java.lang.Object
  extended by net.sourceforge.scuba.smartcards.CardService
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
DummyAcceptingCardService, PassportApduService, PassportPersoService, TerminalCardService

public abstract class CardService
extends Object
implements Serializable

Default abstract service. Provides some functionality for observing apdu events.

Version:
$Revision: 259 $
Author:
Cees-Bart Breunesse (ceesb@cs.ru.nl), Martijn Oostdijk (martijno@cs.ru.nl)
See Also:
Serialized Form

Field Summary
protected  boolean listeners
           
protected static int SESSION_STARTED_STATE
           
protected static int SESSION_STOPPED_STATE
           
protected  int state
           
 
Constructor Summary
CardService()
          Creates a new service.
 
Method Summary
 void addAPDUListener(APDUListener l)
          Adds a listener.
abstract  void close()
          Closes the session with the card.
abstract  boolean isOpen()
           
protected  void notifyExchangedAPDU(CommandAPDU capdu, ResponseAPDU rapdu)
          Notifies listeners about APDU event.
abstract  void open()
          Opens a session with the card.
 void removeAPDUListener(APDUListener l)
          Removes the listener l, if present.
 void setListenersState(boolean state)
           
abstract  ResponseAPDU transmit(CommandAPDU apdu)
          Sends and apdu to the card.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SESSION_STOPPED_STATE

protected static final int SESSION_STOPPED_STATE
See Also:
Constant Field Values

SESSION_STARTED_STATE

protected static final int SESSION_STARTED_STATE
See Also:
Constant Field Values

state

protected int state

listeners

protected boolean listeners
Constructor Detail

CardService

public CardService()
Creates a new service.

Method Detail

addAPDUListener

public void addAPDUListener(APDUListener l)
Adds a listener.

Parameters:
l - the listener to add

removeAPDUListener

public void removeAPDUListener(APDUListener l)
Removes the listener l, if present.

Parameters:
l - the listener to remove

open

public abstract void open()
                   throws CardServiceException
Opens a session with the card. Selects a reader. Connects to the card. Notifies any interested apduListeners.

Throws:
CardServiceException

isOpen

public abstract boolean isOpen()

transmit

public abstract ResponseAPDU transmit(CommandAPDU apdu)
                               throws CardServiceException
Sends and apdu to the card. Notifies any interested apduListeners. This method does not throw a CardServiceException if the ResponseAPDU is status word indicating error.

Parameters:
apdu - the command apdu to send.
Returns:
the response from the card, including the status word.
Throws:
CardServiceException - - if the card operation failed

close

public abstract void close()
Closes the session with the card. Disconnects from the card and reader. Notifies any interested apduListeners.


notifyExchangedAPDU

protected void notifyExchangedAPDU(CommandAPDU capdu,
                                   ResponseAPDU rapdu)
Notifies listeners about APDU event.

Parameters:
capdu - APDU event

setListenersState

public void setListenersState(boolean state)

JMRTD 0.4.5