use of com.microsoft.identity.common.internal.dto.IAccountRecord in project microsoft-authentication-library-common-for-android by AzureAD.
the class SharedPreferencesAccountCredentialCache method removeAccount.
@Override
public boolean removeAccount(@NonNull final AccountRecord accountToRemove) {
Logger.info(TAG, "Removing Account...");
if (null == accountToRemove) {
throw new IllegalArgumentException("Param [accountToRemove] cannot be null.");
}
final Map<String, AccountRecord> accounts = getAccountsWithKeys();
boolean accountRemoved = false;
for (final Map.Entry<String, AccountRecord> entry : accounts.entrySet()) {
Logger.verbosePII(TAG, "Inspecting: [" + entry.getKey() + "]");
final IAccountRecord currentAccount = entry.getValue();
if (currentAccount.equals(accountToRemove)) {
mSharedPreferencesFileManager.remove(entry.getKey());
accountRemoved = true;
break;
}
}
Logger.info(TAG, "Account was removed? [" + accountRemoved + "]");
return accountRemoved;
}
use of com.microsoft.identity.common.internal.dto.IAccountRecord in project microsoft-authentication-library-common-for-android by AzureAD.
the class AdalBrokerResultAdapter method bundleFromAuthenticationResult.
@Override
@NonNull
public Bundle bundleFromAuthenticationResult(@NonNull final ILocalAuthenticationResult authenticationResult, @Nullable final String negotiatedBrokerProtocolVersion) {
Logger.verbose(TAG, "Constructing success bundle from Authentication Result.");
final Bundle resultBundle = new Bundle();
IAccountRecord accountRecord = authenticationResult.getAccountRecord();
resultBundle.putString(AuthenticationConstants.Broker.ACCOUNT_LOGIN_HINT, accountRecord.getUsername());
resultBundle.putString(AuthenticationConstants.Broker.ACCOUNT_USERINFO_USERID, accountRecord.getLocalAccountId());
resultBundle.putString(AuthenticationConstants.Broker.ACCOUNT_USERINFO_USERID_DISPLAYABLE, accountRecord.getUsername());
resultBundle.putString(AuthenticationConstants.Broker.ACCOUNT_USERINFO_GIVEN_NAME, accountRecord.getFirstName());
resultBundle.putString(AuthenticationConstants.Broker.ACCOUNT_USERINFO_FAMILY_NAME, accountRecord.getFamilyName());
resultBundle.putString(AuthenticationConstants.Broker.ACCOUNT_USERINFO_IDENTITY_PROVIDER, SchemaUtil.getIdentityProvider(authenticationResult.getIdToken()));
resultBundle.putString(AuthenticationConstants.Broker.ACCOUNT_USERINFO_TENANTID, authenticationResult.getTenantId());
resultBundle.putLong(AuthenticationConstants.Broker.ACCOUNT_EXPIREDATE, authenticationResult.getExpiresOn().getTime());
resultBundle.putString(AuthenticationConstants.Broker.ACCOUNT_AUTHORITY, getAuthority(authenticationResult));
resultBundle.putString(AuthenticationConstants.Broker.ACCOUNT_ACCESS_TOKEN, authenticationResult.getAccessToken());
resultBundle.putString(AuthenticationConstants.Broker.ACCOUNT_IDTOKEN, authenticationResult.getIdToken());
resultBundle.putString(SPE_RING, authenticationResult.getSpeRing());
resultBundle.putString(RT_AGE, authenticationResult.getRefreshTokenAge());
return resultBundle;
}
use of com.microsoft.identity.common.internal.dto.IAccountRecord in project microsoft-authentication-library-common-for-android by AzureAD.
the class MsalBrokerResultAdapter method bundleFromAuthenticationResult.
@Override
@NonNull
public Bundle bundleFromAuthenticationResult(@NonNull final ILocalAuthenticationResult authenticationResult, @Nullable final String negotiatedBrokerProtocolVersion) {
Logger.info(TAG, "Constructing result bundle from ILocalAuthenticationResult");
final IAccountRecord accountRecord = authenticationResult.getAccountRecord();
final AccessTokenRecord accessTokenRecord = authenticationResult.getAccessTokenRecord();
final BrokerResult brokerResult = new BrokerResult.Builder().tenantProfileRecords(authenticationResult.getCacheRecordWithTenantProfileData()).accessToken(authenticationResult.getAccessToken()).idToken(authenticationResult.getIdToken()).refreshToken(authenticationResult.getRefreshToken()).homeAccountId(accountRecord.getHomeAccountId()).localAccountId(accountRecord.getLocalAccountId()).userName(accountRecord.getUsername()).tokenType(accessTokenRecord.getAccessTokenType()).clientId(accessTokenRecord.getClientId()).familyId(authenticationResult.getFamilyId()).scope(accessTokenRecord.getTarget()).clientInfo(accountRecord.getClientInfo()).authority(accessTokenRecord.getAuthority()).environment(accessTokenRecord.getEnvironment()).tenantId(authenticationResult.getTenantId()).expiresOn(Long.parseLong(accessTokenRecord.getExpiresOn())).extendedExpiresOn(Long.parseLong(accessTokenRecord.getExtendedExpiresOn())).cachedAt(Long.parseLong(accessTokenRecord.getCachedAt())).speRing(authenticationResult.getSpeRing()).refreshTokenAge(authenticationResult.getRefreshTokenAge()).success(true).servicedFromCache(authenticationResult.isServicedFromCache()).build();
final Bundle resultBundle = bundleFromBrokerResult(brokerResult, negotiatedBrokerProtocolVersion);
resultBundle.putBoolean(AuthenticationConstants.Broker.BROKER_REQUEST_V2_SUCCESS, true);
return resultBundle;
}
Aggregations