Skip to content

Commit 687501d

Browse files
authored
Merge pull request #5 from contentpass/decrypt-failure-to-unauthenticated
Add catching of decryption exceptions
2 parents d579e7c + 25c84c4 commit 687501d

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
Our SDK is available on Maven Central.
1515

1616
```groovy
17-
implementation 'de.contentpass:contentpass-android:2.0.0'
17+
implementation 'de.contentpass:contentpass-android:2.0.1'
1818
```
1919

2020
Add this to your app's `build.gradle` file's `dependencies` element.

lib/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ kapt {
5858
extra.apply{
5959
set("PUBLISH_GROUP_ID", "de.contentpass")
6060
set("PUBLISH_ARTIFACT_ID", "contentpass-android")
61-
set("PUBLISH_VERSION", "2.0.0")
61+
set("PUBLISH_VERSION", "2.0.1")
6262
}
6363

6464
apply("${rootProject.projectDir}/scripts/publish-module.gradle")

lib/src/main/java/de/contentpass/lib/TokenStore.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ internal class TokenStore(context: Context, private val keyStore: KeyStore) : To
1919
override fun retrieveAuthState(): AuthState? {
2020
return sharedPreferences.getString(tokenKey, null)?.let { token ->
2121
return retrieveIV()?.let { iv ->
22-
val decrypted = decrypt(token.decoded(), iv)
23-
AuthState.jsonDeserialize(decrypted.encoded())
22+
try {
23+
val decrypted = decrypt(token.decoded(), iv)
24+
AuthState.jsonDeserialize(decrypted.encoded())
25+
} catch (e: Throwable) {
26+
null
27+
}
2428
}
2529
}
2630
}

0 commit comments

Comments
 (0)