public static void SetAuthenticationContinuationEventArgs(int requestCode, Result resultCode, Intent data) { // TODO(migration): how can a public static method get access to the proper ClientRequestBase to wire into the logger and appropriate requestcontext? // Can we move this call to be somewhere on the ClientApplicationBase or something else that's wired into that? var logger = MsalLogger.Create(Guid.Empty, null); logger.Info(string.Format(CultureInfo.InvariantCulture, "Received Activity Result({0})", (int)resultCode)); AuthorizationResult authorizationResult; if (data.Action != null && data.Action.Equals("ReturnFromEmbeddedWebview", StringComparison.OrdinalIgnoreCase)) { authorizationResult = ProcessFromEmbeddedWebview(requestCode, resultCode, data); } else if (!String.IsNullOrEmpty(data.GetStringExtra(BrokerConstants.BrokerResultV2))) { AndroidBroker.SetBrokerResult(data, (int)resultCode); return; } else { authorizationResult = ProcessFromSystemWebview(requestCode, resultCode, data); } WebviewBase.SetAuthorizationResult(authorizationResult, logger); }
public static void SetAuthenticationContinuationEventArgs(int requestCode, Result resultCode, Intent data) { LastRequestLogger?.Info($"SetAuthenticationContinuationEventArgs - resultCode: {(int)resultCode} requestCode: {requestCode}"); AuthorizationResult authorizationResult; if (data?.Action?.Equals("ReturnFromEmbeddedWebview", StringComparison.OrdinalIgnoreCase) == true) { authorizationResult = ProcessFromEmbeddedWebview(requestCode, resultCode, data); WebviewBase.SetAuthorizationResult(authorizationResult, LastRequestLogger); return; } if (data != null && (!string.IsNullOrEmpty(data.GetStringExtra(BrokerConstants.BrokerResultV2)) || requestCode == BrokerConstants.BrokerRequestId)) { //The BrokerRequestId is an ID that is attached to the activity launch during brokered authentication // that indicates that the response returned to this class is for the broker. LastRequestLogger?.Info("Processing result from broker."); AndroidBroker.SetBrokerResult(data, (int)resultCode, LastRequestLogger); return; } if (data != null || AndroidConstants.AuthCodeReceived != (int)resultCode) { LastRequestLogger?.Info("Processing result from system webview."); authorizationResult = ProcessFromSystemWebview(requestCode, resultCode, data); WebviewBase.SetAuthorizationResult(authorizationResult, LastRequestLogger); return; } LastRequestLogger?.Info("SetAuthenticationContinuationEventArgs - ignoring intercepted null intent."); }
private static AuthorizationResult ProcessFromEmbeddedWebview(int requestCode, Result resultCode, Intent data) { switch ((int)resultCode) { case (int)Result.Ok: return(AuthorizationResult.FromUri(data.GetStringExtra("ReturnedUrl"))); case (int)Result.Canceled: return(AuthorizationResult.FromStatus(AuthorizationStatus.UserCancel)); case BrokerResponseCode.ResponseReceived: case BrokerResponseCode.BrowserCodeError: case BrokerResponseCode.UserCancelled: AndroidBroker.SetBrokerResult(data, (int)resultCode); return(null); default: return(AuthorizationResult.FromStatus(AuthorizationStatus.UnknownError)); } }