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

    Fields
    Modifier and Type
    Field
    Description
    static 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 for device-wide reset.
    static final com.yubico.yubikit.core.application.Feature<ManagementSession>
    Support 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 a FidoConnection.
    ManagementSession(com.yubico.yubikit.core.otp.OtpConnection connection)
    Establishes a new session with a YubiKeys Management application, over an OtpConnection.
    ManagementSession(com.yubico.yubikit.core.smartcard.SmartCardConnection connection)
    Establishes a new session with a YubiKeys Management application, over a SmartCardConnection.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    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.
    void
    Perform a device-wide reset in Bio Multi-protocol Edition devices.
    Get device information from the YubiKey.
    com.yubico.yubikit.core.Version
     
    void
    setMode(com.yubico.yubikit.core.UsbInterface.Mode mode, byte chalrespTimeout, short autoejectTimeout)
    Write device configuration for YubiKey NEO and YubiKey 4.
    void
    updateDeviceConfig(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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • 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.
    • FEATURE_DEVICE_RESET

      public static final com.yubico.yubikit.core.application.Feature<ManagementSession> FEATURE_DEVICE_RESET
      Support for device-wide reset.
  • 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 a SmartCardConnection.
      Parameters:
      connection - connection with YubiKey
      Throws:
      IOException - in case of connection error
      com.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 an OtpConnection.
      Parameters:
      connection - connection with YubiKey
      Throws:
      IOException - in case of connection error
      com.yubico.yubikit.core.application.ApplicationNotAvailableException - in case the application is missing/disabled
    • ManagementSession

      public ManagementSession(com.yubico.yubikit.core.fido.FidoConnection connection) throws IOException
      Establishes a new session with a YubiKeys Management application, over a FidoConnection.
      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

      public void close() throws IOException
      Throws:
      IOException
    • getVersion

      public com.yubico.yubikit.core.Version getVersion()
      Specified by:
      getVersion in class com.yubico.yubikit.core.application.ApplicationSession<ManagementSession>
    • getDeviceInfo

      public DeviceInfo getDeviceInfo() throws 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:
      IOException - in case of connection error
      com.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 write
      reboot - if true cause the YubiKey to immediately reboot, applying the new configuration
      currentLockCode - required if a configuration lock code is set
      newLockCode - changes or removes (if 16 byte all-zero) the configuration lock code
      Throws:
      IOException - in case of connection error
      com.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. If FEATURE_DEVICE_CONFIG is supported, the mode will be translated into a DeviceConfig and updateDeviceConfig(com.yubico.yubikit.management.DeviceConfig, boolean, byte[], byte[]) will instead be used.

      Parameters:
      mode - USB transport mode to set
      chalrespTimeout - 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 error
      com.yubico.yubikit.core.smartcard.ApduException - in case of communication or not supported operation error
      com.yubico.yubikit.core.application.CommandException
    • deviceReset

      public void deviceReset() throws IOException, com.yubico.yubikit.core.application.CommandException
      Perform a device-wide reset in Bio Multi-protocol Edition devices.

      This functionality requires support for FEATURE_DEVICE_RESET.

      Throws:
      IOException - in case of connection error
      com.yubico.yubikit.core.smartcard.ApduException - in case of communication or not supported operation error
      com.yubico.yubikit.core.application.CommandException