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


Java ResponseAPDU.getData方法代码示例

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


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

示例1: testReadPhoto

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
@Test
public void testReadPhoto() throws Exception {
	TerminalFactory terminalFactory = TerminalFactory.getDefault();
	CardTerminals cardTerminals = terminalFactory.terminals();
	CardTerminal cardTerminal = cardTerminals.list().get(0);
	Card card = cardTerminal.connect("T=0");
	CardChannel cardChannel = card.getBasicChannel();
	// select file
	cardChannel.transmit(
			new CommandAPDU(0x00, 0xA4, 0x08, 0x0C, new byte[] { 0x3F, 0x00, (byte) 0xDF, 0x01, 0x40, 0x35 }));
	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	int offset = 0;
	ResponseAPDU responseApdu;
	do {
		// read binary
		responseApdu = cardChannel.transmit(new CommandAPDU(0x00, 0xB0, offset >> 8, offset & 0xFF, 0xff));
		baos.write(responseApdu.getData());
		offset += responseApdu.getData().length;
	} while (responseApdu.getData().length == 0xff);
	BufferedImage photo = ImageIO.read(new ByteArrayInputStream(baos.toByteArray()));
	JOptionPane.showMessageDialog(null, new ImageIcon(photo));
}
 
开发者ID:e-Contract,项目名称:eid-applet,代码行数:23,代码来源:PcscTest.java

示例2: testAPDU

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
void testAPDU(CardManager cardMngr, String input, String expectedOutput) {
    try {
        ResponseAPDU response = cardMngr.transmit(new CommandAPDU(hexStringToByteArray(input)));
        if (response.getSW() == (ISO7816.SW_NO_ERROR & 0xffff)) {
            if (!expectedOutput.isEmpty()) {
                byte[] data = response.getData();
                String output = Util.bytesToHex(data);
                assertTrue(expectedOutput.equalsIgnoreCase(output), "Result provided by card mismatch expected");
            }
        }
        else {
            assertTrue(false, String.format("Card failed with 0x%x", response.getSW()));
        }                
    }
    catch (Exception e) {
        e.printStackTrace();
        assertTrue(false, "Card transmit failed with execption");
    }
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:20,代码来源:JCMathLibTests.java

示例3: read

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
/**
 * Read a 4-byte page.
 * 
 * @param page	the page number to be read (0<=page<=43)
 * @return		a 4-byte array with the page contents in hexadecimal, or
 * 				{@code null} on error
 */
public byte[] read(int page) {
	if (page < 0 || page > 43) {
		return null;
	}

	byte[] apdu = {(byte) 0xFF, (byte) 0xB0, 0x00, (byte) page, 0x04};
	CommandAPDU command = new CommandAPDU(apdu);
	ResponseAPDU response = transmit(command);
	feedback(command, response);
	if (response.getSW() != (0x90 << 8 | 0x00)) {
		return null;
	}

	return response.getData();
}
 
开发者ID:EsupPortail,项目名称:esup-nfc-tag-server,代码行数:23,代码来源:UltralightC.java

示例4: processCommand

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
public String processCommand(String command) throws Exception {
	ResponseAPDU[] responses = sendCommand(command);
	List<String> outputs = new ArrayList<String>();
	
	for(ResponseAPDU response: responses) {
		// Return abstract response from card
		String returnValue = "SW:" + Integer.toHexString(response.getSW());
	
		if(response.getData().length > 0) {
			returnValue += ",Len:" + response.getData().length;
		}
		
		outputs.add(returnValue);
	}
	
	//TODO Add support to select part of data to be included in output
	return String.join("/", outputs);
}
 
开发者ID:jderuiter,项目名称:statelearner,代码行数:19,代码来源:SmartcardTestService.java

示例5: sendGA

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
private DynamicAuthenticationData sendGA() throws SecureMessagingException, CardException {
	DynamicAuthenticationData dad80 = new DynamicAuthenticationData();
	dad80.addDataObject(0, ((ECPublicKey)ephPKPCD).getQ().getEncoded());
	
	byte[] dadBytes = null;
	try {
		dadBytes = dad80.getEncoded(ASN1Encoding.DER);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
			
	//TODO Length Expected steht hier auf 0xFF weil CommandAPDU den Wert 0x00 nicht berücksichtigt.
	ResponseAPDU resp = ch.transceive(new CommandAPDU(0x00, 0x86, 00, 00, dadBytes, 0xFF));
	
	DynamicAuthenticationData dad = new DynamicAuthenticationData(resp.getData());
	
	return dad;
}
 
开发者ID:tsenger,项目名称:animamea,代码行数:20,代码来源:CAOperator.java

示例6: getFeaturesUsingPPDU

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
private void getFeaturesUsingPPDU(final Card card) throws CardException {
	ResponseAPDU responseAPDU = card.getBasicChannel().transmit(
			new CommandAPDU((byte) 0xff, (byte) 0xc2, 0x01, 0x00,
					new byte[]{}, 32));
	this.logger.debug("PPDU response: "
			+ Integer.toHexString(responseAPDU.getSW()));
	if (responseAPDU.getSW() == 0x9000) {
		byte[] featureBytes = responseAPDU.getData();
		this.logger
				.debug("CCID FEATURES found using Pseudo-APDU Fallback Strategy");
		for (FEATURE feature : FEATURE.values()) {
			Integer featureCode = findFeaturePPDU(feature.getTag(),
					featureBytes);
			if (featureCode != null) {
				this.features.put(feature, featureCode);
				this.logger.debug("FEATURE " + feature.name() + " = "
						+ Integer.toHexString(featureCode));
			}
		}
		this.usesPPDU = true;
	} else {
		this.logger.error("CCID Features via PPDU Not Supported");
	}
}
 
开发者ID:e-Contract,项目名称:commons-eid,代码行数:25,代码来源:CCID.java

示例7: transmitPPDUCommand

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
protected byte[] transmitPPDUCommand(final int controlCode,
		final byte[] command) throws CardException {
	ResponseAPDU responseAPDU = card.getBasicChannel().transmit(
			new CommandAPDU((byte) 0xff, (byte) 0xc2, 0x01, controlCode,
					command));
	if (responseAPDU.getSW() != 0x9000) {
		throw new CardException("PPDU Command Failed: ResponseAPDU="
				+ responseAPDU.getSW());
	}

	if (responseAPDU.getData().length == 0) {
		return responseAPDU.getBytes();
	} else {
		return responseAPDU.getData();
	}
}
 
开发者ID:e-Contract,项目名称:commons-eid,代码行数:17,代码来源:CCID.java

示例8: getChallenge

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
/**
 * Returns random data generated by the eID card itself.
 * 
 * @param size
 *            the size of the requested random data.
 * @return size bytes of random data
 * @throws CardException
 */
public byte[] getChallenge(final int size) throws CardException {
	final ResponseAPDU responseApdu = transmitCommand(
			BeIDCommandAPDU.GET_CHALLENGE, new byte[]{}, 0, 0, size);
	if (0x9000 != responseApdu.getSW()) {
		this.logger.debug("get challenge failure: "
				+ Integer.toHexString(responseApdu.getSW()));
		throw new ResponseAPDUException("get challenge failure: "
				+ Integer.toHexString(responseApdu.getSW()), responseApdu);
	}
	if (size != responseApdu.getData().length) {
		throw new RuntimeException("challenge size incorrect: "
				+ responseApdu.getData().length);
	}
	return responseApdu.getData();
}
 
开发者ID:e-Contract,项目名称:commons-eid,代码行数:24,代码来源:BeIDCard.java

示例9: openLogicalChannel

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
/**
 * Open a logical channel.
 *
 * <p>
 * Common exceptions:
 * <ul>
 * <li>JnaCardException(6200): processing warning
 * <li>JnaCardException(6881): logical channel not supported
 * <li>JnaCardException(6a81): function not supported
 * </ul>
 */
@Override public CardChannel openLogicalChannel() throws CardException {
	// manage channel: request a new logical channel from 0x01 to 0x13
	JnaCardChannel basicChannel = getBasicChannel();
	ResponseAPDU response = basicChannel.transmit(new CommandAPDU(0, 0x70, 0x00, 0x00, 1));
	int sw = response.getSW();
	if (0x9000 == sw) {
		byte[] body = response.getData();
		if (body.length == 1) {
			int channel = 0xff & body[0];
			if (channel == 0 || channel > 0x13)
				throw new JnaCardException(sw, String.format("Expected manage channel response to contain channel number in 1-19; got %d", channel));
			return new JnaCardChannel(this, channel);
		} else {
			throw new JnaCardException(sw, String.format("Expected body of length 1 in response to manage channel request; got %d", body.length));
		}
	} else {
		throw new JnaCardException(sw, String.format("Error: sw=%04x in response to manage channel command.", sw));
	}
}
 
开发者ID:jnasmartcardio,项目名称:jnasmartcardio,代码行数:31,代码来源:Smartcardio.java

示例10: log

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
private void log(ResponseAPDU response, long time) {
    String swStr = String.format("%02X", response.getSW());
    byte[] data = response.getData();
    if (data.length > 0) {
        System.out.printf("<-- %s %s (%d) [%d ms]\n", Util.toHex(data), swStr,
                data.length, time);
    } else {
        System.out.printf("<-- %s [%d ms]\n", swStr, time);
    }
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:11,代码来源:CardManager.java

示例11: log

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
private void log(ResponseAPDU response, long time) {
    String swStr = String.format("%02X", response.getSW());
    byte[] data = response.getData();
    if (data.length > 0) {
        System.out.printf("<-- %s %s (%d) [%d ms]\n", toHex(data), swStr,
                data.length, time);
    } else {
        System.out.printf("<-- %s [%d ms]\n", swStr, time);
    }
}
 
开发者ID:OpenCryptoProject,项目名称:JCMathLib,代码行数:11,代码来源:CardManager.java

示例12: log

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
private static void log(ResponseAPDU response, long time) {
    String swStr = String.format("%02X", response.getSW());
    byte[] data = response.getData();
    if (data.length > 0) {
        System.out.printf("<-- %s %s (%d)\n", Util.toHex(data), swStr,
                data.length);
    } else {
        System.out.printf("<-- %s\n", swStr);
    }
    if (time > 0) {
        System.out.printf(String.format("Elapsed time %d ms\n", time));
    }
}
 
开发者ID:OpenCryptoProject,项目名称:Myst,代码行数:14,代码来源:CardManagement.java

示例13: RetrieveRI

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
private byte[] RetrieveRI(CardChannel channel, short quorumIndex, short i) throws Exception {
    byte[] packetData = preparePacketData(Consts.INS_SIGN_RETRIEVE_RI, quorumIndex, (short) i);
    CommandAPDU cmd = new CommandAPDU(Consts.CLA_MPC, Consts.INS_SIGN_RETRIEVE_RI,
            0x00, 0x00, packetData);
    ResponseAPDU response = transmit(channel, cmd);

    ///We do nothing with the key, as we just use the Aggregated R in the test cases
    // return checkSW(response);
    return response.getData();
}
 
开发者ID:OpenCryptoProject,项目名称:Myst,代码行数:11,代码来源:CardMPCPlayer.java

示例14: log

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
private void log(ResponseAPDU response, long time) {
    String swStr = String.format("%02X", response.getSW());
    byte[] data = response.getData();
    if (data.length > 0) {
        System.out.printf("<-- %s %s (%d)\n", Util.toHex(data), swStr,
                data.length);
    } else {
        System.out.printf("<-- %s\n", swStr);
    }
    if (time > 0) {
        System.out.printf(String.format("Elapsed time %d ms\n", time));
    }
}
 
开发者ID:OpenCryptoProject,项目名称:Myst,代码行数:14,代码来源:CardMPCPlayer.java

示例15: RetrievePubKeyHash

import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
@Override
public boolean RetrievePubKeyHash(short quorumIndex) throws Exception {
    byte[] packetData = preparePacketData(Consts.INS_KEYGEN_RETRIEVE_COMMITMENT, quorumIndex);
    CommandAPDU cmd = new CommandAPDU(Consts.CLA_MPC, Consts.INS_KEYGEN_RETRIEVE_COMMITMENT,
            0x00, 0x00, packetData);
    ResponseAPDU response = transmit(channel, cmd);
    quorumsCtxMap.get(quorumIndex).pub_key_Hash = response.getData(); // Store pub key hash

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


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