LegacyStorageProvider
interface LegacyStorageProvider
Defines how the migration pipeline sources and cleans up legacy authenticator data.
Implement this interface when your application stores authenticator data in a custom backend (e.g., a different org.forgerock.android.auth.StorageClient implementation, an encrypted database, or a remote store) so that AuthMigration can migrate it to the new OATH and Push credential storage.
The default implementation, StorageClientProvider, wraps a ForgeRock StorageClient and requires no additional configuration for standard FR Authenticator installations.
Implementing a custom provider
class MyCustomStorageProvider(
private val context: Context,
private val storageClient: StorageClient
) : LegacyStorageProvider {
override suspend fun isMigrationRequired(context: Context): Boolean =
storageClient.allAccounts.isNotEmpty()
override suspend fun getMigrationData(context: Context): LegacyExportedData =
withContext(Dispatchers.IO) {
LegacyDataConverter.convertToLegacyExportedData(storageClient)
}
override suspend fun cleanUp(context: Context, backup: (context: Context) -> Unit) {
backup(context) // invoke before clearing to allow caller to persist data
storageClient.allAccounts.forEach { account ->
storageClient.getMechanismsForAccount(account).forEach { storageClient.removeMechanism(it) }
storageClient.removeAccount(account)
}
}
}Content copied to clipboard
See also
Inheritors
Functions
Link copied to clipboard
Returns all legacy authenticator data as a LegacyExportedData object.
Link copied to clipboard
Returns true if legacy authenticator data exists and migration should proceed.