use of org.openecard.common.interfaces.EventCallback 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