use of org.openecard.common.event.EventType 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);
}
}
}
}
use of org.openecard.common.event.EventType in project open-ecard by ecsec.
the class PAOSTask method call.
@Override
public StartPAOSResponse call() throws MalformedURLException, PAOSException, DispatcherException, InvocationTargetException, ConnectionError, PAOSConnectionException {
// add event listener terminating the whole process in case the card is removed
final Thread execThread = Thread.currentThread();
EventCallback disconnectEventSink = new EventCallback() {
@Override
public void signalEvent(EventType eventType, EventObject eventData) {
if (eventType == EventType.CARD_REMOVED) {
LOG.info("Card has been removed during authentication. Shutting down EAC process.");
execThread.interrupt();
}
}
};
EventFilter evFilter = new CardRemovedFilter(connectionHandle.getIFDName(), connectionHandle.getSlotIndex());
evManager.add(disconnectEventSink, evFilter);
try {
TlsConnectionHandler tlsHandler = new TlsConnectionHandler(dispatcher, tokenRequest, connectionHandle);
tlsHandler.setUpClient();
// Set up PAOS connection
PAOS p = new PAOS(dispatcher, tlsHandler);
// Create StartPAOS message
StartPAOS sp = new StartPAOS();
sp.setProfile(ECardConstants.Profile.ECARD_1_1);
sp.getConnectionHandle().add(getHandleForServer());
sp.setSessionIdentifier(tlsHandler.getSessionId());
StartPAOS.UserAgent ua = new StartPAOS.UserAgent();
ua.setName(AppVersion.getName());
ua.setVersionMajor(BigInteger.valueOf(AppVersion.getMajor()));
ua.setVersionMinor(BigInteger.valueOf(AppVersion.getMinor()));
ua.setVersionSubminor(BigInteger.valueOf(AppVersion.getPatch()));
sp.setUserAgent(ua);
StartPAOS.SupportedAPIVersions sv = new StartPAOS.SupportedAPIVersions();
sv.setMajor(ECardConstants.ECARD_API_VERSION_MAJOR);
sv.setMinor(ECardConstants.ECARD_API_VERSION_MINOR);
sv.setSubminor(ECardConstants.ECARD_API_VERSION_SUBMINOR);
sp.getSupportedAPIVersions().add(sv);
sp.getSupportedDIDProtocols().addAll(supportedDIDs);
return p.sendStartPAOS(sp);
} finally {
evManager.del(disconnectEventSink);
TCTokenHandler.disconnectHandle(dispatcher, connectionHandle);
TCTokenHandler.killUserConsent();
}
}
Aggregations