public abstract class YubicoClient extends Object
YubicoClient client = YubicoClient.getClient(CLIENT_ID);
YubicoResponse response = client.verify(otp);
if(response.getStatus() == YubicoResponseStatus.OK) {
return true;
} else {
return false;
}
| Modifier and Type | Field and Description |
|---|---|
protected Integer |
clientId |
protected byte[] |
key |
private static Integer |
OTP_MAX_LEN |
private static Integer |
OTP_MIN_LEN |
protected String |
sync |
protected String |
userAgent |
protected String[] |
wsapi_urls |
| Constructor and Description |
|---|
YubicoClient() |
| Modifier and Type | Method and Description |
|---|---|
static YubicoClient |
getClient(Integer clientId)
Instantiate a YubicoClient object.
|
Integer |
getClientId()
Get the ykval client identifier uset do identify the applicaiton.
|
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 |
getSync()
Get the sync percentage required for a successful auth.
|
String |
getUserAgent()
Get the previously set user agent to be used for requests
|
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 |
setSync(String 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 YubicoResponse |
verify(String otp)
Validate an OTP using a webservice call to one or more ykval validation servers.
|
protected Integer clientId
protected byte[] key
protected String sync
protected String[] wsapi_urls
protected String userAgent
private static final Integer OTP_MIN_LEN
private static final Integer OTP_MAX_LEN
public abstract YubicoResponse verify(String otp) throws YubicoValidationException, YubicoValidationFailure
otp - YubiKey OTP in modhex formatYubicoValidationException - 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(String sync)
sync - percentage or strings 'secure' or 'fast'public String getSync()
public String[] getWsapiUrls()
public void setWsapiUrls(String[] wsapi)
wsapi - list of base URLspublic void setUserAgent(String userAgent)
userAgent - the user agent used in requestspublic String getUserAgent()
public static YubicoClient getClient(Integer clientId)
public 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)
Copyright © 2013 Yubico AB. All Rights Reserved.