forked from payara/patched-src-yubico-java-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
60 lines (45 loc) · 2.09 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
== yubico-java-client
This repository contains a Java library with an accompanying demo server, as well as a
https://github.com/Yubico/yubico-java-client/tree/master/jaas[JAAS module],
to validate YubiKey OTPs (One-Time Passwords).
By default, this library uses the Yubico YubiCloud validation platform,
but it can be configured for another validation server.
NOTE: For more details on how to use a YubiKey OTP library, visit
https://developers.yubico.com/OTP[developers.yubico.com/OTP].
=== Usage
Add this to your pom.xml:
[source,xml]
<dependency>
<groupId>com.yubico</groupId>
<artifactId>yubico-validation-client2</artifactId>
<version>3.0.1</version>
</dependency>
[source,java]
----
// clientId and secretKey are retrieved from https://upgrade.yubico.com/getapikey
YubicoClient client = YubicoClient.getClient(clientId, secretKey);
// otp is the OTP from the YubiKey
VerificationResponse response = client.verify(otp);
assert response.isOk();
----
After validating the OTP you should make sure that the publicId part belongs to
the correct user. For example:
[source,java]
YubicoClient.getPublicId(otp)
.equals(/* Yubikey ID associated with the user */);
For a complete example, see the https://github.com/Yubico/yubico-java-client/tree/master/demo-server[demo server].
=== Logging
The validation client depends on slf4j-api for logging. To get the actual logs
and not receive warnings on System.out you will need to depend on a slf4j logger
binding, for example slf4j-log4j with the following Maven configuration:
[source,xml]
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j</artifactId>
<version>1.6.1</version>
</dependency>
In the Payara patched version of this project the SLF4J Dependency has been removed from the v2 client. Instead the standard java logging is used.
=== Read more
For more complete descriptions of methods and failure states, please see
the https://developers.yubico.com/yubico-java-client[JavaDoc].
NOTE: If you want the client for the legacy version 1 of the API, it can be found https://github.com/Yubico/yubico-java-client/tree/master/v1client[here].