From b5688d400e69aadba1f770c45831bd08b4f94ddf Mon Sep 17 00:00:00 2001 From: siddhijain Date: Mon, 10 Nov 2025 14:27:17 -0600 Subject: [PATCH 1/4] make a method public --- .../identity/common/java/cache/BrokerOAuth2TokenCache.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common4j/src/main/com/microsoft/identity/common/java/cache/BrokerOAuth2TokenCache.java b/common4j/src/main/com/microsoft/identity/common/java/cache/BrokerOAuth2TokenCache.java index 91cf2b29ea..9634d270f8 100644 --- a/common4j/src/main/com/microsoft/identity/common/java/cache/BrokerOAuth2TokenCache.java +++ b/common4j/src/main/com/microsoft/identity/common/java/cache/BrokerOAuth2TokenCache.java @@ -343,7 +343,7 @@ public synchronized List saveAndLoadAggregatedAccountData( } @SuppressWarnings("unchecked") - private List loadAggregatedAccountData(final @NonNull AbstractAuthenticationScheme authScheme, + public List loadAggregatedAccountData(final @NonNull AbstractAuthenticationScheme authScheme, final @NonNull ICacheRecord cacheRecord) { final String methodName = ":loadAggregatedAccountData"; From a6ba161634080b2d966193f03d545205896e404f Mon Sep 17 00:00:00 2001 From: Siddhi Date: Mon, 10 Nov 2025 15:36:26 -0600 Subject: [PATCH 2/4] added comments Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../common/java/cache/BrokerOAuth2TokenCache.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/common4j/src/main/com/microsoft/identity/common/java/cache/BrokerOAuth2TokenCache.java b/common4j/src/main/com/microsoft/identity/common/java/cache/BrokerOAuth2TokenCache.java index 9634d270f8..0d512f835b 100644 --- a/common4j/src/main/com/microsoft/identity/common/java/cache/BrokerOAuth2TokenCache.java +++ b/common4j/src/main/com/microsoft/identity/common/java/cache/BrokerOAuth2TokenCache.java @@ -342,6 +342,18 @@ public synchronized List saveAndLoadAggregatedAccountData( } } + /** + * Loads aggregated account data for the specified authentication scheme and cache record. + * This method retrieves cache records from the appropriate token cache (FOCI or app-specific) + * based on the client ID and environment from the provided cache record. + * + * @param authScheme The authentication scheme to use for loading tokens. + * @param cacheRecord The cache record containing the access token with client ID, environment, + * and other metadata needed to locate the appropriate cache. + * @return A list of cache records with aggregated account data, or null if the cache is not found. + * @throws NullPointerException if either {@code authScheme} or {@code cacheRecord} is null. + * @note This method is synchronized and thread-safe. + */ @SuppressWarnings("unchecked") public List loadAggregatedAccountData(final @NonNull AbstractAuthenticationScheme authScheme, final @NonNull ICacheRecord cacheRecord) { From e844f8c274d133c8bbf38034acb066745dae8864 Mon Sep 17 00:00:00 2001 From: Siddhi Date: Mon, 10 Nov 2025 16:16:10 -0600 Subject: [PATCH 3/4] Make the method synchronized Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../identity/common/java/cache/BrokerOAuth2TokenCache.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common4j/src/main/com/microsoft/identity/common/java/cache/BrokerOAuth2TokenCache.java b/common4j/src/main/com/microsoft/identity/common/java/cache/BrokerOAuth2TokenCache.java index 0d512f835b..3e5d9502ee 100644 --- a/common4j/src/main/com/microsoft/identity/common/java/cache/BrokerOAuth2TokenCache.java +++ b/common4j/src/main/com/microsoft/identity/common/java/cache/BrokerOAuth2TokenCache.java @@ -355,7 +355,7 @@ public synchronized List saveAndLoadAggregatedAccountData( * @note This method is synchronized and thread-safe. */ @SuppressWarnings("unchecked") - public List loadAggregatedAccountData(final @NonNull AbstractAuthenticationScheme authScheme, + public synchronized List loadAggregatedAccountData(final @NonNull AbstractAuthenticationScheme authScheme, final @NonNull ICacheRecord cacheRecord) { final String methodName = ":loadAggregatedAccountData"; From d4c903ac7e5b1f1d3e648f770914d2476bc8327d Mon Sep 17 00:00:00 2001 From: siddhijain Date: Mon, 10 Nov 2025 16:31:34 -0600 Subject: [PATCH 4/4] introduce synchronized version of save method --- .../java/cache/BrokerOAuth2TokenCache.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/common4j/src/main/com/microsoft/identity/common/java/cache/BrokerOAuth2TokenCache.java b/common4j/src/main/com/microsoft/identity/common/java/cache/BrokerOAuth2TokenCache.java index 3e5d9502ee..3f04fbd71b 100644 --- a/common4j/src/main/com/microsoft/identity/common/java/cache/BrokerOAuth2TokenCache.java +++ b/common4j/src/main/com/microsoft/identity/common/java/cache/BrokerOAuth2TokenCache.java @@ -241,6 +241,31 @@ public ICacheRecord save(final @NonNull AccountRecord accountRecord, return result; } + /** + * Saves account data to the cache, including AccountRecord, IdTokenRecord, AccessTokenRecord, + * and optionally RefreshTokenRecord and familyId. + * + * @param accountRecord The AccountRecord to store. Must not be null. + * @param idTokenRecord The IdTokenRecord to store. Must not be null. + * @param accessTokenRecord The AccessTokenRecord to store. Must not be null. + * @param refreshTokenRecord The RefreshTokenRecord to store, or null if not applicable. + * @param familyId The family_id or null, if not applicable. + * @throws ClientException If the supplied Accounts or Credentials are schema invalid. + */ + public synchronized void saveAccountData(final @NonNull AccountRecord accountRecord, + final @NonNull IdTokenRecord idTokenRecord, + final @NonNull AccessTokenRecord accessTokenRecord, + final @Nullable RefreshTokenRecord refreshTokenRecord, + final @Nullable String familyId) throws ClientException { + save( + accountRecord, + idTokenRecord, + accessTokenRecord, + refreshTokenRecord, + familyId + ); + } + /** * Broker-only API to persist WPJ's Accounts and their associated credentials. *