mirror of
https://github.com/bitwarden/android.git
synced 2026-03-21 22:00:42 -05:00
[PM-19866] Migrate BaseEncryptedDiskSource to data module (#4991)
This commit is contained in:
@@ -3,13 +3,13 @@ package com.x8bit.bitwarden.data.auth.datasource.disk
|
|||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import com.bitwarden.core.data.repository.util.bufferedMutableSharedFlow
|
import com.bitwarden.core.data.repository.util.bufferedMutableSharedFlow
|
||||||
import com.bitwarden.core.data.util.decodeFromStringOrNull
|
import com.bitwarden.core.data.util.decodeFromStringOrNull
|
||||||
|
import com.bitwarden.data.datasource.disk.BaseEncryptedDiskSource
|
||||||
import com.x8bit.bitwarden.data.auth.datasource.disk.model.AccountTokensJson
|
import com.x8bit.bitwarden.data.auth.datasource.disk.model.AccountTokensJson
|
||||||
import com.x8bit.bitwarden.data.auth.datasource.disk.model.NewDeviceNoticeDisplayStatus
|
import com.x8bit.bitwarden.data.auth.datasource.disk.model.NewDeviceNoticeDisplayStatus
|
||||||
import com.x8bit.bitwarden.data.auth.datasource.disk.model.NewDeviceNoticeState
|
import com.x8bit.bitwarden.data.auth.datasource.disk.model.NewDeviceNoticeState
|
||||||
import com.x8bit.bitwarden.data.auth.datasource.disk.model.OnboardingStatus
|
import com.x8bit.bitwarden.data.auth.datasource.disk.model.OnboardingStatus
|
||||||
import com.x8bit.bitwarden.data.auth.datasource.disk.model.PendingAuthRequestJson
|
import com.x8bit.bitwarden.data.auth.datasource.disk.model.PendingAuthRequestJson
|
||||||
import com.x8bit.bitwarden.data.auth.datasource.disk.model.UserStateJson
|
import com.x8bit.bitwarden.data.auth.datasource.disk.model.UserStateJson
|
||||||
import com.x8bit.bitwarden.data.platform.datasource.disk.BaseEncryptedDiskSource
|
|
||||||
import com.x8bit.bitwarden.data.platform.datasource.disk.legacy.LegacySecureStorageMigrator
|
import com.x8bit.bitwarden.data.platform.datasource.disk.legacy.LegacySecureStorageMigrator
|
||||||
import com.x8bit.bitwarden.data.vault.datasource.network.model.SyncResponseJson
|
import com.x8bit.bitwarden.data.vault.datasource.network.model.SyncResponseJson
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
package com.bitwarden.authenticator.data.auth.datasource.disk
|
package com.bitwarden.authenticator.data.auth.datasource.disk
|
||||||
|
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import com.bitwarden.authenticator.data.platform.datasource.disk.BaseEncryptedDiskSource
|
import com.bitwarden.data.datasource.disk.BaseEncryptedDiskSource
|
||||||
import com.bitwarden.authenticator.data.platform.datasource.disk.BaseEncryptedDiskSource.Companion.ENCRYPTED_BASE_KEY
|
|
||||||
|
|
||||||
private const val AUTHENTICATOR_SYNC_SYMMETRIC_KEY =
|
private const val AUTHENTICATOR_SYNC_SYMMETRIC_KEY = "authenticatorSyncSymmetricKey"
|
||||||
"$ENCRYPTED_BASE_KEY:authenticatorSyncSymmetricKey"
|
|
||||||
private const val LAST_ACTIVE_TIME_KEY = "lastActiveTime"
|
private const val LAST_ACTIVE_TIME_KEY = "lastActiveTime"
|
||||||
private const val BIOMETRICS_UNLOCK_KEY = "$ENCRYPTED_BASE_KEY:userKeyBiometricUnlock"
|
private const val BIOMETRICS_UNLOCK_KEY = "userKeyBiometricUnlock"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Primary implementation of [AuthDiskSource].
|
* Primary implementation of [AuthDiskSource].
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
package com.bitwarden.authenticator.data.platform.datasource.disk
|
|
||||||
|
|
||||||
import android.content.SharedPreferences
|
|
||||||
import androidx.core.content.edit
|
|
||||||
import androidx.security.crypto.EncryptedSharedPreferences
|
|
||||||
import com.bitwarden.data.datasource.disk.BaseDiskSource
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Base class for simplifying interactions with [SharedPreferences] and
|
|
||||||
* [EncryptedSharedPreferences].
|
|
||||||
*/
|
|
||||||
@Suppress("UnnecessaryAbstractClass")
|
|
||||||
abstract class BaseEncryptedDiskSource(
|
|
||||||
sharedPreferences: SharedPreferences,
|
|
||||||
private val encryptedSharedPreferences: SharedPreferences,
|
|
||||||
) : BaseDiskSource(
|
|
||||||
sharedPreferences = sharedPreferences,
|
|
||||||
) {
|
|
||||||
protected fun getEncryptedString(
|
|
||||||
key: String,
|
|
||||||
default: String? = null,
|
|
||||||
): String? = encryptedSharedPreferences.getString(key, default)
|
|
||||||
|
|
||||||
protected fun putEncryptedString(
|
|
||||||
key: String,
|
|
||||||
value: String?,
|
|
||||||
): Unit = encryptedSharedPreferences.edit { putString(key, value) }
|
|
||||||
|
|
||||||
@Suppress("UndocumentedPublicClass")
|
|
||||||
companion object {
|
|
||||||
const val ENCRYPTED_BASE_KEY: String = "bwSecureStorage"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -39,4 +39,5 @@ kotlin {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(libs.androidx.core.ktx)
|
implementation(libs.androidx.core.ktx)
|
||||||
|
implementation(libs.androidx.security.crypto)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
package com.x8bit.bitwarden.data.platform.datasource.disk
|
package com.bitwarden.data.datasource.disk
|
||||||
|
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import androidx.core.content.edit
|
import androidx.core.content.edit
|
||||||
import androidx.security.crypto.EncryptedSharedPreferences
|
import androidx.security.crypto.EncryptedSharedPreferences
|
||||||
import com.bitwarden.data.datasource.disk.BaseDiskSource
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for simplifying interactions with [SharedPreferences] and
|
* Base class for simplifying interactions with [SharedPreferences] and
|
||||||
Reference in New Issue
Block a user