This repository has been archived by the owner on May 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
/
README
61 lines (45 loc) · 2.18 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
61
== yubico-java-client
NOTE: This project is deprecated and is no longer being maintained. For more information and guidance on how to implement Yubico OTP support in applications, see https://status.yubico.com/2021/04/15/one-api-yubico-com-one-http-get/.
image:https://github.com/Yubico/yubico-java-client/workflows/build/badge.svg["Build Status", link="https://github.com/Yubico/yubico-java-client/actions"]
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.5</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>
=== Read more
For more complete descriptions of methods and failure states, please see
the https://developers.yubico.com/yubico-java-client[JavaDoc].