我调用verify()方法从读卡器读取PIN(omnikey 3821),但我有以下例外:
WINDOWS_ERROR_INVALID_PARAMETER
我认为问题是方法transmitControlCommand的第二个参数抛出以下错误:
javax.smartcardio.CardException: transmitControlCommand() failed
at sun.security.smartcardio.CardImpl.transmitControlCommand(Unknown Source)
at adminServ.Transaction.verify(Transaction.java:34)
at adminServ.Transaction.venteMenu(Transaction.java:160)
at adminServ.SampleClient.main(SampleClient.java:541)
Caused by: sun.security.smartcardio.PCSCException: WINDOWS_ERROR_INVALID_PARAMETER
at sun.security.smartcardio.PCSC.SCardControl(Native Method)
... 4 more
transmitControlCommand() failed.
我的代码:
/* la méthode verify() */
private void verify() throws CadTransportException,IOException, CardException, PCSCException
{
byte[] PIN_VERIFY = super.createPINVerifyStructure();
byte [] rep= super.c.transmitControlCommand(3223564, PIN_VERIFY);
}
/* la méthode createPINVerifyStructure() */
protected static byte[] createPINVerifyStructure() {
// VerifyAPDUSpec apduSpec = new VerifyAPDUSpec(
byte[] apdu = new byte[] { (byte) 0x80, (byte) 0x20, (byte) 0x00,
(byte) 0x00, (byte) 0x06, (byte) 0xFF, (byte) 0xFF,
(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
// 1, VerifyAPDUSpec.PIN_FORMAT_BCD, 7, 4, 4);
ByteArrayOutputStream s = new ByteArrayOutputStream();
s.write(bTimeOut);
s.write(bTimeOut2);
s.write(0x82);
s.write(0x04);
s.write(0x00);
s.write(wPINMaxExtraDigitMax); // max PIN length
s.write(wPINMaxExtraDigitMin); // min PIN length
s.write(bEntryValidationCondition);
// bNumberMessage
s.write(0x01);
// wLangId [0x04 0x09 english, little endian]
s.write(0x04);
s.write(0x09);
// bMsgIndex
s.write(0x01);
// bTeoPrologue
s.write(0x00);
s.write(0x00);
s.write(0x00);
// ulDataLength
s.write(apdu.length);
s.write(0x00);
s.write(0x00);
s.write(0x00);
// abData
try {
s.write(apdu);
} catch (IOException e) {
// As we are dealing with ByteArrayOutputStreams no exception is to
// be
// expected.
throw new RuntimeException(e);
}
return s.toByteArray();
}
请帮忙。