Package com.yubico.yubikit.management
Class ManagementSession
java.lang.Object
com.yubico.yubikit.core.application.ApplicationSession<ManagementSession>
com.yubico.yubikit.management.ManagementSession
- All Implemented Interfaces:
Closeable,AutoCloseable
public class ManagementSession
extends com.yubico.yubikit.core.application.ApplicationSession<ManagementSession>
Application to get information about and configure a YubiKey via the Management Application.
https://developers.yubico.com/yubikey-manager/Config_Reference.html
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.yubico.yubikit.core.application.Feature<ManagementSession>Support for writing DeviceConfig data to the YubiKey.static final com.yubico.yubikit.core.application.Feature<ManagementSession>Support for reading the DeviceInfo data from the YubiKey.static final com.yubico.yubikit.core.application.Feature<ManagementSession>Support the SET_MODE command to change the USB mode of the YubiKey. -
Constructor Summary
ConstructorsConstructorDescriptionManagementSession(com.yubico.yubikit.core.fido.FidoConnection connection) Establishes a new session with a YubiKeys Management application, over aFidoConnection.ManagementSession(com.yubico.yubikit.core.otp.OtpConnection connection) Establishes a new session with a YubiKeys Management application, over anOtpConnection.ManagementSession(com.yubico.yubikit.core.smartcard.SmartCardConnection connection) Establishes a new session with a YubiKeys Management application, over aSmartCardConnection. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()static voidcreate(com.yubico.yubikit.core.YubiKeyDevice device, com.yubico.yubikit.core.util.Callback<com.yubico.yubikit.core.util.Result<ManagementSession, Exception>> callback) Connects to a YubiKeyDevice and establishes a new session with a YubiKeys Management application.Get device information from the YubiKey.com.yubico.yubikit.core.VersionvoidsetMode(com.yubico.yubikit.core.UsbInterface.Mode mode, byte chalrespTimeout, short autoejectTimeout) Write device configuration for YubiKey NEO and YubiKey 4.voidupdateDeviceConfig(DeviceConfig config, boolean reboot, byte[] currentLockCode, byte[] newLockCode) Write device configuration to a YubiKey 5 or later.Methods inherited from class com.yubico.yubikit.core.application.ApplicationSession
require, supports
-
Field Details
-
FEATURE_MODE
Support the SET_MODE command to change the USB mode of the YubiKey. -
FEATURE_DEVICE_INFO
public static final com.yubico.yubikit.core.application.Feature<ManagementSession> FEATURE_DEVICE_INFOSupport for reading the DeviceInfo data from the YubiKey. -
FEATURE_DEVICE_CONFIG
public static final com.yubico.yubikit.core.application.Feature<ManagementSession> FEATURE_DEVICE_CONFIGSupport for writing DeviceConfig data to the YubiKey.
-
-
Constructor Details
-
ManagementSession
public ManagementSession(com.yubico.yubikit.core.smartcard.SmartCardConnection connection) throws IOException, com.yubico.yubikit.core.application.ApplicationNotAvailableException Establishes a new session with a YubiKeys Management application, over aSmartCardConnection.- Parameters:
connection- connection with YubiKey- Throws:
IOException- in case of connection errorcom.yubico.yubikit.core.application.ApplicationNotAvailableException- in case the application is missing/disabled
-
ManagementSession
public ManagementSession(com.yubico.yubikit.core.otp.OtpConnection connection) throws IOException, com.yubico.yubikit.core.application.ApplicationNotAvailableException Establishes a new session with a YubiKeys Management application, over anOtpConnection.- Parameters:
connection- connection with YubiKey- Throws:
IOException- in case of connection errorcom.yubico.yubikit.core.application.ApplicationNotAvailableException- in case the application is missing/disabled
-
ManagementSession
Establishes a new session with a YubiKeys Management application, over aFidoConnection.- Parameters:
connection- a connection over the FIDO USB transport with a YubiKey- Throws:
IOException- in case of connection error
-
-
Method Details
-
create
public static void create(com.yubico.yubikit.core.YubiKeyDevice device, com.yubico.yubikit.core.util.Callback<com.yubico.yubikit.core.util.Result<ManagementSession, Exception>> callback) Connects to a YubiKeyDevice and establishes a new session with a YubiKeys Management application.This method will use whichever connection type is available.
- Parameters:
device- A YubiKey device to use
-
close
- Throws:
IOException
-
getVersion
public com.yubico.yubikit.core.Version getVersion()- Specified by:
getVersionin classcom.yubico.yubikit.core.application.ApplicationSession<ManagementSession>
-
getDeviceInfo
public DeviceInfo getDeviceInfo() throws IOException, com.yubico.yubikit.core.application.CommandExceptionGet device information from the YubiKey.This functionality requires support for
FEATURE_DEVICE_INFO, available on YubiKey 4.1 or later.- Returns:
- a DeviceInfo object
- Throws:
IOException- in case of connection errorcom.yubico.yubikit.core.application.CommandException- in case of error response
-
updateDeviceConfig
public void updateDeviceConfig(DeviceConfig config, boolean reboot, @Nullable byte[] currentLockCode, @Nullable byte[] newLockCode) throws IOException, com.yubico.yubikit.core.application.CommandException Write device configuration to a YubiKey 5 or later.This functionality requires support for
FEATURE_DEVICE_CONFIG, available on YubiKey 5 or later.- Parameters:
config- the device configuration to writereboot- if true cause the YubiKey to immediately reboot, applying the new configurationcurrentLockCode- required if a configuration lock code is setnewLockCode- changes or removes (if 16 byte all-zero) the configuration lock code- Throws:
IOException- in case of connection errorcom.yubico.yubikit.core.application.CommandException- in case of error response
-
setMode
public void setMode(com.yubico.yubikit.core.UsbInterface.Mode mode, byte chalrespTimeout, short autoejectTimeout) throws IOException, com.yubico.yubikit.core.application.CommandException Write device configuration for YubiKey NEO and YubiKey 4.This functionality requires support for
FEATURE_MODE, available on YubiKey 3 and 4. IfFEATURE_DEVICE_CONFIGis supported, the mode will be translated into a DeviceConfig andupdateDeviceConfig(com.yubico.yubikit.management.DeviceConfig, boolean, byte[], byte[])will instead be used.- Parameters:
mode- USB transport mode to setchalrespTimeout- timeout (seconds) for challenge-response requiring touch.autoejectTimeout- timeout (10x seconds) for auto-eject (only used for CCID-only mode).- Throws:
IOException- in case of connection errorcom.yubico.yubikit.core.smartcard.ApduException- in case of communication or not supported operation errorcom.yubico.yubikit.core.application.CommandException
-