Class YubiKitManager


  • public final class YubiKitManager
    extends java.lang.Object
    Starting point for YubiKey device discovery over both USB and NFC. Use this class to listen for YubiKeys and get a YubiKeyDevice reference.
    • Constructor Detail

      • YubiKitManager

        public YubiKitManager​(android.content.Context context)
        Initialize instance of YubiKitManager
        Parameters:
        context - application context
      • YubiKitManager

        public YubiKitManager​(UsbYubiKeyManager usbYubiKeyManager,
                              @Nullable
                              NfcYubiKeyManager nfcYubiKeyManager)
        Initialize an instance of YubiKitManager, providing the USB and NFC YubiKey managers to use for device discovery.
        Parameters:
        usbYubiKeyManager - UsbYubiKeyManager instance to use for USB communication
        nfcYubiKeyManager - NfcYubiKeyManager instance to use for NFC communication
    • Method Detail

      • startUsbDiscovery

        public void startUsbDiscovery​(UsbConfiguration usbConfiguration,
                                      com.yubico.yubikit.core.util.Callback<? super UsbYubiKeyDevice> listener)
        Subscribe on changes that happen via USB and detect if there any Yubikeys got connected

        This registers broadcast receivers, to unsubscribe from receiver use stopUsbDiscovery()

        Parameters:
        usbConfiguration - additional configurations on how USB discovery should be handled
        listener - listener that is going to be invoked upon successful discovery of key session or failure to detect any session (lack of permissions)
      • startNfcDiscovery

        public void startNfcDiscovery​(NfcConfiguration nfcConfiguration,
                                      android.app.Activity activity,
                                      com.yubico.yubikit.core.util.Callback<? super NfcYubiKeyDevice> listener)
                               throws NfcNotAvailable
        Subscribe on changes that happen via NFC and detect if there any Yubikeys tags got passed

        This registers broadcast receivers and blocks Ndef tags to be passed to activity, to unsubscribe use stopNfcDiscovery(Activity)

        Parameters:
        nfcConfiguration - additional configurations on how NFC discovery should be handled
        listener - listener that is going to be invoked upon successful discovery of YubiKeys or failure to detect any device (setting if off or no nfc adapter on device)
        activity - active (not finished) activity required for nfc foreground dispatch
        Throws:
        NfcNotAvailable - in case if NFC not available on android device
      • stopUsbDiscovery

        public void stopUsbDiscovery()
        Unsubscribe from changes that happen via USB
      • stopNfcDiscovery

        public void stopNfcDiscovery​(android.app.Activity activity)
        Unsubscribe from changes that happen via NFC
        Parameters:
        activity - active (not finished) activity required for nfc foreground dispatch