public class YubiKeyConfigurationApplication
extends java.lang.Object
implements java.io.Closeable
| Constructor and Description |
|---|
YubiKeyConfigurationApplication(YubiKeySession session)
Create new instance of
Iso7816Application
and selects the application for use |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
calculateHmacSha1(byte[] challenge,
Slot slot)
Calculates HMAC-SHA1 on given challenge (using secret that configured/programmed on YubiKey)
|
void |
close() |
Version |
getVersion()
Firmware version
|
void |
setHmacSha1ChallengeResponseSecret(byte[] secret,
Slot slot,
boolean requireTouch)
Configures HMAC-SHA1 challenge response secret on YubiKey
(@see calculateHmacSha1() how to use it after configuration)
|
void |
setHotpKey(byte[] secret,
Slot slot,
boolean hotp8digits)
Configures YubiKey to return HOTP
|
void |
setOtpKey(byte[] publicId,
byte[] privateId,
byte[] key,
Slot slot)
Configures YubiKey to return YubiOTP (one-time password) on touch
|
void |
setStaticPassword(byte[] scanCodes,
Slot slot)
Configures YubiKey to return static password on touch
|
void |
swapSlots()
Method allows to swap data between 1st and 2nd slot of the YubiKey
|
public YubiKeyConfigurationApplication(YubiKeySession session)
throws java.io.IOException,
YubiKeyCommunicationException
Iso7816Application
and selects the application for usesession - session with YubiKeyjava.io.IOException - in case of connection errorApplicationNotFound - if the application is missing or disabled.YubiKeyCommunicationExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionpublic byte[] calculateHmacSha1(byte[] challenge,
Slot slot)
throws java.io.IOException,
ApduException,
NotSupportedOperation
challenge - generated challenge that will be sentslot - the slot on YubiKey that configured with challenge response secretjava.io.IOException - in case of communication errorApduExceptionNotSupportedOperationpublic void setHmacSha1ChallengeResponseSecret(byte[] secret,
Slot slot,
boolean requireTouch)
throws java.io.IOException,
NotSupportedOperation,
BadResponseException,
ApduException
secret - the 20 bytes secret for YubiKey to storeslot - the slot on YubiKey that will be configured with challenge response secretjava.io.IOException - in case of communication errorNotSupportedOperationBadResponseExceptionApduExceptionpublic void setStaticPassword(byte[] scanCodes,
Slot slot)
throws java.io.IOException,
ApduException,
BadRequestException,
BadResponseException
scanCodes - the password to store on YubiKey as an array of keyboard scan codes.slot - the slot on YubiKey that will be configured with provided password (One - short touch, Two - long touch)java.io.IOException - in case of communication errorApduException - in case of unexpected usage or error response from YubiKeyBadRequestExceptionBadResponseExceptionpublic void setOtpKey(byte[] publicId,
byte[] privateId,
byte[] key,
Slot slot)
throws java.io.IOException,
NotSupportedOperation,
BadResponseException,
ApduException
publicId - public idprivateId - private idkey - the secret key to store on YubiKeyslot - the slot on YubiKey that will be configured with OTP (One - short touch, Two - long touch)java.io.IOException - in case of communication errorNotSupportedOperationBadResponseExceptionApduExceptionpublic void setHotpKey(byte[] secret,
Slot slot,
boolean hotp8digits)
throws java.io.IOException,
NotSupportedOperation,
BadResponseException,
ApduException
secret - the 20 bytes secret for YubiKey to storeslot - the slot on YubiKey that will be configured with HOTP (slot 1 - short touch, slot 2 - long touch)hotp8digits - if true will generate 8 digits code (default is 6)java.io.IOException - in case of communication errorNotSupportedOperationBadResponseExceptionApduExceptionpublic void swapSlots()
throws java.io.IOException,
NotSupportedOperation,
BadResponseException,
ApduException
java.io.IOException - in case of communication errorNotSupportedOperationBadResponseExceptionApduExceptionpublic Version getVersion()