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:
java.io.Closeable,java.lang.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
Fields Modifier and Type Field Description static com.yubico.yubikit.core.application.Feature<ManagementSession>FEATURE_DEVICE_CONFIGSupport for writing DeviceConfig data to the YubiKey.static com.yubico.yubikit.core.application.Feature<ManagementSession>FEATURE_DEVICE_INFOSupport for reading the DeviceInfo data from the YubiKey.static com.yubico.yubikit.core.application.Feature<ManagementSession>FEATURE_MODESupport the SET_MODE command to change the USB mode of the YubiKey.
-
Constructor Summary
Constructors Constructor Description ManagementSession(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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()static voidcreate(com.yubico.yubikit.core.YubiKeyDevice device, com.yubico.yubikit.core.util.Callback<com.yubico.yubikit.core.util.Result<ManagementSession,java.lang.Exception>> callback)Connects to a YubiKeyDevice and establishes a new session with a YubiKeys Management application.DeviceInfogetDeviceInfo()Get device information from the YubiKey.com.yubico.yubikit.core.VersiongetVersion()voidsetMode(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.
-
-
-
Field Detail
-
FEATURE_MODE
public static final com.yubico.yubikit.core.application.Feature<ManagementSession> 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_INFO
Support for reading the DeviceInfo data from the YubiKey.
-
FEATURE_DEVICE_CONFIG
public static final com.yubico.yubikit.core.application.Feature<ManagementSession> FEATURE_DEVICE_CONFIG
Support for writing DeviceConfig data to the YubiKey.
-
-
Constructor Detail
-
ManagementSession
public ManagementSession(com.yubico.yubikit.core.smartcard.SmartCardConnection connection) throws java.io.IOException, com.yubico.yubikit.core.application.ApplicationNotAvailableExceptionEstablishes a new session with a YubiKeys Management application, over aSmartCardConnection.- Parameters:
connection- connection with YubiKey- Throws:
java.io.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 java.io.IOException, com.yubico.yubikit.core.application.ApplicationNotAvailableExceptionEstablishes a new session with a YubiKeys Management application, over anOtpConnection.- Parameters:
connection- connection with YubiKey- Throws:
java.io.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.fido.FidoConnection connection) throws java.io.IOExceptionEstablishes a new session with a YubiKeys Management application, over aFidoConnection.- Parameters:
connection- a connection over the FIDO USB transport with a YubiKey- Throws:
java.io.IOException- in case of connection error
-
-
Method Detail
-
create
public static void create(com.yubico.yubikit.core.YubiKeyDevice device, com.yubico.yubikit.core.util.Callback<com.yubico.yubikit.core.util.Result<ManagementSession,java.lang.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
public void close() throws java.io.IOException- Throws:
java.io.IOException
-
getVersion
public com.yubico.yubikit.core.Version getVersion()
- Specified by:
getVersionin classcom.yubico.yubikit.core.application.ApplicationSession<ManagementSession>
-
getDeviceInfo
public DeviceInfo getDeviceInfo() throws java.io.IOException, com.yubico.yubikit.core.application.CommandException
Get 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:
java.io.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 java.io.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:
java.io.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 java.io.IOException, com.yubico.yubikit.core.application.CommandExceptionWrite 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:
java.io.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
-
-