当我调用以下代码行时,我的applet崩溃了
RandomData rd = RandomData.getInstance(RandomData.ALG_SECURE_RANDOM);
我得到以下输出:
OffCard Installer [v3.0.2]
Copyright (c) 2009 Sun Microsystems, Inc.
All rights reserved.
Use is subject to license terms.
[ INFO: ] [Creating an instance of ClassicApplet1 with instance ID //aid/E96473AB62/DF on http://localhost:8019/cardmanager]
[ INFO: ] "Off Card Installer validating create information"
[ INFO: ] "Off Card Installer preparing create information"
[ INFO: ] "Off Card Installer sending create request"
[ INFO: ] Create failed: null
run-client:
run-script:
Invoking apdutool on C:\Users\Daniel\Documents\NetBeansProjects\ClassicApplet1/scripts/classicapplet1.scr
ApduTool [v3.0.2]
Copyright (c) 2009 Sun Microsystems, Inc.
All rights reserved.
Use is subject to license terms.
Opening connection to localhost on port 9025.
Connected.
Received ATR = 0x3b 0xf0 0x11 0x00 0xff 0x00
CLA: 00, INS: a4, P1: 04, P2: 00, Lc: 06, e9, 64, 73, ab, 62, df, Le: 00, SW1: 69, SW2: 99
run-for-debug:
BUILD SUCCESSFUL (total time: 25 seconds)
坠机的原因/原因是什么?注意:我是java智能购物车生态系统的新手。
Off Card Installer sending create request
答案 0 :(得分:2)
您的卡可能不支持RandomData.ALG_SECURE_RANDOM
。
为了证明这一点,请尝试使用try-catch块围绕该行:
try {
RandomData.getInstance(RandomData.ALG_SECURE_RANDOM);
} catch(CryptoException e) {
if (e.getReason() != CryptoException.NO_SUCH_ALGORITHM) {
throw e;
}
}
您必须使用RandomData.ALG_PSEUDO_RANDOM
。遗憾的是,此算法的安全性无法保证,因此您必须非常小心,并且应该联系您的卡供应商。