public class Client extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Client.Builder |
| Modifier and Type | Field and Description |
|---|---|
protected DuoConnector |
duoConnector |
| Constructor and Description |
|---|
Client(String clientId,
String clientSecret,
String apiHost,
String redirectUri)
Deprecated.
The constructors are deprecated.
Prefer the
Client.Builder for instantiating Clients |
Client(String clientId,
String clientSecret,
String apiHost,
String redirectUri,
String[] userCaCerts)
Deprecated.
The constructors are deprecated.
Prefer the
Client.Builder for instantiating Clients |
| Modifier and Type | Method and Description |
|---|---|
String |
createAuthUrl(String username,
String state)
Constructs a string which can be used to redirect the client browser to Duo for 2FA.
|
Token |
exchangeAuthorizationCodeFor2FAResult(String duoCode,
String username)
Verifies the duoCode returned by Duo and exchanges it for a
Token which contains
information pertaining to the auth. |
Token |
exchangeAuthorizationCodeFor2FAResult(String duoCode,
TokenValidator validator)
Verifies the duoCode returned by Duo and exchanges it for a
Token which contains
information pertaining to the auth. |
String |
generateState()
Generates a 36 character random identifier to be used as the state variable in the
createAuthUrl method.
|
HealthCheckResponse |
healthCheck()
Checks if Duo is healthy and available for 2FA.
|
protected DuoConnector duoConnector
@Deprecated public Client(String clientId, String clientSecret, String apiHost, String redirectUri) throws DuoException
Client.Builder for instantiating ClientsclientId - This value is the client id provided by Duo in the admin panel.clientSecret - This value is the client secret provided by Duo in the admin panel.apiHost - This value is the api host provided by Duo in the admin panel.redirectUri - This value is the uri which Duo should redirect to after 2FA is completed.DuoException - For problems building the client@Deprecated public Client(String clientId, String clientSecret, String apiHost, String redirectUri, String[] userCaCerts) throws DuoException
Client.Builder for instantiating ClientsclientId - This value is the client id provided by Duo in the admin panel.clientSecret - This value is the client secret provided by Duo in the admin panel.apiHost - This value is the api host provided by Duo in the admin panel.redirectUri - This value is the uri which Duo should redirect to after 2FA is completed.userCaCerts - This value is a list of CA Certificates used to validate connections to DuoDuoException - For problems building the clientpublic HealthCheckResponse healthCheck() throws DuoException
HealthCheckResponseDuoException - For health check errorspublic String createAuthUrl(String username, String state) throws DuoException
username - The user to be authenticated by Duo.state - A randomly generated String with at least 22 characters
This value will be returned to the integration post 2FA
and should be validated. generateState() exists as a utility function to
generate this param.DuoException - For problems creating the auth urlpublic Token exchangeAuthorizationCodeFor2FAResult(String duoCode, String username) throws DuoException
Token which contains
information pertaining to the auth. Uses the default token validator defined in
DuoIdTokenValidator.
To use a custom validator, see exchangeAuthorizationCodeFor2FAResult(String, TokenValidator)duoCode - This string is an identifier for the auth and should be exchanged with Duo for a
token to determine if the auth was successful as well as obtain meta-data about
about the auth.username - The user to be authenticated by DuoTokenDuoException - For errors exchanging duoCode for 2FA resultspublic Token exchangeAuthorizationCodeFor2FAResult(String duoCode, TokenValidator validator) throws DuoException
Token which contains
information pertaining to the auth. This version of the method allows the use of a
custom JWT token validator.
If you use a custom validator:
You MUST confirm the integrity of the token by using the client secret to validate the
SHA512 HMAC
You MUST check the claims for
Issuer
Audience
Issued at / Expiration
Username (preferred_username)duoCode - This string is an identifier for the auth and should be exchanged with Duo for a
token to determine if the auth was successful as well as obtain meta-data about
the auth.validator - A TokenValidator that will validate and decode the JWT ID Token provided
by Duo.TokenDuoException - For errors exchanging duoCode for 2FA resultspublic String generateState()
Copyright © 2021. All rights reserved.