-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Passphrase feature * Security rep and fraud protection * Few fixes
- Loading branch information
1 parent
36b1d78
commit 4db09b1
Showing
48 changed files
with
1,483 additions
and
406 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
app/src/main/java/com/tari/android/wallet/data/sharedPrefs/security/LoginAttemptDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.tari.android.wallet.data.sharedPrefs.security | ||
|
||
class LoginAttemptDto(val timeInMills: Long, val isSuccessful: Boolean) | ||
|
||
class LoginAttemptList : ArrayList<LoginAttemptDto>() | ||
|
||
fun LoginAttemptList?.orEmpty() : LoginAttemptList = this ?: LoginAttemptList() |
66 changes: 66 additions & 0 deletions
66
...src/main/java/com/tari/android/wallet/data/sharedPrefs/security/SecurityPrefRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.tari.android.wallet.data.sharedPrefs.security | ||
|
||
import android.content.Context | ||
import android.content.SharedPreferences | ||
import com.tari.android.wallet.data.repository.CommonRepository | ||
import com.tari.android.wallet.data.sharedPrefs.delegates.SharedPrefBooleanDelegate | ||
import com.tari.android.wallet.data.sharedPrefs.delegates.SharedPrefBooleanNullableDelegate | ||
import com.tari.android.wallet.data.sharedPrefs.delegates.SharedPrefGsonDelegate | ||
import com.tari.android.wallet.data.sharedPrefs.delegates.SharedPrefStringSecuredDelegate | ||
import com.tari.android.wallet.data.sharedPrefs.network.NetworkRepository | ||
import com.tari.android.wallet.data.sharedPrefs.network.formatKey | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class SecurityPrefRepository @Inject constructor( | ||
context: Context, | ||
sharedPrefs: SharedPreferences, | ||
networkRepository: NetworkRepository, | ||
) : CommonRepository(networkRepository) { | ||
|
||
companion object Key { | ||
const val isAuthenticatedKey = "tari_wallet_is_authenticated" | ||
const val isFeatureAuthenticatedKey = "tari_wallet_is_feature_authenticated" | ||
const val pinCodeKey = "tari_is_pincode" | ||
const val biometricsKey = "tari_is_biometrics" | ||
const val walletDatabasePassphraseKey = "tari_wallet_database_passphrase" | ||
const val loginAttemptsKey = "tari_login_attempts" | ||
} | ||
|
||
var isAuthenticated: Boolean by SharedPrefBooleanDelegate(sharedPrefs, this, formatKey(isAuthenticatedKey)) | ||
|
||
var isFeatureAuthenticated: Boolean by SharedPrefBooleanDelegate(sharedPrefs, this, formatKey(isFeatureAuthenticatedKey)) | ||
|
||
var pinCode: String? by SharedPrefStringSecuredDelegate(context, sharedPrefs, this, formatKey(pinCodeKey), null) | ||
|
||
var biometricsAuth: Boolean? by SharedPrefBooleanNullableDelegate(sharedPrefs, this, formatKey(biometricsKey)) | ||
|
||
var databasePassphrase: String? by SharedPrefStringSecuredDelegate(context, sharedPrefs, this, formatKey(walletDatabasePassphraseKey)) | ||
|
||
var attempts: LoginAttemptList? by SharedPrefGsonDelegate<LoginAttemptList>( | ||
sharedPrefs, | ||
this, | ||
formatKey(loginAttemptsKey), | ||
LoginAttemptList::class.java, | ||
LoginAttemptList() | ||
) | ||
|
||
fun saveAttempt(attempt: LoginAttemptDto) { | ||
this.attempts = attempts.orEmpty().apply { | ||
add(attempt) | ||
} | ||
if (attempt.isSuccessful) { | ||
attempts = null | ||
} | ||
} | ||
|
||
fun clear() { | ||
databasePassphrase = null | ||
isAuthenticated = false | ||
isFeatureAuthenticated = false | ||
pinCode = null | ||
biometricsAuth = null | ||
attempts = null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.