use of com.microsoft.identity.common.internal.providers.oauth2.OAuth2TokenCache in project microsoft-authentication-library-common-for-android by AzureAD.
the class BrokerOAuth2TokenCache method getAccountsWithAggregatedAccountData.
@Override
public List<ICacheRecord> getAccountsWithAggregatedAccountData(@Nullable final String environment, @NonNull final String clientId, @NonNull final String homeAccountId) {
final String methodName = ":getAccountsWithAggregatedAccountData";
final List<ICacheRecord> result;
OAuth2TokenCache targetCache;
if (null != environment) {
targetCache = getTokenCacheForClient(clientId, environment, mCallingProcessUid);
if (null == targetCache) {
Logger.verbose(TAG + methodName, "Falling back to FoCI cache...");
targetCache = mFociCache;
}
// Suppressing unchecked warnings due to casting of rawtypes to generic types of OAuth2TokenCache's instance targetCache while calling method getAccountsWithAggregatedAccountData
@SuppressWarnings(WarningType.unchecked_warning) List<ICacheRecord> resultByAggregatedAccountData = targetCache.getAccountsWithAggregatedAccountData(environment, clientId, homeAccountId);
result = resultByAggregatedAccountData;
} else {
// If no environment was specified, return all of the accounts across all of the envs...
// Callers should really specify an environment...
final List<OAuth2TokenCache> caches = getTokenCachesForClientId(clientId);
// Declare a new List to which we will add all of our results...
result = new ArrayList<>();
for (final OAuth2TokenCache cache : caches) {
// Suppressing unchecked warning as the generic type was not provided for cache
@SuppressWarnings(WarningType.unchecked_warning) List<ICacheRecord> accountsWithAggregatedAccountData = cache.getAccountsWithAggregatedAccountData(environment, clientId, homeAccountId);
result.addAll(accountsWithAggregatedAccountData);
}
}
return result;
}
use of com.microsoft.identity.common.internal.providers.oauth2.OAuth2TokenCache in project microsoft-authentication-library-common-for-android by AzureAD.
the class BrokerOAuth2TokenCache method removeAccountInternal.
private AccountDeletionRecord removeAccountInternal(@Nullable final String environment, @Nullable final String clientId, @Nullable final String homeAccountId, @Nullable final String realm, boolean deviceWide) {
final String methodName = ":removeAccountInternal";
final List<BrokerApplicationMetadata> allMetadata = mApplicationMetadataCache.getAll();
final List<AccountDeletionRecord> deletionRecordList = new ArrayList<>();
for (final BrokerApplicationMetadata metadata : allMetadata) {
final OAuth2TokenCache candidateCache = getTokenCacheForClient(metadata.getClientId(), metadata.getEnvironment(), deviceWide ? // Supports the removeAccountFromDevice() function
metadata.getUid() : mCallingProcessUid);
if (null != candidateCache) {
deletionRecordList.add(candidateCache.removeAccount(environment, clientId, homeAccountId, realm));
}
}
// Create a List of the deleted AccountRecords...
final List<AccountRecord> deletedAccountRecords = new ArrayList<>();
for (final AccountDeletionRecord accountDeletionRecord : deletionRecordList) {
deletedAccountRecords.addAll(accountDeletionRecord);
}
Logger.info(TAG + methodName, "Deleted [" + deletedAccountRecords.size() + "] AccountRecords.");
return new AccountDeletionRecord(deletedAccountRecords);
}
Aggregations