Interface WebAuthnCredentialRepository

All Superinterfaces:
com.yubico.webauthn.CredentialRepository
All Known Implementing Classes:
IdPStorageServiceCredentialRepository, StrategyBasedIdPStorageServiceCredentialRepository

@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 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

      boolean addRegistrationByUsername(@Nonnull String username, @Nonnull CredentialRecord credential)
      Add a new credential registration for a given user, by their username.
      Parameters:
      username - the user to add the registration for
      credential - 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 for
      credentialId - the identifier of the credential to update the signature counter for
      newSignatureCount - 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 for
      credentialId - 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 find
      userHandle - 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 for
      credentialRegistration - 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

      @Nonnull @NotLive @Unmodifiable Set<CredentialRecord> 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 from
      credentialId - 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 for
      credentialId - the identifier of the credential to update the last used time for
      lastUsedTime - the new last used time value
      Returns:
      true iff the registration was updated, false otherwise.
      Since:
      1.1.0
    • updateNickname

      default boolean updateNickname(@Nonnull String username, @Nonnull com.yubico.webauthn.data.ByteArray credentialId, @Nonnull String nickname)
      Update the nickname for the credential that belongs to the given user.
      Parameters:
      username - the username of the user to update the nickname for
      credentialId - the identifier of the credential to update the nickname for
      nickname - the new nickname of the credential
      Returns:
      true iff the registration was updated, false otherwise.
      Since:
      1.2.0