-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dc5d66c
commit fe479f7
Showing
47 changed files
with
973 additions
and
34 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
9 changes: 9 additions & 0 deletions
9
template-compose/app/src/main/java/co/nimblehq/template/compose/di/AuthQualifiers.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,9 @@ | ||
package co.nimblehq.template.compose.di | ||
|
||
import javax.inject.Qualifier | ||
|
||
@Qualifier | ||
annotation class Unauthorized | ||
|
||
@Qualifier | ||
annotation class Authorized |
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
3 changes: 3 additions & 0 deletions
3
template-compose/app/src/main/resources/api-config.properties.sample
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,3 @@ | ||
BASE_API_URL=BASE_API_URL | ||
CLIENT_ID=CLIENT_ID | ||
CLIENT_SECRET=CLIENT_SECRET |
2 changes: 1 addition & 1 deletion
2
template-compose/app/src/test/java/co/nimblehq/template/compose/test/CoroutineTestRule.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
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
35 changes: 35 additions & 0 deletions
35
...ava/co/nimblehq/template/compose/data/local/preferences/BaseEncryptedSharedPreferences.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,35 @@ | ||
package co.nimblehq.template.compose.data.local.preferences | ||
|
||
import android.content.Context | ||
import android.content.SharedPreferences | ||
import androidx.security.crypto.EncryptedSharedPreferences | ||
import androidx.security.crypto.MasterKey | ||
import java.security.KeyStore | ||
|
||
abstract class BaseEncryptedSharedPreferences : BaseSharedPreferences() { | ||
|
||
fun deleteExistingPreferences(fileName: String, context: Context) { | ||
context.deleteSharedPreferences(fileName) | ||
} | ||
|
||
fun deleteMasterKeyEntry() { | ||
KeyStore.getInstance("AndroidKeyStore").apply { | ||
load(null) | ||
deleteEntry(MasterKey.DEFAULT_MASTER_KEY_ALIAS) | ||
} | ||
} | ||
|
||
fun createEncryptedSharedPreferences(fileName: String, context: Context): SharedPreferences { | ||
val masterKey = MasterKey.Builder(context) | ||
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM) | ||
.build() | ||
|
||
return EncryptedSharedPreferences.create( | ||
context, | ||
fileName, | ||
masterKey, | ||
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV, | ||
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM | ||
) | ||
} | ||
} |
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
14 changes: 4 additions & 10 deletions
14
...in/java/co/nimblehq/template/compose/data/local/preferences/EncryptedSharedPreferences.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 |
---|---|---|
@@ -1,23 +1,17 @@ | ||
package co.nimblehq.template.compose.data.local.preferences | ||
|
||
import android.content.Context | ||
import androidx.security.crypto.EncryptedSharedPreferences | ||
import androidx.security.crypto.MasterKeys | ||
import javax.inject.Inject | ||
|
||
private const val APP_SECRET_SHARED_PREFS = "app_secret_shared_prefs" | ||
|
||
class EncryptedSharedPreferences @Inject constructor(applicationContext: Context) : | ||
BaseSharedPreferences() { | ||
BaseEncryptedSharedPreferences() { | ||
|
||
init { | ||
val masterKey = MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC) | ||
sharedPreferences = EncryptedSharedPreferences.create( | ||
APP_SECRET_SHARED_PREFS, | ||
masterKey, | ||
applicationContext, | ||
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV, | ||
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM | ||
sharedPreferences = createEncryptedSharedPreferences( | ||
fileName = APP_SECRET_SHARED_PREFS, | ||
context = applicationContext | ||
) | ||
} | ||
} |
Oops, something went wrong.