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


Java TlvUtil.getValue方法代码示例

本文整理汇总了Java中com.github.devnied.emvnfccard.utils.TlvUtil.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java TlvUtil.getValue方法的具体用法?Java TlvUtil.getValue怎么用?Java TlvUtil.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.github.devnied.emvnfccard.utils.TlvUtil的用法示例。


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

示例1: getLeftPinTry

import com.github.devnied.emvnfccard.utils.TlvUtil; //导入方法依赖的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

示例2: parseFCIProprietaryTemplate

import com.github.devnied.emvnfccard.utils.TlvUtil; //导入方法依赖的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

示例3: getLeftPinTry

import com.github.devnied.emvnfccard.utils.TlvUtil; //导入方法依赖的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

示例4: parseFCIProprietaryTemplate

import com.github.devnied.emvnfccard.utils.TlvUtil; //导入方法依赖的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

示例5: extractApplicationLabel

import com.github.devnied.emvnfccard.utils.TlvUtil; //导入方法依赖的package包/类
/**
 * Method used to extract application label
 *
 * @return decoded application label or null
 */
protected String extractApplicationLabel(final byte[] pData) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Extract Application label");
    }
    String label = null;
    byte[] labelByte = TlvUtil.getValue(pData, EmvTags.APPLICATION_LABEL);
    if (labelByte != null) {
        label = new String(labelByte);
    }
    return label;
}
 
开发者ID:JackuyLiu,项目名称:Android-NFC-Paycard-Reader,代码行数:17,代码来源:EmvParser.java

示例6: parse

import com.github.devnied.emvnfccard.utils.TlvUtil; //导入方法依赖的package包/类
/**
 * Method used to parse EMV card
 */
protected boolean parse(final byte[] pSelectResponse, final IProvider pProvider) throws CommunicationException {
    boolean ret = false;
    // Get TLV log entry
    byte[] logEntry = getLogEntry(pSelectResponse);
    // Get PDOL
    byte[] pdol = TlvUtil.getValue(pSelectResponse, EmvTags.PDOL);
    // Send GPO Command
    byte[] gpo = getGetProcessingOptions(pdol, pProvider);

    // Check empty PDOL
    if (!ResponseUtils.isSucceed(gpo)) {
        gpo = getGetProcessingOptions(null, pProvider);
        // Check response
        if (!ResponseUtils.isSucceed(gpo)) {
            return false;
        }
    }

    // Extract commons card data (number, expire date, ...)
    if (extractCommonsCardData(gpo)) {

        // Extract log entry
        card.setListTransactions(extractLogEntry(logEntry));
        ret = true;
    }

    return ret;
}
 
开发者ID:JackuyLiu,项目名称:Android-NFC-Paycard-Reader,代码行数:32,代码来源:EmvParser.java

示例7: extractCardHolderName

import com.github.devnied.emvnfccard.utils.TlvUtil; //导入方法依赖的package包/类
/**
 * Extract card holder lastname and firstname
 *
 * @param pData card data
 */
protected void extractCardHolderName(final byte[] pData) {
    // Extract Card Holder name (if exist)
    byte[] cardHolderByte = TlvUtil.getValue(pData, EmvTags.CARDHOLDER_NAME);
    if (cardHolderByte != null) {
        String[] name = StringUtils.split(new String(cardHolderByte).trim(), CARD_HOLDER_NAME_SEPARATOR);
        if (name != null && name.length == 2) {
            card.setHolderFirstname(StringUtils.trimToNull(name[0]));
            card.setHolderLastname(StringUtils.trimToNull(name[1]));
        }
    }
}
 
开发者ID:JackuyLiu,项目名称:Android-NFC-Paycard-Reader,代码行数:17,代码来源:EmvParser.java

示例8: extractApplicationLabel

import com.github.devnied.emvnfccard.utils.TlvUtil; //导入方法依赖的package包/类
/**
 * Method used to extract application label
 *
 * @return decoded application label or null
 */
protected String extractApplicationLabel(final byte[] pData) {
	if (LOGGER.isDebugEnabled()) {
		LOGGER.debug("Extract Application label");
	}
	String label = null;
	byte[] labelByte = TlvUtil.getValue(pData, EmvTags.APPLICATION_LABEL);
	if (labelByte != null) {
		label = new String(labelByte);
	}
	return label;
}
 
开发者ID:devnied,项目名称:EMV-NFC-Paycard-Enrollment,代码行数:17,代码来源:EmvParser.java

示例9: parse

import com.github.devnied.emvnfccard.utils.TlvUtil; //导入方法依赖的package包/类
/**
 * Method used to parse EMV card
 */
protected boolean parse(final byte[] pSelectResponse, final IProvider pProvider) throws CommunicationException {
	boolean ret = false;
	// Get TLV log entry
	byte[] logEntry = getLogEntry(pSelectResponse);
	// Get PDOL
	byte[] pdol = TlvUtil.getValue(pSelectResponse, EmvTags.PDOL);
	// Send GPO Command
	byte[] gpo = getGetProcessingOptions(pdol, pProvider);

	// Check empty PDOL
	if (!ResponseUtils.isSucceed(gpo)) {
		gpo = getGetProcessingOptions(null, pProvider);
		// Check response
		if (!ResponseUtils.isSucceed(gpo)) {
			return false;
		}
	}

	// Extract commons card data (number, expire date, ...)
	if (extractCommonsCardData(gpo)) {

		// Extract log entry
		card.setListTransactions(extractLogEntry(logEntry));
		ret = true;
	}

	return ret;
}
 
开发者ID:devnied,项目名称:EMV-NFC-Paycard-Enrollment,代码行数:32,代码来源:EmvParser.java

示例10: extractCardHolderName

import com.github.devnied.emvnfccard.utils.TlvUtil; //导入方法依赖的package包/类
/**
 * Extract card holder lastname and firstname
 *
 * @param pData
 *            card data
 */
protected void extractCardHolderName(final byte[] pData) {
	// Extract Card Holder name (if exist)
	byte[] cardHolderByte = TlvUtil.getValue(pData, EmvTags.CARDHOLDER_NAME);
	if (cardHolderByte != null) {
		String[] name = StringUtils.split(new String(cardHolderByte).trim(), CARD_HOLDER_NAME_SEPARATOR);
		if (name != null && name.length == 2) {
			card.setHolderFirstname(StringUtils.trimToNull(name[0]));
			card.setHolderLastname(StringUtils.trimToNull(name[1]));
		}
	}
}
 
开发者ID:devnied,项目名称:EMV-NFC-Paycard-Enrollment,代码行数:18,代码来源:EmvParser.java

示例11: extractCommonsCardData

import com.github.devnied.emvnfccard.utils.TlvUtil; //导入方法依赖的package包/类
/**
 * Method used to extract commons card data
 *
 * @param pGpo global processing options response
 */
protected boolean extractCommonsCardData(final byte[] pGpo) throws CommunicationException {
    boolean ret = false;
    // Extract data from Message Template 1
    byte data[] = TlvUtil.getValue(pGpo, EmvTags.RESPONSE_MESSAGE_TEMPLATE_1);
    if (data != null) {
        data = ArrayUtils.subarray(data, 2, data.length);
    } else { // Extract AFL data from Message template 2
        ret = TrackUtils.extractTrack2Data(card, pGpo);
        if (!ret) {
            data = TlvUtil.getValue(pGpo, EmvTags.APPLICATION_FILE_LOCATOR);
        } else {
            extractCardHolderName(pGpo);
        }
    }

    if (data != null) {
        // Extract Afl
        List<Afl> listAfl = extractAfl(data);
        // for each AFL
        for (Afl afl : listAfl) {
            // check all records
            for (int index = afl.getFirstRecord(); index <= afl.getLastRecord(); index++) {
                byte[] info = provider.transceive(new CommandApdu(CommandEnum.READ_RECORD, index, afl.getSfi() << 3 | 4, 0).toBytes());
                if (ResponseUtils.isEquals(info, SwEnum.SW_6C)) {
                    info = provider.transceive(new CommandApdu(CommandEnum.READ_RECORD, index, afl.getSfi() << 3 | 4,
                            info[info.length - 1]).toBytes());
                }

                // Extract card data
                if (ResponseUtils.isSucceed(info)) {
                    extractCardHolderName(info);
                    if (TrackUtils.extractTrack2Data(card, info)) {
                        return true;
                    }
                }
            }
        }
    }
    return ret;
}
 
开发者ID:JackuyLiu,项目名称:Android-NFC-Paycard-Reader,代码行数:46,代码来源:EmvParser.java

示例12: extractCommonsCardData

import com.github.devnied.emvnfccard.utils.TlvUtil; //导入方法依赖的package包/类
/**
 * Method used to extract commons card data
 *
 * @param pGpo
 *            global processing options response
 */
protected boolean extractCommonsCardData(final byte[] pGpo) throws CommunicationException {
	boolean ret = false;
	// Extract data from Message Template 1
	byte data[] = TlvUtil.getValue(pGpo, EmvTags.RESPONSE_MESSAGE_TEMPLATE_1);
	if (data != null) {
		data = ArrayUtils.subarray(data, 2, data.length);
	} else { // Extract AFL data from Message template 2
		ret = TrackUtils.extractTrack2Data(card, pGpo);
		if (!ret) {
			data = TlvUtil.getValue(pGpo, EmvTags.APPLICATION_FILE_LOCATOR);
		} else {
			extractCardHolderName(pGpo);
		}
	}

	if (data != null) {
		// Extract Afl
		List<Afl> listAfl = extractAfl(data);
		// for each AFL
		for (Afl afl : listAfl) {
			// check all records
			for (int index = afl.getFirstRecord(); index <= afl.getLastRecord(); index++) {
				byte[] info = provider.transceive(new CommandApdu(CommandEnum.READ_RECORD, index, afl.getSfi() << 3 | 4, 0).toBytes());
				if (ResponseUtils.isEquals(info, SwEnum.SW_6C)) {
					info = provider.transceive(new CommandApdu(CommandEnum.READ_RECORD, index, afl.getSfi() << 3 | 4,
							info[info.length - 1]).toBytes());
				}

				// Extract card data
				if (ResponseUtils.isSucceed(info)) {
					extractCardHolderName(info);
					if (TrackUtils.extractTrack2Data(card, info)) {
						return true;
					}
				}
			}
		}
	}
	return ret;
}
 
开发者ID:devnied,项目名称:EMV-NFC-Paycard-Enrollment,代码行数:47,代码来源:EmvParser.java

示例13: getLogEntry

import com.github.devnied.emvnfccard.utils.TlvUtil; //导入方法依赖的package包/类
/**
 * Method used to extract Log Entry from Select response
 *
 * @param pSelectResponse select response
 * @return byte array
 */
protected byte[] getLogEntry(final byte[] pSelectResponse) {
    return TlvUtil.getValue(pSelectResponse, EmvTags.LOG_ENTRY, EmvTags.VISA_LOG_ENTRY);
}
 
开发者ID:JackuyLiu,项目名称:Android-NFC-Paycard-Reader,代码行数:10,代码来源:EmvParser.java

示例14: getLogEntry

import com.github.devnied.emvnfccard.utils.TlvUtil; //导入方法依赖的package包/类
/**
 * Method used to extract Log Entry from Select response
 *
 * @param pSelectResponse
 *            select response
 * @return byte array
 */
protected byte[] getLogEntry(final byte[] pSelectResponse) {
	return TlvUtil.getValue(pSelectResponse, EmvTags.LOG_ENTRY, EmvTags.VISA_LOG_ENTRY);
}
 
开发者ID:devnied,项目名称:EMV-NFC-Paycard-Enrollment,代码行数:11,代码来源:EmvParser.java


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