我遇到与在cref上安装javacard applet有关的问题。
我从oracle javacard示例中获取简单示例 - HelloWorld并添加两个额外行 - import sim.toolkit。*;和私人ToolkitRegistry reg;。 这是applet的代码
package helloworld;
import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISO7816;
import javacard.framework.ISOException;
import javacard.framework.Util;
import sim.toolkit.*;
public class Hello extends Applet {
private byte[] echoBytes;
private static final short LENGTH_ECHO_BYTES = 256;
private ToolkitRegistry reg;
/**
* Only this class's install method should create the applet object.
*/
protected Hello() {
echoBytes = new byte[LENGTH_ECHO_BYTES];
register();
}
/**
* Installs this applet.
*
* @param bArray
* the array containing installation parameters
* @param bOffset
* the starting offset in bArray
* @param bLength
* the length in bytes of the parameter data in bArray
*/
public static void install(byte[] bArray, short bOffset, byte bLength) {
new Hello();
}
/**
* Processes an incoming APDU.
*
* @see APDU
* @param apdu
* the incoming APDU
* @exception ISOException
* with the response bytes per ISO 7816-4
*/
public void process(APDU apdu) {
byte buffer[] = apdu.getBuffer();
// check SELECT APDU command
if ((buffer[ISO7816.OFFSET_CLA] == 0) &&
(buffer[ISO7816.OFFSET_INS] == (byte) (0xA4))) {
return;
}
short bytesRead = apdu.setIncomingAndReceive();
short echoOffset = (short) 0;
while (bytesRead > 0) {
Util.arrayCopyNonAtomic(buffer, ISO7816.OFFSET_CDATA, echoBytes, echoOffset, bytesRead);
echoOffset += bytesRead;
bytesRead = apdu.receiveBytes(ISO7816.OFFSET_CDATA);
}
apdu.setOutgoing();
apdu.setOutgoingLength((short) (echoOffset + 5));
// echo header
apdu.sendBytes((short) 0, (short) 5);
// echo data
apdu.sendBytesLong(echoBytes, (short) 0, echoOffset);
}
}
在添加这些行之前,我的applet安装在cref上没有任何问题(SW1 SW2 90 00),但在这些编辑之后我遇到安装问题 - SW1 SW2 0x6438这意味着找不到导入的包。
我做错了什么?在编译期间我使用了sim.toolkit jar文件,在生成.cap文件时使用了sim工具包中的导出文件。
答案 0 :(得分:1)
据我所知,与Java Card Development Kit捆绑在一起的模拟器不支持SIM Toolkit功能。
您可能想要使用例如Gemalto Developer Suite
祝你好运!