有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

身份验证Java非接触式smard卡身份验证

我是nfc相关开发的新手。我想构建一个java应用程序,用于读取和写入mifare desfire ev1智能卡中的安全元素。所以我找到了免费的图书馆。但问题是我想先验证智能卡。所以我创建了一些身份验证方法,并尝试使用它。但它总是说类不支持错误。在这段代码中,我想向应用程序加载一些键。首先我想知道我是否想创建一些应用程序,如果它想创建应用程序,如何能够首先进行身份验证

这是我的密码

    /**
      * Load key
      */
   public String loadKey(byte[] key, char keyType) throws CardException
   {
       String res = null;
       System.out.println("Load Key");
       CommandAPDU apdu = this.reader.loadKey(this.decoder.decode(key), keyType);
       showAPDU(apdu.getBytes());
       ResponseAPDU r = send(apdu);
       showResponse(r.toString());
       if (r.getSW() == E_NO_ERROR) {
           System.out.println("Sucessfully Load  keys");
       } else{
           System.out.println("load keys failed");
       }
       res = APDUtoJSON(r).toString();
       return res;
   } 
//send command apdu
private ResponseAPDU send(CommandAPDU cmdApdu) throws CardException {
    return card.getBasicChannel().transmit(cmdApdu);
}

// read response in main class i call these methods
byte[] key = new byte[]{(byte) 0x1a, (byte) 0x1a, (byte) 0x1a, (byte) 0x1a,
                        (byte) 0x1a, (byte) 0x1a, (byte) 0x1a, (byte) 0x1a,
                        (byte) 0x1a, (byte) 0x1a, (byte) 0x1a, (byte) 0x1a,
                        (byte) 0x1a, (byte) 0x1a, (byte) 0x1a, (byte) 0x1a};
terminal.loadKey(key, 'a');

共 (0) 个答案