Class DeviceUtil


  • public class DeviceUtil
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      DeviceUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.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 Detail

      • DeviceUtil

        public DeviceUtil()
    • Method Detail

      • readInfo

        public static com.yubico.yubikit.management.DeviceInfo readInfo​(com.yubico.yubikit.core.YubiKeyConnection connection,
                                                                        @Nullable
                                                                        com.yubico.yubikit.core.UsbPid pid)
                                                                 throws java.io.IOException,
                                                                        java.lang.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:
        java.io.IOException - in case of connection error
        java.lang.IllegalArgumentException - in case of pid is null for USB connection
        java.lang.IllegalArgumentException - in case of connection is not SmartCardConnection, OtpConnection or FidoConnection
      • getName

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