Search in sources :

Example 11 with RecognitionInfo

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());
        }
    }
}
Also used : GetStatusResponse(iso.std.iso_iec._24727.tech.schema.GetStatusResponse) IFD(org.openecard.ws.IFD) EstablishContextResponse(iso.std.iso_iec._24727.tech.schema.EstablishContextResponse) ClientEnv(org.openecard.common.ClientEnv) RecognitionInfo(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType.RecognitionInfo) Environment(org.openecard.common.interfaces.Environment) IFDStatusType(iso.std.iso_iec._24727.tech.schema.IFDStatusType) EstablishContext(iso.std.iso_iec._24727.tech.schema.EstablishContext) GetStatus(iso.std.iso_iec._24727.tech.schema.GetStatus) Test(org.testng.annotations.Test)

Example 12 with RecognitionInfo

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);
                }
        }
    }
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) RecognitionInfo(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType.RecognitionInfo) EventType(org.openecard.common.event.EventType)

Aggregations

RecognitionInfo (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType.RecognitionInfo)10 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)7 BigInteger (java.math.BigInteger)6 EstablishContext (iso.std.iso_iec._24727.tech.schema.EstablishContext)5 EstablishContextResponse (iso.std.iso_iec._24727.tech.schema.EstablishContextResponse)5 ListIFDs (iso.std.iso_iec._24727.tech.schema.ListIFDs)4 ListIFDsResponse (iso.std.iso_iec._24727.tech.schema.ListIFDsResponse)4 ClientEnv (org.openecard.common.ClientEnv)4 ChannelHandleType (iso.std.iso_iec._24727.tech.schema.ChannelHandleType)3 IfdEventObject (org.openecard.common.event.IfdEventObject)3 CIFProvider (org.openecard.common.interfaces.CIFProvider)3 Dispatcher (org.openecard.common.interfaces.Dispatcher)3 CardStateMap (org.openecard.common.sal.state.CardStateMap)3 SALStateCallback (org.openecard.common.sal.state.SALStateCallback)3 IFD (org.openecard.ifd.scio.IFD)3 CardRecognitionImpl (org.openecard.recognition.CardRecognitionImpl)3 MessageDispatcher (org.openecard.transport.dispatcher.MessageDispatcher)3 BeforeMethod (org.testng.annotations.BeforeMethod)3 CardApplicationConnect (iso.std.iso_iec._24727.tech.schema.CardApplicationConnect)2 CardApplicationConnectResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse)2