public async Task <IReadOnlyList <IAccount> > GetAccountsAsync( string clientID, string redirectUri, AuthorityInfo authorityInfo, ICacheSessionManager cacheSessionManager, IInstanceDiscoveryManager instanceDiscoveryManager) { using (_logger.LogMethodDuration()) { if (!_wamOptions.ListWindowsWorkAndSchoolAccounts) { _logger.Info("WAM::FindAllAccountsAsync returning no accounts due to configuration option"); return(Array.Empty <IAccount>()); } if ( !ApiInformation.IsMethodPresent( "Windows.Security.Authentication.Web.Core.WebAuthenticationCoreManager", "FindAllAccountsAsync")) { _logger.Info("WAM::FindAllAccountsAsync method does not exist. Returning 0 broker accounts. "); return(Array.Empty <IAccount>()); } var aadAccounts = await _aadPlugin.GetAccountsAsync(clientID, authorityInfo, cacheSessionManager, instanceDiscoveryManager).ConfigureAwait(false); var msaAccounts = await _msaPlugin.GetAccountsAsync(clientID, authorityInfo, cacheSessionManager, instanceDiscoveryManager).ConfigureAwait(false); return((aadAccounts.Concat(msaAccounts)).ToList()); } }
public async Task <IReadOnlyList <IAccount> > GetAccountsAsync( string clientID, string redirectUri, string authority, ICacheSessionManager cacheSessionManager, IInstanceDiscoveryManager instanceDiscoveryManager) { using (_logger.LogMethodDuration()) { if (!IsBrokerInstalledAndInvokable()) { _logger.Warning("Android broker is either not installed or is not reachable so no accounts will be returned. "); return(new List <IAccount>()); } BrokerRequest brokerRequest = new BrokerRequest() { ClientId = clientID, RedirectUri = new Uri(redirectUri) }; try { await _brokerHelper.InitiateBrokerHandshakeAsync(_parentActivity).ConfigureAwait(false); return(_brokerHelper.GetBrokerAccountsInAccountManager(brokerRequest)); } catch (Exception ex) { _logger.Error("Failed to get Android broker accounts from the broker. "); HandleBrokerOperationError(ex); throw; } } }
/// <summary> /// iOS broker does not handle silent flow /// </summary> public Task <IReadOnlyList <IAccount> > GetAccountsAsync( string clientID, string redirectUri, string authority, ICacheSessionManager cacheSessionManager, IInstanceDiscoveryManager instanceDiscoveryManager) { throw new NotImplementedException(); }
/// <summary> /// iOS broker does not handle silent flow /// </summary> public Task <IReadOnlyList <IAccount> > GetAccountsAsync( string clientID, string redirectUri, AuthorityInfo authorityInfo, ICacheSessionManager cacheSessionManager, IInstanceDiscoveryManager instanceDiscoveryManager) { return(Task.FromResult(CollectionHelpers.GetEmptyReadOnlyList <IAccount>())); // nop }
public Task <IReadOnlyList <IAccount> > GetAccountsAsync( string clientID, string redirectUri, AuthorityInfo authorityInfo, ICacheSessionManager cacheSessionManager, IInstanceDiscoveryManager instanceDiscoveryManager) { _logger.Info("NullBroker - returning empty list on GetAccounts request."); return(Task.FromResult(CollectionHelpers.GetEmptyReadOnlyList <IAccount>())); // nop }
public Task <IReadOnlyList <IAccount> > GetAccountsAsync( string clientID, string redirectUri, AuthorityInfo authorityInfo, ICacheSessionManager cacheSessionManager, IInstanceDiscoveryManager instanceDiscoveryManager) { // runtime does not yet support account discovery return(Task.FromResult <IReadOnlyList <IAccount> >(Array.Empty <IAccount>())); }
public void Init() { _logger = Substitute.For <ICoreLogger>(); _wamProxy = Substitute.For <IWamProxy>(); _webAccountProviderFactory = Substitute.For <IWebAccountProviderFactory>(); _accountPickerFactory = Substitute.For <IAccountPickerFactory>(); _webAccountProviderFactory.ClearReceivedCalls(); _cacheSessionManager = Substitute.For <ICacheSessionManager>(); _instanceDiscoveryManager = Substitute.For <IInstanceDiscoveryManager>(); _aadPlugin = new AadPlugin(_wamProxy, _webAccountProviderFactory, _logger); }
/// <summary> /// Generally the MSA plugin will NOT return the accounts back to the app. This is due /// to privacy concerns. However, some test apps are allowed to do this, hence the code. /// Normal 1st and 3rd party apps must use AcquireTokenInteractive to login first, and then MSAL will /// save the account for later use. /// </summary> public async Task <IReadOnlyList <IAccount> > GetAccountsAsync( string clientID, string authority, ICacheSessionManager cacheSessionManager, IInstanceDiscoveryManager instanceDiscoveryManager) { var webAccounProvider = await _webAccountProviderFactory.GetAccountProviderAsync("consumers").ConfigureAwait(false); var webAccounts = await _wamProxy.FindAllWebAccountsAsync(webAccounProvider, clientID).ConfigureAwait(false); var msalAccounts = webAccounts .Select(webAcc => ConvertToMsalAccountOrNull(webAcc)) .Where(a => a != null) .ToList(); _logger.Info($"[WAM MSA Plugin] GetAccountsAsync converted {webAccounts.Count} MSAL accounts"); return(msalAccounts); }
public async Task <IReadOnlyList <IAccount> > GetAccountsAsync( string clientId, string redirectUri, AuthorityInfo authorityInfo, ICacheSessionManager cacheSessionManager, IInstanceDiscoveryManager instanceDiscoveryManager) { using (_logger.LogMethodDuration()) { if (!IsBrokerInstalledAndInvokable()) { _logger.Warning("[Android broker] Broker is either not installed or is not reachable so no accounts will be returned. "); return(null); } return(await GetAccountsInternalAsync(clientId, redirectUri).ConfigureAwait(false)); } }
public async Task <IReadOnlyList <IAccount> > GetAccountsAsync( string clientId, string redirectUri, AuthorityInfo authorityInfo, ICacheSessionManager cacheSessionManager, IInstanceDiscoveryManager instanceDiscoveryManager) { using (_logger.LogMethodDuration()) { if (!IsBrokerInstalledAndInvokable(authorityInfo.AuthorityType)) { _logger.Warning("[Android broker] Broker is either not installed or is not reachable so no accounts will be returned. "); return(CollectionHelpers.GetEmptyReadOnlyList <IAccount>()); } BrokerRequest brokerRequest = new BrokerRequest() { ClientId = clientId, RedirectUri = new Uri(redirectUri) }; try { await InitiateBrokerHandshakeAsync().ConfigureAwait(false); var accounts = GetBrokerAccounts(brokerRequest); return(_brokerHelper.ExtractBrokerAccountsFromAccountData(accounts)); } catch (Exception ex) { _logger.Error("[Android broker] Failed to get Android broker accounts from the broker. "); _brokerHelper.HandleBrokerOperationError(ex); throw; } } }