Class DeviceUtil

java.lang.Object
com.yubico.yubikit.support.DeviceUtil

public class DeviceUtil extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    getName(com.yubico.yubikit.management.DeviceInfo info, com.yubico.yubikit.core.YubiKeyType keyType)
    Determine the product name of a YubiKey
    static com.yubico.yubikit.management.DeviceInfo
    readInfo(com.yubico.yubikit.core.YubiKeyConnection connection, com.yubico.yubikit.core.UsbPid pid)
    Reads out DeviceInfo from a YubiKey, or attempts to synthesize the data.

    Methods inherited from class java.lang.Object

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

    • DeviceUtil

      public DeviceUtil()
  • Method Details

    • readInfo

      public static com.yubico.yubikit.management.DeviceInfo readInfo(com.yubico.yubikit.core.YubiKeyConnection connection, @Nullable com.yubico.yubikit.core.UsbPid pid) throws IOException, IllegalArgumentException
      Reads out DeviceInfo from a YubiKey, or attempts to synthesize the data.

      Reading DeviceInfo from a ManagementSession is only supported for newer YubiKeys. This function attempts to read that information, but will fall back to gathering the data using other mechanisms if needed. It will also make adjustments to the data if required, for example to "fix" known bad values.

      The pid parameter must be provided whenever the YubiKey is connected via USB,

      Parameters:
      connection - SmartCardConnection, OtpConnection or FidoConnection connection to the YubiKey
      pid - USB product ID of the YubiKey, can be null if unknown
      Throws:
      IOException - in case of connection error
      IllegalArgumentException - in case of pid is null for USB connection
      IllegalArgumentException - in case of connection is not SmartCardConnection, OtpConnection or FidoConnection
      IllegalArgumentException - when the hardware key could not be identified
    • getName

      public static String getName(com.yubico.yubikit.management.DeviceInfo info, @Nullable com.yubico.yubikit.core.YubiKeyType keyType)
      Determine the product name of a YubiKey