Search in sources :

Example 6 with BrokerResult

use of com.microsoft.identity.common.internal.broker.BrokerResult 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;
}
Also used : IAccountRecord(com.microsoft.identity.common.internal.dto.IAccountRecord) BrokerResult(com.microsoft.identity.common.internal.broker.BrokerResult) Bundle(android.os.Bundle) AccessTokenRecord(com.microsoft.identity.common.internal.dto.AccessTokenRecord) NonNull(androidx.annotation.NonNull)

Aggregations

BrokerResult (com.microsoft.identity.common.internal.broker.BrokerResult)6 NonNull (androidx.annotation.NonNull)4 ClientException (com.microsoft.identity.common.exception.ClientException)4 GzipUtil.compressString (com.microsoft.identity.common.internal.util.GzipUtil.compressString)3 Bundle (android.os.Bundle)1 ServiceException (com.microsoft.identity.common.exception.ServiceException)1 ICacheRecord (com.microsoft.identity.common.internal.cache.ICacheRecord)1 AccessTokenRecord (com.microsoft.identity.common.internal.dto.AccessTokenRecord)1 IAccountRecord (com.microsoft.identity.common.internal.dto.IAccountRecord)1 MicrosoftRefreshToken (com.microsoft.identity.common.internal.providers.microsoft.MicrosoftRefreshToken)1 ClientInfo (com.microsoft.identity.common.internal.providers.microsoft.azureactivedirectory.ClientInfo)1 MicrosoftStsAccount (com.microsoft.identity.common.internal.providers.microsoft.microsoftsts.MicrosoftStsAccount)1 IDToken (com.microsoft.identity.common.internal.providers.oauth2.IDToken)1 MsalBrokerResultAdapter (com.microsoft.identity.common.internal.result.MsalBrokerResultAdapter)1