public abstract class YubicoClient extends Object
Modifier and Type | Field and Description |
---|---|
protected Integer |
clientId |
protected byte[] |
key |
private static org.slf4j.Logger |
log |
protected int |
maxRetries |
private static Integer |
OTP_MAX_LEN |
private static Integer |
OTP_MIN_LEN |
protected Integer |
sync |
protected String |
userAgent |
protected String[] |
wsapi_urls |
Constructor and Description |
---|
YubicoClient() |
Modifier and Type | Method and Description |
---|---|
static YubicoClient |
getClient(Integer clientId,
String key)
Instantiate a YubicoClient object.
|
Integer |
getClientId()
Get the ykval client identifier used to identify the application.
|
String |
getKey()
Get the api key that is used for signing requests
|
static String |
getPublicId(String otp)
Extract the public ID of a YubiKey from an OTP it generated.
|
String[] |
getWsapiUrls()
Get the list of URLs that will be used for validating OTPs.
|
static boolean |
isValidOTPFormat(String otp)
Determines whether a given OTP is of the correct length
and only contains printable characters, as per the recommendation.
|
void |
setClientId(Integer clientId)
Set the ykval client identifier, used to identify the client application to
the validation servers.
|
void |
setKey(String key)
Set api key to be used for signing requests
|
void |
setMaxRetries(int maxRetries)
Set the maximum number of retries to attempt in the event of a network-related failure.
|
void |
setSync(Integer sync)
Set the sync percentage required for a successful auth.
|
void |
setUserAgent(String userAgent)
Set user agent to be used in request to validation server
|
void |
setWsapiUrls(String[] wsapi)
Configure what URLs to use for validating OTPs.
|
abstract VerificationResponse |
verify(String otp)
Validate an OTP using a webservice call to one or more ykval validation servers.
|
protected void |
warnIfDeprecatedUrl(String url) |
private static final org.slf4j.Logger log
protected Integer clientId
protected byte[] key
protected Integer sync
protected int maxRetries
protected String[] wsapi_urls
protected String userAgent
private static final Integer OTP_MIN_LEN
private static final Integer OTP_MAX_LEN
public abstract VerificationResponse verify(String otp) throws YubicoVerificationException, YubicoValidationFailure
otp
- YubiKey OTPYubicoVerificationException
- for validation errors, like unreachable serversYubicoValidationFailure
- for validation failures, like non matching OTPs in request and responseIllegalArgumentException
- for arguments that are not correctly formatted OTP strings.public Integer getClientId()
setClientId(Integer)
public void setClientId(Integer clientId)
clientId
- ykval client identifierpublic void setKey(String key)
key
- ykval client keysetClientId(Integer)
public String getKey()
setClientId(Integer)
public void setSync(Integer sync)
sync
- percentage or strings 'secure' or 'fast'public void setMaxRetries(int maxRetries)
maxRetries
- maximum number of retries. Must not be negative.public String[] getWsapiUrls()
public void setWsapiUrls(String[] wsapi)
wsapi
- list of base URLsprotected void warnIfDeprecatedUrl(String url)
public void setUserAgent(String userAgent)
userAgent
- the user agent used in requestspublic static YubicoClient getClient(Integer clientId, String key)
clientId
- Retrieved from https://upgrade.yubico.com/getapikeypublic static String getPublicId(String otp)
otp
- The OTP to extract ID from, in modhex format.IllegalArgumentException
- for arguments that are null or too short to be valid OTP strings.public static boolean isValidOTPFormat(String otp)
otp
- The OTP to validateCopyright © 2020 Yubico AB. All Rights Reserved.