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