use of iso.std.iso_iec._24727.tech.schema.ConnectionHandleType.RecognitionInfo in project open-ecard by ecsec.
the class ExecuteRecognition method testExecute.
@Test(enabled = false)
public void testExecute() throws Exception {
Environment env = new ClientEnv();
IFD ifd = new org.openecard.ifd.scio.IFD();
env.setIFD(ifd);
byte[] ctx;
// establish context
EstablishContext eCtx = new EstablishContext();
EstablishContextResponse eCtxR = ifd.establishContext(eCtx);
ctx = eCtxR.getContextHandle();
// get status to see if we can execute the recognition
GetStatus status = new GetStatus();
status.setContextHandle(ctx);
GetStatusResponse statusR = ifd.getStatus(status);
if (statusR.getIFDStatus().size() > 0 && statusR.getIFDStatus().get(0).getSlotStatus().get(0).isCardAvailable()) {
CardRecognitionImpl recog = new CardRecognitionImpl(env);
IFDStatusType stat = statusR.getIFDStatus().get(0);
RecognitionInfo info = recog.recognizeCard(ctx, stat.getIFDName(), BigInteger.ZERO);
if (info == null) {
System.out.println("Card not recognized.");
} else {
System.out.println(info.getCardType());
}
}
}
use of iso.std.iso_iec._24727.tech.schema.ConnectionHandleType.RecognitionInfo in project open-ecard by ecsec.
the class Status method signalEvent.
@Override
public synchronized void signalEvent(EventType eventType, EventObject eventData) {
LOG.debug("Event: {}", eventType);
ConnectionHandleType ch = eventData.getHandle();
if (ch == null) {
LOG.error("No handle provided in event {}.", eventType);
return;
}
LOG.debug("ConnectionHandle: {}", ch);
RecognitionInfo info = ch.getRecognitionInfo();
LOG.debug("RecognitionInfo: {}", info);
String ifdName = ch.getIFDName();
LOG.debug("IFDName: {}", ifdName);
if (null != eventType) {
switch(eventType) {
case TERMINAL_ADDED:
addInfo(ifdName, info);
break;
case TERMINAL_REMOVED:
removeInfo(ifdName);
break;
default:
// track status of the events to prevent double events to overwrite the actual status
EventType lastStatus = cardStatus.get(ifdName);
// only update status for recognized cards in case it is a card removed
if (EventType.CARD_RECOGNIZED == lastStatus) {
if (EventType.CARD_REMOVED == eventType) {
cardStatus.remove(ifdName);
updateInfo(ifdName, info);
}
} else {
if (EventType.CARD_REMOVED == eventType) {
cardStatus.remove(ifdName);
} else {
cardStatus.put(ifdName, eventType);
}
updateInfo(ifdName, info);
}
}
}
}
Aggregations