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;
}
}
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;
}
Aggregations