Ejemplo n.º 1
0
        private void AcquireTokenAndContinueCommon(string resource, string clientId, Uri redirectUri, UserIdentifier userId, string extraQueryParameters, AuthenticationContextDelegate authDelegate)
        {
            IWebUI webUi   = this.CreateWebAuthenticationDialog();
            var    handler = new AcquireTokenInteractiveHandler(this.Authenticator, this.TokenCache, resource, clientId, redirectUri, webUi.PromptBehavior, userId, extraQueryParameters, webUi, false);

            handler.AcquireAuthorization();
            this.authenticationContextDelegate = authDelegate;
        }
Ejemplo n.º 2
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;
            }
        }
Ejemplo n.º 3
0
        private async Task <AuthenticationResult> RunInteractiveHandlerAsync(AcquireTokenInteractiveHandler handler)
        {
            AuthenticationResult result = await RunTask(handler.RunAsync());

            // Execute callback
            if (this.authenticationContextDelegate != null)
            {
                var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher;
                await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => this.authenticationContextDelegate(result));

                this.authenticationContextDelegate = null;
            }

            return(result);
        }
        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;
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Starts security token acquisition from the authority in SSO mode.
 /// </summary>
 /// <param name="resource">Identifier of the target resource that is the recipient of the requested token.</param>
 /// <param name="clientId">Identifier of the client requesting the token.</param>
 /// <param name="userId">Identifier of the user token is requested for. If created from DisplayableId, this parameter will be used to pre-populate the username field in the authentication form. Please note that the end user can still edit the username field and authenticate as a different user.
 /// If you want to be notified of such change with an exception, create UserIdentifier with type RequiredDisplayableId. This parameter can be <see cref="UserIdentifier"/>.Any.</param>
 /// <param name="extraQueryParameters">This parameter will be appended as is to the query string in the HTTP authentication request to the authority. The parameter can be null.</param>
 /// <param name="authDelegate">Optional delegate that can be passed by the developer to process authentication result.</param>
 /// <returns>It contains Access Token, Refresh Token and the Access Token's expiration time.</returns>
 public void AcquireTokenAndContinue(string resource, string clientId, UserIdentifier userId, string extraQueryParameters, AuthenticationContextDelegate authDelegate)
 {
     this.AcquireTokenAndContinueCommon(resource, clientId, WebAuthenticationBroker.GetCurrentApplicationCallbackUri(), userId, extraQueryParameters, authDelegate);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Acquires security token from the authority.
 /// </summary>
 /// <param name="resource">Identifier of the target resource that is the recipient of the requested token.</param>
 /// <param name="clientId">Identifier of the client requesting the token.</param>
 /// <param name="redirectUri">Address to return to upon receiving a response from the authority.</param>
 /// <param name="userId">Identifier of the user token is requested for. If created from DisplayableId, this parameter will be used to pre-populate the username field in the authentication form. Please note that the end user can still edit the username field and authenticate as a different user.
 /// If you want to be notified of such change with an exception, create UserIdentifier with type RequiredDisplayableId. This parameter can be <see cref="UserIdentifier"/>.Any.</param>
 /// <param name="extraQueryParameters">This parameter will be appended as is to the query string in the HTTP authentication request to the authority. The parameter can be null.</param>
 /// <param name="authDelegate">Optional delegate that can be passed by the developer to process authentication result.</param>
 /// <returns>It contains Access Token, Refresh Token and the Access Token's expiration time.</returns>
 public void AcquireTokenAndContinue(string resource, string clientId, Uri redirectUri, UserIdentifier userId, string extraQueryParameters, AuthenticationContextDelegate authDelegate)
 {
     this.AcquireTokenAndContinueCommon(resource, clientId, redirectUri, userId, extraQueryParameters, authDelegate);
 }
Ejemplo n.º 7
0
 public void AcquireTokenAndContinue(string resource, string clientId, Uri redirectUri, UserIdentifier userId, AuthenticationContextDelegate authDelegate)
 {
     this.AcquireTokenAndContinueCommon(resource, clientId, GetRedirectUri(redirectUri), userId, null, authDelegate);
 }
Ejemplo n.º 8
0
 public void AcquireTokenAndContinue(string resource, string clientId, AuthenticationContextDelegate authDelegate)
 {
     this.AcquireTokenAndContinueCommon(resource, clientId, WebAuthenticationBroker.GetCurrentApplicationCallbackUri(), UserIdentifier.AnyUser, null, authDelegate);
 }
 private void AcquireTokenAndContinueCommon(string resource, string clientId, Uri redirectUri, UserIdentifier userId, string extraQueryParameters, AuthenticationContextDelegate authDelegate)
 {
     IWebUI webUi = this.CreateWebAuthenticationDialog();
     var handler = new AcquireTokenInteractiveHandler(this.Authenticator, this.TokenCache, resource, clientId, redirectUri, webUi.PromptBehavior, userId, extraQueryParameters, webUi, false);
     handler.AcquireAuthorization();
     this.authenticationContextDelegate = authDelegate;
 }
        private async Task<AuthenticationResult> RunInteractiveHandlerAsync(AcquireTokenInteractiveHandler handler)
        {
            AuthenticationResult result = await RunTask(handler.RunAsync());
            
            // Execute callback 
            if (this.authenticationContextDelegate != null)
            {
                var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher;
                await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => this.authenticationContextDelegate(result));
                this.authenticationContextDelegate = null;
            }

            return result;
        }
 /// <summary>
 /// Acquires security token from the authority.
 /// </summary>
 /// <param name="resource">Identifier of the target resource that is the recipient of the requested token.</param>
 /// <param name="clientId">Identifier of the client requesting the token.</param>
 /// <param name="redirectUri">Address to return to upon receiving a response from the authority. Pass null or application's callback URI for SSO mode.</param>
 /// <param name="userId">Identifier of the user token is requested for. If created from DisplayableId, this parameter will be used to pre-populate the username field in the authentication form. Please note that the end user can still edit the username field and authenticate as a different user. 
 /// If you want to be notified of such change with an exception, create UserIdentifier with type RequiredDisplayableId. This parameter can be <see cref="UserIdentifier"/>.Any.</param>
 /// <param name="extraQueryParameters">This parameter will be appended as is to the query string in the HTTP authentication request to the authority. The parameter can be null.</param>
 /// <param name="authDelegate">Optional delegate that can be passed by the developer to process authentication result.</param>
 /// <returns>It contains Access Token, Refresh Token and the Access Token's expiration time.</returns>
 public void AcquireTokenAndContinue(string resource, string clientId, Uri redirectUri, UserIdentifier userId, string extraQueryParameters, AuthenticationContextDelegate authDelegate)
 {
     this.AcquireTokenAndContinueCommon(resource, clientId, redirectUri ?? Constant.SsoPlaceHolderUri, userId, extraQueryParameters, authDelegate);
 }
 public void AcquireTokenAndContinue(string resource, string clientId, Uri redirectUri, AuthenticationContextDelegate authDelegate)
 {
     this.AcquireTokenAndContinueCommon(resource, clientId, redirectUri ?? Constant.SsoPlaceHolderUri, UserIdentifier.AnyUser, null, authDelegate);
 }
Ejemplo n.º 13
0
 public void AcquireTokenAndContinue(string resource, string clientId, Uri redirectUri, UserIdentifier userId, AuthenticationContextDelegate authDelegate)
 {
     this.AcquireTokenAndContinueCommon(resource, clientId, redirectUri ?? Constant.SsoPlaceHolderUri, userId, null, authDelegate);
 }