Class YubiOtpSlotConfiguration

java.lang.Object
com.yubico.yubikit.yubiotp.YubiOtpSlotConfiguration
All Implemented Interfaces:
SlotConfiguration

public class YubiOtpSlotConfiguration
extends java.lang.Object
Configures the YubiKey to return YubiOTP (one-time password) on touch.
  • Field Details

  • Constructor Details

    • YubiOtpSlotConfiguration

      public YubiOtpSlotConfiguration​(byte[] fixed, byte[] uid, byte[] key)
      Creates a Yubico OTP configuration with default settings.
      Parameters:
      fixed - "public ID" static portion of each OTP (0-16 bytes)
      uid - "private id" internal to the credential (6 bytes)
      key - the AES key to encrypt the OTP payload (20 bytes)
  • Method Details

    • getThis

      protected YubiOtpSlotConfiguration getThis()
    • tabs

      public YubiOtpSlotConfiguration tabs​(boolean before, boolean afterFirst, boolean afterSecond)
      Inserts tabs in-between different parts of the OTP.
      Parameters:
      before - inserts a tab before any other output (default: false)
      afterFirst - inserts a tab after the static part of the OTP (default: false)
      afterSecond - inserts a tab after the end of the OTP (default: false)
      Returns:
      the configuration for chaining
    • delay

      public YubiOtpSlotConfiguration delay​(boolean afterFirst, boolean afterSecond)
      Inserts delays in-between different parts of the OTP.
      Parameters:
      afterFirst - inserts a delay after the static part of the OTP (default: false)
      afterSecond - inserts a delay after the end of the OTP (default: false)
      Returns:
      the configuration for chaining
    • sendReference

      public YubiOtpSlotConfiguration sendReference​(boolean sendReference)
      Send a reference string of all 16 modhex characters before the OTP.
      Parameters:
      sendReference - if true, sends the reference string (default: false)
      Returns:
      the configuration for chaining
    • appendCr

      public YubiOtpSlotConfiguration appendCr​(boolean appendCr)
      Appends a Carriage Return (Enter key press) at the end of the output.
      Parameters:
      appendCr - if true, the output of the slot will end with a CR (default: true)
      Returns:
      the configuration for chaining
    • fastTrigger

      public YubiOtpSlotConfiguration fastTrigger​(boolean fastTrigger)
      Faster triggering when only slot 1 is configured. This option is always in effect on firmware versions 3.0 and above.
      Parameters:
      fastTrigger - if true, trigger slot 1 quicker when slot 2 is unconfigured (default: true)
      Returns:
      the configuration for chaining
    • pacing

      public YubiOtpSlotConfiguration pacing​(boolean pacing10Ms, boolean pacing20Ms)
      Adds a delay between each key press when sending output. This may sometimes be needed if the host system isn't able to handle the default speed at which keystrokes are sent.

      NOTE: These two flags can be combined to maximize the delay.

      Parameters:
      pacing10Ms - Adds a ~10ms delay between keystrokes (default: false)
      pacing20Ms - Adds a ~20ms delay between keystrokes (default: false)
      Returns:
      the configuration for chaining
    • useNumeric

      public YubiOtpSlotConfiguration useNumeric​(boolean useNumeric)
      Send scancodes for numeric keypad keypresses when sending digits - helps with some keyboard layouts.
      Parameters:
      useNumeric - true to use the numeric keypad (default: false)
      Returns:
      the configuration for chaining
    • getFlags

      protected final byte getFlags​(SlotConfiguration.FlagType type)
    • updateFlags

      protected YubiOtpSlotConfiguration updateFlags​(SlotConfiguration.Flag flag, boolean value)
    • isSupportedBy

      public boolean isSupportedBy​(com.yubico.yubikit.core.Version version)
      Description copied from interface: SlotConfiguration
      Checks the configuration against a YubiKey firmware version to see if it is supported
      Specified by:
      isSupportedBy in interface SlotConfiguration
      Parameters:
      version - the firmware version to check against
      Returns:
      true if the given YubiKey version supports this configuration
    • getConfig

      public byte[] getConfig​(@Nullable byte[] accCode)
      Specified by:
      getConfig in interface SlotConfiguration
    • serialApiVisible

      public YubiOtpSlotConfiguration serialApiVisible​(boolean serialApiVisible)
    • serialUsbVisible

      public YubiOtpSlotConfiguration serialUsbVisible​(boolean serialUsbVisible)
    • allowUpdate

      public YubiOtpSlotConfiguration allowUpdate​(boolean allowUpdate)
    • dormant

      public YubiOtpSlotConfiguration dormant​(boolean dormant)
      Makes the configuration dormant (hidden from use). A dormant configuration needs to be updated and the dormant bit removed to be used.
      Parameters:
      dormant - if true, the configuration cannot be used
      Returns:
      the configuration for chaining
    • invertLed

      public YubiOtpSlotConfiguration invertLed​(boolean invertLed)
      Inverts the behaviour of the led on the YubiKey.
      Parameters:
      invertLed - if true, the LED behavior is inverted
      Returns:
      the configuration for chaining
    • protectSlot2

      public YubiOtpSlotConfiguration protectSlot2​(boolean protectSlot2)
      When set for slot 1, access to modify slot 2 is blocked (even if slot 2 is empty).
      Parameters:
      protectSlot2 - If true, slot 2 cannot be modified.
      Returns:
      the configuration for chaining