Search in sources :

Example 6 with InputAPDUInfoType

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;
}
Also used : Transmit(iso.std.iso_iec._24727.tech.schema.Transmit) InputAPDUInfoType(iso.std.iso_iec._24727.tech.schema.InputAPDUInfoType) TransmitResponse(iso.std.iso_iec._24727.tech.schema.TransmitResponse)

Example 7 with InputAPDUInfoType

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;
}
Also used : Transmit(iso.std.iso_iec._24727.tech.schema.Transmit) InputAPDUInfoType(iso.std.iso_iec._24727.tech.schema.InputAPDUInfoType)

Example 8 with InputAPDUInfoType

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;
    }
}
Also used : Transmit(iso.std.iso_iec._24727.tech.schema.Transmit) InputAPDUInfoType(iso.std.iso_iec._24727.tech.schema.InputAPDUInfoType) TransmitResponse(iso.std.iso_iec._24727.tech.schema.TransmitResponse) ResponseAPDUType(iso.std.iso_iec._24727.tech.schema.ResponseAPDUType)

Example 9 with InputAPDUInfoType

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());
}
Also used : Transmit(iso.std.iso_iec._24727.tech.schema.Transmit) Connect(iso.std.iso_iec._24727.tech.schema.Connect) InputAPDUInfoType(iso.std.iso_iec._24727.tech.schema.InputAPDUInfoType) TransmitResponse(iso.std.iso_iec._24727.tech.schema.TransmitResponse) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest)

Example 10 with InputAPDUInfoType

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;
}
Also used : Transmit(iso.std.iso_iec._24727.tech.schema.Transmit) InputAPDUInfoType(iso.std.iso_iec._24727.tech.schema.InputAPDUInfoType)

Aggregations

InputAPDUInfoType (iso.std.iso_iec._24727.tech.schema.InputAPDUInfoType)10 Transmit (iso.std.iso_iec._24727.tech.schema.Transmit)8 TransmitResponse (iso.std.iso_iec._24727.tech.schema.TransmitResponse)7 Result (oasis.names.tc.dss._1_0.core.schema.Result)3 CardResponseAPDU (org.openecard.common.apdu.common.CardResponseAPDU)3 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)2 DIDAuthenticateResponse (iso.std.iso_iec._24727.tech.schema.DIDAuthenticateResponse)2 InputUnitType (iso.std.iso_iec._24727.tech.schema.InputUnitType)2 PasswordAttributesType (iso.std.iso_iec._24727.tech.schema.PasswordAttributesType)2 PinInputType (iso.std.iso_iec._24727.tech.schema.PinInputType)2 VerifyUserResponse (iso.std.iso_iec._24727.tech.schema.VerifyUserResponse)2 BigInteger (java.math.BigInteger)2 CardStateEntry (org.openecard.common.sal.state.CardStateEntry)2 ResultStatus (org.openecard.gui.ResultStatus)2 UserConsentNavigator (org.openecard.gui.UserConsentNavigator)2 UserConsentDescription (org.openecard.gui.definition.UserConsentDescription)2 ExecutionEngine (org.openecard.gui.executor.ExecutionEngine)2 AltVUMessagesType (iso.std.iso_iec._24727.tech.schema.AltVUMessagesType)1 Connect (iso.std.iso_iec._24727.tech.schema.Connect)1 DIDAuthenticate (iso.std.iso_iec._24727.tech.schema.DIDAuthenticate)1