Interface WebAuthnCredentialRepository
- All Superinterfaces:
com.yubico.webauthn.CredentialRepository
- All Known Implementing Classes:
IdPStorageServiceCredentialRespository
@ThreadSafe
public interface WebAuthnCredentialRepository
extends com.yubico.webauthn.CredentialRepository
A WebAuthn credential repository that extends the
CredentialRepository interface to support additional read
and write operations.
Implementations of this interface are required to be thread-safe.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanaddRegistrationByUsername(String username, CredentialRecord credential) Add a new credential registration for a given user, by their username.Get all credential registrations known to the repository.getRegistrationByUserHandleAndCredentialId(com.yubico.webauthn.data.ByteArray credentialId, com.yubico.webauthn.data.ByteArray userHandle) Get the credential belonging to the user by userHandle and credentialID.getRegistrationByUsernameAndCredentialId(String username, com.yubico.webauthn.data.ByteArray credentialId) Get the credential belonging to the user by its credential identifier.getRegistrationsByUsername(String username) Get credential registrations by username.intremoveRegistrationByCredentialId(com.yubico.webauthn.data.ByteArray credentialId) Remove the credential by its identifier for any user it is registered for.booleanremoveRegistrationByUsername(String username, CredentialRecord credentialRegistration) Remove the registration for the given user.booleanremoveRegistrationByUsernameAndCredentialId(String username, com.yubico.webauthn.data.ByteArray credentialId) Remove the credential with the given credential Id for the given user.default booleanupdateLastUsedTime(String username, com.yubico.webauthn.data.ByteArray credentialId, Instant lastUsedTime) Update the last used time for the credential that belongs to the given user.booleanupdateSignatureCounter(String username, com.yubico.webauthn.data.ByteArray credentialId, long newSignatureCount) Update the signature counter of the credential that belongs to the given user.Methods inherited from interface com.yubico.webauthn.CredentialRepository
getCredentialIdsForUsername, getUserHandleForUsername, getUsernameForUserHandle, lookup, lookupAll
-
Method Details
-
getRegistrationsByUsername
@Nonnull @NonnullElements @NotLive Set<CredentialRecord> getRegistrationsByUsername(@Nonnull String username) Get credential registrations by username.- Parameters:
username- the username to find registrations for- Returns:
- the set of registered credentials associated to the user
-
addRegistrationByUsername
Add a new credential registration for a given user, by their username.- Parameters:
username- the user to add the registration forcredential- the credential to add- Returns:
- true iff the registration was added. False otherwise.
-
updateSignatureCounter
boolean updateSignatureCounter(@Nonnull String username, @Nonnull com.yubico.webauthn.data.ByteArray credentialId, long newSignatureCount) Update the signature counter of the credential that belongs to the given user.- Parameters:
username- the username of the user to update the signature counter forcredentialId- the identifier of the credential to update the signature counter fornewSignatureCount- the new signature counter value- Returns:
- true iff the registration was updated, false otherwise.
-
getRegistrationByUsernameAndCredentialId
@Nonnull Optional<CredentialRecord> getRegistrationByUsernameAndCredentialId(@Nonnull String username, @Nonnull com.yubico.webauthn.data.ByteArray credentialId) Get the credential belonging to the user by its credential identifier.- Parameters:
username- the username to find the credential forcredentialId- the identifier of the credential to find- Returns:
- the credential if found, otherwise an empty
Optional.
-
getRegistrationByUserHandleAndCredentialId
Optional<CredentialRecord> getRegistrationByUserHandleAndCredentialId(@Nonnull com.yubico.webauthn.data.ByteArray credentialId, @Nonnull com.yubico.webauthn.data.ByteArray userHandle) Get the credential belonging to the user by userHandle and credentialID.- Parameters:
credentialId- the identifier of the credential to finduserHandle- the user handle (user.id)- Returns:
- the credential registration if found.
-
removeRegistrationByUsername
boolean removeRegistrationByUsername(@Nonnull String username, @Nonnull CredentialRecord credentialRegistration) Remove the registration for the given user.- Parameters:
username- the user to remove the registration forcredentialRegistration- the credential to remove- Returns:
- true iff the credential was removed, false otherwise.
-
removeRegistrationByCredentialId
int removeRegistrationByCredentialId(@Nonnull com.yubico.webauthn.data.ByteArray credentialId) Remove the credential by its identifier for any user it is registered for. This should, in practice, only be registered to a single user.- Parameters:
credentialId- the credential to remove- Returns:
- the number of credentials that have been removed. Should be 1 if removed from a single user, more than 1 if removed from more than one user, and 0 if not removed from any user.
-
getAllRegistrations
Get all credential registrations known to the repository. Typically used to provide an administrative view of the repository.- Returns:
- all credential registrations known to the system.
-
removeRegistrationByUsernameAndCredentialId
boolean removeRegistrationByUsernameAndCredentialId(@Nonnull String username, @Nonnull com.yubico.webauthn.data.ByteArray credentialId) Remove the credential with the given credential Id for the given user.- Parameters:
username- the user to remove the credential fromcredentialId- the identifier of the credential to remove- Returns:
- true iff the credential was remove, false otherwise.
-
updateLastUsedTime
default boolean updateLastUsedTime(@Nonnull String username, @Nonnull com.yubico.webauthn.data.ByteArray credentialId, @Nonnull Instant lastUsedTime) Update the last used time for the credential that belongs to the given user.- Parameters:
username- the username of the user to update the last used time forcredentialId- the identifier of the credential to update the last used time forlastUsedTime- the new last used time value- Returns:
- true iff the registration was updated, false otherwise.
- Since:
- 1.1.0
-