示例#1
0
        /// <summary>
        /// Event Handler for Login Dialog Response event
        /// </summary>
        private void OnLoginDialogResponse(object o, ResponseArgs args)
        {
            switch (args.ResponseId)
            {
            case Gtk.ResponseType.Ok:
                DomainInformation dom = domainController.GetDomain(LoginDialog.Domain);

                if (WaitDialog != null)
                {
                    WaitDialog.Hide();
                    WaitDialog.Destroy();
                    WaitDialog = null;
                }

                VBox  vbox            = new VBox(false, 0);
                Image connectingImage = new Image(Util.ImagesPath("ifolder-add-account48.png"));
                vbox.PackStart(connectingImage, false, false, 0);

                WaitDialog =
                    new iFolderWaitDialog(
                        topLevelWindow,
                        vbox,
                        iFolderWaitDialog.ButtonSet.None,
                        Util.GS("Connecting..."),
                        Util.GS("Connecting..."),
                        Util.GS("Please wait while your iFolder account is connecting."));

                if (!Util.RegisterModalWindow(WaitDialog))
                {
                    try
                    {
                        Util.CurrentModalWindow.Present();
                    }
                    catch {}
                    WaitDialog.Destroy();
                    return;
                }
                WaitDialog.Show();

                DomainLoginThread domainLoginThread =
                    new DomainLoginThread(domainController);

                domainLoginThread.Completed +=
                    new DomainLoginCompletedHandler(OnDomainLoginCompleted);

                domainLoginThread.Login(dom.ID, LoginDialog.Password, LoginDialog.ShouldSavePassword);

                break;

            case Gtk.ResponseType.Cancel:
            case Gtk.ResponseType.DeleteEvent:
                LoginDialog.Hide();
                LoginDialog.Destroy();
                LoginDialog = null;
                break;
            }
        }
示例#2
0
        /// <summary>
        /// Login to Domain
        /// </summary>
        /// <param name="dom">Domain Information</param>
        public void LoginDomain(DomainInformation dom)
        {
            try
            {
                LoginDialog =
                    new iFolderLoginDialog(dom.ID, dom.Name, dom.MemberName);
                if (!Util.RegisterModalWindow(LoginDialog))
                {
                    LoginDialog.Destroy();
                    LoginDialog = null;
                    return;
                }

                LoginDialog.Response +=
                    new ResponseHandler(OnLoginDialogResponse);

                LoginDialog.ShowAll();

                string password = domainController.GetDomainPassword(dom.ID);
                if (password != null)
                {
                    LoginDialog.Hide();
                    LoginDialog.Password = password;
                    LoginDialog.Respond(Gtk.ResponseType.Ok);
                }
            }
            catch
            {
                Util.ShowLoginError(topLevelWindow, StatusCodes.Unknown);

                UpdateDomainStatus(dom.ID);
            }
        }
 public void LoginDomain(DomainInformation dom)
 {
     try
        {
     LoginDialog =
      new iFolderLoginDialog(dom.ID, dom.Name, dom.MemberName);
     if (!Util.RegisterModalWindow(LoginDialog))
     {
      LoginDialog.Destroy();
      LoginDialog = null;
      return;
     }
     LoginDialog.Response +=
      new ResponseHandler(OnLoginDialogResponse);
     LoginDialog.ShowAll();
     string password = domainController.GetDomainPassword(dom.ID);
     if (password != null)
     {
      LoginDialog.Hide();
      LoginDialog.Password = password;
      LoginDialog.Respond(Gtk.ResponseType.Ok);
     }
        }
        catch
        {
     Util.ShowLoginError(topLevelWindow, StatusCodes.Unknown);
     UpdateDomainStatus(dom.ID);
        }
 }
 private void ReLogin(string domainID)
 {
     if (LoginDialog != Util.CurrentModalWindow) return;
        if (LoginDialog == null)
        {
     DomainInformation dom = domainController.GetDomain(domainID);
     if(dom.Authenticated)
     {
      return;
     }
     if (dom != null)
     {
      LoginDialog =
       new iFolderLoginDialog(dom.ID, dom.Name, dom.MemberName);
      if (!Util.RegisterModalWindow(LoginDialog))
      {
       LoginDialog.Destroy();
       LoginDialog = null;
       return;
      }
      LoginDialog.Response +=
       new ResponseHandler(OnReLoginDialogResponse);
      LoginDialog.ShowAll();
     }
        }
        else
        {
     LoginDialog.Present();
        }
 }
 private void OnReLoginDialogResponse(object o, ResponseArgs args)
 {
     switch (args.ResponseId)
        {
     case Gtk.ResponseType.Ok:
      DomainInformation dom = domainController.GetDomain(LoginDialog.Domain);
      if (dom == null)
      {
       iFolderMsgDialog dialog = new iFolderMsgDialog(
        null,
        iFolderMsgDialog.DialogType.Error,
        iFolderMsgDialog.ButtonSet.None,
        Util.GS("Account Error"),
        Util.GS("This account has been removed from your computer."),
        Util.GS("If you wish to connect to this account again, please add it in the Account Settings Dialog."));
       dialog.Run();
       dialog.Hide();
       dialog.Destroy();
       dialog = null;
       LoginDialog.Hide();
       LoginDialog.Destroy();
       LoginDialog = null;
       break;
      }
      try
      {
       string DomainID = LoginDialog.Domain;
       Status status =
        domainController.AuthenticateDomain(
     LoginDialog.Domain,
     LoginDialog.Password,
     LoginDialog.ShouldSavePassword);
       if (status != null)
       {
        switch(status.statusCode)
        {
     case StatusCodes.Success:
     case StatusCodes.SuccessInGrace:
      ifdata.Refresh();
      Debug.PrintLine("Login dialog response- success");
      LoginDialog.Hide();
      LoginDialog.Destroy();
      LoginDialog = null;
       ShowClientUpgradeMessageBox();
                                         int result;
       int policy = ifws.GetSecurityPolicy(DomainID);
       if( policy % 2 == 0)
        break;
                                         bool passphraseStatus = simws.IsPassPhraseSet(DomainID);
       if(passphraseStatus == true)
       {
        bool rememberOption = simws.GetRememberOption(DomainID);
        if( rememberOption == false)
        {
     ShowVerifyDialog( DomainID, simws);
        }
        else
        {
     Debug.PrintLine(" remember Option true. Checking for passphrase existence");
     string passphrasecheck;
     passphrasecheck= simws.GetPassPhrase(DomainID);
     if(passphrasecheck == null || passphrasecheck == "")
      ShowVerifyDialog( DomainID, simws);
        }
       }
       else
       {
        iFolderWindow.ShowEnterPassPhraseDialog(DomainID, simws);
       }
      break;
     case StatusCodes.InvalidCertificate:
      if( status.UserName != null)
      {
       dom.Host = status.UserName;
      }
      byte[] byteArray = simws.GetCertificate(dom.Host);
      System.Security.Cryptography.X509Certificates.X509Certificate cert = new System.Security.Cryptography.X509Certificates.X509Certificate(byteArray);
      iFolderMsgDialog dialog = new iFolderMsgDialog(
       null,
       iFolderMsgDialog.DialogType.Question,
       iFolderMsgDialog.ButtonSet.YesNo,
       "",
       Util.GS("Accept the certificate of this server?"),
       string.Format(Util.GS("iFolder is unable to verify \"{0}\" as a trusted server.  You should examine this server's identity certificate carefully."), dom.Host),
       cert.ToString(true));
      Gdk.Pixbuf certPixbuf = Util.LoadIcon("gnome-mime-application-x-x509-ca-cert", 48);
      if (certPixbuf != null && dialog.Image != null)
       dialog.Image.Pixbuf = certPixbuf;
      int rc = dialog.Run();
      dialog.Hide();
      dialog.Destroy();
      if(rc == -8)
      {
       simws.StoreCertificate(byteArray, dom.Host);
       OnReLoginDialogResponse(o, args);
      }
      else
      {
       domainController.DisableDomainAutoLogin(LoginDialog.Domain);
       LoginDialog.Hide();
       LoginDialog.Destroy();
       LoginDialog = null;
      }
      break;
     case StatusCodes.UserAlreadyMoved:
      OnReLoginDialogResponse(o, args);
      break;
     default:
      Util.ShowLoginError(LoginDialog, status.statusCode);
      break;
        }
       }
      }
      catch(Exception e)
      {
       iFolderMsgDialog dialog = new iFolderMsgDialog(
        null,
        iFolderMsgDialog.DialogType.Error,
        iFolderMsgDialog.ButtonSet.None,
        Util.GS("Account Error"),
        Util.GS("Unable to connect to the iFolder Server"),
        Util.GS("An error was encountered while connecting to the iFolder server.  Please verify the information entered and try again.  If the problem persists, please contact your network administrator."),
        e.Message);
       dialog.Run();
       dialog.Hide();
       dialog.Destroy();
       dialog = null;
      }
      break;
     case Gtk.ResponseType.Cancel:
     case Gtk.ResponseType.DeleteEvent:
      domainController.DisableDomainAutoLogin(LoginDialog.Domain);
      LoginDialog.Hide();
      LoginDialog.Destroy();
      LoginDialog = null;
      break;
        }
 }
 private void LoginDomain(DomainInformation dom, TreeIter iter)
 {
     try
        {
     bool bSavePassword = false;
     string password = domainController.GetDomainPassword(dom.ID);
     if (password != null)
      bSavePassword = true;
     else
     {
      iFolderLoginDialog dialog =
       new iFolderLoginDialog(
        dom.ID, dom.Name, dom.MemberName);
      int rc = dialog.Run();
      dialog.Hide();
      if (rc == (int)ResponseType.Ok)
      {
       password = dialog.Password;
       bSavePassword = dialog.ShouldSavePassword;
      }
      else
      {
       dialog.Destroy();
       return;
      }
      dialog.Destroy();
     }
     if (WaitDialog != null)
     {
      WaitDialog.Hide();
      WaitDialog.Destroy();
      WaitDialog = null;
     }
     VBox vbox = new VBox(false, 0);
     Image connectingImage = new Image(Util.ImagesPath("ifolder48.png"));
     vbox.PackStart(connectingImage, false, false, 0);
     Label l = new Label("<span size=\"xx-small\">FIXME: This will be\nreplaced with an\nanimated image</span>");
     vbox.PackStart(l);
     l.UseMarkup = true;
     l.LineWrap = true;
     WaitDialog =
      new iFolderWaitDialog(
       topLevelWindow,
       vbox,
       iFolderWaitDialog.ButtonSet.None,
       Util.GS("Connecting..."),
       Util.GS("Connecting..."),
       Util.GS("Please wait while your iFolder account is connecting."));
     WaitDialog.Show();
     DomainLoginThread domainLoginThread =
      new DomainLoginThread(
       domainController, dom.ID, password, bSavePassword);
     domainLoginThread.Completed +=
      new EventHandler(OnDomainLoginCompleted);
     domainLoginThread.Login();
        }
        catch
        {
     Util.ShowLoginError(topLevelWindow, StatusCodes.Unknown);
     UpdateDomainStatus(dom.ID);
        }
 }