StorageClientProvider

open class StorageClientProvider(context: Context, storageClient: StorageClient = DefaultStorageClient(context)) : LegacyStorageProvider

LegacyStorageProvider implementation that sources and cleans up legacy authenticator data via a ForgeRock StorageClient.

This is the default provider used by AuthMigration when no custom LegacyStorageProvider is configured in LegacyAuthenticationConfig. It delegates data reading to LegacyDataConverter.convertToLegacyExportedData and removes accounts and mechanisms directly through the StorageClient API during cleanup.

Parameters

context

The Android application context, used to initialize the default org.forgerock.android.auth.DefaultStorageClient when no custom storageClient is provided.

storageClient

The ForgeRock StorageClient that holds legacy accounts and mechanisms. Defaults to DefaultStorageClient(context), which reads from the standard legacy encrypted SharedPreferences used by the FR Authenticator SDK.

Example — default usage (no configuration needed)

lifecycleScope.launch {
AuthMigration.start(applicationContext)
}

Example — custom StorageClient

lifecycleScope.launch {
AuthMigration.start(applicationContext) {
legacyStorageProvider = StorageClientProvider(
context = applicationContext,
storageClient = MyCustomStorageClient(applicationContext)
)
}
}

Example — backup before cleanup (via LegacyAuthenticationConfig)

lifecycleScope.launch {
AuthMigration.start(applicationContext) {
backup = { ctx -> MyBackupHelper.backup(ctx) }
}
}

See also

Inheritors

Constructors

Link copied to clipboard
constructor(context: Context, storageClient: StorageClient = DefaultStorageClient(context))

Functions

Link copied to clipboard
open suspend override fun cleanUp(context: Context, backup: (context: Context) -> Unit)

Invokes backup and then removes all legacy accounts and mechanisms from the storageClient.

Link copied to clipboard
open suspend override fun getMigrationData(context: Context): LegacyExportedData

Converts all accounts and mechanisms held by the storageClient into a LegacyExportedData object ready for the migration pipeline.

Link copied to clipboard
open suspend override fun isMigrationRequired(context: Context): Boolean

Returns true if the storageClient contains at least one legacy account, indicating that migration is required.