- java.lang.Object
-
- apdu4j.core.SmartCardAppFutures
-
- All Implemented Interfaces:
AsynchronousBIBO
,SmartCardApp
,SmartCardAppListener
public abstract class SmartCardAppFutures extends Object implements SmartCardAppListener, AsynchronousBIBO
Default implementation of SmartCardAppListener that provides CompletableFuture-s for all eventsExtend this class for simple app flow with futures
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface apdu4j.core.SmartCardAppListener
SmartCardAppListener.AppParameters, SmartCardAppListener.CardData
-
-
Constructor Summary
Constructors Constructor Description SmartCardAppFutures()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
CompletableFuture<Map>
getCardPresentFuture()
void
onCardPresent(AsynchronousBIBO transport, SmartCardAppListener.CardData props)
Called for every chip session.void
onCardRemoved()
Called when error occurs or when card is removed in multi-session app.void
onError(Throwable e)
Technical error when communicating with the reader, no further communication possible.CompletableFuture<SmartCardAppListener.AppParameters>
onStart(String[] argv)
Complete the returned future to start application (emit onCardPresent)CompletableFuture<byte[]>
transmit(byte[] apdu)
Transceives a bunch of bytes to a secure element, asynchronously.CompletableFuture<Map>
waitForCard(TimeUnit unit, long duration)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface apdu4j.core.SmartCardApp
getDescription, getName
-
-
-
-
Method Detail
-
transmit
public CompletableFuture<byte[]> transmit(byte[] apdu)
Description copied from interface:AsynchronousBIBO
Transceives a bunch of bytes to a secure element, asynchronously.Comparable to:
IsoDep.transceive() in Android SCardTransmit() in PC/SC CardChannel.transmit(ByteBuffer, ByteBuffer) in javax.smartcardio Channel.transmit() in OpenMobileAPI The future is completed exceptionally if a response APDU can not be retrieved.
- Specified by:
transmit
in interfaceAsynchronousBIBO
- Parameters:
apdu
- payload- Returns:
- the bytes returned from the SE. The size should always be >= 2 bytes
-
getCardPresentFuture
public CompletableFuture<Map> getCardPresentFuture()
-
waitForCard
public CompletableFuture<Map> waitForCard(TimeUnit unit, long duration)
-
close
public void close()
- Specified by:
close
in interfaceAsynchronousBIBO
-
onStart
public CompletableFuture<SmartCardAppListener.AppParameters> onStart(String[] argv)
Description copied from interface:SmartCardAppListener
Complete the returned future to start application (emit onCardPresent)- Specified by:
onStart
in interfaceSmartCardAppListener
- Returns:
-
onCardPresent
public void onCardPresent(AsynchronousBIBO transport, SmartCardAppListener.CardData props)
Description copied from interface:SmartCardAppListener
Called for every chip session. This means a "freshly" started chip. transport.done() may or may not power down the chip for new session- Specified by:
onCardPresent
in interfaceSmartCardAppListener
-
onCardRemoved
public void onCardRemoved()
Description copied from interface:SmartCardAppListener
Called when error occurs or when card is removed in multi-session app. onError could also be triggered.- Specified by:
onCardRemoved
in interfaceSmartCardAppListener
-
onError
public void onError(Throwable e)
Description copied from interface:SmartCardAppListener
Technical error when communicating with the reader, no further communication possible. May be preceded by onCardRemoved.- Specified by:
onError
in interfaceSmartCardAppListener
-
-