当前位置: 首页>>代码示例>>Java>>正文


Java CardException类代码示例

本文整理汇总了Java中javax.smartcardio.CardException的典型用法代码示例。如果您正苦于以下问题:Java CardException类的具体用法?Java CardException怎么用?Java CardException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CardException类属于javax.smartcardio包,在下文中一共展示了CardException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: apply

import javax.smartcardio.CardException; //导入依赖的package包/类
@Override
public ListenableFuture<ApduResponse> apply(byte[] in) {
    // how to actually transmit to the card
    // here we just use the normal transmit stuff
    try {
        ByteBuffer command = ByteBuffer.wrap(in);
        ByteBuffer response = ByteBuffer.allocate(1024); // TODO is this reasonable?
        int size = card.getBasicChannel().transmit(command, response);

        byte[] out = new byte[size];
        System.arraycopy(response.array(), 0,
                out, 0, size);

        return Futures.immediateFuture(new ApduResponse(out));
    } catch (CardException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:identiv,项目名称:ts-cards,代码行数:19,代码来源:SmartcardIoTransmitter.java

示例2: transmit

import javax.smartcardio.CardException; //导入依赖的package包/类
public ResponseAPDU transmit(CommandAPDU cmd)
        throws CardException {

    m_lastCommand = cmd;
    if (m_bDebug == true) {
        log(cmd);
    }

    long elapsed = -System.currentTimeMillis();
    ResponseAPDU response = m_channel.transmit(cmd);
    elapsed += System.currentTimeMillis();
    m_lastTransmitTime = elapsed;

    if (m_bDebug == true) {
        log(response, m_lastTransmitTime);
    }

    return response;
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:20,代码来源:CardManager.java

示例3: transmit

import javax.smartcardio.CardException; //导入依赖的package包/类
private ResponseAPDU transmit(CardChannel channel, CommandAPDU cmd)
        throws CardException {
    log(cmd);

    long elapsed = -System.currentTimeMillis();
    ResponseAPDU response = channel.transmit(cmd);
    elapsed += System.currentTimeMillis();
    lastTransmitTime = elapsed;
    log(response, elapsed);

    return response;
}
 
开发者ID:OpenCryptoProject,项目名称:Myst,代码行数:13,代码来源:CardMPCPlayer.java

示例4: create

import javax.smartcardio.CardException; //导入依赖的package包/类
public static SmartcardIoTransmitter create() throws CardException {
    TerminalFactory tf = TerminalFactory.getDefault();

    CardTerminal cardTerminal = null;

    if (tf.terminals().list().size() == 1) {
        cardTerminal = tf.terminals().list().get(0);
    } else {
        for (CardTerminal terminal : tf.terminals().list()) {
            logger.info("Checking for card: {}", terminal.getName());
            if (terminal.isCardPresent()) {
                cardTerminal = terminal;
            }
        }
    }

    if (cardTerminal != null) {
        cardTerminal.waitForCardPresent(0);
    } else {
        throw new RuntimeException("No card found!");
    }

    logger.info("Using -> " + cardTerminal.getName());

    Card card = cardTerminal.connect("*");

    return new SmartcardIoTransmitter(card);

}
 
开发者ID:identiv,项目名称:ts-cards,代码行数:30,代码来源:SmartcardIoTransmitter.java

示例5: sendCommandWithInitSequence

import javax.smartcardio.CardException; //导入依赖的package包/类
/**
 * Sending command to the card.
 * Enables to send init commands before the main one.
 *
 * @param cardMngr
 * @param command
 * @param initCommands
 * @return
 * @throws CardException
 */
public static ResponseAPDU sendCommandWithInitSequence(CardManager cardMngr, String command, ArrayList<String>  initCommands) throws CardException {
    if (initCommands != null) {
        for (String cmd : initCommands) {
            cardMngr.getChannel().transmit(new CommandAPDU(Util.hexStringToByteArray(cmd)));
        }
    }

    final ResponseAPDU resp = cardMngr.getChannel().transmit(new CommandAPDU(Util.hexStringToByteArray(command)));
    return resp;
}
 
开发者ID:ph4r05,项目名称:javacard-gradle-template,代码行数:21,代码来源:SimpleAPDU.java

示例6: waitForCard

import javax.smartcardio.CardException; //导入依赖的package包/类
private Card waitForCard(CardTerminals terminals)
        throws CardException {
    while (true) {
        for (CardTerminal ct : terminals
                .list(CardTerminals.State.CARD_INSERTION)) {

            return ct.connect("*");
        }
        terminals.waitForChange();
    }
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:12,代码来源:CardManager.java

示例7: transmit

import javax.smartcardio.CardException; //导入依赖的package包/类
@Override
public ResponseAPDU transmit(CommandAPDU apdu) throws CardException {
    ResponseAPDU responseAPDU = null;

    try {
        responseAPDU = this.m_simulator.transmitCommand(apdu);
        // TODO: Add delay corresponding to real cards
        //int delay = OperationTimes.getCardOperationDelay(apdu);
        //Thread.sleep(delay);
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    return responseAPDU;
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:16,代码来源:SimulatedCardChannelLocal.java

示例8: transmit

import javax.smartcardio.CardException; //导入依赖的package包/类
@Override
public ResponseAPDU transmit(CommandAPDU apdu) throws CardException {
    ResponseAPDU responseAPDU = null;

    try {
        responseAPDU = this.m_simulator.transmitCommand(apdu);
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    return responseAPDU;
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:13,代码来源:SimulatedCardChannelLocal.java

示例9: helloTest

import javax.smartcardio.CardException; //导入依赖的package包/类
@Test
public void helloTest() throws CardException {
    CommandAPDU c = new CommandAPDU(0x00, 0x40, 0x00, 0x00);
    ResponseAPDU response = transmitCommand(c);
    assertEquals(0x9000, response.getSW());
    assertArrayEquals(hello, response.getData());
}
 
开发者ID:bertrandmartel,项目名称:javacard-tutorial,代码行数:8,代码来源:HelloWorldTest.java

示例10: transmitCommand

import javax.smartcardio.CardException; //导入依赖的package包/类
public ResponseAPDU transmitCommand(CommandAPDU data) throws CardException {
    if (System.getProperty("testMode") != null && System.getProperty("testMode").equals("smartcard")) {
        return TestSuite.getCard().getBasicChannel().transmit(data);
    } else {
        return TestSuite.getSimulator().transmitCommand(data);
    }
}
 
开发者ID:bertrandmartel,项目名称:javacard-tutorial,代码行数:8,代码来源:JavaCardTest.java

示例11: balanceOverflowTest

import javax.smartcardio.CardException; //导入依赖的package包/类
@Test
public void balanceOverflowTest() throws CardException {
    sendCredit(MAX_CREDIT, 0x9000, MAX_CREDIT);
    sendCredit(MAX_CREDIT, 0x9000, TestUtils.getByte(TestUtils.getInt(MAX_CREDIT) * 2));
    sendCredit(new byte[]{0x00, 0x01}, ISO7816.SW_WRONG_DATA, new byte[]{});
    assertArrayEquals(MAX_BALANCE, getBalance().getData());
}
 
开发者ID:bertrandmartel,项目名称:javacard-tutorial,代码行数:8,代码来源:CounterTest.java

示例12: debitTest

import javax.smartcardio.CardException; //导入依赖的package包/类
@Test
public void debitTest() throws CardException {
    sendCredit(new byte[]{0x00, 0x05}, 0x9000, new byte[]{0x00, 0x05});
    assertArrayEquals(new byte[]{0x00, 0x05}, getBalance().getData());
    sendDebit(new byte[]{0x00, 0x05}, 0x9000, new byte[]{0x00, 0x00});
    assertArrayEquals(new byte[]{0x00, 0x00}, getBalance().getData());
}
 
开发者ID:bertrandmartel,项目名称:javacard-tutorial,代码行数:8,代码来源:CounterTest.java

示例13: debitNegativeTest

import javax.smartcardio.CardException; //导入依赖的package包/类
@Test
public void debitNegativeTest() throws CardException {
    sendCredit(new byte[]{0x00, 0x05}, 0x9000, new byte[]{0x00, 0x05});
    assertArrayEquals(new byte[]{0x00, 0x05}, getBalance().getData());
    sendDebit(new byte[]{0x00, 0x06}, ISO7816.SW_WRONG_DATA, new byte[]{});
    assertArrayEquals(new byte[]{0x00, 0x05}, getBalance().getData());
}
 
开发者ID:bertrandmartel,项目名称:javacard-tutorial,代码行数:8,代码来源:CounterTest.java

示例14: multipleAddPasswordTest

import javax.smartcardio.CardException; //导入依赖的package包/类
@Test
public void multipleAddPasswordTest() throws CardException {
    sendListId(new byte[]{}, 0x9000, new byte[]{});
    sendAddPassword(DATA_ENTRY_VALID.getFullApdu(), 0x9000, new byte[]{});
    sendAddPassword(DATA_ENTRY_VALID1.getFullApdu(), 0x9000, new byte[]{});
    sendAddPassword(DATA_ENTRY_VALID2.getFullApdu(), 0x9000, new byte[]{});
    sendAddPassword(DATA_ENTRY_VALID3.getFullApdu(), 0x9000, new byte[]{});
    sendListId(new byte[]{}, 0x9000, TestUtils.concatByteArray(DATA_ENTRY_VALID3.getId(),
            DATA_ENTRY_VALID2.getId(),
            DATA_ENTRY_VALID1.getId(),
            DATA_ENTRY_VALID.getId()));
}
 
开发者ID:bertrandmartel,项目名称:javacard-tutorial,代码行数:13,代码来源:PasswordManagerPinTest.java

示例15: invalidAddTagTest

import javax.smartcardio.CardException; //导入依赖的package包/类
@Test
public void invalidAddTagTest() throws CardException {
    sendListId(new byte[]{}, 0x9000, new byte[]{});
    sendAddPassword(DATA_ENTRY_INVALID_TAG1, ISO7816.SW_DATA_INVALID, new byte[]{});
    sendAddPassword(DATA_ENTRY_INVALID_TAG2, ISO7816.SW_DATA_INVALID, new byte[]{});
    sendAddPassword(DATA_ENTRY_INVALID_TAG3, ISO7816.SW_DATA_INVALID, new byte[]{});
    sendListId(new byte[]{}, 0x9000, new byte[]{});
}
 
开发者ID:bertrandmartel,项目名称:javacard-tutorial,代码行数:9,代码来源:PasswordManagerPinTest.java


注:本文中的javax.smartcardio.CardException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。