Package io.hanko.sdk.webauthn
Class HankoWebAuthnClient
java.lang.Object
io.hanko.sdk.webauthn.HankoWebAuthnClient
Main client type for performing registration, authentication, transactions and credential management.
-
Constructor Summary
ConstructorsConstructorDescriptionHankoWebAuthnClient(HankoClientConfig hankoClientConfig)
Construct a HankoWebAuthnClient.HankoWebAuthnClient(HankoClientConfig hankoClientConfig, org.apache.http.impl.client.CloseableHttpClient httpClient)
Construct a HankoWebAuthnClient using a custom underlyingCloseableHttpClient
.HankoWebAuthnClient(HankoHttpClient httpClient)
Construct a HankoWebAuthnClient using a customHankoHttpClient
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
deleteCredential(String credentialId)
Deletes theWebAuthnCredential
with the specified credentialId.finalizeAuthentication(String webAuthnResponse)
Finalizes an authentication using the response from the WebAuthn API's navigator.credentials.get() call.finalizeRegistration(String webAuthnResponse)
Finalizes a registration using the response from the WebAuthn API's navigator.credentials.create() call.finalizeTransaction(String webAuthnResponse)
Finalizes the transaction request using the response from the WebAuthn API's navigator.credentials.get() call.getCredential(String credentialId)
Retrieves the registeredWebAuthnCredential
with the specified credentialId.Initializes an authentication with a registered credential using anAuthenticationInitializationRequest
.Initializes the registration of a new credential using aRegistrationInitializationRequest
.Initializes a transaction.listCredentials(CredentialQuery query)
Retrieves a list of registeredWebAuthnCredential
s.updateCredential(String credentialId, CredentialUpdateRequest request)
Updates theWebAuthnCredential
with the specified credentialId.
-
Constructor Details
-
HankoWebAuthnClient
Construct a HankoWebAuthnClient.- Parameters:
hankoClientConfig
- non-null, theHankoClientConfig
-
HankoWebAuthnClient
public HankoWebAuthnClient(HankoClientConfig hankoClientConfig, org.apache.http.impl.client.CloseableHttpClient httpClient)Construct a HankoWebAuthnClient using a custom underlyingCloseableHttpClient
.- Parameters:
hankoClientConfig
- non-null, theHankoClientConfig
httpClient
- the customCloseableHttpClient
-
HankoWebAuthnClient
Construct a HankoWebAuthnClient using a customHankoHttpClient
.- Parameters:
httpClient
- the customHankoHttpClient
-
-
Method Details
-
initializeRegistration
Initializes the registration of a new credential using aRegistrationInitializationRequest
. On successful initialization, the Hanko Authentication API returns a stringified JSON representation of the CredentialCreationOptions for use with the WebAuthn API's navigator.credentials.create() function.- Parameters:
request
- theRegistrationInitializationRequest
- Returns:
- the CredentialCreationOptions as a String
- Throws:
HankoClientException
- on serialization/deserialization errorsHankoApiConnectionException
- on Hanko API connection failureHankoAuthenticationException
- on unauthorized Hanko API call
-
finalizeRegistration
Finalizes a registration using the response from the WebAuthn API's navigator.credentials.create() call.- Parameters:
webAuthnResponse
- the WebAuthn API response- Returns:
- the
FinalizationResponse
- Throws:
HankoClientException
- on serialization/deserialization errorsHankoApiConnectionException
- on Hanko API connection failureHankoAuthenticationException
- on unauthorized Hanko API call
-
initializeAuthentication
Initializes an authentication with a registered credential using anAuthenticationInitializationRequest
. On successful initialization, the Hanko Authentication API returns a stringified JSON representation of the CredentialRequestOptions for use with the WebAuthn API's navigator.credentials.get() function.- Parameters:
request
- theAuthenticationInitializationRequest
- Returns:
- the String
- Throws:
HankoClientException
- on serialization/deserialization errorsHankoApiConnectionException
- on Hanko API connection failureHankoAuthenticationException
- on unauthorized Hanko API call
-
finalizeAuthentication
Finalizes an authentication using the response from the WebAuthn API's navigator.credentials.get() call.- Parameters:
webAuthnResponse
- the WebAuthn API response as a String- Returns:
- the
FinalizationResponse
- Throws:
HankoClientException
- on serialization/deserialization errorsHankoApiConnectionException
- on Hanko API connection failureHankoAuthenticationException
- on unauthorized Hanko API call
-
initializeTransaction
Initializes a transaction. A transaction operation is analogous to the authentication operation, with the main difference being that a transaction context must be provided in the form of a string. This value will become part of the challenge an authenticator signs over during the operation.Initialize a transaction using a TransactionInitializationRequest. On successful initialization, the Hanko Authentication API returns a stringified JSON representation of the CredentialRequestOptions for use with the WebAuthn API's navigator.credentials.get() function.
- Parameters:
request
- theTransactionInitializationRequest
- Returns:
- the CredentialRequestOptions as a String
- Throws:
HankoClientException
- on serialization/deserialization errorsHankoApiConnectionException
- on Hanko API connection failureHankoAuthenticationException
- on unauthorized Hanko API call
-
finalizeTransaction
Finalizes the transaction request using the response from the WebAuthn API's navigator.credentials.get() call.- Parameters:
webAuthnResponse
- the WebAuthn API response as a String- Returns:
- a
FinalizationResponse
- Throws:
HankoClientException
- on serialization/deserialization errorsHankoApiConnectionException
- on Hanko API connection failureHankoAuthenticationException
- on unauthorized Hanko API call
-
getCredential
Retrieves the registeredWebAuthnCredential
with the specified credentialId.- Parameters:
credentialId
- the id of the credential to retrieve- Returns:
- the
WebAuthnCredential
- Throws:
HankoClientException
- on serialization/deserialization errorsHankoApiConnectionException
- on Hanko API connection failureHankoAuthenticationException
- on unauthorized Hanko API callHankoNotFoundException
- if no credential was found
-
listCredentials
Retrieves a list of registeredWebAuthnCredential
s.Credentials can be filtered by userId and results paginated using a
CredentialQuery
. If theCredentialQuery
is null or if any of its values are null, retrieval defaults to searching for credentials for all users with page equal to 1 and page size equal to 10.- Parameters:
query
- theCredentialQuery
, nullable- Returns:
- the list of registered
WebAuthnCredential
s - Throws:
HankoClientException
- on serialization/deserialization errorsHankoApiConnectionException
- on Hanko API connection failureHankoAuthenticationException
- on unauthorized Hanko API call
-
deleteCredential
Deletes theWebAuthnCredential
with the specified credentialId.- Parameters:
credentialId
- the id of the credential to delete- Returns:
- true if deletion was successful, otherwise false
- Throws:
HankoClientException
- on serialization/deserialization errorsHankoApiConnectionException
- on Hanko API connection failureHankoAuthenticationException
- on unauthorized Hanko API callHankoNotFoundException
- if no credential was found
-
updateCredential
Updates theWebAuthnCredential
with the specified credentialId. Provide aCredentialUpdateRequest
with the updated data. Currently, you can only update the name of a Credential.- Parameters:
credentialId
- the id of the credential to updaterequest
- theCredentialUpdateRequest
- Returns:
- the updated
WebAuthnCredential
- Throws:
HankoClientException
- on serialization/deserialization errorsHankoApiConnectionException
- on Hanko API connection failureHankoAuthenticationException
- on unauthorized Hanko API call
-