use of com.microsoft.identity.common.adal.internal.cache.IStorageHelper in project microsoft-authentication-library-common-for-android by AzureAD.
the class BrokerOAuth2TokenCache method initializeProcessUidCache.
private MsalOAuth2TokenCache initializeProcessUidCache(@NonNull final Context context, final int bindingProcessUid) {
final String methodName = ":initializeProcessUidCache";
Logger.verbose(TAG + methodName, "Initializing uid cache.");
if (null != mDelegate) {
Logger.warn(TAG + methodName, "Using swapped delegate cache.");
return mDelegate.getTokenCache(context, bindingProcessUid);
}
final IStorageHelper storageHelper = new StorageHelper(context);
final ISharedPreferencesFileManager sharedPreferencesFileManager = SharedPreferencesFileManager.getSharedPreferences(context, SharedPreferencesAccountCredentialCache.getBrokerUidSequesteredFilename(bindingProcessUid), storageHelper);
return getTokenCache(context, sharedPreferencesFileManager, false);
}
use of com.microsoft.identity.common.adal.internal.cache.IStorageHelper in project microsoft-authentication-library-common-for-android by AzureAD.
the class MsalOAuth2TokenCache method create.
/**
* Factory method for creating an instance of MsalOAuth2TokenCache
* <p>
* NOTE: Currently this is configured for AAD v2 as the only IDP
*
* @param context The Application Context
* @return An instance of the MsalOAuth2TokenCache.
*/
public static MsalOAuth2TokenCache<MicrosoftStsOAuth2Strategy, MicrosoftStsAuthorizationRequest, MicrosoftStsTokenResponse, MicrosoftAccount, MicrosoftRefreshToken> create(@NonNull final Context context) {
final String methodName = ":create";
Logger.verbose(TAG + methodName, "Creating MsalOAuth2TokenCache");
// Init the new-schema cache
final ICacheKeyValueDelegate cacheKeyValueDelegate = new CacheKeyValueDelegate();
final IStorageHelper storageHelper = new StorageHelper(context);
final ISharedPreferencesFileManager sharedPreferencesFileManager = SharedPreferencesFileManager.getSharedPreferences(context, DEFAULT_ACCOUNT_CREDENTIAL_SHARED_PREFERENCES, storageHelper);
final IAccountCredentialCache accountCredentialCache = new SharedPreferencesAccountCredentialCache(cacheKeyValueDelegate, sharedPreferencesFileManager);
final MicrosoftStsAccountCredentialAdapter accountCredentialAdapter = new MicrosoftStsAccountCredentialAdapter();
return new MsalOAuth2TokenCache<>(context, accountCredentialCache, accountCredentialAdapter);
}
use of com.microsoft.identity.common.adal.internal.cache.IStorageHelper in project microsoft-authentication-library-common-for-android by AzureAD.
the class SharedPreferencesFileManagerTests method testGetSharedPreferences.
@Test
public void testGetSharedPreferences() throws Exception {
Field f = SharedPreferencesFileManager.class.getDeclaredField("mStorageHelper");
f.setAccessible(true);
Assert.assertSame(mSharedPreferencesFileManager, SharedPreferencesFileManager.getSharedPreferences(InstrumentationRegistry.getTargetContext(), mSharedPreferencesFileManager.getSharedPreferencesFileName(), (IStorageHelper) f.get(mSharedPreferencesFileManager)));
}
use of com.microsoft.identity.common.adal.internal.cache.IStorageHelper in project microsoft-authentication-library-common-for-android by AzureAD.
the class SharedPreferencesFileManagerTests method testGetSharedPreferencesClear.
@Test
public void testGetSharedPreferencesClear() throws Exception {
Field f = SharedPreferencesFileManager.class.getDeclaredField("mStorageHelper");
f.setAccessible(true);
Assert.assertSame(mSharedPreferencesFileManager, SharedPreferencesFileManager.getSharedPreferences(InstrumentationRegistry.getTargetContext(), mSharedPreferencesFileManager.getSharedPreferencesFileName(), (IStorageHelper) f.get(mSharedPreferencesFileManager)));
SharedPreferencesFileManager.clearSingletonCache();
Assert.assertNotSame(mSharedPreferencesFileManager, SharedPreferencesFileManager.getSharedPreferences(InstrumentationRegistry.getTargetContext(), mSharedPreferencesFileManager.getSharedPreferencesFileName(), (IStorageHelper) f.get(mSharedPreferencesFileManager)));
}
use of com.microsoft.identity.common.adal.internal.cache.IStorageHelper in project microsoft-authentication-library-common-for-android by AzureAD.
the class SharedPreferencesFileManagerTests method testGetSharedPreferencesNoStorageHelper.
@Test
public void testGetSharedPreferencesNoStorageHelper() throws Exception {
Field f = SharedPreferencesFileManager.class.getDeclaredField("mStorageHelper");
f.setAccessible(true);
IStorageHelper storageHelper = (IStorageHelper) f.get(mSharedPreferencesFileManager);
IStorageHelper newStorageHelper;
if (storageHelper == null) {
newStorageHelper = new StorageHelper(InstrumentationRegistry.getTargetContext());
} else {
newStorageHelper = null;
}
Assert.assertNotSame(mSharedPreferencesFileManager, SharedPreferencesFileManager.getSharedPreferences(InstrumentationRegistry.getTargetContext(), mSharedPreferencesFileManager.getSharedPreferencesFileName(), newStorageHelper));
Assert.assertSame(mSharedPreferencesFileManager, SharedPreferencesFileManager.getSharedPreferences(InstrumentationRegistry.getTargetContext(), mSharedPreferencesFileManager.getSharedPreferencesFileName(), storageHelper));
}
Aggregations