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


Java CommunicationException类代码示例

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


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

示例1: main

import com.github.devnied.emvnfccard.exception.CommunicationException; //导入依赖的package包/类
public static void main(final String[] args) throws CardException, CommunicationException {

		TerminalFactory factory = TerminalFactory.getDefault();
		List<CardTerminal> terminals = factory.terminals().list();
		LOGGER.info("Terminals: " + terminals);

		if (terminals != null && !terminals.isEmpty()) {
			// Use the first terminal
			CardTerminal terminal = terminals.get(0);

			// Connect with the card
			Card card = terminal.connect("*");
			LOGGER.info("card: " + card);
			CardChannel channel = card.getBasicChannel();

			PcscProvider provider = new PcscProvider(channel);
			EmvParser parser = new EmvParser(provider, false);
			parser.readEmvCard();

			// Disconnect the card
			card.disconnect(false);
		} else {
			LOGGER.error("No pcsc terminal found");
		}

	}
 
开发者ID:devnied,项目名称:EMV-NFC-Paycard-Enrollment,代码行数:27,代码来源:Main.java

示例2: getLeftPinTry

import com.github.devnied.emvnfccard.exception.CommunicationException; //导入依赖的package包/类
/**
 * Method used to get the number of pin try left
 *
 * @return the number of pin try left
 * @throws CommunicationException
 */
protected int getLeftPinTry() throws CommunicationException {
    int ret = UNKNOW;
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Get Left PIN try");
    }
    // Left PIN try command
    byte[] data = provider.transceive(new CommandApdu(CommandEnum.GET_DATA, 0x9F, 0x17, 0).toBytes());
    if (ResponseUtils.isSucceed(data)) {
        // Extract PIN try counter
        byte[] val = TlvUtil.getValue(data, EmvTags.PIN_TRY_COUNTER);
        if (val != null) {
            ret = BytesUtils.byteArrayToInt(val);
        }
    }
    return ret;
}
 
开发者ID:JackuyLiu,项目名称:Android-NFC-Paycard-Reader,代码行数:23,代码来源:EmvParser.java

示例3: parseFCIProprietaryTemplate

import com.github.devnied.emvnfccard.exception.CommunicationException; //导入依赖的package包/类
/**
 * Method used to parse FCI Proprietary Template
 *
 * @param pData data to parse
 * @return
 * @throws CommunicationException
 */
protected byte[] parseFCIProprietaryTemplate(final byte[] pData) throws CommunicationException {
    // Get SFI
    byte[] data = TlvUtil.getValue(pData, EmvTags.SFI);

    // Check SFI
    if (data != null) {
        int sfi = BytesUtils.byteArrayToInt(data);
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("SFI found:" + sfi);
        }
        data = provider.transceive(new CommandApdu(CommandEnum.READ_RECORD, sfi, sfi << 3 | 4, 0).toBytes());
        // If LE is not correct
        if (ResponseUtils.isEquals(data, SwEnum.SW_6C)) {
            data = provider.transceive(new CommandApdu(CommandEnum.READ_RECORD, sfi, sfi << 3 | 4, data[data.length - 1]).toBytes());
        }
        return data;
    }
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("(FCI) Issuer Discretionary Data is already present");
    }
    return pData;
}
 
开发者ID:JackuyLiu,项目名称:Android-NFC-Paycard-Reader,代码行数:30,代码来源:EmvParser.java

示例4: extractPublicData

import com.github.devnied.emvnfccard.exception.CommunicationException; //导入依赖的package包/类
/**
 * Read public card data from parameter AID
 *
 * @param pAid              card AID in bytes
 * @param pApplicationLabel application scheme (Application label)
 * @return true if succeed false otherwise
 */
protected boolean extractPublicData(final byte[] pAid, final String pApplicationLabel) throws CommunicationException {
    boolean ret = false;
    // Select AID
    byte[] data = selectAID(pAid);
    // check response
    if (ResponseUtils.isSucceed(data)) {
        // Parse select response
        ret = parse(data, provider);
        if (ret) {
            // Get AID
            String aid = BytesUtils.bytesToStringNoSpace(TlvUtil.getValue(data, EmvTags.DEDICATED_FILE_NAME));
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Application label:" + pApplicationLabel + " with Aid:" + aid);
            }
            card.setAid(aid);
            card.setType(findCardScheme(aid, card.getCardNumber()));
            card.setApplicationLabel(pApplicationLabel);
            card.setLeftPinTry(getLeftPinTry());
        }
    }
    return ret;
}
 
开发者ID:JackuyLiu,项目名称:Android-NFC-Paycard-Reader,代码行数:30,代码来源:EmvParser.java

示例5: getLeftPinTry

import com.github.devnied.emvnfccard.exception.CommunicationException; //导入依赖的package包/类
/**
 * Method used to get the number of pin try left
 *
 * @return the number of pin try left
 * @throws CommunicationException
 */
protected int getLeftPinTry() throws CommunicationException {
	int ret = UNKNOW;
	if (LOGGER.isDebugEnabled()) {
		LOGGER.debug("Get Left PIN try");
	}
	// Left PIN try command
	byte[] data = provider.transceive(new CommandApdu(CommandEnum.GET_DATA, 0x9F, 0x17, 0).toBytes());
	if (ResponseUtils.isSucceed(data)) {
		// Extract PIN try counter
		byte[] val = TlvUtil.getValue(data, EmvTags.PIN_TRY_COUNTER);
		if (val != null) {
			ret = BytesUtils.byteArrayToInt(val);
		}
	}
	return ret;
}
 
开发者ID:devnied,项目名称:EMV-NFC-Paycard-Enrollment,代码行数:23,代码来源:EmvParser.java

示例6: parseFCIProprietaryTemplate

import com.github.devnied.emvnfccard.exception.CommunicationException; //导入依赖的package包/类
/**
 * Method used to parse FCI Proprietary Template
 *
 * @param pData
 *            data to parse
 * @return
 * @throws CommunicationException
 */
protected byte[] parseFCIProprietaryTemplate(final byte[] pData) throws CommunicationException {
	// Get SFI
	byte[] data = TlvUtil.getValue(pData, EmvTags.SFI);

	// Check SFI
	if (data != null) {
		int sfi = BytesUtils.byteArrayToInt(data);
		if (LOGGER.isDebugEnabled()) {
			LOGGER.debug("SFI found:" + sfi);
		}
		data = provider.transceive(new CommandApdu(CommandEnum.READ_RECORD, sfi, sfi << 3 | 4, 0).toBytes());
		// If LE is not correct
		if (ResponseUtils.isEquals(data, SwEnum.SW_6C)) {
			data = provider.transceive(new CommandApdu(CommandEnum.READ_RECORD, sfi, sfi << 3 | 4, data[data.length - 1]).toBytes());
		}
		return data;
	}
	if (LOGGER.isDebugEnabled()) {
		LOGGER.debug("(FCI) Issuer Discretionary Data is already present");
	}
	return pData;
}
 
开发者ID:devnied,项目名称:EMV-NFC-Paycard-Enrollment,代码行数:31,代码来源:EmvParser.java

示例7: extractPublicData

import com.github.devnied.emvnfccard.exception.CommunicationException; //导入依赖的package包/类
/**
 * Read public card data from parameter AID
 *
 * @param pAid
 *            card AID in bytes
 * @param pApplicationLabel
 *            application scheme (Application label)
 * @return true if succeed false otherwise
 */
protected boolean extractPublicData(final byte[] pAid, final String pApplicationLabel) throws CommunicationException {
	boolean ret = false;
	// Select AID
	byte[] data = selectAID(pAid);
	// check response
	if (ResponseUtils.isSucceed(data)) {
		// Parse select response
		ret = parse(data, provider);
		if (ret) {
			// Get AID
			String aid = BytesUtils.bytesToStringNoSpace(TlvUtil.getValue(data, EmvTags.DEDICATED_FILE_NAME));
			if (LOGGER.isDebugEnabled()) {
				LOGGER.debug("Application label:" + pApplicationLabel + " with Aid:" + aid);
			}
			card.setAid(aid);
			card.setType(findCardScheme(aid, card.getCardNumber()));
			card.setApplicationLabel(pApplicationLabel);
			card.setLeftPinTry(getLeftPinTry());
		}
	}
	return ret;
}
 
开发者ID:devnied,项目名称:EMV-NFC-Paycard-Enrollment,代码行数:32,代码来源:EmvParser.java

示例8: getGetProcessingOptions

import com.github.devnied.emvnfccard.exception.CommunicationException; //导入依赖的package包/类
/**
 * Method used to create GPO command and execute it
 *
 * @param pPdol
 *            PDOL data
 * @param pProvider
 *            provider
 * @return return data
 */
protected byte[] getGetProcessingOptions(final byte[] pPdol, final IProvider pProvider) throws CommunicationException {
	// List Tag and length from PDOL
	List<TagAndLength> list = TlvUtil.parseTagAndLength(pPdol);
	ByteArrayOutputStream out = new ByteArrayOutputStream();
	try {
		out.write(EmvTags.COMMAND_TEMPLATE.getTagBytes()); // COMMAND
		// TEMPLATE
		out.write(TlvUtil.getLength(list)); // ADD total length
		if (list != null) {
			for (TagAndLength tl : list) {
				out.write(EmvTerminal.constructValue(tl));
			}
		}
	} catch (IOException ioe) {
		LOGGER.error("Construct GPO Command:" + ioe.getMessage(), ioe);
	}
	return pProvider.transceive(new CommandApdu(CommandEnum.GPO, out.toByteArray(), 0).toBytes());
}
 
开发者ID:devnied,项目名称:EMV-NFC-Paycard-Enrollment,代码行数:28,代码来源:EmvParser.java

示例9: testPPSEVisa

import com.github.devnied.emvnfccard.exception.CommunicationException; //导入依赖的package包/类
@Test
public void testPPSEVisa() throws CommunicationException {

	IProvider prov = new PpseProviderVisaTest();

	EmvParser parser = new EmvParser(prov, true);
	EmvCard card = parser.readEmvCard();

	if (card != null) {
		LOGGER.debug(card.toString());
	}
	Assertions.assertThat(card).isNotNull();
	Assertions.assertThat(card.getAid()).isEqualTo("A0000000421010");
	Assertions.assertThat(card.getCardNumber()).isEqualTo("4999999999999999");
	Assertions.assertThat(card.getType()).isEqualTo(EmvCardScheme.VISA);
	Assertions.assertThat(card.getHolderLastname()).isNull();
	Assertions.assertThat(card.getHolderFirstname()).isNull();
	Assertions.assertThat(card.getApplicationLabel()).isEqualTo("CB");
	Assertions.assertThat(card.getListTransactions().size()).isEqualTo(30);
	SimpleDateFormat sdf = new SimpleDateFormat("MM/yyyy");
	Assertions.assertThat(sdf.format(card.getExpireDate())).isEqualTo("09/2015");
	Assertions.assertThat(card.isNfcLocked()).isFalse();
}
 
开发者ID:devnied,项目名称:EMV-NFC-Paycard-Enrollment,代码行数:24,代码来源:EmvParserTest.java

示例10: testPPSEVisa3

import com.github.devnied.emvnfccard.exception.CommunicationException; //导入依赖的package包/类
@Test
public void testPPSEVisa3() throws CommunicationException {

	IProvider prov = new PpseProviderVisa3Test();

	EmvParser parser = new EmvParser(prov, true);
	EmvCard card = parser.readEmvCard();

	if (card != null) {
		LOGGER.debug(card.toString());
	}
	Assertions.assertThat(card).isNotNull();
	Assertions.assertThat(card.getAid()).isEqualTo("A0000000421010");
	Assertions.assertThat(card.getCardNumber()).isEqualTo("4999999999999999");
	Assertions.assertThat(card.getType()).isEqualTo(EmvCardScheme.VISA);
	Assertions.assertThat(card.getHolderFirstname()).isNull();
	Assertions.assertThat(card.getHolderLastname()).isNull();
	Assertions.assertThat(card.getApplicationLabel()).isEqualTo(null);
	Assertions.assertThat(card.getListTransactions().size()).isEqualTo(0);
	SimpleDateFormat sdf = new SimpleDateFormat("MM/yyyy");
	Assertions.assertThat(sdf.format(card.getExpireDate())).isEqualTo("06/2018");
	Assertions.assertThat(card.isNfcLocked()).isFalse();
}
 
开发者ID:devnied,项目名称:EMV-NFC-Paycard-Enrollment,代码行数:24,代码来源:EmvParserTest.java

示例11: testPPSEVisaNullLog

import com.github.devnied.emvnfccard.exception.CommunicationException; //导入依赖的package包/类
@Test
public void testPPSEVisaNullLog() throws CommunicationException {

	IProvider prov = new PpseProviderVisaNulTransactionsTest();

	EmvParser parser = new EmvParser(prov, true);
	EmvCard card = parser.readEmvCard();

	if (card != null) {
		LOGGER.debug(card.toString());
	}
	Assertions.assertThat(card).isNotNull();
	Assertions.assertThat(card.getAid()).isEqualTo("A0000000421010");
	Assertions.assertThat(card.getCardNumber()).isEqualTo("4999999999999999");
	Assertions.assertThat(card.getType()).isEqualTo(EmvCardScheme.VISA);
	Assertions.assertThat(card.getHolderLastname()).isNull();
	Assertions.assertThat(card.getHolderFirstname()).isNull();
	Assertions.assertThat(card.getApplicationLabel()).isEqualTo("CB");
	Assertions.assertThat(card.getListTransactions().size()).isEqualTo(0);
	SimpleDateFormat sdf = new SimpleDateFormat("MM/yyyy");
	Assertions.assertThat(sdf.format(card.getExpireDate())).isEqualTo("09/2015");
	Assertions.assertThat(card.isNfcLocked()).isFalse();
}
 
开发者ID:devnied,项目名称:EMV-NFC-Paycard-Enrollment,代码行数:24,代码来源:EmvParserTest.java

示例12: testPPSEMasterCard

import com.github.devnied.emvnfccard.exception.CommunicationException; //导入依赖的package包/类
@Test
public void testPPSEMasterCard() throws CommunicationException {

	IProvider prov = new PpseProviderMasterCardTest();

	EmvParser parser = new EmvParser(prov, true);
	EmvCard card = parser.readEmvCard();

	if (card != null) {
		LOGGER.debug(card.toString());
	}
	Assertions.assertThat(card).isNotNull();
	Assertions.assertThat(card.getAid()).isEqualTo("A0000000421010");
	Assertions.assertThat(card.getCardNumber()).isEqualTo("5599999999999999");
	Assertions.assertThat(card.getType()).isEqualTo(EmvCardScheme.MASTER_CARD);
	Assertions.assertThat(card.getHolderLastname()).isNull();
	Assertions.assertThat(card.getHolderFirstname()).isNull();
	Assertions.assertThat(card.getApplicationLabel()).isEqualTo("CB");
	Assertions.assertThat(card.getListTransactions()).isEmpty();
	SimpleDateFormat sdf = new SimpleDateFormat("MM/yyyy");
	Assertions.assertThat(sdf.format(card.getExpireDate())).isEqualTo("09/2015");
	Assertions.assertThat(card.isNfcLocked()).isFalse();
}
 
开发者ID:devnied,项目名称:EMV-NFC-Paycard-Enrollment,代码行数:24,代码来源:EmvParserTest.java

示例13: testPPSEVisa2

import com.github.devnied.emvnfccard.exception.CommunicationException; //导入依赖的package包/类
@Test
public void testPPSEVisa2() throws CommunicationException {

	IProvider prov = new PpseProviderVisa2Test();

	EmvParser parser = new EmvParser(prov, true);
	EmvCard card = parser.readEmvCard();

	if (card != null) {
		LOGGER.debug(card.toString());
	}
	Assertions.assertThat(card).isNotNull();
	Assertions.assertThat(card.getAid()).isEqualTo("A0000000421010");
	Assertions.assertThat(card.getCardNumber()).isEqualTo("4999999999999999");
	Assertions.assertThat(card.getType()).isEqualTo(EmvCardScheme.VISA);
	Assertions.assertThat(card.getHolderLastname()).isNull();
	Assertions.assertThat(card.getHolderFirstname()).isNull();
	Assertions.assertThat(card.getApplicationLabel()).isEqualTo("CB");
	SimpleDateFormat sdf = new SimpleDateFormat("MM/yyyy");
	Assertions.assertThat(sdf.format(card.getExpireDate())).isEqualTo("09/2015");
	Assertions.assertThat(card.isNfcLocked()).isFalse();
}
 
开发者ID:devnied,项目名称:EMV-NFC-Paycard-Enrollment,代码行数:23,代码来源:EmvParserTest.java

示例14: testAid

import com.github.devnied.emvnfccard.exception.CommunicationException; //导入依赖的package包/类
@Test
public void testAid() throws CommunicationException {

	IProvider prov = new ProviderAidTest();

	EmvParser parser = new EmvParser(prov, true);
	EmvCard card = parser.readEmvCard();

	if (card != null) {
		LOGGER.debug(card.toString());
	}
	Assertions.assertThat(card).isNotNull();
	Assertions.assertThat(card.getAid()).isEqualTo("A0000000031010");
	Assertions.assertThat(card.getCardNumber()).isEqualTo("5772829193253472");
	Assertions.assertThat(card.getType()).isEqualTo(EmvCardScheme.VISA);
	Assertions.assertThat(card.getApplicationLabel()).isEqualTo("VISA");
	Assertions.assertThat(card.getHolderLastname()).isNull();
	Assertions.assertThat(card.getHolderFirstname()).isNull();
	SimpleDateFormat sdf = new SimpleDateFormat("MM/yyyy");
	Assertions.assertThat(sdf.format(card.getExpireDate())).isEqualTo("08/2014");
	Assertions.assertThat(card.isNfcLocked()).isFalse();
}
 
开发者ID:devnied,项目名称:EMV-NFC-Paycard-Enrollment,代码行数:23,代码来源:EmvParserTest.java

示例15: readEmvCard

import com.github.devnied.emvnfccard.exception.CommunicationException; //导入依赖的package包/类
/**
 * Method used to read public data from EMV card
 *
 * @return data read from card or null if any provider match the card type
 */
public EmvCard readEmvCard() throws CommunicationException {
    // use PSE first
    if (!readWithPSE()) {
        // Find with AID
        readWithAID();
    }
    return card;
}
 
开发者ID:JackuyLiu,项目名称:Android-NFC-Paycard-Reader,代码行数:14,代码来源:EmvParser.java


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