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

# Class StorageServiceCredentialRepositoryFactory

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.idp.plugin.authn.webauthn.storage.impl.StorageServiceCredentialRepositoryFactory

All Implemented Interfaces:
  `Component`, `DestructableComponent`, `InitializableComponent`, `FactoryBean<WebAuthnCredentialRepository>`

@ThreadSafe public class StorageServiceCredentialRepositoryFactory extends AbstractInitializableComponent implements FactoryBean<WebAuthnCredentialRepository>
A factory bean that decides which credential repository implementation to create based on the options set. If a `WebAuthnJDBCQueryAccelerator` has been injected, the `StrategyBasedIdPStorageServiceCredentialRepository` will be instantiated, else the `IdPStorageServiceCredentialRepository` is instantiated.

Since:
  1.3.0

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static enum`
`StorageServiceCredentialRepositoryFactory.AcceleratorType`
The type of JDBC accelerator.
`(package private) static class`
`StorageServiceCredentialRepositoryFactory.Base64URLKeyExtractionStrategy`
An extraction strategy that converts the `ByteArray` into a base64Url encoded string.
`(package private) static class`
`StorageServiceCredentialRepositoryFactory.CredentialIdB64FromCredentialExtractionStrategy`
An extraction strategy that converts the `CredentialRecord` into a base64Url encoded string of the credentialId inside the credential.
`(package private) static class`
`StorageServiceCredentialRepositoryFactory.UserHandleB64FromCredentialExtractionStrategy`
An extraction strategy that converts the `CredentialRecord` into a base64Url encoded string of the userHandle inside the credential.
`(package private) static class`
`StorageServiceCredentialRepositoryFactory.UsernameFromCredentialExtractionStrategy`
An extraction strategy that converts the `CredentialRecord` into a username inside the registration.

## Field Summary

Fields
Modifier and Type
Field
Description
`private BiFunction<String,com.yubico.webauthn.data.ByteArray,List<StorageRecord<Set<CredentialRecord>>>>`
`credentialByCredentialIdLookupStrategy`
A strategy used to lookup credentials by credentialId.
`private BiFunction<String,com.yubico.webauthn.data.ByteArray,List<StorageRecord<Set<CredentialRecord>>>>`
`credentialByUserHandleLookupStrategy`
A strategy used to lookup credentials by userHandle.
`private StorageServiceCredentialRepositoryFactory.AcceleratorType`
`defaultAcceleratorType`
If the lookup strategies are not used, the jdbcAccelerator has been injected, then the default accelerator type will be injected into the `StrategyBasedIdPStorageServiceCredentialRepository`.
`private boolean`
`enableCache`
Should the cache be enabled? Defaults to true.
`private Duration`
`expireAfterAccess`
The duration to wait after last access to expire entries in the cache.
`private WebAuthnJDBCAccelerator`
`jdbcAccelerator`
A JDBC based storage service accelerator which improves the performance of specific WebAuthn queries.
`private final org.slf4j.Logger`
`log`
Class logger.
`private StorageSerializer<Set<CredentialRecord>>`
`serializer`
Storage record serializer.
`private Function<String,List<StorageRecord<Set<CredentialRecord>>>>`
`storageRecordCacheLoader`
A cache loader to be used when the credential repository is initialized.
`private EnumeratableStorageService`
`storageService`
The Storage Service used to hold the credential registrations.

### Fields inherited from interface org.springframework.beans.factory.FactoryBean

`OBJECT_TYPE_ATTRIBUTE`

## Constructor Summary

Constructors
Constructor
Description
`StorageServiceCredentialRepositoryFactory()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`protected void`
`doInitialize()`
`private BiFunction<String,com.yubico.webauthn.data.ByteArray,List<StorageRecord<Set<CredentialRecord>>>>`
`getCredentialByCredentialIdLookupStrategy()`
Get the JDBC strategy used to lookup credential records based on the credentialId.
`private BiFunction<String,com.yubico.webauthn.data.ByteArray,List<StorageRecord<Set<CredentialRecord>>>>`
`getCredentialByUserHandleLookupStrategy()`
Get the JDBC strategy used to lookup credential records based on the userHandle.
`StorageServiceCredentialRepositoryFactory.AcceleratorType`
`getDefaultAcceleratorType()`
Get the default accelerator type to use if the lookup strategies are not set.
`private WebAuthnJDBCAccelerator`
`getJdbcAccelerator()`
Get the JDBC accelerator to use, if enabled.
`WebAuthnCredentialRepository`
`getObject()`
`Class<?>`
`getObjectType()`
`StorageSerializer<Set<CredentialRecord>>`
`getSerializer()`
Get the storage service serializer to use.
`Function<String,List<StorageRecord<Set<CredentialRecord>>>>`
`getStorageRecordCacheLoader()`
Get the loader that loads entries to be cached on initialisation of the credential repository.
`EnumeratableStorageService`
`getStorageService()`
Get the storage service to use.
`private boolean`
`isEnableCache()`
Is the cache enabled?
`boolean`
`isSingleton()`
`void`
`setCredentialByCredentialIdLookupStrategy(BiFunction<String,com.yubico.webauthn.data.ByteArray,List<StorageRecord<Set<CredentialRecord>>>> strategy)`
Set the JDBC 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 JDBC strategy used to lookup credential records based on the userHandle.
`void`
`setDefaultAcceleratorType(StorageServiceCredentialRepositoryFactory.AcceleratorType type)`
Set the default accelerator type to use if the lookup strategies are not set.
`void`
`setEnableCache(boolean flag)`
Set if the cache should be enabled or disabled.
`void`
`setExpireAfterAccess(Duration expiry)`
Set the duration to wait after last access to expire entries from the cache.
`void`
`setJdbcAccelerator(WebAuthnJDBCQueryAccelerator accelerator)`
Set a JDBC based storage service accelerator which improves the performance of specific WebAuthn queries.
`void`
`setSerializer(StorageSerializer<Set<CredentialRecord>> storageSerializer)`
Set the storage service serializer to handle `CredentialRecord`s.
`void`
`setStorageRecordCacheLoader(Function<String,List<StorageRecord<Set<CredentialRecord>>>> loader)`
Set a loader that loads entries to be cached on initialisation of the credential repository.
`void`
`setStorageService(StorageService service)`
Set the storage service to store credentials.

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

`checkComponentActive, checkSetterPreconditions, destroy, doDestroy, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, initialize, isDestroyed, isInitialized`

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

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

## Field Details

### log

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

### storageService

@NonnullAfterInit private EnumeratableStorageService storageService
The Storage Service used to hold the credential registrations.

### jdbcAccelerator

@Nullable private WebAuthnJDBCAccelerator jdbcAccelerator
A JDBC based storage service accelerator which improves the performance of specific WebAuthn queries.

### serializer

@NonnullAfterInit private StorageSerializer<Set<CredentialRecord>> serializer
Storage record serializer.

### expireAfterAccess

@Nonnull private Duration expireAfterAccess
The duration to wait after last access to expire entries in the cache.

### enableCache

private boolean enableCache
Should the cache be enabled? Defaults to true.

### credentialByUserHandleLookupStrategy

@Nullable private BiFunction<String,com.yubico.webauthn.data.ByteArray,List<StorageRecord<Set<CredentialRecord>>>> credentialByUserHandleLookupStrategy
A strategy used to lookup credentials by userHandle. Overrides any of the default strategies.

### credentialByCredentialIdLookupStrategy

@Nullable private BiFunction<String,com.yubico.webauthn.data.ByteArray,List<StorageRecord<Set<CredentialRecord>>>> credentialByCredentialIdLookupStrategy
A strategy used to lookup credentials by credentialId. Overrides any of the default strategies.

### defaultAcceleratorType

@Nonnull private StorageServiceCredentialRepositoryFactory.AcceleratorType defaultAcceleratorType
If the lookup strategies are not used, the jdbcAccelerator has been injected, then the default accelerator type will be injected into the `StrategyBasedIdPStorageServiceCredentialRepository`.

### storageRecordCacheLoader

@Nullable private Function<String,List<StorageRecord<Set<CredentialRecord>>>> storageRecordCacheLoader
A cache loader to be used when the credential repository is initialized.

## Constructor Details

### StorageServiceCredentialRepositoryFactory

public StorageServiceCredentialRepositoryFactory()
Constructor.

## Method Details

### doInitialize

protected void doInitialize() throws ComponentInitializationException

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

### setDefaultAcceleratorType

public void setDefaultAcceleratorType(@Nonnull StorageServiceCredentialRepositoryFactory.AcceleratorType type)
Set the default accelerator type to use if the lookup strategies are not set.

Parameters:
  `type` - The defaultAcceleratorType to set.

### getDefaultAcceleratorType

@Nonnull public StorageServiceCredentialRepositoryFactory.AcceleratorType getDefaultAcceleratorType()
Get the default accelerator type to use if the lookup strategies are not set.

Returns:
  Returns the defaultAcceleratorType.

### setExpireAfterAccess

public void setExpireAfterAccess(@Nonnull Duration expiry)
Set the duration to wait after last access to expire entries from the cache.

Parameters:
  `expiry` - The expireAfterAccess to set.

### setJdbcAccelerator

public void setJdbcAccelerator(@Nullable WebAuthnJDBCQueryAccelerator accelerator)
Set a JDBC based storage service accelerator which improves the performance of specific WebAuthn queries.

Parameters:
  `accelerator` - The jdbcAccelerator to set.

### getJdbcAccelerator

@Nullable private WebAuthnJDBCAccelerator getJdbcAccelerator()
Get the JDBC accelerator to use, if enabled.

Returns:
  the jdbcAccelerator.

### setEnableCache

public void setEnableCache(boolean flag)
Set if the cache should be enabled or disabled.

Parameters:
  `flag` - should the cache be enabled or disabled.

### isEnableCache

private boolean isEnableCache()
Is the cache enabled?

Returns:
  true if the cache is enabled, false otherwise.

### setStorageService

public void setStorageService(@Nonnull StorageService service)
Set the storage service to store credentials.

Parameters:
  `service` - the storageService to set.

### getStorageService

@NonnullAfterInit public EnumeratableStorageService getStorageService()
Get the storage service to use.

Returns:
  the storageService.

### setSerializer

public void setSerializer(@Nonnull StorageSerializer<Set<CredentialRecord>> storageSerializer)
Set the storage service serializer to handle `CredentialRecord`s.

Parameters:
  `storageSerializer` - the serializer to set.

### getSerializer

@NonnullAfterInit public StorageSerializer<Set<CredentialRecord>> getSerializer()
Get the storage service serializer to use.

Returns:
  Returns the serializer.

### setCredentialByUserHandleLookupStrategy

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

Parameters:
  `strategy` - The userHandleLookupStrategy to set.

### getCredentialByUserHandleLookupStrategy

private BiFunction<String,com.yubico.webauthn.data.ByteArray,List<StorageRecord<Set<CredentialRecord>>>> getCredentialByUserHandleLookupStrategy()
Get the JDBC strategy used to lookup credential records based on the userHandle.

Returns:
  the lookup strategy

### setCredentialByCredentialIdLookupStrategy

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

Parameters:
  `strategy` - The credentialIdLookupStrategy to set.

### getCredentialByCredentialIdLookupStrategy

private BiFunction<String,com.yubico.webauthn.data.ByteArray,List<StorageRecord<Set<CredentialRecord>>>> getCredentialByCredentialIdLookupStrategy()
Get the JDBC strategy used to lookup credential records based on the credentialId.

Returns:
  the lookup strategy

### setStorageRecordCacheLoader

public void setStorageRecordCacheLoader(@Nullable Function<String,List<StorageRecord<Set<CredentialRecord>>>> loader)
Set a loader that loads entries to be cached on initialisation of the credential repository.

Parameters:
  `loader` - The initialCacheLoader to set.

### getStorageRecordCacheLoader

@Nullable public Function<String,List<StorageRecord<Set<CredentialRecord>>>> getStorageRecordCacheLoader()
Get the loader that loads entries to be cached on initialisation of the credential repository.

Returns:
  the user handle mapping initial cache loader.

### getObject

public WebAuthnCredentialRepository getObject() throws Exception

Specified by:
  `getObject` in interface `FactoryBean<WebAuthnCredentialRepository>`
Throws:
  `Exception`

### getObjectType

public Class<?> getObjectType()

Specified by:
  `getObjectType` in interface `FactoryBean<WebAuthnCredentialRepository>`

### isSingleton

public boolean isSingleton()

Specified by:
  `isSingleton` in interface `FactoryBean<WebAuthnCredentialRepository>`