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..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. * @@ -342,8 +367,20 @@ 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") - private List loadAggregatedAccountData(final @NonNull AbstractAuthenticationScheme authScheme, + public synchronized List loadAggregatedAccountData(final @NonNull AbstractAuthenticationScheme authScheme, final @NonNull ICacheRecord cacheRecord) { final String methodName = ":loadAggregatedAccountData";