This module provides general YubiKey management functionality such as enabling or disabling applications and transports.
To add the Management module, along with the Android module as a dependencies to your project, add the following to your gradle configuration:
dependencies {
implementation 'com.yubico.yubikit:android:(insert version here)'
implementation 'com.yubico.yubikit:management:(insert version here)'
}
This module depends on the core module, which will automatically be added as a transitive dependency to your project.
To communicate with the Management application on a YubiKey, use the ManagementSession class. The class provides constructors for all types of YubiKeyConnections, as well as a factory method which takes a YubiKeyDevice and will use the best suited connection type available:
ManagementSession.create(device, result -> {
try {
ManagementSession management = result.getValue();
// Get the YubiKey serial number:
DeviceInfo info = management.getDeviceInfo();
int serialNumber = info.getSerial();
// Toggle the OTP capability over NFC:
int capabilities = info.getConfig().getEnabledCapabilities(Transport.NFC);
capabilities ^= Capability.OTP;
management.updateDeviceConfig(
new DeviceConfig.Builder()
.enabledCapabilities(Transport.NFC, capabilities)
.build(),
false,
null,
null,
);
} catch (...) {
// handle errors
}
});