Search in sources :

Example 6 with CommandAPDU

use of javax.smartcardio.CommandAPDU in project open-ecard by ecsec.

the class PCSCTest method PCSCTest.

@Test(enabled = false)
public void PCSCTest() {
    connect();
    byte[] selectmf = new byte[] { (byte) 0x00, (byte) 0xA4, (byte) 0x00, (byte) 0x0C, (byte) 0x02, (byte) 0x3F, (byte) 0x00 };
    try {
        logger.info("Send APDU {}", ByteUtils.toHexString(selectmf));
        ResponseAPDU response = connection.transmit(new CommandAPDU(selectmf));
        logger.info("Receive APDU {}", ByteUtils.toHexString(response.getBytes()));
    } catch (CardException ex) {
        logger.error(ex.getMessage(), ex);
    }
}
Also used : ResponseAPDU(javax.smartcardio.ResponseAPDU) CardException(javax.smartcardio.CardException) CommandAPDU(javax.smartcardio.CommandAPDU) Test(org.testng.annotations.Test)

Example 7 with CommandAPDU

use of javax.smartcardio.CommandAPDU in project open-ecard by ecsec.

the class PCSCChannel method transmit.

@Override
public CardResponseAPDU transmit(byte[] command) throws SCIOException {
    try {
        CommandAPDU convertCommand = new CommandAPDU(command);
        ResponseAPDU response = channel.transmit(convertCommand);
        return new CardResponseAPDU(response.getBytes());
    } catch (CardException ex) {
        String msg = "Failed to transmit APDU to the card in terminal '%s'.";
        throw new SCIOException(String.format(msg, card.getTerminal().getName()), getCode(ex), ex);
    }
}
Also used : SCIOException(org.openecard.common.ifd.scio.SCIOException) ResponseAPDU(javax.smartcardio.ResponseAPDU) CardResponseAPDU(org.openecard.common.apdu.common.CardResponseAPDU) CardException(javax.smartcardio.CardException) CardCommandAPDU(org.openecard.common.apdu.common.CardCommandAPDU) CommandAPDU(javax.smartcardio.CommandAPDU) CardResponseAPDU(org.openecard.common.apdu.common.CardResponseAPDU)

Aggregations

CommandAPDU (javax.smartcardio.CommandAPDU)7 ResponseAPDU (javax.smartcardio.ResponseAPDU)4 CardException (javax.smartcardio.CardException)3 IOException (java.io.IOException)2 Card (javax.smartcardio.Card)2 CardChannel (javax.smartcardio.CardChannel)2 CardTerminal (javax.smartcardio.CardTerminal)2 ResponseApdu (es.gob.jmulticard.apdu.ResponseApdu)1 ApduConnectionException (es.gob.jmulticard.apdu.connection.ApduConnectionException)1 ApduConnectionOpenedInExclusiveModeException (es.gob.jmulticard.apdu.connection.ApduConnectionOpenedInExclusiveModeException)1 CardNotPresentException (es.gob.jmulticard.apdu.connection.CardNotPresentException)1 LostChannelException (es.gob.jmulticard.apdu.connection.LostChannelException)1 NoReadersFoundException (es.gob.jmulticard.apdu.connection.NoReadersFoundException)1 GetResponseApduCommand (es.gob.jmulticard.apdu.iso7816four.GetResponseApduCommand)1 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 CardCommandAPDU (org.openecard.common.apdu.common.CardCommandAPDU)1 CardResponseAPDU (org.openecard.common.apdu.common.CardResponseAPDU)1 SCIOException (org.openecard.common.ifd.scio.SCIOException)1