public AuthorizationResult ProcessAuthorizationResult(IWebAuthenticationBrokerContinuationEventArgs args, CallState callState)
        {
            AuthorizationResult result;

            switch (args.WebAuthenticationResult.ResponseStatus)
            {
            case WebAuthenticationStatus.Success:
                // Issue #129 - Windows Phone cannot handle ms-app URI's so use the placeholder URI for SSO
                var responseData = args.WebAuthenticationResult.ResponseData;
                if (responseData.StartsWith(Constant.MsAppScheme, StringComparison.OrdinalIgnoreCase))
                {
                    responseData = Constant.SsoPlaceHolderUri + responseData.Substring(responseData.IndexOf('?'));
                }

                result = OAuth2Response.ParseAuthorizeResponse(responseData, callState);
                break;

            case WebAuthenticationStatus.ErrorHttp:
                result = new AuthorizationResult(AdalError.AuthenticationFailed, args.WebAuthenticationResult.ResponseErrorDetail.ToString());
                break;

            case WebAuthenticationStatus.UserCancel:
                result = new AuthorizationResult(AdalError.AuthenticationCanceled, AdalErrorMessage.AuthenticationCanceled);
                break;

            default:
                result = new AuthorizationResult(AdalError.AuthenticationFailed, AdalErrorMessage.AuthorizationServerInvalidResponse);
                break;
            }

            return(result);
        }
        public AuthorizationResult ProcessAuthorizationResult(IWebAuthenticationBrokerContinuationEventArgs args, CallState callState)
        {
            AuthorizationResult result;
            switch (args.WebAuthenticationResult.ResponseStatus)
            {
                case WebAuthenticationStatus.Success:
					// Issue #129 - Windows Phone cannot handle ms-app URI's so use the placeholder URI for SSO
					var responseData = args.WebAuthenticationResult.ResponseData;
					if(responseData.StartsWith(Constant.MsAppScheme, StringComparison.OrdinalIgnoreCase))
					{
						responseData = Constant.SsoPlaceHolderUri + responseData.Substring(responseData.IndexOf('?'));
					}

					result = OAuth2Response.ParseAuthorizeResponse(responseData, callState);
                    break;
                case WebAuthenticationStatus.ErrorHttp:
                    result = new AuthorizationResult(AdalError.AuthenticationFailed, args.WebAuthenticationResult.ResponseErrorDetail.ToString());
                    break;
                case WebAuthenticationStatus.UserCancel:
                    result = new AuthorizationResult(AdalError.AuthenticationCanceled, AdalErrorMessage.AuthenticationCanceled);
                    break;
                default:
                    result = new AuthorizationResult(AdalError.AuthenticationFailed, AdalErrorMessage.AuthorizationServerInvalidResponse);
                    break;
            }

            return result;
        }
Example #3
0
        public AuthorizationResult ProcessAuthorizationResult(IWebAuthenticationBrokerContinuationEventArgs args, CallState callState)
        {
            AuthorizationResult result;

            switch (args.WebAuthenticationResult.ResponseStatus)
            {
            case WebAuthenticationStatus.Success:
                result = OAuth2Response.ParseAuthorizeResponse(args.WebAuthenticationResult.ResponseData, callState);
                break;

            case WebAuthenticationStatus.ErrorHttp:
                result = new AuthorizationResult(AdalError.AuthenticationFailed, args.WebAuthenticationResult.ResponseErrorDetail.ToString());
                break;

            case WebAuthenticationStatus.UserCancel:
                result = new AuthorizationResult(AdalError.AuthenticationCanceled, AdalErrorMessage.AuthenticationCanceled);
                break;

            default:
                result = new AuthorizationResult(AdalError.AuthenticationFailed, AdalErrorMessage.AuthorizationServerInvalidResponse);
                break;
            }

            return(result);
        }
Example #4
0
        /// <summary>
        /// Continues security token acquisition from the authority.
        /// </summary>
        /// <param name="args">Information to an app that was launched after being suspended for a web authentication broker operation.</param>
        /// <returns>It contains Access Token, Refresh Token and the Access Token's expiration time.</returns>
        public IAsyncOperation <AuthenticationResult> ContinueAcquireTokenAsync(IWebAuthenticationBrokerContinuationEventArgs args)
        {
            var handler = new AcquireTokenInteractiveHandler(this.Authenticator, this.TokenCache, this.authenticationContextDelegate, args);

            try
            {
                return(RunTaskAsAsyncOperation(handler.RunAsync()));
            }
            finally
            {
                this.authenticationContextDelegate = null;
            }
        }
 // This constructor is called by ContinueAcquireTokenAsync after WAB call has returned.
 public AcquireTokenInteractiveHandler(Authenticator authenticator, TokenCache tokenCache, IWebAuthenticationBrokerContinuationEventArgs args)
     : this(
         authenticator, 
         tokenCache, 
         (string)args.ContinuationData[WabArgName.Resource], 
         (string)args.ContinuationData[WabArgName.ClientId],
         GetRedirectUri((string)args.ContinuationData[WabArgName.RedirectUri]),	// Issue #129 - Windows Phone cannot handle ms-app URI's so use the placeholder URI for SSO
         PromptBehavior.Always,  // This is simply to disable cache lookup. In fact, there is no authorize call at this point and promptBehavior is not applicable.
         new UserIdentifier((string)args.ContinuationData[WabArgName.UserId],
             (UserIdentifierType)((int)args.ContinuationData[WabArgName.UserIdType])),
         null, 
         NetworkPlugin.WebUIFactory.Create(), 
         false)
 {
     CallState callState = new CallState(new Guid((string)args.ContinuationData[WabArgName.CorrelationId]), false);
     this.authorizationResult = this.webUi.ProcessAuthorizationResult(args, callState);
 }
Example #6
0
        // This constructor is called by ContinueAcquireTokenAsync after WAB call has returned.
        public AcquireTokenInteractiveHandler(Authenticator authenticator, TokenCache tokenCache, IWebAuthenticationBrokerContinuationEventArgs args)
            : this(
                authenticator,
                tokenCache,
                (string)args.ContinuationData[WabArgName.Resource],
                (string)args.ContinuationData[WabArgName.ClientId],
                new Uri((string)args.ContinuationData[WabArgName.RedirectUri]),
                PromptBehavior.Always,  // This is simply to disable cache lookup. In fact, there is no authorize call at this point and promptBehavior is not applicable.
                new UserIdentifier((string)args.ContinuationData[WabArgName.UserId],
                                   (UserIdentifierType)((int)args.ContinuationData[WabArgName.UserIdType])),
                null,
                NetworkPlugin.WebUIFactory.Create(),
                false)
        {
            CallState callState = new CallState(new Guid((string)args.ContinuationData[WabArgName.CorrelationId]), false);

            this.authorizationResult = this.webUi.ProcessAuthorizationResult(args, callState);
        }
        public async Task ContinueAcquireToken(IWebAuthenticationBrokerContinuationEventArgs args)
        {
            var result = await authContext.ContinueAcquireTokenAsync(args);

            acquireTokenTcs.SetResult(Convert(result));
        }
        public AuthorizationResult ProcessAuthorizationResult(IWebAuthenticationBrokerContinuationEventArgs args, CallState callState)
        {
            var replayerArgs = (ReplayerWebAuthenticationBrokerContinuationEventArgs)args;

            return(replayerArgs.AuthorizationResult);
        }
 public AuthorizationResult ProcessAuthorizationResult(IWebAuthenticationBrokerContinuationEventArgs args, CallState callState)
 {
     var replayerArgs = (ReplayerWebAuthenticationBrokerContinuationEventArgs)args;
     return replayerArgs.AuthorizationResult;
 }
 /// <summary>
 /// Continues security token acquisition from the authority.
 /// </summary>
 /// <param name="args">Information to an app that was launched after being suspended for a web authentication broker operation.</param>
 /// <returns>It contains Access Token, Refresh Token and the Access Token's expiration time.</returns>
 public IAsyncOperation<AuthenticationResult> ContinueAcquireTokenAsync(IWebAuthenticationBrokerContinuationEventArgs args)
 {
     var handler = new AcquireTokenInteractiveHandler(this.Authenticator, this.TokenCache, args);
     return this.RunInteractiveHandlerAsync(handler).AsAsyncOperation();
 }
Example #11
0
        /// <summary>
        /// Continues security token acquisition from the authority.
        /// </summary>
        /// <param name="args">Information to an app that was launched after being suspended for a web authentication broker operation.</param>
        /// <returns>It contains Access Token, Refresh Token and the Access Token's expiration time.</returns>
        public IAsyncOperation <AuthenticationResult> ContinueAcquireTokenAsync(IWebAuthenticationBrokerContinuationEventArgs args)
        {
            var handler = new AcquireTokenInteractiveHandler(this.Authenticator, this.TokenCache, args);

            return(this.RunInteractiveHandlerAsync(handler).AsAsyncOperation());
        }
 public static void SetWebAuthenticationBrokerContinuationEventArgs(IWebAuthenticationBrokerContinuationEventArgs args)
 {
     WebUI.SetAuthorizationResultUri(args.WebAuthenticationResult);
 }
        public AcquireTokenInteractiveHandler(Authenticator authenticator, TokenCache tokenCache, AuthenticationContextDelegate authenticationContextDelegate, IWebAuthenticationBrokerContinuationEventArgs args)
            : this(
                authenticator,
                tokenCache,
                (string)args.ContinuationData[WabArgName.Resource],
                (string)args.ContinuationData[WabArgName.ClientId],
                new Uri((string)args.ContinuationData[WabArgName.RedirectUri]),
                PromptBehavior.RefreshSession,
                new UserIdentifier((string)args.ContinuationData[WabArgName.UserId],
                                   (UserIdentifierType)((int)args.ContinuationData[WabArgName.UserIdType])),
                null,
                NetworkPlugin.WebUIFactory.Create(),
                false)
        {
            CallState callState = new CallState(new Guid((string)args.ContinuationData[WabArgName.CorrelationId]), false);

            this.authorizationResult           = this.webUi.ProcessAuthorizationResult(args, callState);
            this.authenticationContextDelegate = authenticationContextDelegate;
        }