FileCredentialStore

class FileCredentialStore(val directory: File, val options: FileCredentialStore.Options = Options()) : CredentialStore(source)

A credential store of files: one per credential record, in a directory of the app's (noBackupFilesDir/credentials, by default, which no backup or device transfer copies). Each record is encrypted (AES-256-GCM, its ID as associated data) under an Android Keystore key that, by default, works only while the device is unlocked — iOS's complete file protection. A credential is useless without its holder key, which is in this device's Keystore and can't be restored elsewhere; so is a record without the store's key.

A directory of your own should be one no backup copies too (noBackupFilesDir, or excluded in the app's backup rules): a restored record can't be read without the key, which isn't restored. records skips a record that doesn't decrypt, logging its ID, rather than make every other credential unreadable; record reports it.

Constructors

Link copied to clipboard
constructor(directory: File, options: FileCredentialStore.Options = Options())

Types

Link copied to clipboard
object Companion

Stores in the app's standard places.

Link copied to clipboard
data class Options(val protection: FileCredentialStore.Protection = Protection.WHEN_UNLOCKED, val keyAlias: String = FileCredentialStore.DEFAULT_KEY_ALIAS)

How a FileCredentialStore encrypts its records: by default under a key that works only while the device is unlocked.

Link copied to clipboard

When records can be read and written.

Properties

Link copied to clipboard

The directory the records are kept in.

Link copied to clipboard
open override val isDurable: Boolean

Records are files: they survive the app quitting.

Link copied to clipboard

How the records are encrypted.

Functions

Link copied to clipboard
open override fun delete(id: String)

Deletes the record; deleting one that doesn't exist isn't an error.

Link copied to clipboard
open override fun put(id: String, record: ByteArray)

Stores record under id, replacing any record with that ID.

Link copied to clipboard
open override fun record(id: String): ByteArray?

The record stored under id, or null.

Link copied to clipboard
open override fun records(): List<ByteArray>

Every record.