Prevent software slots to trigger events
@@ -74,6 +74,7 @@ class MwEventRunner implements Runnable {
void initRunner() throws CryptokiException {
for (MwSlot slot : this.mwModule.getSlotList(TokenState.NotPresent)) {
+ if (isHwSlot(slot)) {
this.sendTerminalAdded(slot);
String ifdName = slot.getSlotInfo().getSlotDescription();
@@ -88,6 +89,7 @@ class MwEventRunner implements Runnable {
}
}
}
+ }
@Override
public void run() {
@@ -120,7 +122,7 @@ class MwEventRunner implements Runnable {
boolean isProcessed = false;
// find actual slot object
for (MwSlot slot : this.mwModule.getSlotList(false)) {
- if (slot.getSlotInfo().getSlotID() == slotId) {
+ if (isHwSlot(slot) && slot.getSlotInfo().getSlotID() == slotId) {
isProcessed = true;
String ifdName = slot.getSlotInfo().getSlotDescription();
LOG.debug("Slot event recognized, slotId={}, ifdName={}.", slotId, ifdName);
@@ -136,7 +138,6 @@ class MwEventRunner implements Runnable {
LOG.debug("Error requesting token information.", ex);
this.sendCardRemoved(slot);
}
- } else {
}
}
if (! isProcessed) {
@@ -311,6 +312,10 @@ class MwEventRunner implements Runnable {
return h;
}
+ private boolean isHwSlot(MwSlot slot) {
+ return (slot.getSlotInfo().getFlags() & CryptokiLibrary.CKF_HW_SLOT) > 0;
+ }
+
//Struct for caching
private class SlotInfo {
public long slotId;
