Java卡可共享接口:lookupAID返回援助,但getAppletShareableInterface返回null [英] Javacard Shareable Interface: lookupAID returns AID but getAppletShareableInterface returns null

查看:345
本文介绍了Java卡可共享接口:lookupAID返回援助,但getAppletShareableInterface返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑2:发现的错误。我试图初始化共享对象的构造函数。当时客户端的寄存器方法尚未叫,所以JCRE没有其AID。虽然我的服务器getShareableInterfaceObject(AID clientaid,字节参数)方法不需要客户端的援助是!= null,则JCRE可能确实,因为它要求我的客户此方法。我现在当我处理我的第一个APDU,现在可初始化我的共享对象。

edit 2: Found the mistake. I tried to initialize the Shareable object in the constructor. At that time the client's register method is not yet called, so the JCRE doesn't have its AID. While my server's getShareableInterfaceObject(AID clientaid, byte parameter) method doesn't require the client's AID to be != null the JCRE probably does, since it calls this method for my client. I now initialize my Shareable object when I process my first APDU and it now works.

和顺便说一句,谢谢你owlstead与我的帖子的格式帮助。无疑使其更容易阅读!

And btw, thank you owlstead for helping with formatting of my post. Definitely made it easier to read!

我是新来的Java卡的发展,我不能让我的可共享接口才能正常工作。

I'm new to Java Card development and I can't get my Shareable interface to work.

我有一个接口类声明我的客户端applet想要使用的功能。我的服务器小程序实现了这个类。我的客户机applet查找的援助,并试图通过调用获取接口 getAppletShareableInterface()。但是,这总是返回

I have an interface class declaring a function my client applet wants to use. My server applet implements this class. My client applet looks up the AID and tries to acquire the interface by calling getAppletShareableInterface(). But this always returns null.

我的服务器小程序的 getShareableInterface()由刚返回这一点; ,所以我想错不在于此。但我不知道在哪里。

My server applet's getShareableInterface() consists of just return this;, so I guess the fault lies elsewhere. But I have no idea where.

我使用的JCWDE并通过code我看到我的服务器小程序通话记录,所以客户端小程序应该能找到它的步进。谁能给我一些指点有什么可以去错了?

I'm using the JCWDE and stepping through the code I see that my server applet calls register so the client applet should be able to find it. Can anyone give me some pointers what could be going wrong?

编辑:

public interface IF extends Shareable {
    public void method();
}

public class Server extends Applet implements IF {
    public getShareableInterfaceObject {
        return this;
    }
}

public class Client extends Applet {

    private Client() {
        AID ServerAID = JCSystem.lookupAID(byteArrayAID, (short)0, (byte)byteArrayAID.length);
        interface = (IF)JCSystem.getAppletShareableInterfaceObject(ServerAID, (byte)0x00);
    }

    public void process(APDU apdu) {
        interface.method();
    }
}

lookupAID返回正确的援助,但getAppletShareableInterfaceObject返回null,如果服务器小程序并不存在。

lookupAID returns the correct AID, but getAppletShareableInterfaceObject returns null as if the server applet didn't exist.

推荐答案

发现的错误。我试图初始化共享对象的构造函数。当时客户端的寄存器方法尚未叫,所以JCRE没有其AID。虽然我的服务器getShareableInterfaceObject(AID clientaid,字节参数)方法不需要客户端的援助是!= null,则JCRE可能确实,因为它要求我的客户此方法。我现在当我处理我的第一个APDU,现在可初始化我的共享对象。

Found the mistake. I tried to initialize the Shareable object in the constructor. At that time the client's register method is not yet called, so the JCRE doesn't have its AID. While my server's getShareableInterfaceObject(AID clientaid, byte parameter) method doesn't require the client's AID to be != null the JCRE probably does, since it calls this method for my client. I now initialize my Shareable object when I process my first APDU and it now works.

这篇关于Java卡可共享接口:lookupAID返回援助,但getAppletShareableInterface返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆