|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jaccal.pcsc.JaccalPCSC
JaccalPCSC class provides a set of native methods allowing to power on, power down and send APDU command to a card. JaccalPCSC class is in charge of establish the context with the system and in charge of getting the list of the smart card readers installed in the system.
How to use JaccalPCSC ?
Example:
try {
String[] readerList;
// Create a JaccalPCSC object and initialize it
// Initialisation means:
// - Allocating enough memory for storing all the reader names
// attached to the system
// - Establishing a context with the system
// - Retrieving the list of all the readers attached to the system
JaccalPCSC jaccalPcsc = new JaccalPCSC();
// Select MF APDU command
byte [] selectMF = {0x00,0xA4,0x00,0x00,0x02,0x3F,0x00};
// Retrieve the list of the readers bind to the system
readerList = jaccalPcsc.getReaderList();
// Connect to the first reader in the list
// (power on the card inserted in the first reader in the list
jaccalPcsc.connectCard(readerList[0],PCSC.SCARD_SHARE_SHARED);
// Send the select APDU command
byte [] resp = jaccalPcsc.transmitApdu(selectMF,0,selectMF.length);
// Power Off the card
jaccalPcsc.disconnectCard(PCSC.SCARD_UNPOWER_CARD);
} catch (JaccalPCSCException e) {
System.out.println(e.getMessage());
}
Field Summary | |
private byte[] |
cardAtr
|
private long |
cardHandle
|
private long |
cardProtocol
|
private String |
cardReader
|
private static long |
contextHandle
|
private static String[] |
readerList
|
private boolean |
t0GetResponse
|
Constructor Summary | |
JaccalPCSC()
Allocate enough space to contain 20 smart card readers in the cardReaderList |
|
JaccalPCSC(int nbReader2Allocate)
Define the number of readers to be allocated in the cardReaderList. |
Method Summary | |
private void |
adjustReaderList()
|
private int |
connect(String readerName,
int dwShareMode,
long dwProtocol)
|
void |
connectCard(int shareMode)
Power on the card in the reader name that has been set previously. |
void |
connectCard(String readerName,
int shareMode)
Power on the card inserted in the reader name given in parameters. |
void |
connectCard(String readerName,
int shareMode,
long preferedProtocol)
Power on the card inserted in the reader name given in parameters. |
private int |
disconnect(int dwDisposition)
|
void |
disconnectCard(int swDisposition)
Power off the card. |
private int |
establishContext(int dwScope)
|
byte[] |
getCardAtr()
Returns the ATR of the card currently powered on. |
long |
getCardHandle()
Returns the handle of the card currently powered on |
String |
getCardReader()
Get the name of the JaccalPCSC active reader |
String[] |
getReaderList()
Returns the list of the smart card readers attached to the system. |
private int |
getReadersList()
|
void |
getStatus()
Get the status of the card (inserted, removed etc ...) |
private int |
getStatusChange()
|
private void |
initialize()
Initialize the context and get the list of the smart card readers bind to the system |
boolean |
isT0GetResponse()
Indicates if Get Response apdu command is automatically chained whenever the card status words are 61xxh with xxh the number of bytes available in the card IO buffer. |
void |
setCardReader(String cardReader)
Set the name of the JaccalPCSC active reader |
private static void |
setReaderList(String[] readerList)
|
void |
setT0GetResponse(boolean getResponse)
Set or unset the automatic chaining of Get Reponse APDU command whenever its needed. |
private byte[] |
transmit(byte[] apduCmd,
int offset,
int cmdLen,
byte[] errorCode)
|
byte[] |
transmitApdu(byte[] cmd,
int offsetInCmdBuff,
int cmdLen)
Send a APDU command as defined in ISO7816-4 to the card that has been powered on by a previous connectCard call. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static long contextHandle
private static String[] readerList
private long cardHandle
private String cardReader
private byte[] cardAtr
private long cardProtocol
private boolean t0GetResponse
Constructor Detail |
public JaccalPCSC(int nbReader2Allocate) throws JaccalPCSCException
nbReader2Allocate
- public JaccalPCSC() throws JaccalPCSCException
Method Detail |
private int establishContext(int dwScope)
private int connect(String readerName, int dwShareMode, long dwProtocol)
private int disconnect(int dwDisposition)
private int getReadersList()
private byte[] transmit(byte[] apduCmd, int offset, int cmdLen, byte[] errorCode)
private int getStatusChange()
private void initialize() throws JaccalPCSCException
JaccalPCSCException
public void connectCard(String readerName, int shareMode) throws JaccalPCSCException
readerName
- shareMode
-
JaccalPCSCException
public void connectCard(String readerName, int shareMode, long preferedProtocol) throws JaccalPCSCException
readerName
- shareMode
- preferedProtocol
-
JaccalPCSCException
public void connectCard(int shareMode) throws JaccalPCSCException
shareMode
-
JaccalPCSCException
public void disconnectCard(int swDisposition) throws JaccalPCSCException
swDisposition
- tells what kind of power off to perform. Can be SCARD_LEAVE_CARD, SCARD_RESET_CARD, SCARD_UNPOWER_CARD or SCARD_EJECT_CARD
JaccalPCSCException
public void getStatus() throws JaccalPCSCException
JaccalPCSCException
public byte[] transmitApdu(byte[] cmd, int offsetInCmdBuff, int cmdLen) throws JaccalPCSCException
cmd
- offsetInCmdBuff
- cmdLen
-
JaccalPCSCException
public String[] getReaderList()
public long getCardHandle()
public byte[] getCardAtr()
private static void setReaderList(String[] readerList)
readerList
- The readerList to set.private void adjustReaderList()
public void setCardReader(String cardReader)
cardReader
- public String getCardReader()
public boolean isT0GetResponse()
public void setT0GetResponse(boolean getResponse)
getResponse
- The t0GetResponse to set.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |