Search in sources :

Example 11 with StorageHelper

use of com.microsoft.identity.common.adal.internal.cache.StorageHelper 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));
}
Also used : Field(java.lang.reflect.Field) IStorageHelper(com.microsoft.identity.common.adal.internal.cache.IStorageHelper) StorageHelper(com.microsoft.identity.common.adal.internal.cache.StorageHelper) IStorageHelper(com.microsoft.identity.common.adal.internal.cache.IStorageHelper) Test(org.junit.Test)

Example 12 with StorageHelper

use of com.microsoft.identity.common.adal.internal.cache.StorageHelper in project microsoft-authentication-library-common-for-android by AzureAD.

the class BrokerOAuth2TokenCache method initializeFociCache.

private static MicrosoftFamilyOAuth2TokenCache initializeFociCache(@NonNull final Context context) {
    final String methodName = ":initializeFociCache";
    Logger.verbose(TAG + methodName, "Initializing foci cache");
    final IStorageHelper storageHelper = new StorageHelper(context);
    final ISharedPreferencesFileManager sharedPreferencesFileManager = SharedPreferencesFileManager.getSharedPreferences(context, BROKER_FOCI_ACCOUNT_CREDENTIAL_SHARED_PREFERENCES, storageHelper);
    return getTokenCache(context, sharedPreferencesFileManager, true);
}
Also used : IStorageHelper(com.microsoft.identity.common.adal.internal.cache.IStorageHelper) StorageHelper(com.microsoft.identity.common.adal.internal.cache.StorageHelper) IStorageHelper(com.microsoft.identity.common.adal.internal.cache.IStorageHelper)

Aggregations

StorageHelper (com.microsoft.identity.common.adal.internal.cache.StorageHelper)12 Context (android.content.Context)5 IStorageHelper (com.microsoft.identity.common.adal.internal.cache.IStorageHelper)4 CacheKeyValueDelegate (com.microsoft.identity.common.internal.cache.CacheKeyValueDelegate)4 SharedPreferencesAccountCredentialCache (com.microsoft.identity.common.internal.cache.SharedPreferencesAccountCredentialCache)4 SharedPreferencesFileManager (com.microsoft.identity.common.internal.cache.SharedPreferencesFileManager)3 Test (org.junit.Test)3 IAccountCredentialCache (com.microsoft.identity.common.internal.cache.IAccountCredentialCache)2 AccountRecord (com.microsoft.identity.common.internal.dto.AccountRecord)2 Before (org.junit.Before)2 SuppressLint (android.annotation.SuppressLint)1 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 SharedPreferences (android.content.SharedPreferences)1 CookieManager (android.webkit.CookieManager)1 UiThreadTest (androidx.test.annotation.UiThreadTest)1 BearerAuthenticationSchemeInternal (com.microsoft.identity.common.internal.authscheme.BearerAuthenticationSchemeInternal)1 IAccountCredentialAdapter (com.microsoft.identity.common.internal.cache.IAccountCredentialAdapter)1 ICacheKeyValueDelegate (com.microsoft.identity.common.internal.cache.ICacheKeyValueDelegate)1 ICacheRecord (com.microsoft.identity.common.internal.cache.ICacheRecord)1