public class OathApplication
extends Iso7816Application
| Modifier and Type | Field and Description |
|---|---|
static short |
APPLICATION_NOT_FOUND_ERROR |
static short |
AUTHENTICATION_REQUIRED_ERROR |
static short |
GENERIC_ERROR |
static short |
NO_SUCH_OBJECT |
static short |
WRONG_SYNTAX |
| Constructor and Description |
|---|
OathApplication(YubiKeySession session)
Create new instance of
OathApplication
and selects the application for use |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
calculate(byte[] credentialId,
byte[] challenge)
Perform a raw non-truncated CALCULATE (HMAC) for a credential using the given challenge.
|
Code |
calculate(Credential credential)
Performs CALCULATE for one named credential.
|
Code |
calculate(Credential credential,
java.lang.Long timestamp)
Performs CALCULATE for one named credential.
|
java.util.Map<Credential,Code> |
calculateAll()
Performs CALCULATE for all available credentials,
|
java.util.Map<Credential,Code> |
calculateAll(long timestamp)
Performs CALCULATE for all available credentials,
|
static byte[] |
calculateSecret(java.lang.String password,
byte[] salt)
Passes a user-supplied UTF-8 encoded password through 1000 rounds of PBKDF2
with the device ID from select used as salt.
|
void |
deleteCredential(byte[] credentialId)
Deletes an existing credential.
|
OathApplicationInfo |
getApplicationInfo() |
java.util.List<Credential> |
listCredentials()
Lists configured credentials.
|
Credential |
putCredential(CredentialData credential)
Adds a new (or overwrites) OATH credential.
|
void |
reset()
Resets the application, deleting all credentials and removing any lock code.
|
byte[] |
sendAndReceive(Apdu command)
Uses ApduUtils.sendAndReceive method with specific ins byte for "send remaining data" command
|
void |
setPassword(java.lang.String password)
Configures Authentication.
|
void |
setSecret(byte[] secret)
Configures Authentication.
|
void |
unsetSecret()
Removes authentication.
|
boolean |
validate(ChallengeSigner signer)
Validates authentication (mutually).
|
boolean |
validate(java.lang.String password)
Validates authentication (mutually).
|
public static final short AUTHENTICATION_REQUIRED_ERROR
public static final short WRONG_SYNTAX
public static final short GENERIC_ERROR
public static final short NO_SUCH_OBJECT
public static final short APPLICATION_NOT_FOUND_ERROR
public OathApplication(YubiKeySession session)
throws java.io.IOException,
ApduException,
ApplicationNotFound
OathApplication
and selects the application for usesession - session with YubiKeyjava.io.IOException - in case of connection errorApduException - in case of communication errorApplicationNotFoundpublic OathApplicationInfo getApplicationInfo()
public void reset()
throws java.io.IOException,
ApduException
java.io.IOException - in case of connection errorApduException - in case of communication errorpublic boolean validate(java.lang.String password)
throws java.io.IOException,
ApduException
password - user-supplied passwordjava.io.IOException - in case of connection errorApduException - in case of communication errorpublic boolean validate(ChallengeSigner signer) throws java.io.IOException, ApduException
signer - the provide of HMAC calculationjava.io.IOException - in case of connection errorApduException - in case of communication errorpublic void setPassword(java.lang.String password)
throws java.io.IOException,
ApduException
password - user-supplied password. If null or empty, authentication is removed.java.io.IOException - in case of connection errorApduException - in case of communication errorpublic void setSecret(byte[] secret)
throws java.io.IOException,
ApduException,
BadRequestException
secret - 16 bytes of user-supplied UTF-8 encoded password passed through 1000 rounds of PBKDF2
with the ID from select used as saltjava.io.IOException - in case of connection errorApduException - in case of communication errorBadRequestExceptionpublic void unsetSecret()
throws java.io.IOException,
ApduException
java.io.IOExceptionApduExceptionpublic java.util.List<Credential> listCredentials() throws java.io.IOException, ApduException
java.io.IOException - in case of connection errorApduException - in case of communication errorpublic java.util.Map<Credential,Code> calculateAll() throws java.io.IOException, ApduException
java.io.IOException - in case of connection errorApduException - in case of communication errorpublic java.util.Map<Credential,Code> calculateAll(long timestamp) throws java.io.IOException, ApduException
timestamp - the timestamp which is used as start point for TOTPjava.io.IOException - in case of connection errorApduException - in case of communication errorpublic byte[] calculate(byte[] credentialId,
byte[] challenge)
throws java.io.IOException,
ApduException
credentialId - credential ID to identify the credentialchallenge - challenge bytesjava.io.IOException - in case of connection errorApduException - in case of communication errorpublic Code calculate(Credential credential) throws java.io.IOException, ApduException
credential - credential that will get new codejava.io.IOException - in case of connection errorApduException - in case of communication errorpublic Code calculate(Credential credential, java.lang.Long timestamp) throws java.io.IOException, ApduException
credential - credential that will get new codetimestamp - the timestamp which is used as start point for TOTP, can be null for HOTPjava.io.IOException - in case of connection errorApduException - in case of communication errorpublic Credential putCredential(CredentialData credential) throws java.io.IOException, ApduException, NotSupportedOperation
credential - credential data to addjava.io.IOException - in case of connection errorApduException - in case of communication errorNotSupportedOperationpublic void deleteCredential(byte[] credentialId)
throws java.io.IOException,
ApduException
credentialId - ID of credential data to removejava.io.IOException - in case of connection errorApduException - in case of communication errorpublic static byte[] calculateSecret(java.lang.String password,
byte[] salt)
throws java.security.NoSuchAlgorithmException,
java.security.spec.InvalidKeySpecException
password - a user-supplied passwordsalt - the salt value (the deviceId returned by select command)java.security.spec.InvalidKeySpecException - in case of crypto operation errorjava.security.NoSuchAlgorithmException - in case of crypto operation errorpublic byte[] sendAndReceive(Apdu command)
throws java.io.IOException,
ApduException
command - apdu command that will be sentjava.io.IOException - in case of connection errorApduException - in case of communication error