Javacard 共享接口:lookupAID 返回 AID 但 getAppletShareableInterface 返回 null [英] Javacard Shareable Interface: lookupAID returns AID but getAppletShareableInterface returns null

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

问题描述

发现错误.我试图在构造函数中初始化 Shareable 对象.那时客户端的注册方法还没有被调用,所以 JCRE 没有它的 AID.虽然我的服务器的 getShareableInterfaceObject(AID clientaid, byte parameter) 方法不要求客户端的 AID 为 != null,但 JCRE 可能会这样做,因为它为我的客户端调用了这个方法.我现在在处理我的第一个 APDU 时初始化了我的 Shareable 对象,它现在可以工作了.

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 Card 开发的新手,我的 Shareable 界面无法正常工作.

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

我有一个接口类,声明了我的客户端小程序想要使用的函数.我的服务器小程序实现了这个类.我的客户端小程序查找 AID 并尝试通过调用 getAppletShareableInterface() 获取接口.但这总是返回 null.

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() 仅由 return this; 组成,所以我猜问题出在别处.但我不知道在哪里.

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

我正在使用 JCWDE 并逐步执行代码,我看到我的服务器小程序调用注册,因此客户端小程序应该能够找到它.谁能给我一些提示可能出了什么问题?

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 返回正确的 AID,但 getAppletShareableInterfaceObject 返回 null,就好像服务器小程序不存在一样.

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

推荐答案

发现错误.我试图在构造函数中初始化 Shareable 对象.那时客户端的注册方法还没有被调用,所以 JCRE 没有它的 AID.虽然我的服务器的 getShareableInterfaceObject(AID clientaid, byte parameter) 方法不要求客户端的 AID 为 != null,但 JCRE 可能会这样做,因为它为我的客户端调用了这个方法.我现在在处理我的第一个 APDU 时初始化了我的 Shareable 对象,它现在可以工作了.

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.

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

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