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

# Class StrategyBasedIdPStorageServiceCredentialRepository

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
net.shibboleth.idp.plugin.authn.webauthn.storage.impl.IdPStorageServiceCredentialRepository
net.shibboleth.idp.plugin.authn.webauthn.storage.impl.StrategyBasedIdPStorageServiceCredentialRepository

All Implemented Interfaces:
  `com.yubico.webauthn.CredentialRepository`, `WebAuthnCredentialRepository`, `Component`, `DestructableComponent`, `IdentifiableComponent`, `IdentifiedComponent`, `InitializableComponent`

@ThreadSafeAfterInit public class StrategyBasedIdPStorageServiceCredentialRepository extends IdPStorageServiceCredentialRepository
An extension of the `IdPStorageServiceCredentialRepository` that utalizes specialised lookup functions to improve the performance of userHandle and credentialId lookup operations.

It is the responsibility of the lookup functions to query the underlying storage service, produce correct, well-formed storage records, and return them to this repository implementation for further processing. Strategies must also ensure that the number of records returned is sensible and bounded; large result sets may impact performance.

Since:
  1.3.0

## Field Summary

Fields
Modifier and Type
Field
Description
`private BiFunction<String,com.yubico.webauthn.data.ByteArray,List<StorageRecord<Set<CredentialRecord>>>>`
`credentialByCredentialIdLookupStrategy`
The strategy used to lookup credentials by credentialId.
`private BiFunction<String,com.yubico.webauthn.data.ByteArray,List<StorageRecord<Set<CredentialRecord>>>>`
`credentialByUserHandleLookupStrategy`
The strategy used to lookup credentials by userHandle.
`private final org.slf4j.Logger`
`log`
Class logger.

### Fields inherited from class net.shibboleth.idp.plugin.authn.webauthn.storage.impl.IdPStorageServiceCredentialRepository

`STORAGE_CONTEXT`

## Constructor Summary

Constructors
Constructor
Description
`StrategyBasedIdPStorageServiceCredentialRepository()`
Package-private Constructor.

## Method Summary

Modifier and Type
Method
Description
`protected void`
`doInitialize()`
`protected Set<CredentialRecord>`
`getRegistrationsByCredentialId(com.yubico.webauthn.data.ByteArray credentialId)`
Get registrations from any user by credentialId.
`protected Collection<CredentialRecord>`
`getRegistrationsByUserHandle(com.yubico.webauthn.data.ByteArray userHandle)`
Get registrations from any user by userHandle.
`void`
`setCredentialByCredentialIdLookupStrategy(BiFunction<String,com.yubico.webauthn.data.ByteArray,List<StorageRecord<Set<CredentialRecord>>>> strategy)`
Set the strategy used to lookup credential records based on the credentialId.
`void`
`setCredentialByUserHandleLookupStrategy(BiFunction<String,com.yubico.webauthn.data.ByteArray,List<StorageRecord<Set<CredentialRecord>>>> strategy)`
Set the strategy used to lookup credential records based on the userHandle.

### Methods inherited from class net.shibboleth.idp.plugin.authn.webauthn.storage.impl.IdPStorageServiceCredentialRepository

`addRegistrationByUsername, doDestroy, getAllRegistrations, getCredentialIdMappingCacheService, getCredentialIdsForUsername, getLock, getRegistrationByUserHandleAndCredentialId, getRegistrationByUsernameAndCredentialId, getRegistrationsByUsername, getSerializer, getUserHandleForUsername, getUserHandleMappingCacheService, getUsernameForUserHandle, getUsernameFromCredentialIdCache, getUsernameFromUserHandleCache, lookup, lookupAll, reloadCache, removeRegistrationByCredentialId, removeRegistrationByUsername, removeRegistrationByUsernameAndCredentialId, setCredentialIdMappingCacheService, setSerializer, setStorageRecordCacheLoader, setStorageService, setUserHandleMappingCacheService, updateCache, updateCredentialIdCache, updateLastUsedTime, updateNickname, updateSignatureCounter, updateUserHandleCache`

### Methods inherited from class net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent

`setId`

### Methods inherited from class net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent

`ensureId, getId, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException`

### Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent

`checkComponentActive, checkSetterPreconditions, destroy, initialize, isDestroyed, isInitialized`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface net.shibboleth.shared.component.IdentifiedComponent

`getId`

## Field Details

### log

@Nonnull private final org.slf4j.Logger log
Class logger.

### credentialByUserHandleLookupStrategy

@NonnullAfterInit private BiFunction<String,com.yubico.webauthn.data.ByteArray,List<StorageRecord<Set<CredentialRecord>>>> credentialByUserHandleLookupStrategy
The strategy used to lookup credentials by userHandle. Returned is a List of storage records, where each storage record can contain a number of unique credentials for a given user.

### credentialByCredentialIdLookupStrategy

@NonnullAfterInit private BiFunction<String,com.yubico.webauthn.data.ByteArray,List<StorageRecord<Set<CredentialRecord>>>> credentialByCredentialIdLookupStrategy
The strategy used to lookup credentials by credentialId. Returned is a List of storage records, where each storage record can contain a number of unique credentials for a given user.

## Constructor Details

### StrategyBasedIdPStorageServiceCredentialRepository

StrategyBasedIdPStorageServiceCredentialRepository()
Package-private Constructor.

Should only be instantiated by the `StorageServiceCredentialRepositoryFactory`.

## Method Details

### doInitialize

protected void doInitialize() throws ComponentInitializationException

Overrides:
  `doInitialize` in class `IdPStorageServiceCredentialRepository`
Throws:
  `ComponentInitializationException`

### setCredentialByUserHandleLookupStrategy

public void setCredentialByUserHandleLookupStrategy(@Nonnull BiFunction<String,com.yubico.webauthn.data.ByteArray,List<StorageRecord<Set<CredentialRecord>>>> strategy)
Set the strategy used to lookup credential records based on the userHandle.

Parameters:
  `strategy` - The userHandleLookupStrategy to set.

### setCredentialByCredentialIdLookupStrategy

public void setCredentialByCredentialIdLookupStrategy(@Nonnull BiFunction<String,com.yubico.webauthn.data.ByteArray,List<StorageRecord<Set<CredentialRecord>>>> strategy)
Set the strategy used to lookup credential records based on the credentialId.

Parameters:
  `strategy` - The credentialIdLookupStrategy to set.

### getRegistrationsByUserHandle

@Nonnull protected Collection<CredentialRecord> getRegistrationsByUserHandle(com.yubico.webauthn.data.ByteArray userHandle)
Get registrations from any user by userHandle.

The lookup strategy is responsible for returning the set of registrations by userHandle. The set of credentials returned by the lookup strategy are further checked to ensure they are sound — the credentials are a match to the userHandle given.

Overrides:
  `getRegistrationsByUserHandle` in class `IdPStorageServiceCredentialRepository`
Parameters:
  `userHandle` - the userHandle to match
Returns:
  registrations that match the userHandle from any user.

### getRegistrationsByCredentialId

@Nonnull protected Set<CredentialRecord> getRegistrationsByCredentialId(com.yubico.webauthn.data.ByteArray credentialId)
Get registrations from any user by credentialId.

The lookup strategy is responsible for returning the set of registrations by credentialId. The set of credentials returned by the lookup strategy are further checked to ensure they are sound — the credentials are a match to the credentialId given.

Overrides:
  `getRegistrationsByCredentialId` in class `IdPStorageServiceCredentialRepository`
Parameters:
  `credentialId` - the credentialId to match
Returns:
  registrations that match the credentialId.