Class DuoSDKClientAdaptor
java.lang.Object
net.shibboleth.idp.plugin.authn.duo.AbstractDuoOIDCClient
net.shibboleth.idp.plugin.authn.duo.sdk.impl.DuoSDKClientAdaptor
- All Implemented Interfaces:
DuoOIDCClient,DuoOIDCClientCapabilities
An Object Adaptor class for bridging between the Duo SDK implementation
and the internal DuoOIDCClient interface.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classDefault health check response converter.private final classDefault Duo token converter. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final com.duosecurity.ClientThe wrapped Duo native client.private final DuoOIDCIntegrationSave off the integration to help generate the JWT.private final Function<com.duosecurity.model.HealthCheckResponse,DuoHealthCheck> Function to map the native DuoHealthCheckResponseobject to the interfaceDuoHealthCheckobject.private final org.slf4j.LoggerClass logger.private final BiFunction<com.duosecurity.model.Token,DuoOIDCIntegration, com.nimbusds.jwt.JWT> Function to map the native DuoTokenobject to the interfaceJWTobject. -
Constructor Summary
ConstructorsConstructorDescriptionDuoSDKClientAdaptor(DuoOIDCIntegration integration, List<String> caCerts) Package-private constructor. -
Method Summary
Modifier and TypeMethodDescriptioncreateAuthUrl(String username, String state, String nonce, String redirectURIOverride) Constructs an authorization redirection URL string with the query parameters required to initiate a Duo 2FA request.com.nimbusds.jwt.JWTexchangeAuthorizationCodeFor2FAResult(String code, String username, String redirectURIOverride) Exchanges the authorizaton code for a signed Json Web Token (JWT) which contains information pertaining to the authentication.Check the health of the Duo 2FA endpoint and the clients configuration.booleanDoes this client support the OIDC nonce parameter.Methods inherited from class net.shibboleth.idp.plugin.authn.duo.AbstractDuoOIDCClient
getCapabilities, getClientId
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
client
@Nonnull private final com.duosecurity.Client clientThe wrapped Duo native client. -
healthCheckResponseConverter
@Nonnull private final Function<com.duosecurity.model.HealthCheckResponse,DuoHealthCheck> healthCheckResponseConverterFunction to map the native DuoHealthCheckResponseobject to the interfaceDuoHealthCheckobject. -
tokenResponseConverter
@Nonnull private final BiFunction<com.duosecurity.model.Token,DuoOIDCIntegration, tokenResponseConvertercom.nimbusds.jwt.JWT> Function to map the native DuoTokenobject to the interfaceJWTobject. -
duoIntegration
Save off the integration to help generate the JWT.
-
-
Constructor Details
-
DuoSDKClientAdaptor
DuoSDKClientAdaptor(@Nonnull DuoOIDCIntegration integration, @Nullable List<String> caCerts) throws DuoClientException Package-private constructor. Initialises the native Duo SDK client.Should only be instantiated by the
DuoSDKClientFactory.- Parameters:
integration- the Duo integration to initialize the client from. Nevernull.caCerts- the list of CA Certificates used to validate connections to Duo. Can benull.- Throws:
DuoClientException- if there is an error instantiating the client
-
-
Method Details
-
healthCheck
Check the health of the Duo 2FA endpoint and the clients configuration.- Returns:
- the heath check response, never
null. - Throws:
DuoClientException- if there is an error returning the health check response.
-
createAuthUrl
@Nonnull public String createAuthUrl(@Nonnull @NotEmpty String username, @Nonnull @NotEmpty String state, @Nullable String nonce, @Nullable String redirectURIOverride) throws DuoClientException Constructs an authorization redirection URL string with the query parameters required to initiate a Duo 2FA request.The Duo WebSDK Client does not support either the
nonceorredirectURIOverrideparameters.- Parameters:
username- The user to be authenticated by Duo, nevernull.state- A randomly generated minimum 22 character String, which is relayed back to the client, nevernull.nonce- a randomly generated (minimum 22 character) cryptographically secure nonce that is replayed in the id_token. Can benullif not supported by the client as indicated by the clients described capabilities.redirectURIOverride- the redirectURI to use in the authorization request. If not null and the client supports dynamic redirect URIs, it should override any redirect_uri held internally to the client e.g. from theDuoOIDCIntegration. If the client does not support dynamic redirect URIs, it can be ignored in favour of one held internally.- Returns:
- the authorization redirect URL as a string, never
null. - Throws:
DuoClientException- if there is an error creating the authentication URL.
-
exchangeAuthorizationCodeFor2FAResult
@Nonnull public com.nimbusds.jwt.JWT exchangeAuthorizationCodeFor2FAResult(@Nonnull String code, @Nonnull String username, @Nullable String redirectURIOverride) throws DuoClientException Exchanges the authorizaton code for a signed Json Web Token (JWT) which contains information pertaining to the authentication. There is no requirement on the client to verify the tokens authenticity or claims - these should be performed elsewhere in the flow. The JWT **must** be signed.The Duo WebSDK Client does not support the
redirectURIOverrideparameter.- Parameters:
code- An authentication identifier which is exchanged (per OAuth2.0 spec) with Duo for a token. the token can be used to determine if authentication was successful as well as obtain meta-data about the authentication, nevernull. *username- The user to be authenticated by Duo, nevernull.redirectURIOverride- the redirectURI to use in the code exchange request. If not null and the client supports dynamic redirect URIs, it should override any redirect_uri held internally to the client e.g. from theDuoOIDCIntegration. If the client does not support dynamic redirect URIs, it can be ignored in favour of one held internally.- Returns:
- the **signed** JWT, never
null. - Throws:
DuoClientException- if there is an error exchanging the auth_code for a token result.
-
isSupportsNonce
public boolean isSupportsNonce()Description copied from interface:DuoOIDCClientCapabilitiesDoes this client support the OIDC nonce parameter.
If the client does support a nonce, it must be included by the client in the authorisation request URL, where it must then be returned by the provider in the id_token as part of the 2FA result.
- Returns:
- true iff the client supports the nonce parameter, false otherwise.
-