Laid at least groundworks to encrypt Room database
This commit is contained in:
parent
497b82ce09
commit
d360ff1def
|
@ -70,6 +70,8 @@ ext {
|
||||||
|
|
||||||
roomVersion = "2.2.5"
|
roomVersion = "2.2.5"
|
||||||
|
|
||||||
|
sqlCipherVersion = "4.4.0"
|
||||||
|
|
||||||
|
|
||||||
/* JavaFX */
|
/* JavaFX */
|
||||||
|
|
||||||
|
|
|
@ -34,4 +34,6 @@ dependencies {
|
||||||
kapt "androidx.room:room-compiler:$roomVersion"
|
kapt "androidx.room:room-compiler:$roomVersion"
|
||||||
implementation "androidx.room:room-ktx:$roomVersion"
|
implementation "androidx.room:room-ktx:$roomVersion"
|
||||||
|
|
||||||
|
implementation "net.zetetic:android-database-sqlcipher:$sqlCipherVersion"
|
||||||
|
|
||||||
}
|
}
|
|
@ -14,14 +14,22 @@ import net.dankito.banking.ui.model.tan.MobilePhoneTanMedium
|
||||||
import net.dankito.banking.ui.model.tan.TanGeneratorTanMedium
|
import net.dankito.banking.ui.model.tan.TanGeneratorTanMedium
|
||||||
import net.dankito.banking.util.persistence.doSaveUrlToFile
|
import net.dankito.banking.util.persistence.doSaveUrlToFile
|
||||||
import net.dankito.utils.multiplatform.File
|
import net.dankito.utils.multiplatform.File
|
||||||
|
import net.sqlcipher.database.SQLiteDatabase
|
||||||
|
import net.sqlcipher.database.SupportFactory
|
||||||
|
|
||||||
|
|
||||||
open class RoomBankingPersistence(applicationContext: Context) : IBankingPersistence, IRemitteeSearcher {
|
open class RoomBankingPersistence(applicationContext: Context, password: String? = null) : IBankingPersistence, IRemitteeSearcher {
|
||||||
|
|
||||||
protected val db = Room.databaseBuilder(
|
protected val db: BankingDatabase
|
||||||
applicationContext,
|
|
||||||
BankingDatabase::class.java, "banking-database"
|
init {
|
||||||
).build()
|
val passphrase = password?.let { SQLiteDatabase.getBytes(password.toCharArray()) } ?: ByteArray(0)
|
||||||
|
val factory = SupportFactory(passphrase)
|
||||||
|
|
||||||
|
db = Room.databaseBuilder(applicationContext, BankingDatabase::class.java, "banking-database")
|
||||||
|
.openHelperFactory(factory)
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun saveOrUpdateAccount(customer: TypedCustomer, allCustomers: List<TypedCustomer>) {
|
override fun saveOrUpdateAccount(customer: TypedCustomer, allCustomers: List<TypedCustomer>) {
|
||||||
|
|
Loading…
Reference in New Issue