1chenar:
私は共有可能なインターフェースを使用してEclipseの3.7 SDKを使用してJavaカード2.2.2で簡単なクライアントとサーバーのアプレットを作成しようとしました。この方法は、場合JCSystem.getAppletShareableInterfaceObject
と呼ばれ、それは例外と6F00に非常に戻りSWセットをスロー。
これは、(クライアントアプリのコードですTest_Client.java
):
package client;
import server.Test_ServerInf;
import javacard.framework.AID;
import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISO7816;
import javacard.framework.ISOException;
import javacard.framework.JCSystem;
public class Test_Client extends Applet {
protected static final byte INS1 = (byte)0xE2;
protected static final byte INS2 = (byte)0x21;
byte[] ServerAIDbyte={(byte)0x20,(byte)0x21,(byte)0x22,(byte)0x23,(byte)0x24,(byte)0x25,(byte)0x26,(byte)0x27,(byte)0x01};
AID ServerAID;
private Test_Client() {
}
public static void install(byte bArray[], short bOffset, byte bLength)
throws ISOException {
new Test_Client().register();
}
public void process(APDU apdu) throws ISOException {
// TODO Auto-generated method stub
byte[] apduBuffer = apdu.getBuffer();
byte Ins=apduBuffer[ISO7816.OFFSET_INS];
short byteread = apdu.setIncomingAndReceive();
if (selectingApplet())
return;
switch (Ins){
case INS1:
Ins1_Handler(apdu);
return;
case INS2:
Ins2_Handler(apdu,apduBuffer);
return;
default:
ISOException.throwIt(ISO7816.SW_FUNC_NOT_SUPPORTED);
}
}
private void Ins1_Handler(APDU apdu){
Test_ServerInf sio = null;
ServerAID=JCSystem.lookupAID(ServerAIDbyte,(short) 0,(byte) ServerAIDbyte.length);
if(ServerAID==null)
ISOException.throwIt( (short) 0x6A82);
////server request
try{
sio=(Test_ServerInf)(JCSystem.getAppletShareableInterfaceObject(ServerAID, (byte) 0));
}
catch(SecurityException e)
{
ISOException.throwIt((short)0x12);
}
catch(Exception e)
{
ISOException.throwIt((short)0x10);
}
if(sio==null)
ISOException.throwIt((short)0x6A00);
}
private void Ins2_Handler(APDU apdu,byte[] apduBuffer){
Test_ServerInf sio = null;
////connect to server
ServerAID=JCSystem.lookupAID(ServerAIDbyte,(short) 0,(byte) ServerAIDbyte.length);
if(ServerAID==null)
ISOException.throwIt( (short) 0x6A82);
////server request
try{
sio=(Test_ServerInf)(JCSystem.getAppletShareableInterfaceObject(ServerAID, (byte) 0));
}
catch(SecurityException e)
{
ISOException.throwIt((short)0x12);
}
catch(Exception e)
{
ISOException.throwIt((short)0x10);
}
if(sio==null)
ISOException.throwIt((short)0x6A00);
}
}
そして、これは(サーバアプレットのコードですTest_Server.java
):
package server;
import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISOException;
import server.Test_ServerInf;
import javacard.framework.Shareable;
import javacard.framework.AID;
public class Test_Server extends Applet implements Test_ServerInf{
private Test_Server() {
}
public static void install(byte bArray[], short bOffset, byte bLength)
throws ISOException {
new Test_Server().register();
}
public void process(APDU apdu) throws ISOException {
// TODO Auto-generated method stub
}
public Shareable getShareableInterfaceObject(AID clientAID, byte parameter) {
return this;
}
public short method1(){
return (short)0x01;
}
public short method2(){
return (short)0x02;
}
}
そして、共有可能なインタフェースファイル(Test_ServerInf.java
):
package server;
import javacard.framework.Shareable;
public interface Test_ServerInf extends Shareable {
public short method1();
public short method2();
}
1chenar:
私は、このエラーの原因を発見しました。私の代わりにGPShellの内部で開発したアプリケーションを使用してアプレットをロードしてインストールするために使用しました。私はGPShellを使用してアプレットをロードしてインストールしようとすると問題が解決し、すべてがOKです。そのアプリケーションがロードされたパッケージを損なうどのように私は知らないが、それは(デバッグの2週間後)細かい知る権利に動作します。