Search in sources :

Example 1 with MwToken

use of org.openecard.mdlw.sal.MwToken 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 2 with MwToken

use of org.openecard.mdlw.sal.MwToken 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)

Aggregations

ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)2 MwToken (org.openecard.mdlw.sal.MwToken)2 CardInfoType (iso.std.iso_iec._24727.tech.schema.CardInfoType)1 CardStateEntry (org.openecard.common.sal.state.CardStateEntry)1 MwSlot (org.openecard.mdlw.sal.MwSlot)1 MiddlewareConfig (org.openecard.mdlw.sal.config.MiddlewareConfig)1 CryptokiException (org.openecard.mdlw.sal.exceptions.CryptokiException)1 CkSlot (org.openecard.mdlw.sal.struct.CkSlot)1