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


Java ResponseAPDU.getSW2方法代码示例

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


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

示例1: getKeyVersion

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
/**
 * Read the current version of a key stored in the PICC.
 * <p>
 * Note that the key version should be set when changing a key
 * since this command will allow to see the parity bits of the
 * DES/3DES keys. It can be set to a default value.
 * <p>
 * To change the version of a key the {@linkplain #changeKey()} command
 * should be used.
 * 
 * @param keyNo	the key number
 * @return		the 1-byte version of the key
 */
public byte getKeyVersion(byte keyNo) {
	byte[] apdu = new byte[7];
	apdu[0] = (byte) 0x90;
	apdu[1] = (byte) Command.GET_KEY_VERSION.getCode();
	apdu[4] = 0x01;
	apdu[5] = keyNo;

	preprocess(apdu, CommunicationSetting.PLAIN);
	CommandAPDU command = new CommandAPDU(apdu);
	ResponseAPDU response = transmit(command);
	code = response.getSW2();
	feedback(command, response);

	byte[] ret = postprocess(response.getBytes(), CommunicationSetting.PLAIN);
	if (ret.length != 1)
		return FAKE_NO;
	else
		return ret[0];
}
 
开发者ID:EsupPortail,项目名称:esup-nfc-tag-server,代码行数:33,代码来源:DESFireEV1.java

示例2: createApplication

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
/**
 * Create a new application.
 * Requires the PICC-level AID to be selected (00 00 00).
 * 
 * @param aid	3-byte AID
 * @param amks	application master key settings
 * @param nok	number of keys (concatenated with 0x40 or 0x80 for 3K3DES and AES respectively)
 * @return		<code>true</code> on success, <code>false</code> otherwise
 */
public boolean createApplication(byte[] aid, byte amks, byte nok) {
	byte[] apdu = new byte[11];
	apdu[0] = (byte) 0x90;
	apdu[1] = (byte) Command.CREATE_APPLICATION.getCode();
	apdu[4] = 0x05;
	System.arraycopy(aid, 0, apdu, 5, 3);
	apdu[8] = amks;
	apdu[9] = nok;

	preprocess(apdu, CommunicationSetting.PLAIN);
	CommandAPDU command = new CommandAPDU(apdu);
	ResponseAPDU response = transmit(command);
	code = response.getSW2();
	feedback(command, response);

	return postprocess(response.getBytes(), CommunicationSetting.PLAIN) != null;
}
 
开发者ID:EsupPortail,项目名称:esup-nfc-tag-server,代码行数:27,代码来源:DESFireEV1.java

示例3: deleteApplication

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
/**
 * Delete an application.
 * Depending on the PICC master key settings, an authentication is required
 * either with the PICC master key or with the application master key.
 * 
 * @param aid	the 3-byte AID of the application to delete
 * @return		{@code true} on success, {@code false} otherwise
 */
public boolean deleteApplication(byte[] aid) {
	byte[] apdu = new byte[9];
	apdu[0] = (byte) 0x90;
	apdu[1] = (byte) Command.DELETE_APPLICATION.getCode();
	apdu[4] = 0x03;
	System.arraycopy(aid, 0, apdu, 5, 3);

	preprocess(apdu, CommunicationSetting.PLAIN);
	CommandAPDU command = new CommandAPDU(apdu);
	ResponseAPDU response = transmit(command);
	code = response.getSW2();
	feedback(command, response);

	byte[] ret = postprocess(response.getBytes(), CommunicationSetting.PLAIN);
	if (ret != null) {
		System.out.println("ret is null");
		if (this.aid == aid)
			reset();
		return true;
	}
	System.out.println("ret is NOT null");
	return false;
}
 
开发者ID:EsupPortail,项目名称:esup-nfc-tag-server,代码行数:32,代码来源:DESFireEV1.java

示例4: selectApplication

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
/**
 * Select the PICC or a specific application for further access.
 * The authentication state is lost.
 * 
 * @param aid	the 3-byte AID
 * @return		{@code true} on success, {@code false} otherwise
 */
public boolean selectApplication(byte[] aid) {
	byte[] apdu = new byte[9];
	apdu[0] = (byte) 0x90;
	apdu[1] = (byte) Command.SELECT_APPLICATION.getCode();
	apdu[4] = 0x03;
	System.arraycopy(aid, 0, apdu, 5, 3);

	CommandAPDU command = new CommandAPDU(apdu);
	ResponseAPDU response = transmit(command);
	code = response.getSW2();
	feedback(command, response);

	reset();
	if (code != 0x00)
		return false;
	this.aid = aid;
	return true;
}
 
开发者ID:EsupPortail,项目名称:esup-nfc-tag-server,代码行数:26,代码来源:DESFireEV1.java

示例5: getFileSettings

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
/**
 * Get information on the properties of a specific file.
 * 
 * @param fileNo	the file number
 * @return			the properties of the file on success, {@code null} otherwise
 */
public byte[] getFileSettings(int fileNo) {
	//TODO: create some file object that allows to query properties?
	byte[] apdu = new byte[7];
	apdu[0] = (byte) 0x90;
	apdu[1] = (byte) 0xF5;
	apdu[2] = 0x00;
	apdu[3] = 0x00;
	apdu[4] = 0x01;
	apdu[5] = (byte) fileNo;
	apdu[6] = 0x00;

	preprocess(apdu, CommunicationSetting.PLAIN);
	CommandAPDU command = new CommandAPDU(apdu);
	ResponseAPDU response = transmit(command);
	code = response.getSW2();
	feedback(command, response);

	return postprocess(response.getBytes(), CommunicationSetting.PLAIN);
}
 
开发者ID:EsupPortail,项目名称:esup-nfc-tag-server,代码行数:26,代码来源:DESFireEV1.java

示例6: createValueFile

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
/**
 * Create a value file, used for the storage and
 * manipulation of a 32-bit signed integer value.
 * 
 * @param payload	17-byte byte array, with the following contents:
 * 					<br>file number (1 byte),
 * 					<br>communication settings (1 byte),
 * 					<br>access rights (2 bytes),
 * 					<br>lower limit (4 bytes),
 * 					<br>upper limit (4 bytes),
 * 					<br>value (4 bytes),
 * 					<br>limited credit enabled (1 byte)
 * @return			{@code true} on success, {@code false} otherwise
 */
public boolean createValueFile(byte[] payload) {
	byte[] apdu = new byte[23];
	apdu[0] = (byte) 0x90;
	apdu[1] = (byte) 0xCC;
	apdu[2] = 0x00;
	apdu[3] = 0x00;
	apdu[4] = 0x11;
	System.arraycopy(payload, 0, apdu, 5, 17);
	apdu[22] = 0x00;

	preprocess(apdu, CommunicationSetting.PLAIN);
	CommandAPDU command = new CommandAPDU(apdu);
	ResponseAPDU response = transmit(command);
	code = response.getSW2();
	feedback(command, response);

	return postprocess(response.getBytes(), CommunicationSetting.PLAIN) != null;
}
 
开发者ID:EsupPortail,项目名称:esup-nfc-tag-server,代码行数:33,代码来源:DESFireEV1.java

示例7: createRecordFile

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
private boolean createRecordFile(byte[] payload, byte cmd) {
	byte[] apdu = new byte[16];
	apdu[0] = (byte) 0x90;
	apdu[1] = cmd;
	apdu[2] = 0x00;
	apdu[3] = 0x00;
	apdu[4] = 0x0A;
	System.arraycopy(payload, 0, apdu, 5, 10);
	apdu[15] = 0x00;

	preprocess(apdu, CommunicationSetting.PLAIN);
	CommandAPDU command = new CommandAPDU(apdu);
	ResponseAPDU response = transmit(command);
	code = response.getSW2();
	feedback(command, response);

	return postprocess(response.getBytes(), CommunicationSetting.PLAIN) != null;
}
 
开发者ID:EsupPortail,项目名称:esup-nfc-tag-server,代码行数:19,代码来源:DESFireEV1.java

示例8: clearRecordFile

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
/**
 * Reset a cyclic record file or a linear record file to empty state.
 * 
 * <p>Requires full read-write permission and a
 * subsequent {@link #commitTransaction()}.
 * 
 * @param fileNo	the file number
 * @return			{@code true} on success, {@code false} otherwise
 */
public boolean clearRecordFile(byte fileNo) {
	byte[] apdu = new byte[] {
			(byte) 0x90,
			(byte) Command.CLEAR_RECORD_FILE.getCode(),
			0x00,
			0x00,
			0x01,
			fileNo,
			0x00
	};

	preprocess(apdu, CommunicationSetting.PLAIN);
	CommandAPDU command = new CommandAPDU(apdu);
	ResponseAPDU response = transmit(command);
	code = response.getSW2();
	feedback(command, response);

	return postprocess(response.getBytes(), CommunicationSetting.PLAIN) != null;
}
 
开发者ID:EsupPortail,项目名称:esup-nfc-tag-server,代码行数:29,代码来源:DESFireEV1.java

示例9: exchangeSecondMsg

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
/**
 * Second message exchange with the smart card.
 * @param randABre	the ciphered <code>randA||randBr</code>
 * @return			the enciphered rotated random number A, or {@code null} otherwise 
 */
public static byte[] exchangeSecondMsg(DESFireEV1 desfire, byte[] randABre) {
	byte[] apdu = new byte[5 + randABre.length + 1];
	apdu[0] = (byte) 0x90;
	apdu[1] = (byte) 0xAF;
	apdu[4] = (byte) randABre.length;	
	System.arraycopy(randABre, 0, apdu, 5, randABre.length);

	CommandAPDU command = new CommandAPDU(apdu);
	ResponseAPDU response = desfire.transmit(command);
	feedback(command, response);

	return response.getSW2() != 0x00 ? null : response.getData();
}
 
开发者ID:EsupPortail,项目名称:esup-nfc-tag-server,代码行数:19,代码来源:DESFireEV1.java

示例10: exchangeSecondMsg

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
/**
 * Second message exchange with the smart card.
 * @param randABre	the ciphered <code>randA||randBr</code>
 * @return			the enciphered rotated random number A, or {@code null} otherwise 
 */
public static byte[] exchangeSecondMsg(DESFireEV1Service desfire, byte[] randABre) {
	byte[] apdu = new byte[5 + randABre.length + 1];
	apdu[0] = (byte) 0x90;
	apdu[1] = (byte) 0xAF;
	apdu[4] = (byte) randABre.length;	
	System.arraycopy(randABre, 0, apdu, 5, randABre.length);

	CommandAPDU command = new CommandAPDU(apdu);
	ResponseAPDU response = desfire.transmit(command);
	feedback(command, response);

	return response.getSW2() != 0x00 ? null : response.getData();
}
 
开发者ID:EsupPortail,项目名称:esup-nfc-tag-server,代码行数:19,代码来源:DESFireEV1Service.java

示例11: getDFNames

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
/**
 * ????? TODO (variable result? ciphered?)
 * @return
 */
public byte[] getDFNames() {
	byte[] apdu = new byte[5];
	apdu[0] = (byte) 0x90;
	apdu[1] = (byte) Command.GET_DF_NAMES.getCode();

	preprocess(apdu, CommunicationSetting.PLAIN);
	CommandAPDU command = new CommandAPDU(apdu);
	ResponseAPDU response = transmit(command);
	code = response.getSW2();
	feedback(command, response);

	return postprocess(response.getBytes(), CommunicationSetting.PLAIN);
}
 
开发者ID:EsupPortail,项目名称:esup-nfc-tag-server,代码行数:18,代码来源:DESFireEV1.java

示例12: getKeySettings

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
/**
 * Get information about the settings of keys.
 * 
 * @return	2-byte array (key-settings||max-keys),
 * 			or {@code null} on error
 */
public byte[] getKeySettings() {
	byte[] apdu = new byte[5];
	apdu[0] = (byte) 0x90;
	apdu[1] = (byte) Command.GET_KEY_SETTINGS.getCode();

	preprocess(apdu, CommunicationSetting.PLAIN);
	CommandAPDU command = new CommandAPDU(apdu);
	ResponseAPDU response = transmit(command);
	code = response.getSW2();
	feedback(command, response);

	return postprocess(response.getBytes(), CommunicationSetting.PLAIN);
}
 
开发者ID:EsupPortail,项目名称:esup-nfc-tag-server,代码行数:20,代码来源:DESFireEV1.java

示例13: formatPICC

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
/**
 * Release the allocated user memory on the PICC. This will delete all
 * the applications and respective files. The PICC master key and
 * the PICC master key settings are kept.
 * 
 * <p>A previous authentication with the PICC master key is required.
 * 
 * @return {@code true} on success, {@code false} otherwise
 */
public boolean formatPICC() {
	byte[] apdu = new byte[5];
	apdu[0] = (byte) 0x90;
	apdu[1] = (byte) Command.FORMAT_PICC.getCode();

	preprocess(apdu, CommunicationSetting.PLAIN);
	CommandAPDU command = new CommandAPDU(apdu);
	ResponseAPDU response = transmit(command);
	code = response.getSW2();
	feedback(command, response);

	return postprocess(response.getBytes(), CommunicationSetting.PLAIN) != null;
}
 
开发者ID:EsupPortail,项目名称:esup-nfc-tag-server,代码行数:23,代码来源:DESFireEV1.java

示例14: getCardUID

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
/**
 * Get the card UID.
 * <p>
 * Requires a previous authentication.
 * 
 * @return	the card UID on success, {@code null} on error
 */
public byte[] getCardUID() {
	byte[] apdu = new byte[5];
	apdu[0] = (byte) 0x90;
	apdu[1] = (byte) Command.GET_CARD_UID.getCode();

	preprocess(apdu, CommunicationSetting.PLAIN);
	CommandAPDU command = new CommandAPDU(apdu);
	ResponseAPDU response = transmit(command);
	code = response.getSW2();
	feedback(command, response);

	return postprocess(response.getBytes(), 7, CommunicationSetting.ENCIPHERED);
}
 
开发者ID:EsupPortail,项目名称:esup-nfc-tag-server,代码行数:21,代码来源:DESFireEV1.java

示例15: getFileIds

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
/**
 * Get the file identifiers of all the active files within the
 * currently selected application.
 * 
 * @return the identifiers of files, or <code>null</code> on error
 */
public byte[] getFileIds() {
	byte[] apdu = new byte[5];
	apdu[0] = (byte) 0x90;
	apdu[1] = (byte) 0x6F;
	preprocess(apdu, CommunicationSetting.PLAIN);
	CommandAPDU command = new CommandAPDU(apdu);
	ResponseAPDU response = transmit(command);
	code = response.getSW2();
	feedback(command, response);

	return postprocess(response.getBytes(), CommunicationSetting.PLAIN);
}
 
开发者ID:EsupPortail,项目名称:esup-nfc-tag-server,代码行数:19,代码来源:DESFireEV1.java


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