本文整理汇总了Java中javax.smartcardio.CommandAPDU.getBytes方法的典型用法代码示例。如果您正苦于以下问题:Java CommandAPDU.getBytes方法的具体用法?Java CommandAPDU.getBytes怎么用?Java CommandAPDU.getBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.smartcardio.CommandAPDU
的用法示例。
在下文中一共展示了CommandAPDU.getBytes方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: formatFailedAPDUCmd
import javax.smartcardio.CommandAPDU; //导入方法依赖的package包/类
static String formatFailedAPDUCmd(CommandAPDU failedCommand) {
// If command corectness verification failed, then output for easy resend during debugging later
byte[] failedcmd = failedCommand.getBytes();
String failedAPDU = String.format("\tcardMngr.transmit(new CommandAPDU(hexStringToByteArray(\"%s\")));", Util.bytesToHex(failedcmd));
failedAPDU += "\n\tstatic byte[] failedCommand = {";
for (int i = 0; i < failedcmd.length; i++) {
failedAPDU += String.format("(byte) 0x%x", failedcmd[i]);
if (i != failedcmd.length - 1) {
failedAPDU += ", ";
}
}
failedAPDU += "};";
failedAPDU += "\n\t";
return failedAPDU;
}
示例2: getAPDUStructure
import javax.smartcardio.CommandAPDU; //导入方法依赖的package包/类
/**
* Bestimmt welchem Case die CAPDU enstpricht. (Siehe ISO/IEC 7816-3 Kapitel
* 12.1)
*
* @return Strukurtype (1 = CASE1, ...)
*/
private byte getAPDUStructure(CommandAPDU capdu) {
byte[] cardcmd = capdu.getBytes();
if (cardcmd.length == 4)
return 1;
if (cardcmd.length == 5)
return 2;
if (cardcmd.length == (5 + (cardcmd[4]&0xff)) && cardcmd[4] != 0)
return 3;
if (cardcmd.length == (6 + (cardcmd[4]&0xff)) && cardcmd[4] != 0)
return 4;
if (cardcmd.length == 7 && cardcmd[4] == 0)
return 5;
if (cardcmd.length == (7 + (cardcmd[5]&0xff) * 256 + (cardcmd[6]&0xff))
&& cardcmd[4] == 0 && (cardcmd[5] != 0 || cardcmd[6] != 0))
return 6;
if (cardcmd.length == (9 + (cardcmd[5]&0xff) * 256 + (cardcmd[6]&0xff))
&& cardcmd[4] == 0 && (cardcmd[5] != 0 || cardcmd[6] != 0))
return 7;
return 0;
}
示例3: withZeroLe
import javax.smartcardio.CommandAPDU; //导入方法依赖的package包/类
public static byte[] withZeroLe(CommandAPDU command) {
byte[] commandBytes = command.getBytes();
byte[] withResponseLength = new byte[commandBytes.length + 1];
System.arraycopy(commandBytes, 0,
withResponseLength, 0, commandBytes.length);
return withResponseLength;
}
示例4: transmit
import javax.smartcardio.CommandAPDU; //导入方法依赖的package包/类
@Override
public ResponseAPDU transmit(CommandAPDU apdu) throws CardException {
RequestAPDU request = new RequestAPDU(apdu.getBytes());
de.intarsys.security.smartcard.card.ResponseAPDU response;
try {
response = connection.transmit(request);
} catch (de.intarsys.security.smartcard.card.CardException e) {
throw new CardException(e);
}
ResponseAPDU result = new ResponseAPDU(response.getBytes());
return result;
}
示例5: transmit
import javax.smartcardio.CommandAPDU; //导入方法依赖的package包/类
public ResponseAPDU transmit(CommandAPDU command) throws CardException {
checkClosed();
card.checkExclusive();
byte[] commandBytes = command.getBytes();
byte[] responseBytes = doTransmit(commandBytes);
return new ResponseAPDU(responseBytes);
}
示例6: transmit
import javax.smartcardio.CommandAPDU; //导入方法依赖的package包/类
@Override
public ResponseAPDU transmit(CommandAPDU arg0) throws CardException {
try {
lengthOfLastAPDU = arg0.getBytes().length;
return new ResponseAPDU(this.card.isodep.transceive(arg0.getBytes()));
} catch (IOException e) {
throw new CardException("Transmit failed", e);
}
}
示例7: setUpClass
import javax.smartcardio.CommandAPDU; //导入方法依赖的package包/类
@BeforeClass
public static void setUpClass() throws Exception {
//expected values of apdu, data, headers, nc, ne
CommandAPDU capdu = new CommandAPDU(C1);
apdu = capdu.getBytes();
data = capdu.getData();
cla = capdu.getCLA();
if (cla != (C1[0] & 0xff)) {
throw new RuntimeException("Failure: cla is not right");
}
ins = capdu.getINS();
if (ins != (C1[1] & 0xff)) {
throw new RuntimeException("Failure: ins is not right");
}
p1 = capdu.getP1();
if (p1 != (C1[2] & 0xff)) {
throw new RuntimeException("Failure: p1 is not right");
}
p2 = capdu.getP2();
if (p2 != (C1[3] & 0xff)) {
throw new RuntimeException("Failure: p2 is not right");
}
nc = capdu.getNc();
ne = capdu.getNe();
//Test on following constructors
cm1 = new CommandAPDU(apdu);
cm2 = new CommandAPDU(cla, ins, p1, p2);
cm3 = new CommandAPDU(cla, ins, p1, p2, data);
cm4 = new CommandAPDU(cla, ins, p1, p2, data, ne);
cm5 = new CommandAPDU(cla, ins, p1, p2, ne);
cm6 = new CommandAPDU(ByteBuffer.wrap(apdu));
cm7 = new CommandAPDU(apdu, 0, apdu.length);
cm8 = new CommandAPDU(cla, ins, p1, p2, data, 0, nc);
cm9 = new CommandAPDU(cla, ins, p1, p2, data, 0, nc, ne);
}
示例8: transmit
import javax.smartcardio.CommandAPDU; //导入方法依赖的package包/类
public ResponseAPDU transmit(CommandAPDU capdu)
throws CardException
{
// XXX check for manage channel commands
// XXX manage T=0 pecularities
if(verbosity > 0) {
System.out.println("JC transmit");
}
card.check_exclusive();
check_not_closed_or_disconnected();
// only do short apdu's
// if(capdu.getNc() >= 256 || capdu.getNe() >= 256)
// throw new
// CardException("Emulators do not support extended APDU's");
byte[] apdu_bytes = capdu.getBytes();
if(verbosity > 0) {
printba("command apdu", apdu_bytes);
}
byte[] res = null;
try {
res = jcard.send(0, apdu_bytes, 0, apdu_bytes.length);
}
catch(JCException e) {
if(e.errorCode == JCException.TERMINAL_ERROR)
throw new IllegalStateException("card error (disconnected?)",
e);
else
throw new CardException(e);
}
if(verbosity > 0) {
printba("response apdu", res);
}
return new ResponseAPDU(res);
}
示例9: transmit
import javax.smartcardio.CommandAPDU; //导入方法依赖的package包/类
/**
* Transmit the command and return the result APDU.
*
* <p>
* Note: currently, the response (including status bytes) is limited to
* 8192 bytes.
*
* <p>
* The command sent to the card is the same as the given command, except
* that:
* <ul>
* <li>The class byte (CLA) is modified to contain the channel number.
* The secure messaging indication and command chaining control are not
* modified, but they must already be in the correct bits depending on
* the channel number!
* <li>If T=0 and there is request data, then the Le byte is removed.
* </ul>
*
* <p>
* Automatically handles sw=61xx (get response) and sw=6cxx (Le)
* responses by re-sending the appropriate request.
*/
@Override public ResponseAPDU transmit(CommandAPDU command) throws CardException {
if (command == null) {
throw new IllegalArgumentException("command is null");
}
byte[] commandCopy = command.getBytes();
ByteBuffer response = transmitImpl(commandCopy, null);
ResponseAPDU responseApdu = convertResponse(response);
return responseApdu;
}