Class SmartCardProtocol
java.lang.Object
com.yubico.yubikit.core.smartcard.SmartCardProtocol
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class SmartCardProtocol
extends java.lang.Object
implements java.io.Closeable
Support class for communication over a SmartCardConnection.
This class handles APDU encoding and chaining, and implements workarounds for known issues.
-
Constructor Summary
Constructors Constructor Description SmartCardProtocol(SmartCardConnection connection)
Create new instance ofSmartCardProtocol
and selects the application for useSmartCardProtocol(SmartCardConnection connection, byte insSendRemaining)
-
Method Summary
Modifier and Type Method Description void
close()
void
enableWorkarounds(Version firmwareVersion)
Enable all relevant workarounds given the firmware version of the YubiKey.SmartCardConnection
getConnection()
byte[]
select(byte[] aid)
Sends an APDU to SELECT an Application.byte[]
sendAndReceive(Apdu command)
Sends APDU command and receives byte array from connection In case if output has status code that it has remaining info sends another APDU command to receive what's remainingvoid
setApduFormat(ApduFormat apduFormat)
YubiKey NEO doesn't support extended APDU's for most applications.void
setEnableTouchWorkaround(boolean enableTouchWorkaround)
YubiKey 4.2.0 - 4.2.6 have an issue with the touch timeout being too short in certain cases.
-
Constructor Details
-
SmartCardProtocol
Create new instance ofSmartCardProtocol
and selects the application for use- Parameters:
connection
- connection to the YubiKey
-
SmartCardProtocol
-
-
Method Details
-
close
public void close() throws java.io.IOException- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
enableWorkarounds
Enable all relevant workarounds given the firmware version of the YubiKey.- Parameters:
firmwareVersion
- the firmware version to use for detection to enable the workarounds
-
setEnableTouchWorkaround
public void setEnableTouchWorkaround(boolean enableTouchWorkaround)YubiKey 4.2.0 - 4.2.6 have an issue with the touch timeout being too short in certain cases. Enable this workaround on such devices to trigger sending a dummy command which mitigates the issue.- Parameters:
enableTouchWorkaround
- true to enable the workaround, false to disable it
-
setApduFormat
YubiKey NEO doesn't support extended APDU's for most applications.- Parameters:
apduFormat
- the APDU encoding to use when sending commands
-
getConnection
- Returns:
- the underlying connection
-
select
Sends an APDU to SELECT an Application.- Parameters:
aid
- the AID to select.- Returns:
- the response data from selecting the Application
- Throws:
java.io.IOException
- in case of connection or communication errorApplicationNotAvailableException
- in case the AID doesn't match an available application
-
sendAndReceive
Sends APDU command and receives byte array from connection In case if output has status code that it has remaining info sends another APDU command to receive what's remaining- Parameters:
command
- well structured command that needs to be send- Returns:
- data blob concatenated from all APDU commands that were sent *set of output commands and send remaining commands)
- Throws:
java.io.IOException
- in case of connection and communication errorApduException
- in case if received error in APDU response
-