Search in sources :

Example 16 with ConnectionHandleType

use of iso.std.iso_iec._24727.tech.schema.ConnectionHandleType in project open-ecard by ecsec.

the class MwEventRunner method sendCardRecognized.

private void sendCardRecognized(MwSlot slot) throws CryptokiException {
    if (slots.get(slot.getSlotInfo().getSlotID()).isCardRecognized) {
        // Event already sended
        return;
    }
    MwToken token = slot.getTokenInfo();
    CkSlot ckSlot = slot.getSlotInfo();
    String cardType = String.format("%s_%s", token.getManufacturerID(), token.getModel());
    LOG.info("Middleware card type: {}", cardType);
    cardType = mwModule.getMiddlewareSALConfig().mapMiddlewareType(cardType);
    if (cardType != null) {
        boolean protectedAuthPath = token.containsFlag(Flag.CKF_PROTECTED_AUTHENTICATION_PATH);
        ConnectionHandleType recHandle = makeKnownCardHandle(ckSlot.getSlotDescription(), ckSlot.getSlotID(), cardType, protectedAuthPath);
        MwEventObject recEvent = new MwEventObject(recHandle, slot);
        // recognize card and create card state entry
        if (mwCallback.addEntry(recEvent)) {
            notify(EventType.CARD_RECOGNIZED, recEvent);
        }
        // For Cache
        slots.get(slot.getSlotInfo().getSlotID()).isCardRecognized = true;
    }
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) CkSlot(org.openecard.mdlw.sal.struct.CkSlot) MwToken(org.openecard.mdlw.sal.MwToken)

Example 17 with ConnectionHandleType

use of iso.std.iso_iec._24727.tech.schema.ConnectionHandleType in project open-ecard by ecsec.

the class MwEventRunner method sendTerminalAdded.

private void sendTerminalAdded(MwSlot slot) {
    // Add Terminal to cache if not present
    if (slots.get(slot.getSlotInfo().getSlotID()) == null) {
        SlotInfo sl = new SlotInfo();
        sl.ifdName = slot.getSlotInfo().getSlotDescription();
        sl.slotId = slot.getSlotInfo().getSlotID();
        slots.put(slot.getSlotInfo().getSlotID(), sl);
    } else {
        // Event already sent
        return;
    }
    String ifdName = slot.getSlotInfo().getSlotDescription();
    long slotId = slot.getSlotInfo().getSlotID();
    // send terminal added
    LOG.debug("Sending TERMINAL_ADDED event, ifdName={} id={}.", ifdName, slotId);
    ConnectionHandleType insertHandle = makeConnectionHandle(ifdName, slotId);
    MwEventObject addedEvent = new MwEventObject(insertHandle, slot);
    notify(EventType.TERMINAL_ADDED, addedEvent);
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)

Example 18 with ConnectionHandleType

use of iso.std.iso_iec._24727.tech.schema.ConnectionHandleType in project open-ecard by ecsec.

the class MwEventRunner method sendCardRemoved.

private void sendCardRemoved(SlotInfo sl) {
    if (!slots.get(sl.slotId).isCardPresent) {
        // Event already sended
        return;
    }
    ConnectionHandleType handle = makeConnectionHandle(sl.ifdName, sl.slotId);
    MwEventObject remEvent = new MwEventObject(handle, null);
    // remove card state entry
    mwCallback.removeEntry(remEvent);
    notify(EventType.CARD_REMOVED, remEvent);
    // For Cache
    slots.get(sl.slotId).isCardPresent = false;
    slots.get(sl.slotId).isCardRecognized = false;
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)

Example 19 with ConnectionHandleType

use of iso.std.iso_iec._24727.tech.schema.ConnectionHandleType in project open-ecard by ecsec.

the class MwStateCallback method addEntry.

public boolean addEntry(MwEventObject o) {
    try {
        ConnectionHandleType handle = o.getHandle();
        MwSlot slot = o.getMwSlot();
        MwToken token = slot.getTokenInfo();
        String cardType = null;
        String type = String.format("%s_%s", token.getManufacturerID(), token.getModel());
        for (MiddlewareConfig mwConfig : mwConfigs) {
            cardType = mwConfig.mapMiddlewareType(type);
            if (cardType != null) {
                break;
            }
        }
        CardInfoType cif = null;
        if (cardType != null) {
            cif = env.getCIFProvider().getCardInfo(handle, cardType);
        }
        if (cif == null) {
            LOG.warn("Unknown card recognized by Middleware.");
            return false;
        }
        // create new entry in card states
        CardStateEntry entry = new CardStateEntry(handle, cif, null);
        states.addEntry(entry);
        return true;
    } catch (CryptokiException ex) {
        LOG.info("Cryptoki Token invalid.", ex);
    } catch (RuntimeException ex) {
        LOG.error("Error in CIF augmentation process.", ex);
    }
    return false;
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) MwSlot(org.openecard.mdlw.sal.MwSlot) CardStateEntry(org.openecard.common.sal.state.CardStateEntry) CardInfoType(iso.std.iso_iec._24727.tech.schema.CardInfoType) CryptokiException(org.openecard.mdlw.sal.exceptions.CryptokiException) MiddlewareConfig(org.openecard.mdlw.sal.config.MiddlewareConfig) MwToken(org.openecard.mdlw.sal.MwToken)

Example 20 with ConnectionHandleType

use of iso.std.iso_iec._24727.tech.schema.ConnectionHandleType in project open-ecard by ecsec.

the class MwStateCallback method removeEntry.

public void removeEntry(MwEventObject o) {
    LOG.info("Remove card");
    ConnectionHandleType handle = o.getHandle();
    states.removeEntry(handle);
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)

Aggregations

ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)110 CardStateEntry (org.openecard.common.sal.state.CardStateEntry)47 ECardException (org.openecard.common.ECardException)43 IncorrectParameterException (org.openecard.common.sal.exception.IncorrectParameterException)37 ThreadTerminateException (org.openecard.common.ThreadTerminateException)36 NamedEntityNotFoundException (org.openecard.common.sal.exception.NamedEntityNotFoundException)34 UnknownProtocolException (org.openecard.common.sal.exception.UnknownProtocolException)34 TLVException (org.openecard.common.tlv.TLVException)29 AddonNotFoundException (org.openecard.addon.AddonNotFoundException)28 InappropriateProtocolForActionException (org.openecard.common.sal.exception.InappropriateProtocolForActionException)28 NameExistsException (org.openecard.common.sal.exception.NameExistsException)28 PrerequisitesNotSatisfiedException (org.openecard.common.sal.exception.PrerequisitesNotSatisfiedException)28 SecurityConditionNotSatisfiedException (org.openecard.common.sal.exception.SecurityConditionNotSatisfiedException)28 UnknownConnectionHandleException (org.openecard.common.sal.exception.UnknownConnectionHandleException)28 DIDStructureType (iso.std.iso_iec._24727.tech.schema.DIDStructureType)22 Publish (org.openecard.common.interfaces.Publish)17 CardApplicationConnectResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse)15 ArrayList (java.util.ArrayList)15 CardApplicationConnect (iso.std.iso_iec._24727.tech.schema.CardApplicationConnect)14 CardApplicationPathType (iso.std.iso_iec._24727.tech.schema.CardApplicationPathType)14