Skip to content

Commit 7f38e13

Browse files
authored
Merge pull request #489 from ForgeRock/develop
ForgeRock Android SDK 4.8.1 Release
2 parents ca39431 + 8040f2a commit 7f38e13

File tree

21 files changed

+281
-77
lines changed

21 files changed

+281
-77
lines changed

.github/workflows/bitbar-prepare-artifacts.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: Prepare BitBar Artifacts
22
on:
33
workflow_call:
44
secrets:
5+
E2E_CONFIG:
6+
description: 'Variables for the e2e tests'
7+
required: true
58
SIGNING_KEYSTORE:
69
description: 'Needed for signing the apk artifacts'
710
required: true
@@ -30,6 +33,17 @@ jobs:
3033
repository: ${{github.event.pull_request.head.repo.full_name}}
3134
fetch-depth: 0
3235

36+
# Set up the variables for the tests from the secrets
37+
- name: Setup config file for e2e tests
38+
run: |
39+
echo "${{ secrets.E2E_CONFIG }}" > forgerock-integration-tests/src/main/assets/test_config.properties
40+
41+
# Use the following step to debug the config file in case of issues
42+
- name: Verify config file exists (debug only)
43+
run: |
44+
ls -l forgerock-integration-tests/src/main/assets
45+
shasum -a 256 forgerock-integration-tests/src/main/assets/test_config.properties
46+
3347
# Setup JDK and cache and restore dependencies.
3448
- name: Set up JDK 17
3549
uses: actions/setup-java@v3

.github/workflows/ci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ jobs:
4646
if: ${{ github.actor != 'dependabot[bot]' }}
4747
needs: build-and-test
4848
secrets:
49+
E2E_CONFIG: ${{ secrets.E2E_CONFIG }}
4950
SIGNING_KEYSTORE: ${{ secrets.SIGNING_KEYSTORE }}
5051
SIGNING_ALIAS: ${{ secrets.SIGNING_ALIAS }}
5152
SIGNING_KEYSTORE_PASSWORD: ${{ secrets.SIGNING_KEYSTORE_PASSWORD }}

.github/workflows/release.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040
# Tag the repo, and create a new release
4141
release:
4242
name: Tag the repo and create a new release
43+
runs-on: macos-latest
4344
needs: publish
4445
steps:
4546
# Clone the repo

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## [4.8.1]
2+
3+
#### Fixed
4+
- Encryption and decryption performance has been enhanced through the implementation of caching for the KeyStore, Cipher, and Symmetric Key. Additionally, developers now have the flexibility to enable or disable StrongBox during key generation. [SDKS-4090]
5+
16
## [4.8.0]
27
#### Added
38
- Support for new response payload in WebAuthn authentication and registration [SDKS-3843]

e2e/app/src/main/java/com/example/app/token/TokenViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class TokenViewModel : ViewModel() {
3030
fun getAccessToken() {
3131
viewModelScope.launch(Dispatchers.Default) {
3232
try {
33-
FRUser.getCurrentUser().accessToken?.let { token ->
33+
FRUser.getCurrentUser()?.accessToken?.let { token ->
3434
state.update {
3535
it.copy(token, null)
3636
}

forgerock-auth/src/main/java/org/forgerock/android/auth/storage/CookiesStorage.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import android.content.Context
1111
import kotlinx.serialization.KSerializer
1212
import kotlinx.serialization.json.Json
1313
import kotlinx.serialization.serializer
14+
import org.forgerock.android.auth.ContextProvider
15+
import org.forgerock.android.auth.Encryptor
1416
import org.forgerock.android.auth.Logger
1517
import org.forgerock.android.auth.SharedPreferencesSignOnManager
1618

@@ -26,15 +28,17 @@ private const val TAG = "CookiesStorage"
2628
* @param keyAlias The alias for the encryption key.
2729
* @param key The key used to store the cookies.
2830
* @param serializer The serializer for the collection of cookies.
31+
* @param encryptor An optional encryptor for securing the cookies.
2932
*/
3033
class CookiesStorage(
3134
context: Context,
3235
filename: String,
3336
keyAlias: String,
3437
key: String,
35-
serializer: KSerializer<Collection<String>>
38+
serializer: KSerializer<Collection<String>>,
39+
encryptor: Encryptor? = null
3640
) : SecureSharedPreferencesStorage<Collection<String>>(
37-
context, filename, keyAlias, key, serializer
41+
context, filename, keyAlias, key, serializer, encryptor
3842
) {
3943

4044
init {
@@ -63,10 +67,11 @@ class CookiesStorage(
6367
* @return A `StorageDelegate` for `CookiesStorage`.
6468
*/
6569
fun CookiesStorage(
66-
context: Context,
70+
context: Context = ContextProvider.context,
6771
filename: String = ORG_FORGEROCK_V_2_COOKIES,
6872
keyAlias: String = ORG_FORGEROCK_V_2_KEYS,
6973
key: String = COOKIES,
74+
encryptor: Encryptor? = null
7075
): StorageDelegate<Collection<String>> =
7176
StorageDelegate {
7277
CookiesStorage(
@@ -75,5 +80,6 @@ fun CookiesStorage(
7580
keyAlias = keyAlias,
7681
key = key,
7782
serializer = Json.serializersModule.serializer(),
83+
encryptor
7884
)
7985
}

forgerock-auth/src/main/java/org/forgerock/android/auth/storage/SSOTokenStorage.kt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import android.content.Context
1111
import kotlinx.serialization.KSerializer
1212
import kotlinx.serialization.json.Json
1313
import kotlinx.serialization.serializer
14+
import org.forgerock.android.auth.ContextProvider
15+
import org.forgerock.android.auth.Encryptor
1416
import org.forgerock.android.auth.Logger
1517
import org.forgerock.android.auth.SSOToken
1618
import org.forgerock.android.auth.SharedPreferencesSignOnManager
@@ -28,15 +30,17 @@ private const val TAG = "SSOTokenStorage"
2830
* @param keyAlias The alias for the encryption key.
2931
* @param key The key used to store the SSO tokens.
3032
* @param serializer The serializer for the SSO tokens.
33+
* @param encryptor An optional encryptor for securing the SSO tokens.
3134
*/
3235
class SSOTokenStorage(
3336
context: Context,
3437
filename: String,
3538
keyAlias: String,
3639
key: String,
37-
serializer: KSerializer<SSOToken>
40+
serializer: KSerializer<SSOToken>,
41+
encryptor: Encryptor? = null
3842
) : SecureSharedPreferencesStorage<SSOToken>(
39-
context, filename, keyAlias, key, serializer
43+
context, filename, keyAlias, key, serializer, encryptor
4044
) {
4145

4246
init {
@@ -56,17 +60,19 @@ class SSOTokenStorage(
5660
/**
5761
* Factory function to create a `SSOTokenStorage` instance.
5862
*
59-
* @param context The application context.
63+
* @param context The application context. Defaults to [ContextProvider.context]`.
6064
* @param filename The name of the file where SSO tokens are stored. Defaults to `ORG_FORGEROCK_V_2_SSO_TOKENS`.
6165
* @param keyAlias The alias for the encryption key. Defaults to `ORG_FORGEROCK_V_2_KEYS`.
6266
* @param key The key used to store the SSO tokens. Defaults to `SSO_TOKEN`.
67+
* @param encryptor An optional encryptor for securing the SSO tokens. Defaults to `null`.
6368
* @return A `StorageDelegate` for `SSOTokenStorage`.
6469
*/
6570
fun SSOTokenStorage(
66-
context: Context,
71+
context: Context = ContextProvider.context,
6772
filename: String = ORG_FORGEROCK_V_2_SSO_TOKENS,
6873
keyAlias: String = ORG_FORGEROCK_V_2_KEYS,
69-
key: String = SSO_TOKEN
74+
key: String = SSO_TOKEN,
75+
encryptor: Encryptor? = null
7076
): StorageDelegate<SSOToken> =
7177
StorageDelegate {
7278
SSOTokenStorage(
@@ -75,5 +81,6 @@ fun SSOTokenStorage(
7581
keyAlias = keyAlias,
7682
key = key,
7783
serializer = Json.serializersModule.serializer(),
84+
encryptor
7885
)
7986
}

forgerock-auth/src/main/java/org/forgerock/android/auth/storage/SecureSharedPreferencesStorage.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import android.content.Context
1111
import android.content.SharedPreferences
1212
import kotlinx.serialization.KSerializer
1313
import kotlinx.serialization.Serializable
14+
import org.forgerock.android.auth.Encryptor
1415
import org.forgerock.android.auth.SecuredSharedPreferences
1516
import org.forgerock.android.auth.json
1617

@@ -23,17 +24,19 @@ import org.forgerock.android.auth.json
2324
* @param keyAlias The alias for the encryption key.
2425
* @param key The key used to store the data.
2526
* @param serializer The serializer for the data.
27+
* @param encryptor An optional encryptor for securing the data.
2628
*/
2729
open class SecureSharedPreferencesStorage<T : @Serializable Any>(
2830
context: Context,
2931
filename: String,
3032
keyAlias: String,
3133
private var key: String,
3234
private val serializer: KSerializer<T>,
35+
encryptor: Encryptor? = null
3336
) : Storage<T> {
3437

3538
private var sharedPreferences: SharedPreferences =
36-
SecuredSharedPreferences(context, filename, keyAlias)
39+
SecuredSharedPreferences(context, filename, keyAlias, encryptor)
3740

3841
/**
3942
* Save an item to the secure shared preferences storage.

forgerock-auth/src/main/java/org/forgerock/android/auth/storage/TokenStorage.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import android.content.Context
1111
import kotlinx.serialization.json.Json
1212
import kotlinx.serialization.serializer
1313
import org.forgerock.android.auth.AccessToken
14+
import org.forgerock.android.auth.ContextProvider
15+
import org.forgerock.android.auth.Encryptor
1416
import org.forgerock.android.auth.OAuth2
1517

1618
//Alias to store keys
@@ -25,13 +27,15 @@ const val ORG_FORGEROCK_V_1_TOKENS = "org.forgerock.v1.TOKENS"
2527
* @param filename The name of the file where tokens are stored.
2628
* @param keyAlias The alias for the encryption key.
2729
* @param key The key used to store the tokens.
30+
* @param encryptor An optional Encryptor for securing the tokens.
2831
* @return A StorageDelegate for AccessToken.
2932
*/
3033
fun TokenStorage(
31-
context: Context,
34+
context: Context = ContextProvider.context,
3235
filename: String = ORG_FORGEROCK_V_1_TOKENS,
3336
keyAlias: String = ORG_FORGEROCK_V_1_KEYS,
34-
key: String = OAuth2.ACCESS_TOKEN
37+
key: String = OAuth2.ACCESS_TOKEN,
38+
encryptor: Encryptor? = null
3539
): StorageDelegate<AccessToken> =
3640
StorageDelegate {
3741
SecureSharedPreferencesStorage(
@@ -40,5 +44,6 @@ fun TokenStorage(
4044
keyAlias = keyAlias,
4145
key = key,
4246
serializer = Json.serializersModule.serializer(),
47+
encryptor
4348
)
4449
}

forgerock-core/src/main/java/org/forgerock/android/auth/SecuredSharedPreferences.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,26 @@ public class SecuredSharedPreferences implements SharedPreferences {
5454
@Getter
5555
private final String keyAlias;
5656

57+
/**
58+
* Creates a new instance of SecuredSharedPreferences.
59+
*
60+
* @param context The application context.
61+
* @param fileName The name of the shared preferences file.
62+
* @param keyAlias The alias for the encryption key.
63+
*/
5764
public SecuredSharedPreferences(Context context, String fileName, String keyAlias) {
5865
this(context, fileName, keyAlias, null);
5966
}
6067

61-
SecuredSharedPreferences(Context context, String fileName, String keyAlias, Encryptor encryptor) {
68+
/**
69+
* Creates a new instance of SecuredSharedPreferences.
70+
*
71+
* @param context The application context.
72+
* @param fileName The name of the shared preferences file.
73+
* @param keyAlias The alias for the encryption key.
74+
* @param encryptor An optional custom encryptor. If null, a default encryptor will be used.
75+
*/
76+
public SecuredSharedPreferences(Context context, String fileName, String keyAlias, Encryptor encryptor) {
6277
this.sharedPreferences = context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
6378
this.listeners = new ArrayList<>();
6479
this.keyAlias = keyAlias;

0 commit comments

Comments
 (0)