use of iso.std.iso_iec._24727.tech.schema.InputAPDUInfoType in project open-ecard by ecsec.
the class AbstractPINAction method recognizeState.
/**
* Recognize the PIN state of the card given through the connection handle.
*
* @param cHandle The connection handle for the card for which the pin state should be recognized.
* @return The recognized State (may be {@code RecognizedState.UNKNOWN}).
*/
protected RecognizedState recognizeState(ConnectionHandleType cHandle) {
Transmit t = new Transmit();
t.setSlotHandle(cHandle.getSlotHandle());
InputAPDUInfoType inputAPDU = new InputAPDUInfoType();
inputAPDU.setInputAPDU(RECOGNIZE_APDU);
t.getInputAPDUInfo().add(inputAPDU);
TransmitResponse response = (TransmitResponse) dispatcher.safeDeliver(t);
byte[] responseAPDU = response.getOutputAPDU().get(0);
RecognizedState state;
if (ByteUtils.compare(RESPONSE_RC3, responseAPDU)) {
state = RecognizedState.PIN_activated_RC3;
} else if (ByteUtils.compare(RESPONSE_DEACTIVATED, responseAPDU)) {
state = RecognizedState.PIN_deactivated;
} else if (ByteUtils.compare(RESPONSE_RC2, responseAPDU)) {
state = RecognizedState.PIN_activated_RC2;
} else if (ByteUtils.compare(RESPONSE_SUSPENDED, responseAPDU)) {
state = RecognizedState.PIN_suspended;
} else if (ByteUtils.compare(RESPONSE_BLOCKED, responseAPDU)) {
state = RecognizedState.PIN_blocked;
} else {
LOG.error("Unhandled response to the PIN state recognition APDU: {}\n");
state = RecognizedState.UNKNOWN;
}
LOG.info("State of the PIN: {}.", state);
return state;
}
use of iso.std.iso_iec._24727.tech.schema.InputAPDUInfoType in project open-ecard by ecsec.
the class CardCommandAPDU method makeTransmit.
/**
* Creates a new Transmit message.
*
* @param slotHandle Slot handle
* @param responses Positive responses
* @return Transmit
*/
public Transmit makeTransmit(byte[] slotHandle, List<byte[]> responses) {
InputAPDUInfoType apdu = new InputAPDUInfoType();
apdu.setInputAPDU(toByteArray());
apdu.getAcceptableStatusCode().addAll(responses);
Transmit t = new Transmit();
t.setSlotHandle(slotHandle);
t.getInputAPDUInfo().add(apdu);
return t;
}
use of iso.std.iso_iec._24727.tech.schema.InputAPDUInfoType in project open-ecard by ecsec.
the class CardRecognitionImpl method transmit.
private byte[] transmit(byte[] slotHandle, byte[] input, List<ResponseAPDUType> results) {
Transmit t = new Transmit();
t.setSlotHandle(slotHandle);
InputAPDUInfoType apdu = new InputAPDUInfoType();
apdu.setInputAPDU(input);
for (ResponseAPDUType result : results) {
apdu.getAcceptableStatusCode().add(result.getTrailer());
}
t.getInputAPDUInfo().add(apdu);
TransmitResponse r = (TransmitResponse) env.getDispatcher().safeDeliver(t);
if (checkTransmitResult(r)) {
return r.getOutputAPDU().get(0);
} else {
return null;
}
}
use of iso.std.iso_iec._24727.tech.schema.InputAPDUInfoType in project open-ecard by ecsec.
the class TerminalTest method testTransmit.
@Test(enabled = false)
public void testTransmit() {
init();
Connect con = new Connect();
con.setContextHandle(ctxHandle);
con.setIFDName(ifdName);
con.setSlot(BigInteger.ZERO);
con.setExclusive(Boolean.FALSE);
slotHandle = ifd.connect(con).getSlotHandle();
Transmit t = new Transmit();
InputAPDUInfoType apdu = new InputAPDUInfoType();
apdu.getAcceptableStatusCode().add(new byte[] { (byte) 0x90, (byte) 0x00 });
apdu.setInputAPDU(new byte[] { (byte) 0x00, (byte) 0xA4, (byte) 0x04, (byte) 0x0C });
t.getInputAPDUInfo().add(apdu);
t.setSlotHandle(slotHandle);
TransmitResponse res = ifd.transmit(t);
assertEquals(ECardConstants.Major.OK, res.getResult().getResultMajor());
}
use of iso.std.iso_iec._24727.tech.schema.InputAPDUInfoType in project open-ecard by ecsec.
the class PINUtils method buildVerifyTransmit.
/**
* Build a Transmit containing a verify APDU.
*
* @param rawPIN the pin as entered by the user
* @param attributes attributes of the password (e.g. encoding and length)
* @param template the verify template
* @param slotHandle slot handle
* @return Transmit containing the built verify APDU
* @throws UtilException if an pin related error occurs (e.g. wrong PIN length)
*/
public static Transmit buildVerifyTransmit(char[] rawPIN, PasswordAttributesType attributes, byte[] template, byte[] slotHandle) throws UtilException {
// concatenate template with encoded pin
byte[] pin = PINUtils.encodePin(rawPIN, attributes);
byte[] pinCmd = ByteUtils.concatenate(template, (byte) pin.length);
pinCmd = ByteUtils.concatenate(pinCmd, pin);
Arrays.fill(pin, (byte) 0);
Transmit transmit = new Transmit();
transmit.setSlotHandle(slotHandle);
InputAPDUInfoType pinApdu = new InputAPDUInfoType();
pinApdu.setInputAPDU(pinCmd);
pinApdu.getAcceptableStatusCode().add(new byte[] { (byte) 0x90, (byte) 0x00 });
transmit.getInputAPDUInfo().add(pinApdu);
return transmit;
}
Aggregations