Package net.shibboleth.idp.plugin.authn.webauthn.storage

# 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 Summary

Modifier and Type
Method
Description
`boolean`
`addRegistrationByUsername(String username, CredentialRecord credential)`
Add a new credential registration for a given user, by their username.
`Set<CredentialRecord>`
`getAllRegistrations()`
Get all credential registrations known to the repository.
`Optional<CredentialRecord>`
`getRegistrationByUserHandleAndCredentialId(com.yubico.webauthn.data.ByteArray credentialId, com.yubico.webauthn.data.ByteArray userHandle)`
Get the credential belonging to the user by userHandle and credentialID.
`Optional<CredentialRecord>`
`getRegistrationByUsernameAndCredentialId(String username, com.yubico.webauthn.data.ByteArray credentialId)`
Get the credential belonging to the user by its credential identifier.
`Set<CredentialRecord>`
`getRegistrationsByUsername(String username)`
Get credential registrations by username.
`int`
`removeRegistrationByCredentialId(com.yubico.webauthn.data.ByteArray credentialId)`
Remove the credential by its identifier for any user it is registered for.
`boolean`
`removeRegistrationByUsername(String username, CredentialRecord credentialRegistration)`
Remove the registration for the given user.
`boolean`
`removeRegistrationByUsernameAndCredentialId(String username, com.yubico.webauthn.data.ByteArray credentialId)`
Remove the credential with the given credential Id for the given user.
`default boolean`
`updateLastUsedTime(String username, com.yubico.webauthn.data.ByteArray credentialId, Instant lastUsedTime)`
Update the last used time for the credential that belongs to the given user.
`default boolean`
`updateNickname(String username, com.yubico.webauthn.data.ByteArray credentialId, String nickname)`
Update the nickname for the credential that belongs to the given user.
`boolean`
`updateSignatureCounter(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

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