Пример #1
0
        private void EnsureCredentials(ScmUserNamePasswordEventArgs e)
        {
            ISvnClientPool pool = (Context != null) ? Context.GetService <ISvnClientPool>() : null;

            if (pool != null)
            {
                using (SvnPoolClient client = pool.GetNoUIClient())
                {
                    EventHandler <SvnUserNamePasswordEventArgs> handler = delegate(object sender, SvnUserNamePasswordEventArgs args)
                    {
                        args.Save     = true;
                        args.UserName = e.UserName;
                        args.Password = e.Password;
                    };
                    client.Authentication.UserNamePasswordHandlers += handler;
                    try
                    {
                        SvnInfoArgs infoArgs = new SvnInfoArgs();
                        infoArgs.ThrowOnError = false;
                        System.Collections.ObjectModel.Collection <SvnInfoEventArgs> info;
                        if (client.GetInfo(SvnUriTarget.FromString(e.RepositoryUri), infoArgs, out info))
                        {
                        }
                    }
                    finally
                    {
                        client.Authentication.UserNamePasswordHandlers -= handler;
                    }
                }
            }
        }
Пример #2
0
 internal void FillUsernamePassword(ScmUserNamePasswordEventArgs e)
 {
     if (this.repoProviderControl != null)
     {
         this.repoProviderControl.UserNamePasswordCallback(e);
         if (!e.Cancel && (string.IsNullOrEmpty(e.UserName) || string.IsNullOrEmpty(e.Password)))
         {
             e.Cancel = true;
         }
     }
 }
Пример #3
0
        public override void OnFinish(System.ComponentModel.CancelEventArgs e)
        {
            WizardMessage newMsg = null;

            this.resultUri = null;
            EnablePageAndButtons(false);
            ScmUserNamePasswordEventArgs credentialsArgs = null;

            try
            {
                Uri uri = this.providerSelectionPage.Uri;
                if (uri == null && this.repositorySelectionPages != null)
                {
                    ScmRepositoryProvider repoProvider = this.providerSelectionPage.SelectedRepositoryProvider;
                    if (repoProvider != null)
                    {
                        RepositorySelectionPage repoSelectionPage;
                        if (this.repositorySelectionPages.TryGetValue(repoProvider.Id, out repoSelectionPage))
                        {
                            uri = repoSelectionPage.Uri;
                            if (uri != null)
                            {
                                credentialsArgs = new ScmUserNamePasswordEventArgs(uri.AbsoluteUri);
                                repoSelectionPage.FillUsernamePassword(credentialsArgs);
                                if (credentialsArgs.Cancel)
                                {
                                    credentialsArgs = null;
                                }
                            }
                        }
                    }
                }
                bool cancel = false;
                if (uri == null)
                {
                    cancel = true;
                }
                else
                {
                    Exception exc = null;
                    if (credentialsArgs != null)
                    {
                        try
                        {
                            ProgressRunnerArgs runnerArgs = new ProgressRunnerArgs();
                            runnerArgs.CreateLog = false;
                            // Make sure username and password is saved for future use
                            ProgressRunnerResult result = Context.GetService <IProgressRunner>().RunModal("Checking repository",
                                                                                                          runnerArgs,
                                                                                                          delegate(object sender, ProgressWorkerArgs ee)
                                                                                                          { EnsureCredentials(credentialsArgs); });
                            cancel = !(result.Succeeded || result.Exception == null);
                            exc    = result.Exception;
                        }
                        catch (Exception runnere)
                        {
                            cancel = true;
                            exc    = runnere.InnerException == null ? runnere : runnere.InnerException;
                        }
                    }
                    // TODO (BA) Should we validate here?

                    /*
                     * try
                     * {
                     *  ProgressRunnerArgs runnerArgs = new ProgressRunnerArgs();
                     *  runnerArgs.CreateLog = false;
                     *  // Check the validity of the specified repository location using IProgressRunner
                     *  ProgressRunnerResult result = Context.GetService<IProgressRunner>().RunModal("Checking URI",
                     *      runnerArgs,
                     *      delegate(object sender, ProgressWorkerArgs ee)
                     *      { CheckResult(uri); });
                     *  cancel = !(result.Succeeded || result.Exception == null);
                     *  exc = result.Exception;
                     * }
                     * catch (Exception runnere)
                     * {
                     *  cancel = true;
                     *  exc = runnere.InnerException == null ? runnere : runnere.InnerException;
                     * }
                     */
                    if (cancel && exc != null)
                    {
                        newMsg = new WizardMessage(exc.Message, WizardMessage.MessageType.Error);
                    }
                }
                this.resultUri = cancel ? null : uri;
                DialogResult   = cancel ? System.Windows.Forms.DialogResult.None : System.Windows.Forms.DialogResult.OK;
                if (CurrentPage.Message != newMsg)
                {
                    CurrentPage.Message = newMsg;
                    UpdateMessage();
                }
                e.Cancel = cancel;
            }
            finally
            {
                EnablePageAndButtons(true);
            }
        }