Example #1
0
        /// <summary>
        /// Bind the Data to the Page.
        /// </summary>
        private void BindData()
        {
            string RAName;

            // query
            RAName = Request.QueryString.Get("RAName");

            //proceed only if there is a valid RAName
            if (!RAName.Equals(GetString("NONE")))
            {
                byte [] RACertificateObj = web.GetRACertificate(RAName);

                if (RACertificateObj != null && RACertificateObj.Length != 0)
                {
                    System.Security.Cryptography.X509Certificates.X509Certificate Cert = new System.Security.Cryptography.X509Certificates.X509Certificate(RACertificateObj);
                    CertDetails.Text         = Cert.ToString(true);
                    Session["CertPublicKey"] = Cert.GetPublicKey();
                }
            }
            else
            {
                Message.Text = GetString("NO.RA.SELECTED");
                return;
            }

            // Pass the page information so that it can be added to help link
            Head.AddHelpLink(GetString("CERTIFICATE"));
        }
Example #2
0
        private void jc_OnAuthenticate(object sender)
        {
            pnlPresence.Text = "Available";
            pnlCon.Text      = "Connected";
            mnuAway.Enabled  = mnuAvailable.Enabled = true;

            if (jc.SSLon)
            {
                pnlSSL.Text = "SSL";
                System.Security.Cryptography.X509Certificates.X509Certificate cert2 =
                    (System.Security.Cryptography.X509Certificates.X509Certificate)
                    jc[Options.REMOTE_CERTIFICATE];

                string cert_str = cert2.ToString(true);
                debug.Write("CERT:", cert_str);
                pnlSSL.ToolTipText = cert_str;
            }
            idler.Enabled = true;
        }
Example #3
0
 private void next_Click(object sender, System.EventArgs e)
 {
     if (currentIndex == (maxPages - 1))
        {
     return;
        }
        System.Resources.ResourceManager resManager = new System.Resources.ResourceManager(typeof(Connecting));
        if( currentIndex == 3 )
        {
     if( this.passphrasePage.Passphrase != this.passphrasePage.RetypePassphrase)
     {
      MessageBox.Show(Resource.GetString("TypeRetypeMisMatch"));
     }
     else
     {
      string publicKey = "";
      string ragent = null;
      if( this.passphrasePage.RecoveryAgent != null && this.passphrasePage.RecoveryAgent != "None")
      {
       byte[] CertificateObj = this.simws.GetRACertificateOnClient(this.identityPage.domain.ID, this.passphrasePage.RecoveryAgent);
       System.Security.Cryptography.X509Certificates.X509Certificate cert = new System.Security.Cryptography.X509Certificates.X509Certificate(CertificateObj);
       MyMessageBox mmb = new MyMessageBox( string.Format(resManager.GetString("verifyCert"), this.passphrasePage.RecoveryAgent), resManager.GetString("verifyCertTitle"), cert.ToString(true), MyMessageBoxButtons.YesNo, MyMessageBoxIcon.Question, MyMessageBoxDefaultButton.Button2);
       DialogResult messageDialogResult = mmb.ShowDialog();
       mmb.Dispose();
       mmb.Close();
       if( messageDialogResult != DialogResult.OK )
        return;
       else
       {
        ragent = this.passphrasePage.RecoveryAgent;
        publicKey = Convert.ToBase64String(cert.GetPublicKey());
       }
      }
      Status passPhraseStatus = null;
      try
      {
       passPhraseStatus = this.simiasWebService.SetPassPhrase( this.identityPage.domain.ID, this.passphrasePage.Passphrase, null, publicKey);
      }
      catch(Exception ex)
      {
       MessageBox.Show( Resource.GetString("IsPassphraseSetException")+ex.Message);
       return;
      }
      if(passPhraseStatus.statusCode == StatusCodes.Success)
      {
       this.simiasWebService.StorePassPhrase( this.identityPage.domain.ID, this.passphrasePage.Passphrase, CredentialType.Basic, this.passphrasePage.RememberPassphrase);
       Novell.iFolderCom.MyMessageBox mmb = new MyMessageBox(Resource.GetString("SetPassphraseSuccess"), "", "", MyMessageBoxButtons.OK, MyMessageBoxIcon.Information);
       mmb.ShowDialog();
       mmb.Dispose();
       this.Dispose();
       this.Close();
      }
      else
      {
       Novell.iFolderCom.MyMessageBox mmb = new MyMessageBox(Resource.GetString("IsPassphraseSetException"), "", "", MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
       mmb.ShowDialog();
       mmb.Dispose();
       return;
      }
     }
        }
        else if(currentIndex == 4)
        {
     Status passPhraseStatus = null;
     try
     {
      passPhraseStatus = this.simiasWebService.ValidatePassPhrase(this.identityPage.domain.ID, this.passphraseVerifyPage.Passphrase);
     }
     catch(Exception ex)
     {
      MessageBox.Show(resManager.GetString("ValidatePPError"), ex.Message);
      return;
     }
     if( passPhraseStatus != null)
     {
      if( passPhraseStatus.statusCode == StatusCodes.PassPhraseInvalid)
      {
       Novell.iFolderCom.MyMessageBox mmb = new MyMessageBox(Resource.GetString("InvalidPPText"), Resource.GetString("VerifyPP"), "", MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
       mmb.ShowDialog();
       mmb.Dispose();
       return;
      }
      else if(passPhraseStatus.statusCode == StatusCodes.Success)
      {
       try
       {
        this.simiasWebService.StorePassPhrase( this.identityPage.domain.ID, this.passphraseVerifyPage.Passphrase, CredentialType.Basic, this.passphraseVerifyPage.RememberPassphrase);
       }
       catch(Exception ex)
       {
        MessageBox.Show("Unable to store Passphrase");
        return;
       }
      }
     }
        }
        int nextIndex = this.pages[currentIndex].ValidatePage(currentIndex);
        if( nextIndex == 4 )
        {
     nextIndex = 5;
        }
        else if( nextIndex == 3)
        {
     if( this.identityPage.Encrypion == false )
     {
      if( this.encryptedOriginal == true )
      {
       MyMessageBox mmb1 = new MyMessageBox(Resource.GetString("EncryptTotext"), Resource.GetString("MigrationAlert"), "", MyMessageBoxButtons.YesNo, MyMessageBoxIcon.Warning, MyMessageBoxDefaultButton.Button1);
       DialogResult res = mmb1.ShowDialog();
       if( res == DialogResult.No )
        nextIndex = currentIndex;
       else
        nextIndex = 5;
      }
      else
       nextIndex = 5;
     }
     else
     {
      try
      {
       string passphrasecheck = this.simiasWebService.GetPassPhrase(this.identityPage.domain.ID);
       if( passphrasecheck!= null && passphrasecheck != "")
       {
        Status status = this.simiasWebService.ValidatePassPhrase(this.identityPage.domain.ID, passphrasecheck);
        if( status != null && status.statusCode == StatusCodes.Success)
        {
     nextIndex = 5;
        }
       }
       else if(this.simiasWebService.IsPassPhraseSet(this.identityPage.domain.ID) == true)
       {
        nextIndex = 4;
       }
      }
      catch(Exception ex)
      {
       MessageBox.Show("Unable to get passphrase. \nLogin to the domain and try again.");
       nextIndex = currentIndex;
      }
     }
        }
        if (nextIndex != currentIndex)
        {
     this.pages[currentIndex].DeactivatePage();
     this.pages[nextIndex].ActivatePage(currentIndex);
     if( nextIndex == 5)
     {
      this.pages[nextIndex].PreviousIndex = 2;
     }
     currentIndex = nextIndex;
     if (currentIndex == (maxPages - 2))
     {
      next.Text = Resource.GetString("MigrateText");
      this.verifyPage.UpdateDetails();
     }
     else if (currentIndex == (maxPages - 1))
     {
      next.DialogResult = DialogResult.OK;
      next.Text = Resource.GetString("FinishText");
     }
        }
 }
Example #4
0
 private void btnReset_Click(object sender, System.EventArgs e)
 {
     try
        {
     DomainItem domainItem = (DomainItem)this.DomainComboBox.SelectedItem;
     this.domainID = domainItem.ID;
     System.Resources.ResourceManager resManager = new System.Resources.ResourceManager(typeof(Connecting));
     string publicKey = null;
     string ragent = null;
         Status status = null;
         try
         {
             status = simws.ValidatePassPhrase(this.domainID, this.passPhrase.Text);
       if(status.statusCode == StatusCodes.PassPhraseInvalid)
       {
     status = simws.ValidatePassPhrase(this.domainID, this.newPassphrase.Text);
       }
         }
         catch (Exception ex)
         {
             System.Resources.ResourceManager resMgr = new System.Resources.ResourceManager(typeof(VerifyPassphraseDialog));
             MessageBox.Show(resMgr.GetString("ValidatePPError"), ex.Message);
         }
         if (status.statusCode == StatusCodes.PassPhraseInvalid)
         {
             MessageBox.Show(Resource.GetString("InvalidCurrentPPText") , Resource.GetString("ResetTitle") );
             this.success = false;
             return;
         }
         if (this.recoveryAgentCombo.SelectedItem != null && (string)this.recoveryAgentCombo.SelectedItem != TrayApp.Properties.Resources.serverDefaultRA)
         {
             byte[] CertificateObj = this.simws.GetRACertificateOnClient(this.DomainID, (string)this.recoveryAgentCombo.SelectedItem);
             System.Security.Cryptography.X509Certificates.X509Certificate cert = new System.Security.Cryptography.X509Certificates.X509Certificate(CertificateObj);
             MyMessageBox mmb = new MyMessageBox(string.Format(resManager.GetString("verifyCert"), (string)this.recoveryAgentCombo.SelectedItem), resManager.GetString("verifyCertTitle"), cert.ToString(true), MyMessageBoxButtons.YesNo, MyMessageBoxIcon.Question, MyMessageBoxDefaultButton.Button2);
             DialogResult messageDialogResult = mmb.ShowDialog();
             mmb.Dispose();
             mmb.Close();
             if (messageDialogResult != DialogResult.Yes)
                 return;
             else
             {
                 ragent = (string)this.recoveryAgentCombo.SelectedItem;
                 publicKey = Convert.ToBase64String(cert.GetPublicKey());
             }
         }
         else
         {
             ragent = "DEFAULT";
             DomainInformation domainInfo = (DomainInformation)this.simws.GetDomainInformation(this.DomainID);
             string memberUID = domainInfo.MemberUserID;
             publicKey = this.ifws.GetDefaultServerPublicKey(this.DomainID, memberUID);
         }
     status = this.simws.ReSetPassPhrase(this.DomainID, this.passPhrase.Text , this.newPassphrase.Text, ragent, publicKey);
     if( status.statusCode == StatusCodes.Success)
     {
      simws.StorePassPhrase(this.DomainID, "", CredentialType.None, false);
      simws.StorePassPhrase(this.DomainID, this.newPassphrase.Text, CredentialType.Basic, this.rememberPassphrase.Checked);
      MyMessageBox mb = new MyMessageBox(string.Format(Resource.GetString("ResetSuccess")), Resource.GetString("ResetTitle"), "", MyMessageBoxButtons.OK, MyMessageBoxIcon.Information);
      mb.ShowDialog();
      mb.Dispose();
      this.success = true;
      this.Dispose();
      this.Close();
     }
     else
     {
      MessageBox.Show(Resource.GetString("ResetError") , Resource.GetString("ResetTitle") );
      this.success = false;
     }
        }
        catch(Exception ex)
        {
     MessageBox.Show(Resource.GetString("ResetError") , Resource.GetString(ex.Message) );
     this.success = false;
        }
 }
Example #5
0
 private static bool PassphraseHelper( EnterPassPhraseDialog epd, string DomainID, SimiasWebService simws)
 {
     bool status = false;
       int result;
     do
     {
       result = epd.Run();
      if(result == (int)ResponseType.Cancel || result == (int) ResponseType.DeleteEvent)
      {
         epd.Hide();
       return false;
     }
       if( epd.PassPhrase != epd.RetypedPassPhrase )
       {
        iFolderMsgDialog dialog = new iFolderMsgDialog(
     null,
     iFolderMsgDialog.DialogType.Error,
     iFolderMsgDialog.ButtonSet.None,
     Util.GS("passphrase mismatch"),
     Util.GS("The passphrase and retyped passphrase are not same"),
        Util.GS("Please enter the passphrase again"));
        dialog.Run();
        dialog.Hide();
        dialog.Destroy();
        dialog = null;
       }
     else
     {
         break;
     }
     }while( result != (int)ResponseType.Cancel );
       if( result != (int)ResponseType.Cancel || result != (int) ResponseType.DeleteEvent)
       {
        string publicKey = null;
        if( epd.RecoveryAgent != null && epd.RecoveryAgent != "Server_Default")
        {
     byte [] RACertificateObj = DomainController.GetDomainController().GetRACertificate(DomainID, epd.RecoveryAgent);
     if( RACertificateObj != null && RACertificateObj.Length != 0)
     {
      System.Security.Cryptography.X509Certificates.X509Certificate Cert = new System.Security.Cryptography.X509Certificates.X509Certificate(RACertificateObj);
      CertificateDialog dlg = new CertificateDialog(Cert.ToString(true));
      if (!Util.RegisterModalWindow(dlg))
      {
       dlg.Destroy();
       dlg = null;
       return false;
      }
      int res = dlg.Run();
      dlg.Hide();
      dlg.Destroy();
      dlg = null;
      if( res == (int)ResponseType.Ok)
      {
       publicKey = Convert.ToBase64String(Cert.GetPublicKey());
      }
      else
      {
                 status = false;
           simws.StorePassPhrase(DomainID, "", CredentialType.None, false);
       return ShowEnterPassPhraseDialog(DomainID, simws);
      }
     }
         status = SetPassPhrase( epd, DomainID, publicKey, simws );
         epd.Hide();
         return status;
        }
       else
       {
      DomainInformation domainInfo = (DomainInformation)simws.GetDomainInformation(DomainID);
                 string memberID = domainInfo.MemberUserID;
       iFolderWebService ifWebService = DomainController.GetiFolderService();
      publicKey = ifWebService.GetDefaultServerPublicKey(DomainID,memberID);
                 status = SetPassPhrase(epd,DomainID,publicKey,simws);
                 epd.Hide();
                 return status;
       }
       }
     else
     {
     epd.Hide();
     }
     return true;
 }
Example #6
0
 private static bool PassphraseHelper( EnterPassPhraseDialog epd, string DomainID, SimiasWebService simws)
 {
     bool status = false;
       int result;
     do
     {
       result = epd.Run();
      if(result == (int)ResponseType.Cancel || result == (int) ResponseType.DeleteEvent)
      {
         epd.Hide();
       return false;
     }
       if( epd.PassPhrase != epd.RetypedPassPhrase )
       {
        iFolderMsgDialog dialog = new iFolderMsgDialog(
     null,
     iFolderMsgDialog.DialogType.Error,
     iFolderMsgDialog.ButtonSet.None,
     Util.GS("passphrase mismatch"),
     Util.GS("The passphrase and retyped passphrase are not same"),
        Util.GS("Please enter the passphrase again"));
        dialog.Run();
        dialog.Hide();
        dialog.Destroy();
        dialog = null;
       }
     else
     {
         break;
     }
     }while( result != (int)ResponseType.Cancel );
       if( result != (int)ResponseType.Cancel || result != (int) ResponseType.DeleteEvent)
       {
        string publicKey = null;
        if( epd.RecoveryAgent != null)
        {
     byte [] RACertificateObj = DomainController.GetDomainController().GetRACertificate(DomainID, epd.RecoveryAgent);
     if( RACertificateObj != null && RACertificateObj.Length != 0)
     {
      System.Security.Cryptography.X509Certificates.X509Certificate Cert = new System.Security.Cryptography.X509Certificates.X509Certificate(RACertificateObj);
      CertificateDialog dlg = new CertificateDialog(Cert.ToString(true));
      if (!Util.RegisterModalWindow(dlg))
      {
       dlg.Destroy();
       dlg = null;
       return false;
      }
      int res = dlg.Run();
      dlg.Hide();
      dlg.Destroy();
      dlg = null;
      if( res == (int)ResponseType.Ok)
      {
       publicKey = Convert.ToBase64String(Cert.GetPublicKey());
      }
      else
      {
                 status = false;
           simws.StorePassPhrase(DomainID, "", CredentialType.None, false);
       return ShowEnterPassPhraseDialog(DomainID, simws);
      }
     }
         status = SetPassPhrase( epd, DomainID, publicKey, simws );
         epd.Hide();
         return status;
        }
     else
     {
         iFolderMsgDialog dg = new iFolderMsgDialog(
             epd,
             iFolderMsgDialog.DialogType.Warning,
             iFolderMsgDialog.ButtonSet.YesNo,
             "No Recovery Agent",
             Util.GS("Recovery Agent Not Selected"),
             Util.GS("There is no Recovery Agent selected. Encrypted data cannot be recovered later, if passphrase is lost. Do you want to continue?"));
       int rc = dg.Run();
        dg.Hide();
      dg.Destroy();
         if( (ResponseType)rc == ResponseType.Yes )
         {
             status = SetPassPhrase( epd, DomainID, publicKey, simws );
             epd.Hide();
             return status;
         }
         else
         {
             epd.Hide();
             PassphraseHelper( epd, DomainID, simws );
         }
     }
       }
     else
     {
     epd.Hide();
     }
     return true;
 }
 private void OnAddDomainCompleted(object o, EventArgs args)
 {
     AddDomainThread addDomainThread = (AddDomainThread)o;
        DomainInformation dom = addDomainThread.Domain;
        Exception e = addDomainThread.Exception;
        if (dom == null && e != null)
        {
     if (e is DomainAccountAlreadyExistsException)
     {
      iFolderMsgDialog dg = new iFolderMsgDialog(
       this,
       iFolderMsgDialog.DialogType.Error,
       iFolderMsgDialog.ButtonSet.Ok,
       "",
       Util.GS("An account already exists"),
       Util.GS("An account for this server already exists on the local machine.  Only one account per server is allowed."));
      dg.Run();
      dg.Hide();
      dg.Destroy();
     }
     else
     {
      iFolderMsgDialog dg2 = new iFolderMsgDialog(
       this,
       iFolderMsgDialog.DialogType.Error,
       iFolderMsgDialog.ButtonSet.Ok,
       "",
       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."),
       Util.GS(e.Message));
      dg2.Run();
      dg2.Hide();
      dg2.Destroy();
     }
     if (WaitDialog != null)
     {
      WaitDialog.Hide();
      WaitDialog.Destroy();
      WaitDialog = null;
     }
        }
        if (dom == null)
        {
     if (WaitDialog != null)
     {
      WaitDialog.Hide();
      WaitDialog.Destroy();
      WaitDialog = null;
     }
     return;
        }
        switch(dom.StatusCode)
        {
     case StatusCodes.InvalidCertificate:
      if (WaitDialog != null)
      {
       WaitDialog.Hide();
       WaitDialog.Destroy();
       WaitDialog = null;
      }
      string serverName = addDomainThread.ServerName;
      byte[] byteArray = simws.GetCertificate(serverName);
      System.Security.Cryptography.X509Certificates.X509Certificate cert = new System.Security.Cryptography.X509Certificates.X509Certificate(byteArray);
      iFolderMsgDialog dialog = new iFolderMsgDialog(
       this,
       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."), serverName),
       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, serverName);
       OnConnectClicked(o, args);
      }
      break;
     case StatusCodes.Success:
     case StatusCodes.SuccessInGrace:
      if (WaitDialog != null)
      {
       WaitDialog.Hide();
       WaitDialog.Destroy();
       WaitDialog = null;
      }
      string password = addDomainThread.Password;
      bool bRememberPassword = addDomainThread.RememberPassword;
      Status authStatus =
       domainController.AuthenticateDomain(
        dom.ID, password, bRememberPassword);
      if (authStatus != null)
      {
       if (authStatus.statusCode == StatusCodes.Success ||
        authStatus.statusCode == StatusCodes.SuccessInGrace)
       {
        ConnectedDomain = dom;
        AccountDruid.Page = SummaryPage;
        break;
       }
       else
       {
        Util.ShowLoginError(this, authStatus.statusCode);
       }
      }
      else
      {
       Util.ShowLoginError(this, StatusCodes.Unknown);
      }
      break;
     default:
      if (WaitDialog != null)
      {
       WaitDialog.Hide();
       WaitDialog.Destroy();
       WaitDialog = null;
      }
      Util.ShowLoginError(this, dom.StatusCode);
      break;
        }
 }
Example #8
0
 private bool OnValidateCertificate(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
 {
     ts.TraceInformation("OnValidateCertificate {0}", this.Jid.ToString(), certificate.ToString());
     return(true);
 }
Example #9
0
        /// <summary>
        /// Event handler for OK button click event
        /// </summary>
        private void btnOk_Click(object sender, System.EventArgs e)
        {
            // Check for passphrase

            /*	If passphrase is valid try setting the passphrase.
             *	if successful try storing on local place
             *	if success close dialog.
             *	else show dialog again..
             *
             */
            System.Resources.ResourceManager resManager = new System.Resources.ResourceManager(typeof(Connecting));
            if (this.Passphrase.Text == this.RetypePassphrase.Text)
            {
                string publicKey = null;
                string ragent    = null;
                if (this.RecoveryAgentCombo.SelectedItem != null && (string)this.RecoveryAgentCombo.SelectedItem != TrayApp.Properties.Resources.serverDefaultRA)
                {
                    // Show the certificate.....
                    byte[] CertificateObj = this.simws.GetRACertificateOnClient(this.DomainID, (string)this.RecoveryAgentCombo.SelectedItem);
                    System.Security.Cryptography.X509Certificates.X509Certificate cert = new System.Security.Cryptography.X509Certificates.X509Certificate(CertificateObj);
                    //	MyMessageBox mmb = new MyMessageBox( "Verify Certificate", "Verify Certificate", cert.ToString(true), MyMessageBoxButtons.YesNo, MyMessageBoxIcon.Question, MyMessageBoxDefaultButton.Button2 );
                    MyMessageBox mmb = new MyMessageBox(string.Format(resManager.GetString("verifyCert"), (string)this.RecoveryAgentCombo.SelectedItem), resManager.GetString("verifyCertTitle"), cert.ToString(true), MyMessageBoxButtons.YesNo, MyMessageBoxIcon.Question, MyMessageBoxDefaultButton.Button2);
                    DialogResult messageDialogResult = mmb.ShowDialog();
                    mmb.Dispose();
                    mmb.Close();
                    if (messageDialogResult != DialogResult.Yes)
                    {
                        return;
                    }
                    else
                    {
                        ragent    = (string)this.RecoveryAgentCombo.SelectedItem;
                        publicKey = Convert.ToBase64String(cert.GetPublicKey());
                    }
                    //return;
                }

                /*else	// If recovery agent is not selected...
                 * {
                 *      MyMessageBox mmb = new MyMessageBox( resManager.GetString("NoCertWarning"), resManager.GetString("NoCertTitle"), "", MyMessageBoxButtons.YesNo, MyMessageBoxIcon.Question, MyMessageBoxDefaultButton.Button2);
                 *      DialogResult messageDialogResult = mmb.ShowDialog();
                 *      mmb.Dispose();
                 *      mmb.Close();
                 *      if( messageDialogResult != DialogResult.Yes )
                 *              return;
                 * }*/

                else
                {
                    ragent = "DEFAULT";

                    DomainInformation domainInfo = (DomainInformation)this.simws.GetDomainInformation(this.DomainID);
                    string            memberUID  = domainInfo.MemberUserID;
                    try
                    {
                        publicKey = this.ifws.GetDefaultServerPublicKey(this.DomainID, memberUID);
                    }
                    catch (Exception)
                    {
                        Novell.iFolderCom.MyMessageBox mmb = new MyMessageBox(Resource.GetString("PassStoreErr") /*"Unable to set the passphrase"*/, resourceManager.GetString("$this.Text") /*"Error setting the passphrase"*/, "" /*Resource.GetString("TryAgain")*//*"Please try again"*/, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
                        mmb.ShowDialog();
                        mmb.Dispose();
                        return;
                    }
                }
                Status passPhraseStatus = null;
                try

                {
                    passPhraseStatus = simws.SetPassPhrase(DomainID, this.Passphrase.Text, ragent, publicKey);
                }
                catch (Exception ex)
                {
                    //MessageBox.Show("Unable to set Passphrase. "+ ex.Message);
                    MessageBox.Show(Resource.GetString("IsPassphraseSetException") + ex.Message);
                }
                if (passPhraseStatus.statusCode == StatusCodes.Success)
                {
                    // Validating Passphrase
                    //passPhraseStatus = simws.ValidatePassPhrase( DomainID, PadString(this.Passphrase.Text, 16));
                    //if(passPhraseStatus.statusCode != StatusCodes.Success)
                    //	MessageBox.Show("Passphrase not validated");
                    simws.StorePassPhrase(DomainID, this.Passphrase.Text, CredentialType.Basic, this.savePassphrase.Checked);
                    //string passphr = simws.GetPassPhrase(DomainID);
                    //MessageBox.Show("Passphrase is set & stored", passphr, MessageBoxButtons.OK);
                    //this.status= simws.IsPassPhraseSet(DomainID);
                    //if( status == true)
                    status = true;
                    Novell.iFolderCom.MyMessageBox mmb = new MyMessageBox(Resource.GetString("SetPassphraseSuccess") /*"Successfully set the passphrase"*/, resourceManager.GetString("$this.Text"), "", MyMessageBoxButtons.OK, MyMessageBoxIcon.Information);
                    mmb.ShowDialog();
                    mmb.Dispose();
                    this.Dispose();
                    this.Close();
                }
                else
                {
                    // Unable to set the passphrase
                    status = false;
                    Novell.iFolderCom.MyMessageBox mmb = new MyMessageBox(Resource.GetString("PassStoreErr") /*"Unable to set the passphrase"*/, resourceManager.GetString("$this.Text") /*"Error setting the passphrase"*/, "" /*Resource.GetString("TryAgain")*//*"Please try again"*/, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
                    mmb.ShowDialog();
                    mmb.Dispose();
                }
            }
            else
            {
                status = false;
            }
        }
Example #10
0
        }     // End Sub ctr_tree_AfterSelect

        public static void AddLdapObjectAsString(string propertyName, object Iter, System.Windows.Forms.ListViewItem item)
        {
            // lastLogon	        System.__ComObject
            // lastLogoff	        System.__ComObject
            // lastLogonTimestamp	System.__ComObject

            // accountExpires	System.__ComObject
            // badPasswordTime	System.__ComObject
            // pwdLastSet	    System.__ComObject
            // lockoutTime	    System.__ComObject
            // uSNCreated	    System.__ComObject
            // uSNChanged	    System.__ComObject


            // msExchMailboxGuid	            System.Byte[]
            // msExchVersion	                System.__ComObject
            // msExchMailboxSecurityDescriptor	System.__ComObject
            // nTSecurityDescriptor	            System.__ComObject

            if (System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "lastLogon") ||
                System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "lastLogoff") ||
                System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "lastLogonTimestamp")

                || System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "pwdLastSet") ||
                System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "badPasswordTime") ||
                System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "lockoutTime")

                || System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "uSNCreated") ||
                System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "uSNChanged")

                || System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "accountExpires")

                )
            {
                // http://social.technet.microsoft.com/wiki/contents/articles/22461.understanding-the-ad-account-attributes-lastlogon-lastlogontimestamp-and-lastlogondate.aspx
                // http://stackoverflow.com/questions/1602036/how-to-list-all-computers-and-the-last-time-they-were-logged-onto-in-ad
                // http://stackoverflow.com/questions/33274162/the-namespace-of-iadslargeinteger
                // Active DS Type Library

                // System.Console.WriteLine(Iter);
                // System.Console.WriteLine(str);
                try
                {
                    // SecurityDescriptor sd = (SecurityDescriptor)ent.Properties["ntSecurityDescriptor"].Value;
                    // ActiveDs.SecurityDescriptor sd = (ActiveDs.SecurityDescriptor)Iter;

                    // sd.DiscretionaryAcl
                    // ActiveDs.AccessControlList acl = (ActiveDs.AccessControlList)sd.DiscretionaryAcl;


                    //foreach (ActiveDs.AccessControlEntry ace in (System.Collections.IEnumerable)acl)
                    //{
                    //    System.Console.WriteLine("Trustee: {0}", ace.Trustee);
                    //    System.Console.WriteLine("AccessMask: {0}", ace.AccessMask);
                    //    System.Console.WriteLine("Access Type: {0}", ace.AceType);
                    //}



                    // ActiveDs.IADsLargeInteger ISomeAdTime = (ActiveDs.IADsLargeInteger)Iter;
                    // long lngSomeAdTime = (long)ISomeAdTime.HighPart << 32 | (uint)ISomeAdTime.LowPart;

                    // IADsLargeInteger noActiveDsSomeTime = (IADsLargeInteger)Iter;
                    // System.Console.WriteLine(noActiveDsSomeTime);

                    long lngSomeAdTime = ConvertLargeIntegerToLong(Iter);

                    System.DateTime someAdTime = System.DateTime.MaxValue;

                    if (lngSomeAdTime == long.MaxValue || lngSomeAdTime <= 0 || System.DateTime.MaxValue.ToFileTime() <= lngSomeAdTime)
                    {
                        someAdTime = System.DateTime.MaxValue;
                    }
                    else
                    {
                        // someAdTime = System.DateTime.FromFileTime(lngSomeAdTime);
                        someAdTime = System.DateTime.FromFileTimeUtc(lngSomeAdTime).ToLocalTime();
                    }

                    item.SubItems.Add(someAdTime.ToString("dd.MM.yyyy HH:mm:ss"));
                }
                catch (System.Exception ex)
                {
                    item.SubItems.Add(ex.Message + System.Environment.NewLine + Iter.ToString());
                }
            }
            else if (System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "msExchRecipientTypeDetails"))
            {
                try
                {
                    long   lngSomeVersion = ConvertLargeIntegerToLong(Iter);
                    string strVersion     = lngSomeVersion.ToString();
                    // http://memphistech.net/?p=457
                    // https://blogs.technet.microsoft.com/johnbai/2013/09/11/o365-exchange-and-ad-how-msexchrecipientdisplaytype-and-msexchangerecipienttypedetails-relate-to-your-on-premises/

                    switch (lngSomeVersion)
                    {
                    case 1:
                        strVersion = "User Mailbox";
                        break;

                    case 2:
                        strVersion = "Linked Mailbox";
                        break;

                    case 4:
                        strVersion = "Shared Mailbox";
                        break;

                    case 8:
                        strVersion = "Legacy Mailbox";
                        break;

                    case 16:
                        strVersion = "Room Mailbox";
                        break;

                    case 32:
                        strVersion = "Equipment Mailbox";
                        break;

                    case 64:
                        strVersion = "Mail Contact";
                        break;

                    case 128:
                        strVersion = "Mail User";
                        break;

                    case 256:
                        strVersion = "Mail-Enabled Universal Distribution Group";
                        break;

                    case 512:
                        strVersion = "Mail-Enabled Non-Universal Distribution Group";
                        break;

                    case 1024:
                        strVersion = "Mail-Enabled Universal Security Group";
                        break;

                    case 2048:
                        strVersion = "Dynamic Distribution Group";
                        break;

                    case 4096:
                        strVersion = "Public Folder";
                        break;

                    case 8192:
                        strVersion = "System Attendant Mailbox";
                        break;

                    case 16384:
                        strVersion = "System Mailbox";
                        break;

                    case 32768:
                        strVersion = "Cross-Forest Mail Contact";
                        break;

                    case 65536:
                        strVersion = "User";
                        break;

                    case 131072:
                        strVersion = "Contact";
                        break;

                    case 262144:
                        strVersion = "Universal Distribution Group";
                        break;

                    case 524288:
                        strVersion = "Universal Security Group";
                        break;

                    case 1048576:
                        strVersion = "Non-Universal Group";
                        break;

                    case 2097152:
                        strVersion = "Disabled User";
                        break;

                    case 4194304:
                        strVersion = "Microsoft Exchange";
                        break;

                    case 8388608:
                        strVersion = "Arbitration Mailbox";
                        break;

                    case 16777216:
                        strVersion = "Mailbox Plan";
                        break;

                    case 33554432:
                        strVersion = "Linked User";
                        break;

                    case 268435456:
                        strVersion = "Room List";
                        break;

                    case 536870912:
                        strVersion = "Discovery Mailbox";
                        break;

                    case 1073741824:
                        strVersion = "Role Group";
                        break;

                    case 2147483648L:
                        strVersion = "Remote Mailbox";
                        break;

                    case 137438953472L:
                        strVersion = "Team Mailbox";
                        break;

                    default:
                        strVersion = lngSomeVersion.ToString();
                        break;
                    }

                    item.SubItems.Add(strVersion);
                }
                catch (System.Exception ex)
                {
                    item.SubItems.Add(ex.Message + System.Environment.NewLine + Iter.ToString());
                }
            }
            else if (System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "msExchRemoteRecipientType"))
            {
                try
                {
                    System.Int64 lngSomeVersion = System.Convert.ToInt64(Iter);
                    string       strVersion     = lngSomeVersion.ToString();
                    // http://memphistech.net/?p=457
                    // https://blogs.technet.microsoft.com/johnbai/2013/09/11/o365-exchange-and-ad-how-msexchrecipientdisplaytype-and-msexchangerecipienttypedetails-relate-to-your-on-premises/

                    switch (lngSomeVersion)
                    {
                    case 1:
                        strVersion = "ProvisionedMailbox (Cloud MBX)";
                        break;

                    case 2:
                        strVersion = "ProvisionedArchive (Cloud Archive)";
                        break;

                    case 3:
                        strVersion = "ProvisionedMailbox, ProvisionedArchive";
                        // (mailbox provisioned in Cloud & Archive provisioned in Cloud)* either via EMC or new-remotemailbox cmd
                        break;

                    case 4:
                        strVersion = "Migrated mailbox from on-prem";
                        break;

                    case 6:
                        strVersion = "Migrated mailbox from on-prem, ProvisionedArchive in EXO";
                        // (mailbox migrated from on-prem & archive provisioned in Cloud)
                        break;

                    case 16:
                        strVersion = "DeprovisionArchive";
                        break;

                    case 20:
                        strVersion = "DeprovisionArchive, Migrated";
                        break;

                    case 32:
                        strVersion = "RoomMailbox";
                        break;

                    case 36:
                        strVersion = "Migrated, RoomMailbox";
                        break;

                    case 64:
                        strVersion = "EquipmentMailbox";
                        break;

                    case 68:
                        strVersion = "Migrated, EquipmentMailbox";
                        break;

                    case 96:
                        strVersion = "SharedMailbox";
                        break;

                    case 100:
                        strVersion = "Migrated, Shared Mailbox in EXO";
                        break;

                    default:
                        strVersion = lngSomeVersion.ToString();
                        break;
                    }

                    item.SubItems.Add(strVersion);
                }
                catch (System.Exception ex)
                {
                    item.SubItems.Add(ex.Message + System.Environment.NewLine + Iter.ToString());
                }
            }
            else if (System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "msExchRecipientDisplayType"))
            {
                try
                {
                    System.Int64 lngSomeVersion = System.Convert.ToInt64(Iter);
                    string       strVersion     = lngSomeVersion.ToString();
                    // http://memphistech.net/?p=457

                    switch (lngSomeVersion)
                    {
                    case 0:
                        strVersion = "MailboxUser";
                        break;

                    case 1:
                        strVersion = "DistrbutionGroup";
                        break;

                    case 2:
                        strVersion = "PublicFolder";
                        break;

                    case 3:
                        strVersion = "DynamicDistributionGroup";
                        break;

                    case 4:
                        strVersion = "Organization";
                        break;

                    case 5:
                        strVersion = "PrivateDistributionList";
                        break;

                    case 6:
                        strVersion = "RemoteMailUser";
                        break;

                    case 7:
                        strVersion = "ConferenceRoomMailbox";
                        break;

                    case 8:
                        strVersion = "EquipmentMailbox";
                        break;

                    case 1073741824:
                        strVersion = "ACLableMailboxUser";
                        break;

                    case 1043741833:
                        strVersion = "SecurityDistributionGroup";
                        break;

                    case -2147483642:
                        strVersion = "SyncedMailboxUser";
                        break;

                    case -2147483391:
                        strVersion = "SyncedUDGasUDG";
                        break;

                    case -2147483386:
                        strVersion = "SyncedUDGasContact";
                        break;

                    case -2147483130:
                        strVersion = "SyncedPublicFolder";
                        break;

                    case -2147482874:
                        strVersion = "SyncedDynamicDistributionGroup";
                        break;

                    case -2147482106:
                        strVersion = "SyncedRemoteMailUser";
                        break;

                    case -2147481850:
                        strVersion = "SyncedConferenceRoomMailbox";
                        break;

                    case -2147481594:
                        strVersion = "SyncedEquipmentMailbox";
                        break;

                    case -2147481343:
                        strVersion = "SyncedUSGasUDG";
                        break;

                    case -2147481338:
                        strVersion = "SyncedUSGasContact";
                        break;

                    case -1073741818:
                        strVersion = "ACLableSyncedMailboxUser";
                        break;

                    case -1073740282:
                        strVersion = "ACLableSyncedRemoteMailUser";
                        break;

                    case -1073739514:
                        strVersion = "ACLableSyncedUSGasContact";
                        break;

                    case -1073739511:
                        strVersion = "SyncedUSGasUSG";
                        break;

                    default:
                        strVersion = lngSomeVersion.ToString();
                        break;
                    }

                    item.SubItems.Add(strVersion);
                }
                catch (System.Exception ex)
                {
                    item.SubItems.Add(ex.Message + System.Environment.NewLine + Iter.ToString());
                }
            }
            else if (System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "msExchVersion"))
            {
                try
                {
                    long   lngSomeVersion = ConvertLargeIntegerToLong(Iter);
                    string strVersion     = "";

                    // http://blogs.metcorpconsulting.com/tech/?p=1313
                    if (lngSomeVersion < 4535486012416L)
                    {
                        strVersion = "Exchange 2003 and earlier (" + lngSomeVersion.ToString() + ")";
                    }
                    else if (lngSomeVersion == 4535486012416L)
                    {
                        strVersion = "Exchange 2007 (4535486012416)";
                    }
                    else if (lngSomeVersion == 44220983382016L)
                    {
                        strVersion = "Exchange 2010 (44220983382016)";
                    }
                    else
                    {
                        strVersion = lngSomeVersion.ToString();
                    }

                    item.SubItems.Add(strVersion);
                }
                catch (System.Exception ex)
                {
                    item.SubItems.Add(ex.Message + System.Environment.NewLine + Iter.ToString());
                }
            }
            else if (System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "userCertificate")
                     // || System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "mSMQSignCertificates")
                     // || System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "mSMQDigest")
                     )
            {
                System.Security.Cryptography.X509Certificates.X509Certificate cert = new System.Security.Cryptography.X509Certificates.X509Certificate((byte[])Iter);
                item.SubItems.Add(cert.ToString());
            }
            else if (System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "objectSid"))
            {
                System.Security.Principal.SecurityIdentifier sid = new System.Security.Principal.SecurityIdentifier((byte[])Iter, 0);
                item.SubItems.Add(sid.ToString());
            }
            else if (
                System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "objectGUID") ||
                System.StringComparer.OrdinalIgnoreCase.Equals(propertyName, "msExchMailboxGuid")
                )
            {
                System.Guid guid = new System.Guid((byte[])Iter);
                item.SubItems.Add(guid.ToString());
            }
            else if (Iter != null && object.ReferenceEquals(Iter.GetType(), typeof(byte[])))
            {
                byte[] ba = (byte[])Iter;
                item.SubItems.Add("0x" + System.BitConverter.ToString(ba).Replace("-", ""));
            }
            else
            {
                item.SubItems.Add(Iter.ToString());
            }
        } // End Sub AddLdapObjectAsString
 private void OnResetClicked( object o, EventArgs args)
 {
     Debug.PrintLine("Reset clicked");
        string publicKey = null;
        bool reset = false;
        DomainController domainController = DomainController.GetDomainController();
     Status passphraseStatus = simws.ValidatePassPhrase(this.Domain, this.OldPassphrase);
     if( passphraseStatus != null)
     {
         if( passphraseStatus.statusCode == StatusCodes.PassPhraseInvalid)
         {
             iFolderMsgDialog dialog = new iFolderMsgDialog(
                 null,
                 iFolderMsgDialog.DialogType.Error,
                 iFolderMsgDialog.ButtonSet.None,
                 Util.GS("Invalid Passphrase"),
                 Util.GS("The Current PassPhrase entered is not valid"),
                 Util.GS("Please enter the passphrase again"));
             dialog.Run();
             dialog.Hide();
             dialog.Destroy();
             dialog = null;
             return;
         }
     }
        if( this.RAName != null)
        {
     byte [] RACertificateObj = domainController.GetRACertificate(this.Domain, this.RAName);
     if( RACertificateObj != null && RACertificateObj.Length != 0)
     {
      System.Security.Cryptography.X509Certificates.X509Certificate Cert = new System.Security.Cryptography.X509Certificates.X509Certificate(RACertificateObj);
      CertificateDialog dlg = new CertificateDialog(Cert.ToString(true));
      if (!Util.RegisterModalWindow(dlg))
      {
       dlg.Destroy();
       dlg = null;
       return ;
      }
      int res = dlg.Run();
      dlg.Hide();
      dlg.Destroy();
      dlg = null;
      if( res == (int)ResponseType.Ok)
      {
       publicKey = Convert.ToBase64String(Cert.GetPublicKey());
       Debug.PrintLine(String.Format(" The public key is: {0}", publicKey));
       reset = true;
      }
      else
      {
       reset = false;
       Debug.PrintLine("Response type is not ok");
       return;
      }
     }
        }
        else
        {
           iFolderMsgDialog dg = new iFolderMsgDialog(
               this,
               iFolderMsgDialog.DialogType.Warning,
               iFolderMsgDialog.ButtonSet.YesNo,
               "No Recovery Agent",
               Util.GS("Recovery Agent Not Selected"),
               Util.GS("There is no Recovery Agent selected. Encrypted data cannot be recovered later, if passphrase is lost. Do you want to continue?"));
     int rc = dg.Run();
      dg.Hide();
        dg.Destroy();
           if( (ResponseType)rc == ResponseType.Yes )
           {
      reset = true;
           }
           else
           {
      return;
           }
        }
        if( reset == true)
        {
     try
     {
      status = domainController.ReSetPassphrase(this.Domain, this.OldPassphrase, this.NewPassphrase, this.RAName, publicKey);
      simws.StorePassPhrase(this.Domain, "", CredentialType.None, false);
      simws.StorePassPhrase(this.Domain, this.NewPassphrase, CredentialType.Basic, this.SavePassphrase);
     }
     catch(Exception ex)
     {
      throw ex;
     }
        }
        if( status == false)
        {
      iFolderMsgDialog dialog = new iFolderMsgDialog(
                                                                                                        null,
                                                                                                        iFolderMsgDialog.DialogType.Error,
                                                                                                         iFolderMsgDialog.ButtonSet.None,
                                                                                                         Util.GS("Reset Passphrase"),
                                                                                                         Util.GS("Unable to change the Passphrase"),
                                                                     Util.GS("Please try again"));
     dialog.Run();
     dialog.Hide();
     dialog.Destroy();
     dialog = null;
        }
 }
Example #12
0
 private void btnOk_Click(object sender, System.EventArgs e)
 {
     System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(CreateiFolder));
        if( this.Passphrase.Text == this.RetypePassphrase.Text)
        {
     string publicKey = null;
     string ragent = null;
         if (this.RecoveryAgentCombo.SelectedItem != null && (string)this.RecoveryAgentCombo.SelectedItem != resources.GetString("serverDefaultRA"))
         {
             byte[] CertificateObj = this.simws.GetRACertificateOnClient(DomainID, (string)this.RecoveryAgentCombo.SelectedItem);
             System.Security.Cryptography.X509Certificates.X509Certificate cert = new System.Security.Cryptography.X509Certificates.X509Certificate(CertificateObj);
             MyMessageBox mmb = new MyMessageBox(string.Format(resources.GetString("verifyCert"), (string)this.RecoveryAgentCombo.SelectedItem), resources.GetString("verifyCertTitle"), cert.ToString(true), MyMessageBoxButtons.YesNo, MyMessageBoxIcon.Question, MyMessageBoxDefaultButton.Button2);
             DialogResult messageDialogResult = mmb.ShowDialog();
             mmb.Dispose();
             mmb.Close();
             if (messageDialogResult != DialogResult.Yes)
                 return;
             else
             {
                 ragent = this.RecoveryAgentCombo.SelectedText;
                 publicKey = Convert.ToBase64String(cert.GetPublicKey());
             }
         }
         else
         {
             ragent = "DEFAULT";
             DomainInformation domainInfo = (DomainInformation)this.simws.GetDomainInformation(this.DomainID);
             string memberUID = domainInfo.MemberUserID;
             publicKey = this.ifws.GetDefaultServerPublicKey(this.DomainID, memberUID);
         }
     Status passPhraseStatus = null;
     try
     {
      passPhraseStatus = simws.SetPassPhrase( DomainID, this.Passphrase.Text, ragent, publicKey);
     }
     catch(Exception ex)
     {
      MessageBox.Show(resources.GetString("ErrorSetPP") + ex.Message);
     }
     if(passPhraseStatus.statusCode == StatusCodes.Success)
     {
      simws.StorePassPhrase( DomainID, this.Passphrase.Text, CredentialType.Basic, this.savePassphrase.Checked);
      string passphr = simws.GetPassPhrase(DomainID);
      this.status= simws.IsPassPhraseSet(DomainID);
      if( status == true)
      {
       Novell.iFolderCom.MyMessageBox mmb = new MyMessageBox(resources.GetString("SetPPSuccess") , resources.GetString("EnterPPTitle") , "",MyMessageBoxButtons.OK, MyMessageBoxIcon.Information);
       mmb.ShowDialog();
       mmb.Dispose();
       this.Dispose();
       this.Close();
      }
     }
     else
     {
      status = false;
      Novell.iFolderCom.MyMessageBox mmb = new MyMessageBox(resources.GetString("ErrorSetPP") , resources.GetString("EnterPPTitle") , resources.GetString("TryAgain") , MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
      mmb.ShowDialog();
      mmb.Dispose();
     }
        }
        else
        {
     MessageBox.Show(resources.GetString("PPSDontMatch") );
     status = false;
        }
 }
Example #13
0
        /// <summary>
        /// Event handler for Reset button click event
        /// </summary>
        private void btnReset_Click(object sender, System.EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                DomainItem domainItem = (DomainItem)this.DomainComboBox.SelectedItem;
                this.domainID = domainItem.ID;
                System.Resources.ResourceManager resManager = new System.Resources.ResourceManager(typeof(Connecting));
                string publicKey = null;
                string ragent    = null;

                //Check whether the current/old passphrase is valid before reseting the passphrase
                Status status = null;
                try
                {
                    status = simws.ValidatePassPhrase(this.domainID, this.passPhrase.Text);
                }
                catch (Exception ex)
                {
                    System.Resources.ResourceManager resMgr = new System.Resources.ResourceManager(typeof(VerifyPassphraseDialog));
                    MessageBox.Show(resMgr.GetString("ValidatePPError") /*"Unable to validate the Passphrase. {0}"*/, ex.Message);
                }
                if (status.statusCode == StatusCodes.PassPhraseInvalid)
                {
                    Cursor.Current = Cursors.Default;
                    MessageBox.Show(Resource.GetString("InvalidCurrentPPText") /*"Error resetting passphrase"*/, Resource.GetString("ResetTitle") /*"reset error"*/);
                    this.success = false;
                    return;
                }

                if (status.statusCode == StatusCodes.ServerUnAvailable)
                {
                    Cursor.Current = Cursors.Default;
                    MessageBox.Show(Resource.GetString("NoLoggedInDomainsText") /*"Error resetting passphrase"*/, Resource.GetString("ResetTitle") /*"reset error"*/);
                    this.success = false;
                    return;
                }

                if (this.recoveryAgentCombo.SelectedItem != null && (string)this.recoveryAgentCombo.SelectedItem != TrayApp.Properties.Resources.serverDefaultRA)
                {
                    // Show the certificate.....
                    byte[] CertificateObj = this.simws.GetRACertificateOnClient(this.DomainID, (string)this.recoveryAgentCombo.SelectedItem);
                    System.Security.Cryptography.X509Certificates.X509Certificate cert = new System.Security.Cryptography.X509Certificates.X509Certificate(CertificateObj);
                    MyMessageBox mmb = new MyMessageBox(string.Format(resManager.GetString("verifyCert"), (string)this.recoveryAgentCombo.SelectedItem), resManager.GetString("verifyCertTitle"), cert.ToString(true), MyMessageBoxButtons.YesNo, MyMessageBoxIcon.Question, MyMessageBoxDefaultButton.Button2);
                    DialogResult messageDialogResult = mmb.ShowDialog();
                    mmb.Dispose();
                    mmb.Close();
                    if (messageDialogResult != DialogResult.Yes)
                    {
                        return;
                    }
                    else
                    {
                        ragent    = (string)this.recoveryAgentCombo.SelectedItem;
                        publicKey = Convert.ToBase64String(cert.GetPublicKey());
                    }
                }

                /*else	// If recovery agent is not selected...
                 * {
                 *  MyMessageBox mmb = new MyMessageBox( resManager.GetString("NoCertWarning"), resManager.GetString("NoCertTitle"), "", MyMessageBoxButtons.YesNo, MyMessageBoxIcon.Question, MyMessageBoxDefaultButton.Button2);
                 *  DialogResult messageDialogResult = mmb.ShowDialog();
                 *  mmb.Dispose();
                 *  mmb.Close();
                 *  if( messageDialogResult != DialogResult.Yes )
                 *      return;
                 * }*/

                else
                {
                    ragent = "DEFAULT";
                    //DomainInformation domainInfo = new DomainInformation(this.domainID);
                    DomainInformation domainInfo = (DomainInformation)this.simws.GetDomainInformation(this.DomainID);
                    string            memberUID  = domainInfo.MemberUserID;
                    publicKey = this.ifws.GetDefaultServerPublicKey(this.DomainID, memberUID);
                }

                status = this.simws.ReSetPassPhrase(this.DomainID, this.passPhrase.Text, this.newPassphrase.Text, ragent, publicKey);
                if (status.statusCode == StatusCodes.Success)
                {
                    //clear the values
                    simws.StorePassPhrase(this.DomainID, "", CredentialType.None, false);
                    //set the values
                    simws.StorePassPhrase(this.DomainID, this.newPassphrase.Text, CredentialType.Basic, this.rememberPassphrase.Checked);

                    MyMessageBox mb = new MyMessageBox(string.Format(Resource.GetString("ResetSuccess")), Resource.GetString("ResetTitle"), "", MyMessageBoxButtons.OK, MyMessageBoxIcon.Information);
                    mb.ShowDialog();
                    mb.Dispose();
                    this.success = true;
                    this.Dispose();
                    this.Close();
                }
                else
                {
                    MessageBox.Show(Resource.GetString("ResetError") /*"Error resetting passphrase"*/, Resource.GetString("ResetTitle") /*"reset error"*/);
                    this.success = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(Resource.GetString("ResetError") /*"Error resetting passphrase"*/, Resource.GetString(ex.Message) /*"reset error"*/);
                this.success = false;
            }
            Cursor.Current = Cursors.Default;
        }
Example #14
0
 private void OnValidateClicked(object o, EventArgs args)
 {
     bool NextPage = true;
        string publicKey = null;
       try {
       if ( !PassPhraseSet )
        {
        if (PassPhraseEntry.Text == PassPhraseVerifyEntry.Text)
     {
      string recoveryAgentName = "";
      TreeSelection tSelect = RATreeView.Selection;
      if(tSelect != null && tSelect.CountSelectedRows() == 1)
      {
       TreeModel tModel;
       TreeIter iter;
       tSelect.GetSelected(out tModel, out iter);
       recoveryAgentName = (string) tModel.GetValue(iter, 0);
       if(recoveryAgentName == Util.GS("None"))
        recoveryAgentName = null;
      }
      if( recoveryAgentName != null && recoveryAgentName != Util.GS("None"))
      {
       byte [] RACertificateObj = domainController.GetRACertificate((domains[domainList.Active]).ID, recoveryAgentName);
       if( RACertificateObj != null && RACertificateObj.Length != 0)
       {
        System.Security.Cryptography.X509Certificates.X509Certificate Cert = new System.Security.Cryptography.X509Certificates.X509Certificate(RACertificateObj);
        CertificateDialog dlg = new CertificateDialog(Cert.ToString(true));
        int res = dlg.Run();
        dlg.Hide();
        dlg.Destroy();
        dlg = null;
        if( res == (int)ResponseType.Ok)
        {
     publicKey = Convert.ToBase64String(Cert.GetPublicKey());
     Debug.PrintLine(String.Format(" The public key is: {0}", publicKey));
        }
        else
        {
     Debug.PrintLine("Response type is not ok");
                             simws.StorePassPhrase((domains[domainList.Active]).ID, "", CredentialType.None, false);
     NextPage = false;
        }
       }
      }
      if( NextPage)
      {
      Status passPhraseStatus = simws.SetPassPhrase ((domains[domainList.Active]).ID, PassPhraseEntry.Text, recoveryAgentName, publicKey);
       if(passPhraseStatus.statusCode == StatusCodes.Success)
       {
        simws.StorePassPhrase( (domains[domainList.Active]).ID, PassPhraseEntry.Text,
     CredentialType.Basic, RememberPassPhraseCheckButton.Active);
       }
       else
       {
      iFolderMsgDialog dialog = new iFolderMsgDialog(
                                          null,
                                          iFolderMsgDialog.DialogType.Error,
                                          iFolderMsgDialog.ButtonSet.None,
                                          Util.GS("Error setting the passphrase"),
                                          Util.GS("Unable to change the Passphrase"),
                                           Util.GS("Please try again"));
                                  dialog.Run();
                                  dialog.Hide();
                                  dialog.Destroy();
                                  dialog = null;
        NextPage = false;
       }
      }
     } else {
        iFolderMsgDialog dialog = new iFolderMsgDialog(
                                        null,
                                        iFolderMsgDialog.DialogType.Error,
                                        iFolderMsgDialog.ButtonSet.None,
                                        Util.GS("Passphrase mismatch"),
                                        Util.GS("The passphrase and retyped passphrase are not same"),
                                        Util.GS("Please enter the passphrase again"));
                                dialog.Run();
                                dialog.Hide();
                                dialog.Destroy();
                                dialog = null;
      NextPage = false;
     }
        } else {
        Status validationStatus = domainController.ValidatePassPhrase ((domains[domainList.Active]).ID, PassPhraseEntry.Text );
     if (validationStatus.statusCode == StatusCodes.PassPhraseInvalid )
     {
      NextPage = false;
        iFolderMsgDialog dialog = new iFolderMsgDialog(
                                        null,
                                        iFolderMsgDialog.DialogType.Error,
                                        iFolderMsgDialog.ButtonSet.None,
                                        Util.GS("PassPhrase Invalid"),
                                        Util.GS("The PassPhrase entered is not valid"),
                                        Util.GS("Please enter the passphrase again"));
                                dialog.Run();
                                dialog.Hide();
                                dialog.Destroy();
                                dialog = null;
     }
     else if(validationStatus.statusCode == StatusCodes.Success )
                          domainController.StorePassPhrase( (domains[domainList.Active]).ID, PassPhraseEntry.Text,
       CredentialType.Basic, RememberPassPhraseCheckButton.Active);
        }
       }
        catch (Exception ex)
        {
     iFolderMsgDialog dialog = new iFolderMsgDialog(
                                           null,
                                           iFolderMsgDialog.DialogType.Error,
                                           iFolderMsgDialog.ButtonSet.None,
                                           Util.GS("Unable to set the passphrase"),
                                           Util.GS(ex.Message),
                                           Util.GS("Please enter the passphrase again"));
     dialog.Run();
     dialog.Hide();
     dialog.Destroy();
     dialog = null;
     NextPage = false;
       }
        if( NextPage == false)
        {
     Debug.PrintLine("In the same page");
     AccountDruid.Page = UserInformationPage;
        }
 }
Example #15
0
        /// <summary>
        /// Event handler for Domain Login COmpleted
        /// </summary>
        private void OnDomainLoginCompleted(object o, DomainLoginCompletedArgs args)
        {
            if (WaitDialog != null)
            {
                WaitDialog.Hide();
                WaitDialog.Destroy();
                WaitDialog = null;
            }

            Status authStatus = args.AuthenticationStatus;

            if (authStatus != null)
            {
                switch (authStatus.statusCode)
                {
                case StatusCodes.Success:
                case StatusCodes.SuccessInGrace:
                    if (LoginDialog != null)
                    {
                        LoginDialog.Hide();
                        LoginDialog.Destroy();
                        LoginDialog = null;
                    }
                    // Check if any recovery agent present;
                    // if( domainController.GetRAList(args.DomainID) == null)
                    // {
                    // No recovery agent present;
                    //		return;
                    // }
                    ShowClientUpgradeMessageBox();
                    iFolderWebService ifws = DomainController.GetiFolderService();
                    int policy             = ifws.GetSecurityPolicy(args.DomainID);
                    if (policy % 2 == 0)
                    {
                        break;
                    }
                    bool passphraseStatus = simws.IsPassPhraseSet(args.DomainID);
                    if (passphraseStatus == true)
                    {
                        bool rememberOption = simws.GetRememberOption(args.DomainID);
                        if (rememberOption == false)
                        {
                            ShowVerifyDialog(args.DomainID, simws);
                        }
                        else
                        {
                            Debug.PrintLine(" remember Option true. Checking for passphrase existence");
                            string passphrasecheck = simws.GetPassPhrase(args.DomainID);
                            if (passphrasecheck == null || passphrasecheck == "")
                            {
                                Debug.PrintLine("BugBug: Passphrase doesn't exist");
                                ShowVerifyDialog(args.DomainID, simws);
                            }
                        }
                    }
                    else
                    {
                        iFolderWindow.ShowEnterPassPhraseDialog(args.DomainID, simws);
                    }

//						string[] array = domainController.GetRAList( args.DomainID);
                    iFolderData ifdata = iFolderData.GetData();
                    ifdata.Refresh();
                    UpdateWidgetSensitivity();
                    break;

                case StatusCodes.InvalidCertificate:
                    DomainInformation dom = domainController.GetDomain(args.DomainID);
                    if (authStatus.UserName != null)
                    {
                        dom.Host = authStatus.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 = new Gdk.Pixbuf(Util.ImagesPath("ifolder-application-x-x509-ca-cert_48.png"));
                    if (certPixbuf != null && dialog.Image != null)
                    {
                        dialog.Image.Pixbuf = certPixbuf;
                    }

                    int rc = dialog.Run();
                    dialog.Hide();
                    dialog.Destroy();
                    if (rc == -8)                            // User clicked the Yes button
                    {
                        simws.StoreCertificate(byteArray, dom.Host);
                        LoginDialog.Respond(Gtk.ResponseType.Ok);
                    }
                    else
                    {
                        LoginDialog.Respond(Gtk.ResponseType.Cancel);
                    }
                    break;

                case StatusCodes.UserAlreadyMoved:
                    LoginDialog.Respond(Gtk.ResponseType.Ok);
                    break;

                default:
                    Util.ShowLoginError(topLevelWindow, authStatus.statusCode);

                    if (LoginDialog != null)
                    {
                        LoginDialog.Present();
                    }

                    UpdateDomainStatus(args.DomainID);
                    break;
                }
                //UpdateiFolderWindowOnLoginComplete();
            }
            else
            {
                Util.ShowLoginError(topLevelWindow, StatusCodes.Unknown);

                if (LoginDialog != null)
                {
                    LoginDialog.Present();
                }

                UpdateDomainStatus(args.DomainID);
            }

            iFolderWindow ifwin = Util.GetiFolderWindow();

            ifwin.UpdateServerInfoForSelectedDomain();
            ifwin.UpdateListViewItems();
        }
Example #16
0
 private bool login()
 {
     bool result = false;
        DomainAuthentication domainAuth = new DomainAuthentication("iFolder", domainInfo.ID, password);
     string HostUrl = domainInfo.Host;
        Status authStatus = domainAuth.Authenticate(simiasManager.WebServiceUri, simiasManager.DataPath);
        switch (authStatus.statusCode)
        {
     case StatusCodes.InvalidCertificate:
             if (authStatus.UserName != null)
                 domainInfo.Host = authStatus.UserName;
             byte[] byteArray = simiasWebService.GetCertificate(domainInfo.Host);
      System.Security.Cryptography.X509Certificates.X509Certificate cert = new System.Security.Cryptography.X509Certificates.X509Certificate(byteArray);
      BeginInvoke( displayMessageDelegate,
                 new object[] { string.Format(resourceManager.GetString("verifyCert"), domainInfo.Host), resourceManager.GetString("verifyCertTitle"), cert.ToString(true), MyMessageBoxButtons.YesNo, MyMessageBoxIcon.Question, MyMessageBoxDefaultButton.Button2 });
      messageEvent.WaitOne();
      if ( messageDialogResult == DialogResult.Yes )
      {
                 simiasWebService.StoreCertificate(byteArray, domainInfo.Host);
       result = login();
      }
      break;
     case StatusCodes.Success:
     case StatusCodes.SuccessInGrace:
      result = true;
      if (authStatus.statusCode.Equals(StatusCodes.SuccessInGrace))
      {
       BeginInvoke( displayMessageDelegate,
        new object[] { string.Format(resourceManager.GetString("graceLogin"), authStatus.RemainingGraceLogins),
     resourceManager.GetString("graceLoginTitle"),
     string.Empty,
     MyMessageBoxButtons.OK,
     MyMessageBoxIcon.Information, MyMessageBoxDefaultButton.Button1 } );
       messageEvent.WaitOne();
      }
      if ( updatePasswordPreference )
      {
       try
       {
        if ( rememberPassword )
        {
     simiasWebService.SetDomainCredentials( domainInfo.ID, password, CredentialType.Basic );
        }
        else
        {
     simiasWebService.SetDomainCredentials( domainInfo.ID, null, CredentialType.None );
        }
       }
       catch (Exception ex)
       {
        BeginInvoke( displayMessageDelegate,
     new object[] { resourceManager.GetString("savePasswordError"), string.Empty, ex.Message, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 } );
        messageEvent.WaitOne();
       }
      }
      break;
     case StatusCodes.InvalidCredentials:
     case StatusCodes.InvalidPassword:
     case StatusCodes.UnknownUser:
      BeginInvoke( displayMessageDelegate,
       new object[] { resourceManager.GetString("failedAuth"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 } );
      messageEvent.WaitOne();
      break;
     case StatusCodes.AccountDisabled:
      BeginInvoke( displayMessageDelegate,
       new object[] { resourceManager.GetString("accountDisabled"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 } );
      messageEvent.WaitOne();
      break;
     case StatusCodes.AccountLockout:
      BeginInvoke( displayMessageDelegate,
       new object[] { resourceManager.GetString("accountLockout"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 } );
      messageEvent.WaitOne();
      break;
     case StatusCodes.SimiasLoginDisabled:
      BeginInvoke( displayMessageDelegate,
       new object[] { resourceManager.GetString("iFolderAccountDisabled"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 } );
      messageEvent.WaitOne();
      break;
         case StatusCodes.UserAlreadyMoved:
                 result = login();
             break;
     default:
      BeginInvoke( displayMessageDelegate,
       new object[] { resourceManager.GetString("serverConnectError"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 } );
      messageEvent.WaitOne();
      break;
        }
        return result;
 }
Example #17
0
        /// <summary>
        /// Event Handler for next click event
        /// </summary>
        private void next_Click(object sender, System.EventArgs e)
        {
            // Check if we're on the last page.
            if (currentIndex == (maxPages - 1))
            {
                // Exit
                return;
            }

            System.Resources.ResourceManager resManager = new System.Resources.ResourceManager(typeof(Connecting));

            if (currentIndex == 3)             // Set Passphrase
            {
                if (this.passphrasePage.Passphrase != this.passphrasePage.RetypePassphrase)
                {
                    MessageBox.Show(Resource.GetString("TypeRetypeMisMatch"));
                }
                else
                {
                    string publicKey = "";
                    string ragent    = null;
                    if (this.passphrasePage.RecoveryAgent != null && this.passphrasePage.RecoveryAgent != "None")
                    {
                        // Show the certificate.....
                        byte[] CertificateObj = this.simws.GetRACertificateOnClient(this.identityPage.domain.ID, this.passphrasePage.RecoveryAgent);
                        System.Security.Cryptography.X509Certificates.X509Certificate cert = new System.Security.Cryptography.X509Certificates.X509Certificate(CertificateObj);
                        //	MyMessageBox mmb = new MyMessageBox( "Verify Certificate", "Verify Certificate", cert.ToString(true), MyMessageBoxButtons.YesNo, MyMessageBoxIcon.Question, MyMessageBoxDefaultButton.Button2 );
                        MyMessageBox mmb = new MyMessageBox(string.Format(resManager.GetString("verifyCert"), this.passphrasePage.RecoveryAgent), resManager.GetString("verifyCertTitle"), cert.ToString(true), MyMessageBoxButtons.YesNo, MyMessageBoxIcon.Question, MyMessageBoxDefaultButton.Button2);
                        DialogResult messageDialogResult = mmb.ShowDialog();
                        mmb.Dispose();
                        mmb.Close();
                        if (messageDialogResult != DialogResult.OK)
                        {
                            return;
                        }
                        else
                        {
                            ragent    = this.passphrasePage.RecoveryAgent;
                            publicKey = Convert.ToBase64String(cert.GetPublicKey());
                        }
                    }
                    Status passPhraseStatus = null;
                    try
                    {
                        passPhraseStatus = this.simiasWebService.SetPassPhrase(this.identityPage.domain.ID, this.passphrasePage.Passphrase, null, publicKey);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(Resource.GetString("IsPassphraseSetException") + ex.Message);
                        return;
                    }
                    if (passPhraseStatus.statusCode == StatusCodes.Success)
                    {
                        this.simiasWebService.StorePassPhrase(this.identityPage.domain.ID, this.passphrasePage.Passphrase, CredentialType.Basic, this.passphrasePage.RememberPassphrase);
                        Novell.iFolderCom.MyMessageBox mmb = new MyMessageBox(Resource.GetString("SetPassphraseSuccess") /*"Successfully set the passphrase"*/, "", "", MyMessageBoxButtons.OK, MyMessageBoxIcon.Information);
                        mmb.ShowDialog();
                        mmb.Dispose();
                        this.Dispose();
                        this.Close();
                    }
                    else
                    {
                        // Unable to set the passphrase
                        Novell.iFolderCom.MyMessageBox mmb = new MyMessageBox(Resource.GetString("IsPassphraseSetException") /*"Unable to set the passphrase"*/, "" /*"Error setting the passphrase"*/, "" /*Resource.GetString("TryAgain")*//*"Please try again"*/, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
                        mmb.ShowDialog();
                        mmb.Dispose();
                        return;
                    }
                }
            }
            else if (currentIndex == 4)           // Validate passphrase
            {
                Status passPhraseStatus = null;
                try
                {
                    passPhraseStatus = this.simiasWebService.ValidatePassPhrase(this.identityPage.domain.ID, this.passphraseVerifyPage.Passphrase);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(resManager.GetString("ValidatePPError") /*"Unable to validate the Passphrase. {0}"*/, ex.Message);
                    return;
                }
                if (passPhraseStatus != null)
                {
                    if (passPhraseStatus.statusCode == StatusCodes.PassPhraseInvalid)                      // check for invalid passphrase
                    {
                        Novell.iFolderCom.MyMessageBox mmb = new MyMessageBox(Resource.GetString("InvalidPPText") /*"Invalid the passphrase"*/, Resource.GetString("VerifyPP") /*"Passphrase Invalid"*/, "" /*Resource.GetString("TryAgain")*//*"Please try again"*/, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
                        mmb.ShowDialog();
                        mmb.Dispose();
                        return;
                    }
                    else if (passPhraseStatus.statusCode == StatusCodes.Success)
                    {
                        try
                        {
                            this.simiasWebService.StorePassPhrase(this.identityPage.domain.ID, this.passphraseVerifyPage.Passphrase, CredentialType.Basic, this.passphraseVerifyPage.RememberPassphrase);
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Unable to store Passphrase");
                            return;
                        }
                    }
                }
            }

            int nextIndex = this.pages[currentIndex].ValidatePage(currentIndex);

            if (nextIndex == 4)
            {
                // Set the passphrase
                nextIndex = 5;
            }
            else if (nextIndex == 3)
            {
                if (this.identityPage.Encrypion == false)
                {
                    // if 2.x is encrypted make a prompt
                    if (this.encryptedOriginal == true)
                    {
                        MyMessageBox mmb1 = new MyMessageBox(Resource.GetString("EncryptTotext"), Resource.GetString("MigrationAlert"), "", MyMessageBoxButtons.YesNo, MyMessageBoxIcon.Warning, MyMessageBoxDefaultButton.Button1);
                        DialogResult res  = mmb1.ShowDialog();
                        if (res == DialogResult.No)
                        {
                            nextIndex = currentIndex;
                        }
                        else
                        {
                            nextIndex = 5;
                        }
                    }
                    else
                    {
                        nextIndex = 5;
                    }
                }
                else                 // encryption selected..
                {
                    try
                    {
                        string passphrasecheck = this.simiasWebService.GetPassPhrase(this.identityPage.domain.ID);
                        if (passphrasecheck != null && passphrasecheck != "")
                        {
                            Status status = this.simiasWebService.ValidatePassPhrase(this.identityPage.domain.ID, passphrasecheck);
                            if (status != null && status.statusCode == StatusCodes.Success)
                            {
                                // Passphrase validated.
                                nextIndex = 5;
                            }
                        }
                        else if (this.simiasWebService.IsPassPhraseSet(this.identityPage.domain.ID) == true)
                        {
                            //MessageBox.Show("passphrase set");
                            nextIndex = 4;
                        }
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Unable to get passphrase. \nLogin to the domain and try again.");
                        // Stay in the same page
                        nextIndex = currentIndex;
                    }
                }
            }

            if (nextIndex != currentIndex)
            {
                this.pages[currentIndex].DeactivatePage();
                this.pages[nextIndex].ActivatePage(currentIndex);
                if (nextIndex == 5)
                {
                    this.pages[nextIndex].PreviousIndex = 2;
                }

                currentIndex = nextIndex;

                if (currentIndex == (maxPages - 2))
                {
                    next.Text = Resource.GetString("MigrateText");
                    this.verifyPage.UpdateDetails();
                }
                else if (currentIndex == (maxPages - 1))
                {
                    // We're on the completion page ... change the Next
                    // button to a Finish button.
                    next.DialogResult = DialogResult.OK;
                    next.Text         = Resource.GetString("FinishText");            //"&Finish";
                }
            }
        }
Example #18
0
 private bool OnValidateClicked(object o, EventArgs args)
 {
     bool NextPage = true;
        string publicKey = null;
        string memberUID = null;
        iFolderData ifdata = iFolderData.GetData();
        try
        {
     if ( PassPhraseSet ==false )
     {
      if (PassPhraseEntry.Text != PassPhraseVerifyEntry.Text)
      {
       iFolderMsgDialog dialog = new iFolderMsgDialog(
        null,
        iFolderMsgDialog.DialogType.Error,
        iFolderMsgDialog.ButtonSet.None,
        Util.GS("Passphrase mismatch"),
        Util.GS("The passphrase and retyped passphrase are not same"),
        Util.GS("Please enter the passphrase again"));
        dialog.Run();
        dialog.Hide();
        dialog.Destroy();
        dialog = null;
        NextPage = false;
      }
      else
      {
       string recoveryAgentName = null;
       TreeSelection tSelect = RATreeView.Selection;
       if(tSelect != null && tSelect.CountSelectedRows() == 1)
       {
        TreeModel tModel;
        TreeIter iter;
        tSelect.GetSelected(out tModel, out iter);
        recoveryAgentName = (string) tModel.GetValue(iter, 0);
       }
       if( recoveryAgentName != null && recoveryAgentName != Util.GS("Server_Default") )
       {
        byte [] RACertificateObj = domainController.GetRACertificate(ConnectedDomain.ID, recoveryAgentName);
        if( RACertificateObj != null && RACertificateObj.Length != 0)
        {
     System.Security.Cryptography.X509Certificates.X509Certificate Cert = new System.Security.Cryptography.X509Certificates.X509Certificate(RACertificateObj);
     CertificateDialog dlg = new CertificateDialog(Cert.ToString(true));
     int res = dlg.Run();
     dlg.Hide();
     dlg.Destroy();
     dlg = null;
     if( res == (int)ResponseType.Ok)
     {
      publicKey = Convert.ToBase64String(Cert.GetPublicKey());
      Debug.PrintLine(String.Format(" The public key is: {0}", publicKey));
     }
     else
     {
      Debug.PrintLine("Response type is not ok");
         simws.StorePassPhrase(ConnectedDomain.ID, "", CredentialType.None, false);
      NextPage = false;
     }
        }
       }
        else
        {
     recoveryAgentName = "DEFAULT";
     DomainInformation domainInfo = (DomainInformation)this.simws.GetDomainInformation(ConnectedDomain.ID);
     memberUID = domainInfo.MemberUserID;
     iFolderWebService ifws = DomainController.GetiFolderService();
     try{
      publicKey = ifws.GetDefaultServerPublicKey(ConnectedDomain.ID,memberUID);
     }
     catch
     {
      return false;
     }
        }
       if( NextPage)
       {
        Status passPhraseStatus = simws.SetPassPhrase (ConnectedDomain.ID, PassPhraseEntry.Text, recoveryAgentName, publicKey);
        if(passPhraseStatus.statusCode == StatusCodes.Success)
        {
     simws.StorePassPhrase( ConnectedDomain.ID, PassPhraseEntry.Text,
      CredentialType.Basic, RememberPassPhraseCheckButton.Active);
     this.passPhraseEntered = true;
     if( this.waitForPassphrase == true)
     {
      if( upload == true)
      {
       return CreateDefaultiFolder();
      }
      else
      {
       return DownloadiFolder();
      }
     }
        }
        else
        {
       iFolderMsgDialog dialog = new iFolderMsgDialog(
         null,
         iFolderMsgDialog.DialogType.Error,
         iFolderMsgDialog.ButtonSet.None,
         Util.GS("Error setting the passphrase"),
         Util.GS("Unable to set the passphrase"),
         Util.GS("Please try again"));
         dialog.Run();
         dialog.Hide();
         dialog.Destroy();
         dialog = null;
         NextPage = false;
        }
       }
      }
     }
     else
     {
      Debug.PrintLine("Validating passphrase");
      Status validationStatus = domainController.ValidatePassPhrase (ConnectedDomain.ID, PassPhraseEntry.Text );
      if (validationStatus.statusCode == StatusCodes.PassPhraseInvalid )
      {
       NextPage = false;
       iFolderMsgDialog dialog = new iFolderMsgDialog(
       null,
       iFolderMsgDialog.DialogType.Error,
       iFolderMsgDialog.ButtonSet.None,
       Util.GS("PassPhrase Invalid"),
       Util.GS("The PassPhrase entered is not valid"),
       Util.GS("Please enter the passphrase again"));
       dialog.Run();
       dialog.Hide();
       dialog.Destroy();
       dialog = null;
      }
      else if(validationStatus.statusCode == StatusCodes.Success )
      {
       Debug.PrintLine("Success. storing passphrase");
       domainController.StorePassPhrase( ConnectedDomain.ID, PassPhraseEntry.Text,
     CredentialType.Basic, RememberPassPhraseCheckButton.Active);
       this.passPhraseEntered = true;
       if( this.waitForPassphrase == true)
       {
        if( upload == true)
        {
     return CreateDefaultiFolder();
        }
        else
        {
     return DownloadiFolder();
        }
       }
      }
     }
        }
        catch (Exception ex)
        {
     iFolderMsgDialog dialog = new iFolderMsgDialog(
     null,
     iFolderMsgDialog.DialogType.Error,
     iFolderMsgDialog.ButtonSet.None,
     Util.GS("Unable to set the passphrase"),
     Util.GS(ex.Message),
     Util.GS("Please enter the passphrase again"));
     dialog.Run();
     dialog.Hide();
     dialog.Destroy();
     dialog = null;
     NextPage = false;
        }
        if( NextPage == false)
        {
     Debug.PrintLine("In the same page");
     AccountDruid.Page = RAPage;
     return false;
        }
        BackButton.Label = Util.GS("gtk-go-back");
        return true;
 }
 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;
        }
 }
Example #20
0
 private void OnAddDomainCompleted(object o, EventArgs args)
 {
     AddDomainThread addDomainThread = (AddDomainThread)o;
        DomainInformation dom = addDomainThread.Domain;
        string serverName = addDomainThread.ServerName;
        Exception e = addDomainThread.Exception;
        Gdk.Pixbuf certPixbuf1 = new Gdk.Pixbuf(Util.ImagesPath("ifolder-application-x-x509-ca-cert_48.png"));
        if (dom == null && e != null)
        {
     if (e is DomainAccountAlreadyExistsException)
     {
      iFolderMsgDialog dg = new iFolderMsgDialog(
       this,
       iFolderMsgDialog.DialogType.Error,
       iFolderMsgDialog.ButtonSet.Ok,
       "",
       Util.GS("An account already exists"),
       Util.GS("An account for this server already exists on the local machine.  Only one account per server is allowed."));
      dg.Run();
      dg.Hide();
      dg.Destroy();
     }
     else
     {
      iFolderMsgDialog dg2 = new iFolderMsgDialog(
       this,
       iFolderMsgDialog.DialogType.Error,
       iFolderMsgDialog.ButtonSet.Ok,
       "",
       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."),
       Util.GS(String.Format("Msg {0} \n Stack {1}", e.Message, e.StackTrace)));
      dg2.Run();
      dg2.Hide();
      dg2.Destroy();
     }
     if (WaitDialog != null)
     {
      WaitDialog.Hide();
      WaitDialog.Destroy();
      WaitDialog = null;
     }
        }
        if (dom == null)
        {
     if (WaitDialog != null)
     {
      WaitDialog.Hide();
      WaitDialog.Destroy();
      WaitDialog = null;
     }
     return;
        }
        switch(dom.StatusCode)
        {
     case StatusCodes.InvalidCertificate:
      if (WaitDialog != null)
      {
       WaitDialog.Hide();
       WaitDialog.Destroy();
       WaitDialog = null;
      }
      serverName = (dom.HostUrl != null) ? dom.HostUrl : addDomainThread.ServerName;
      CertificateProblem certprob;
      byte[] byteArray = simws.GetCertificate2(serverName, out certprob);
      System.Security.Cryptography.X509Certificates.X509Certificate cert = new System.Security.Cryptography.X509Certificates.X509Certificate(byteArray);
      if(CertPolicy.CertificateProblem.CertEXPIRED.Equals(certprob))
      {
       iFolderMsgDialog dialog1 = new iFolderMsgDialog(
        this,
        iFolderMsgDialog.DialogType.Question,
        iFolderMsgDialog.ButtonSet.YesNo,
        Util.GS("Unable to Verify Identity"),
        Util.GS("Expired!"),
        string.Format(Util.GS("Certificate Expired! for \"{0}\" iFolder server.  You should examine this server's identity certificate carefully.Do you still want to continue?"), serverName),
        cert.ToString(true));
       if (certPixbuf1 != null && dialog1.Image != null)
        dialog1.Image.Pixbuf = certPixbuf1;
       int rc1 = dialog1.Run();
       dialog1.Hide();
       dialog1.Destroy();
       if(rc1 == 8)
       {
        iFolderMsgDialog dialog = new iFolderMsgDialog(
     this,
     iFolderMsgDialog.DialogType.Question,
     iFolderMsgDialog.ButtonSet.YesNo,
     Util.GS("Unable to Verify Identity"),
     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."), serverName),
     cert.ToString(true));
        if (certPixbuf1 != null && dialog.Image != null)
     dialog.Image.Pixbuf = certPixbuf1;
        int rc = dialog.Run();
        dialog.Hide();
        dialog.Destroy();
        if(rc == -8)
        {
     if( !(serverName.ToLower()).StartsWith(Uri.UriSchemeHttp))
     {
      serverName = (new Uri( Uri.UriSchemeHttps + Uri.SchemeDelimiter + serverName.TrimEnd( new char[] {'/'}))).ToString();
     }
     else
     {
      UriBuilder ub = new UriBuilder(serverName);
         ub.Scheme = Uri.UriSchemeHttps;
      serverName = ub.ToString();
     }
     ServerNameEntry.Text = string.Copy(serverName);
     simws.StoreCertificate(byteArray, serverName);
     CertAcceptedCond1 = true;
     ServersForCertStore.Add(serverName);
     OnConnectClicked(o, args);
        }
        else
        {
     CertAcceptedCond1 = false;
     simws.RemoveCertFromTable(serverName);
        }
       }
      }
      else
      {
        iFolderMsgDialog dialog = new iFolderMsgDialog(
     this,
     iFolderMsgDialog.DialogType.Question,
     iFolderMsgDialog.ButtonSet.YesNo,
     Util.GS("Unable to Verify Identity"),
     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."), serverName),
     cert.ToString(true));
        if (certPixbuf1 != null && dialog.Image != null)
     dialog.Image.Pixbuf = certPixbuf1;
        int rc = dialog.Run();
        dialog.Hide();
        dialog.Destroy();
        if(rc == -8)
        {
     if( !(serverName.ToLower()).StartsWith(Uri.UriSchemeHttp))
     {
      serverName = (new Uri( Uri.UriSchemeHttps + Uri.SchemeDelimiter + serverName.TrimEnd( new char[] {'/'}))).ToString();
     }
     else
     {
      UriBuilder ub = new UriBuilder(serverName);
         ub.Scheme = Uri.UriSchemeHttps;
      serverName = ub.ToString();
     }
     ServerNameEntry.Text = string.Copy(serverName);
     simws.StoreCertificate(byteArray, serverName);
     CertAcceptedCond1 = true;
     ServersForCertStore.Add(serverName);
     OnConnectClicked(o, args);
        }
        else
        {
     CertAcceptedCond1 = false;
     simws.RemoveCertFromTable(serverName);
        }
      }
      break;
     case StatusCodes.Success:
     case StatusCodes.SuccessInGrace:
      if (WaitDialog != null)
      {
       WaitDialog.Hide();
       WaitDialog.Destroy();
       WaitDialog = null;
      }
      string password = addDomainThread.Password;
      bool bRememberPassword = addDomainThread.RememberPassword;
      Status authStatus =
       domainController.AuthenticateDomain(
        dom.ID, password, bRememberPassword);
      if (authStatus != null)
      {
       if (authStatus.statusCode == StatusCodes.Success ||
        authStatus.statusCode == StatusCodes.SuccessInGrace)
       {
        ConnectedDomain = dom;
        if(ServersForCertStore.Count > 1 )
        {
     string serverKey = ServersForCertStore[ServersForCertStore.Count - 2] as string;
     UriBuilder TempServerUri = new UriBuilder(serverKey);
     {
      simws.RemoveCertFromTable(TempServerUri.Host);
     }
        }
        ServersForCertStore.Clear();
        iFolderWebService ifws = DomainController.GetiFolderService();
        int policy = ifws.GetSecurityPolicy(dom.ID);
        if( policy % 2 ==0)
        {
     AccountDruid.Page = SummaryPage;
     AccountDruid.Page = DefaultiFolderPage;
        }
        else
        {
     AccountDruid.Page = RAPage;
     ForwardButton.Sensitive = false;
     AccountDruid.CancelButton.Sensitive = false;
        }
        break;
       }
       else
       {
        Debug.PrintLine("Error while authenticating");
        Util.ShowLoginError(this, authStatus.statusCode);
       }
      }
      else
      {
       Util.ShowLoginError(this, StatusCodes.Unknown);
      }
      if(dom.ID != null)
      {
      }
      break;
     default:
      if (WaitDialog != null)
      {
       WaitDialog.Hide();
       WaitDialog.Destroy();
       WaitDialog = null;
      }
      Util.ShowLoginError(this, dom.StatusCode);
      break;
        }
 }
 private void OnResetClicked( object o, EventArgs args)
 {
     Debug.PrintLine("Reset clicked");
        string publicKey = null;
        bool reset = false;
        DomainController domainController = DomainController.GetDomainController();
        try{
        Status passphraseStatus = simws.ValidatePassPhrase(this.Domain, this.OldPassphrase);
        if( (passphraseStatus != null)
     && (passphraseStatus.statusCode == StatusCodes.PassPhraseInvalid))
       {
     passphraseStatus = simws.ValidatePassPhrase(this.Domain, this.NewPassphrase);
       }
     if( passphraseStatus != null)
     {
         if( passphraseStatus.statusCode == StatusCodes.PassPhraseInvalid)
         {
             iFolderMsgDialog dialog = new iFolderMsgDialog(
                 null,
                 iFolderMsgDialog.DialogType.Error,
                 iFolderMsgDialog.ButtonSet.None,
                 Util.GS("Invalid Passphrase"),
                 Util.GS("The Current PassPhrase entered is not valid"),
                 Util.GS("Please enter the passphrase again"));
             dialog.Run();
             dialog.Hide();
             dialog.Destroy();
             dialog = null;
             return;
         }
     }
        if( this.RAName != "DEFAULT")
        {
     byte [] RACertificateObj = domainController.GetRACertificate(this.Domain, this.RAName);
     if( RACertificateObj != null && RACertificateObj.Length != 0)
     {
      System.Security.Cryptography.X509Certificates.X509Certificate Cert = new System.Security.Cryptography.X509Certificates.X509Certificate(RACertificateObj);
      CertificateDialog dlg = new CertificateDialog(Cert.ToString(true));
      if (!Util.RegisterModalWindow(dlg))
      {
       dlg.Destroy();
       dlg = null;
       return ;
      }
      int res = dlg.Run();
      dlg.Hide();
      dlg.Destroy();
      dlg = null;
      if( res == (int)ResponseType.Ok)
      {
       publicKey = Convert.ToBase64String(Cert.GetPublicKey());
       Debug.PrintLine(String.Format(" The public key is: {0}", publicKey));
       reset = true;
      }
      else
      {
       reset = false;
       Debug.PrintLine("Response type is not ok");
       return;
      }
     }
        }
        else
        {
      DomainInformation domainInfo = (DomainInformation)this.simws.GetDomainInformation(this.Domain);
             string memberUID = domainInfo.MemberUserID;
             publicKey = this.ifws.GetDefaultServerPublicKey(this.Domain, memberUID);
                 reset = true;
        }
        if( reset == true)
        {
     try
     {
      status = domainController.ReSetPassphrase(this.Domain, this.OldPassphrase, this.NewPassphrase, this.RAName, publicKey);
      simws.StorePassPhrase(this.Domain, "", CredentialType.None, false);
      simws.StorePassPhrase(this.Domain, this.NewPassphrase, CredentialType.Basic, this.SavePassphrase);
     }
     catch(Exception ex)
     {
      throw ex;
     }
        }
        if( status == false)
        {
      iFolderMsgDialog dialog = new iFolderMsgDialog(
                                                                                                        null,
                                                                                                        iFolderMsgDialog.DialogType.Error,
                                                                                                         iFolderMsgDialog.ButtonSet.None,
                                                                                                         Util.GS("Change Passphrase"),
                                                                                                         Util.GS("Unable to change the Passphrase"),
                                                                     Util.GS("Please try again"));
     dialog.Run();
     dialog.Hide();
     dialog.Destroy();
     dialog = null;
        }}
        catch(Exception e)
                 {
                         Debug.PrintLine(String.Format("Exception in reset passphrase : {0}",e.Message));
                 }
 }
Example #22
0
        protected bool AskCertificateApproval(System.Net.Security.SslPolicyErrors sslPolicyErrors, System.Security.Cryptography.X509Certificates.X509Certificate certificate)
        {
            DialogResult res = MessageBox.Show(this,
                                               String.Format("Warning: server certificate cannot be verified as trusted (Errors: {0}). Continue?\r\n\r\n{1}", sslPolicyErrors.ToString(), certificate.ToString()),
                                               "Certificate error",
                                               MessageBoxButtons.YesNo,
                                               MessageBoxIcon.Exclamation);

            return(res == System.Windows.Forms.DialogResult.Yes);
        }
Example #23
0
 bool jc_OnInvalidCertificate(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
 {
     Console.WriteLine("Invalid certificate ({0}):\n{1}", sslPolicyErrors.ToString(), certificate.ToString(true));
     return(true);
 }
Example #24
0
 private bool authenticate()
 {
     bool result = false;
        Cursor.Current = Cursors.WaitCursor;
        try
        {
     DomainAuthentication domainAuth = new DomainAuthentication("iFolder", domainInfo.ID, password.Text);
     Status authStatus = domainAuth.Authenticate(simiasManager.WebServiceUri, simiasManager.DataPath);
     MyMessageBox mmb;
     switch (authStatus.statusCode)
     {
      case StatusCodes.InvalidCertificate:
       byte[] byteArray = simiasWebService.GetCertificate(domainInfo.Host);
       System.Security.Cryptography.X509Certificates.X509Certificate cert = new System.Security.Cryptography.X509Certificates.X509Certificate(byteArray);
       mmb = new MyMessageBox(string.Format(resourceManager.GetString("verifyCert"), domainInfo.Host), resourceManager.GetString("verifyCertTitle"), cert.ToString(true), MyMessageBoxButtons.YesNo, MyMessageBoxIcon.Question, MyMessageBoxDefaultButton.Button2);
       if (mmb.ShowDialog() == DialogResult.Yes)
       {
        simiasWebService.StoreCertificate(byteArray, domainInfo.Host);
        result = authenticate();
       }
       break;
      case StatusCodes.Success:
      case StatusCodes.SuccessInGrace:
       if (authStatus.statusCode.Equals(StatusCodes.SuccessInGrace))
       {
        mmb = new MyMessageBox(
     string.Format(resourceManager.GetString("graceLogin"), authStatus.RemainingGraceLogins),
     resourceManager.GetString("graceLoginTitle"),
     string.Empty,
     MyMessageBoxButtons.OK,
     MyMessageBoxIcon.Information);
        mmb.ShowDialog();
       }
       try
       {
        updateStarted = FormsTrayApp.CheckForClientUpdate(domainInfo.ID);
       }
       catch
       {
       }
       if (rememberPassword.Checked)
       {
        try
        {
     simiasWebService.SetDomainCredentials(domainInfo.ID, password.Text, CredentialType.Basic);
        }
        catch (Exception ex)
        {
     mmb = new MyMessageBox(resourceManager.GetString("savePasswordError"), string.Empty, ex.Message, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
     mmb.ShowDialog();
        }
       }
       result = true;
       break;
      case StatusCodes.InvalidCredentials:
      case StatusCodes.InvalidPassword:
      case StatusCodes.UnknownUser:
       mmb = new MyMessageBox(resourceManager.GetString("badPassword"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
       mmb.ShowDialog();
       break;
      case StatusCodes.AccountDisabled:
       mmb = new MyMessageBox(resourceManager.GetString("accountDisabled"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
       mmb.ShowDialog();
       break;
      case StatusCodes.AccountLockout:
       mmb = new MyMessageBox(resourceManager.GetString("accountLockout"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
       mmb.ShowDialog();
       break;
      case StatusCodes.SimiasLoginDisabled:
       mmb = new MyMessageBox(resourceManager.GetString("iFolderAccountDisabled"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
       mmb.ShowDialog();
       break;
      default:
       mmb = new MyMessageBox(string.Format(resourceManager.GetString("serverReconnectError"), authStatus.statusCode.ToString()), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
       mmb.ShowDialog();
       break;
     }
        }
        catch (Exception ex)
        {
     MyMessageBox mmb = new MyMessageBox(resourceManager.GetString("serverConnectError"), resourceManager.GetString("serverConnectErrorTitle"), ex.Message, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
     mmb.ShowDialog();
        }
        Cursor.Current = Cursors.Default;
        return result;
 }
 private void OnDomainLoginCompleted(object o, DomainLoginCompletedArgs args)
 {
     if (WaitDialog != null)
        {
     WaitDialog.Hide();
     WaitDialog.Destroy();
     WaitDialog = null;
        }
        Status authStatus = args.AuthenticationStatus;
        if (authStatus != null)
        {
     switch (authStatus.statusCode)
     {
      case StatusCodes.Success:
      case StatusCodes.SuccessInGrace:
       if (LoginDialog != null)
       {
        LoginDialog.Hide();
        LoginDialog.Destroy();
        LoginDialog = null;
       }
       int result;
       iFolderWebService ifws = DomainController.GetiFolderService();
       int policy = ifws.GetSecurityPolicy(args.DomainID);
       if( policy % 2 == 0)
        break;
       bool passphraseStatus = simws.IsPassPhraseSet(args.DomainID);
       if(passphraseStatus == true)
       {
        bool rememberOption = simws.GetRememberOption(args.DomainID);
        if( rememberOption == false)
        {
     ShowVerifyDialog( args.DomainID, simws);
        }
        else
        {
     Debug.PrintLine(" remember Option true. Checking for passphrase existence");
     string passphrasecheck = simws.GetPassPhrase(args.DomainID);
     if(passphrasecheck == null || passphrasecheck == "")
     {
      Debug.PrintLine("BugBug: Passphrase doesn't exist");
      ShowVerifyDialog( args.DomainID, simws);
     }
        }
       }
       else
       {
        iFolderWindow.ShowEnterPassPhraseDialog(args.DomainID, simws);
       }
       iFolderData ifdata = iFolderData.GetData();
                 ifdata.Refresh();
       UpdateWidgetSensitivity();
       break;
      case StatusCodes.InvalidCertificate:
       DomainInformation dom = domainController.GetDomain(args.DomainID);
       if( authStatus.UserName != null)
       {
        dom.Host = authStatus.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);
        LoginDialog.Respond(Gtk.ResponseType.Ok);
       }
       else
       {
        LoginDialog.Respond(Gtk.ResponseType.Cancel);
       }
       break;
       case StatusCodes.UserAlreadyMoved:
        LoginDialog.Respond(Gtk.ResponseType.Ok);
        break;
      default:
       Util.ShowLoginError(topLevelWindow, authStatus.statusCode);
       if (LoginDialog != null)
        LoginDialog.Present();
       UpdateDomainStatus(args.DomainID);
       break;
     }
        }
        else
        {
     Util.ShowLoginError(topLevelWindow, StatusCodes.Unknown);
     if (LoginDialog != null)
      LoginDialog.Present();
     UpdateDomainStatus(args.DomainID);
        }
        iFolderWindow ifwin = Util.GetiFolderWindow();
        ifwin.UpdateServerInfoForSelectedDomain();
        ifwin.UpdateListViewItems();
 }
Example #26
0
 public bool initialConnect()
 {
     bool result = false;
     bool certPrompt = false;
     try
     {
         SetProxyForDomain(server, true);
         domainInfo = simiasWebService.ConnectToDomain(user, password, server);
         switch (domainInfo.StatusCode)
         {
             case StatusCodes.InvalidCertificate:
                 string serverName = domainInfo.HostUrl != null ? domainInfo.HostUrl : server;
                 byte[] byteArray = simiasWebService.GetCertificate(server);
                 System.Security.Cryptography.X509Certificates.X509Certificate cert = new System.Security.Cryptography.X509Certificates.X509Certificate(byteArray);
                 if (!autoAccountEnabled || (autoAccountEnabled && promptForInvalidCert))
                     certPrompt = true;
                 if (certPrompt)
                 {
                     if (!autoAccountEnabled)
                     {
                         BeginInvoke(displayMessageDelegate,
                             new object[] { string.Format(resourceManager.GetString("verifyCert"), serverName), resourceManager.GetString("verifyCertTitle"), cert.ToString(true), MyMessageBoxButtons.YesNo, MyMessageBoxIcon.Question, MyMessageBoxDefaultButton.Button2 });
                         messageEvent.WaitOne();
                     }
                     else
                     {
                         MyMessageBox mmb = new MyMessageBox(string.Format(resourceManager.GetString("verifyCert"), serverName), resourceManager.GetString("verifyCertTitle"), cert.ToString(true), MyMessageBoxButtons.YesNo, MyMessageBoxIcon.Question, MyMessageBoxDefaultButton.Button2);
                         mmb.StartPosition = FormStartPosition.CenterScreen;
                         messageDialogResult = mmb.ShowDialog();
                     }
                     if (messageDialogResult == DialogResult.Yes)
                     {
                         if (!(server.ToLower()).StartsWith(Uri.UriSchemeHttp))
                         {
                             server = (new Uri(Uri.UriSchemeHttps + Uri.SchemeDelimiter + server.TrimEnd(new char[] { '/' }))).ToString();
                         }
                         else
                         {
                             UriBuilder ub = new UriBuilder(server);
                             ub.Scheme = Uri.UriSchemeHttps;
                             server = ub.ToString();
                         }
                         simiasWebService.StoreCertificate(byteArray, server);
                         ServersForCertStore.Add(server);
                         result = initialConnect();
                     }
                     else
                     {
                         simiasWebService.RemoveCertFromTable(server);
                     }
                 }
                 else
                 {
                     if (!(server.ToLower()).StartsWith(Uri.UriSchemeHttp))
                     {
                         server = (new Uri(Uri.UriSchemeHttps + Uri.SchemeDelimiter + server.TrimEnd(new char[] { '/' }))).ToString();
                     }
                     else
                     {
                         UriBuilder ub = new UriBuilder(server);
                         ub.Scheme = Uri.UriSchemeHttps;
                         server = ub.ToString();
                     }
                     simiasWebService.StoreCertificate(byteArray, server);
                     ServersForCertStore.Add(server);
                     result = initialConnect();
                 }
                 break;
             case StatusCodes.Success:
             case StatusCodes.SuccessInGrace:
                 DomainAuthentication domainAuth = new DomainAuthentication("iFolder", domainInfo.ID, password);
                 domainAuth.Authenticate(simiasManager.WebServiceUri, simiasManager.DataPath);
                 domainInfo.Authenticated = true;
                 if (rememberPassword)
                 {
                     try
                     {
                         simiasWebService.SetDomainCredentials(domainInfo.ID, password, CredentialType.Basic);
                     }
                     catch (Exception ex)
                     {
                         if (!autoAccountEnabled)
                         {
                             BeginInvoke(displayMessageDelegate,
                                 new object[] { resourceManager.GetString("savePasswordError"), string.Empty, ex.Message, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 });
                             messageEvent.WaitOne();
                         }
                         else
                         {
                             FormsTrayApp.log.Info("Exception is {0}", ex.Message);
                         }
                     }
                 }
                 ServersForCertStore.Clear();
                 if (defaultServer)
                 {
                     try
                     {
                         simiasWebService.SetDefaultDomain(domainInfo.ID);
                         domainInfo.IsDefault = true;
                     }
                     catch (Exception ex)
                     {
                         if (!autoAccountEnabled)
                         {
                             BeginInvoke(displayMessageDelegate,
                                 new object[] { resourceManager.GetString("setDefaultError"), resourceManager.GetString("accountErrorTitle"), ex.Message, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 });
                             messageEvent.WaitOne();
                         }
                         else
                         {
                             FormsTrayApp.log.Info("{0} : {1}", resourceManager.GetString("accountErrorTitle"), resourceManager.GetString("setDefaultError"));
                         }
                     }
                 }
                 if (domainInfo.StatusCode.Equals(StatusCodes.SuccessInGrace) && !autoAccountEnabled)
                 {
                     BeginInvoke(displayMessageDelegate,
                         new object[] { string.Format(resourceManager.GetString("graceLogin"), domainInfo.RemainingGraceLogins),
      resourceManager.GetString("graceLoginTitle"),
      string.Empty,
      MyMessageBoxButtons.OK,
      MyMessageBoxIcon.Information, MyMessageBoxDefaultButton.Button1 });
                     messageEvent.WaitOne();
                 }
                 if (EnterpriseConnect != null)
                 {
                     EnterpriseConnect(this, new DomainConnectEventArgs(domainInfo));
                 }
                 result = true;
                 break;
             case StatusCodes.InvalidCredentials:
             case StatusCodes.InvalidPassword:
             case StatusCodes.UnknownUser:
                 string servername = domainInfo.HostUrl != null ? domainInfo.HostUrl : server;
                 if (!autoAccountEnabled)
                 {
                     BeginInvoke(displayMessageDelegate,
                         new object[] { resourceManager.GetString("failedAuth"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 });
                     messageEvent.WaitOne();
                 }
                 else
                 {
                     if (password != "")
                     {
                         FormsTrayApp.log.Info("{0}:{1} RetCode: {2}", resourceManager.GetString("serverConnectErrorTitle"), resourceManager.GetString("failedAuth"), domainInfo.StatusCode);
                     }
                 }
                 simiasWebService.RemoveCertFromTable(servername);
                 break;
             case StatusCodes.AccountDisabled:
                 if (!autoAccountEnabled)
                 {
                     BeginInvoke(displayMessageDelegate,
                         new object[] { resourceManager.GetString("accountDisabled"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 });
                     messageEvent.WaitOne();
                 }
                 else
                 {
                     FormsTrayApp.log.Info("{0}:{1}", resourceManager.GetString("serverConnectErrorTitle"), resourceManager.GetString("accountDisabled"));
                 }
                 break;
             case StatusCodes.AccountLockout:
                 if (!autoAccountEnabled)
                 {
                     BeginInvoke(displayMessageDelegate,
                         new object[] { resourceManager.GetString("accountLockout"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 });
                     messageEvent.WaitOne();
                 }
                 else
                 {
                     FormsTrayApp.log.Info("{0}:{1}", resourceManager.GetString("serverConnectErrorTitle"), resourceManager.GetString("accountLockout"));
                 }
                 break;
             case StatusCodes.SimiasLoginDisabled:
                 if (!autoAccountEnabled)
                 {
                     BeginInvoke(displayMessageDelegate,
                         new object[] { resourceManager.GetString("iFolderAccountDisabled"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 });
                     messageEvent.WaitOne();
                 }
                 else
                 {
                     FormsTrayApp.log.Info("{0}:{1}", resourceManager.GetString("serverConnectErrorTitle"), resourceManager.GetString("iFolderAccountDisabled"));
                 }
                 break;
             case StatusCodes.UnknownDomain:
                 if (!autoAccountEnabled)
                 {
                     BeginInvoke(displayMessageDelegate,
                         new object[] { resourceManager.GetString("unknownDomain"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 });
                     messageEvent.WaitOne();
                 }
                 else
                 {
                     FormsTrayApp.log.Info("{0}:{1}", resourceManager.GetString("serverConnectErrorTitle"), resourceManager.GetString("unknownDomain"));
                 }
                 break;
             default:
                 if (!autoAccountEnabled)
                 {
                     BeginInvoke(displayMessageDelegate,
                         new object[] { resourceManager.GetString("serverConnectError"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 });
                     messageEvent.WaitOne();
                 }
                 else
                 {
                     FormsTrayApp.log.Info("{0}:{1}", resourceManager.GetString("serverConnectErrorTitle"), resourceManager.GetString("serverConnectError"));
                 }
                 break;
         }
     }
     catch (Exception ex)
     {
         if (ex.Message.Contains("logging to old server"))
         {
             MyMessageBox box = new MyMessageBox(resourceManager.GetString("Upgrade.Text"), resourceManager.GetString("Upgrade.Title"), "", MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
             box.StartPosition = FormStartPosition.CenterScreen;
             switch (box.ShowDialog())
             {
                 case DialogResult.OK:
                 case DialogResult.Cancel:
                     return false;
             }
         }
         if ((ex.Message.IndexOf("Simias.ExistsException") != -1) ||
             (ex.Message.IndexOf("already exists") != -1))
         {
             if (!autoAccountEnabled)
             {
                 BeginInvoke(displayMessageDelegate,
                     new object[] { resourceManager.GetString("alreadyJoined"), resourceManager.GetString("alreadyJoinedTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Information, MyMessageBoxDefaultButton.Button1 });
                 messageEvent.WaitOne();
             }
             else
             {
                 FormsTrayApp.log.Info("{0}:{1}", resourceManager.GetString("alreadyJoinedTitle"), resourceManager.GetString("alreadyJoined"));
             }
         }
         else if (!httpsConnect && (ex.Message.IndexOf("InvalidOperationException") != -1))
         {
             if (!(server.ToLower()).StartsWith(Uri.UriSchemeHttp))
             {
                 server = (new Uri(Uri.UriSchemeHttps + Uri.SchemeDelimiter + server.TrimEnd(new char[] { '/' }))).ToString();
             }
             else
             {
                 UriBuilder ub = new UriBuilder(server);
                 ub.Scheme = Uri.UriSchemeHttps;
                 server = ub.ToString();
             }
             httpsConnect = true;
             result = initialConnect();
         }
         else
         {
             if (!autoAccountEnabled)
             {
                 BeginInvoke(displayMessageDelegate,
                     new object[] { resourceManager.GetString("serverConnectError"),
                         resourceManager.GetString("serverConnectErrorTitle"),
                         "",
                         MyMessageBoxButtons.OK,
                         MyMessageBoxIcon.Error,
                         MyMessageBoxDefaultButton.Button1
                 });
                 messageEvent.WaitOne();
                 FormsTrayApp.log.Info("{0}:{1}", resourceManager.GetString("serverConnectError"), ex.Message);
             }
             else
             {
                 FormsTrayApp.log.Info("{0}:{1}", resourceManager.GetString("serverConnectErrorTitle"),
                     resourceManager.GetString("serverConnectError"));
             }
         }
     }
     return result;
 }
Example #27
0
        /// <summary>
        /// Event Handler for Reset Clicked
        /// </summary>
        private void OnResetClicked(object o, EventArgs args)
        {
            Debug.PrintLine("Reset clicked");
            string publicKey = null;
            bool   reset     = false;

            try
            {
                if (this.GdkWindow != null)
                {
                    this.GdkWindow.Cursor = new Gdk.Cursor(Gdk.CursorType.Watch);
                }
                DomainController domainController = DomainController.GetDomainController();

                Status passphraseStatus = simws.ValidatePassPhrase(this.Domain, this.OldPassphrase);
                if (passphraseStatus != null)
                {
                    iFolderMsgDialog dialog = null;
                    if (passphraseStatus.statusCode == StatusCodes.PassPhraseInvalid)                      // check for invalid passphrase
                    {
                        dialog = new iFolderMsgDialog(
                            null,
                            iFolderMsgDialog.DialogType.Error,
                            iFolderMsgDialog.ButtonSet.None,
                            Util.GS("Invalid PassPhrase"),
                            Util.GS("The Current PassPhrase entered is not valid"),
                            Util.GS("Please enter the passphrase again"));
                    }
                    else if (passphraseStatus.statusCode == StatusCodes.ServerUnAvailable)
                    {
                        dialog = new iFolderMsgDialog(
                            null,
                            iFolderMsgDialog.DialogType.Info,
                            iFolderMsgDialog.ButtonSet.None,
                            Util.GS("No Logged-In domains"),
                            Util.GS("There are no logged-in domains for changing the passphrase."),
                            Util.GS("For changing passphrase the domain should be connected. Log on to the domain and try."));
                    }

                    if (dialog != null)
                    {
                        dialog.Run();
                        dialog.Hide();
                        dialog.Destroy();
                        dialog = null;
                        return;
                    }
                }
                if (this.RAName != "DEFAULT")
                {
                    byte [] RACertificateObj = domainController.GetRACertificate(this.Domain, this.RAName);
                    if (RACertificateObj != null && RACertificateObj.Length != 0)
                    {
                        System.Security.Cryptography.X509Certificates.X509Certificate Cert =
                            new System.Security.Cryptography.X509Certificates.X509Certificate(RACertificateObj);
                        CertificateDialog dlg = new CertificateDialog(Cert.ToString(true));
                        if (!Util.RegisterModalWindow(dlg))
                        {
                            dlg.Destroy();
                            dlg = null;
                            return;
                        }
                        int res = dlg.Run();
                        dlg.Hide();
                        dlg.Destroy();
                        dlg = null;
                        if (res == (int)ResponseType.Ok)
                        {
                            publicKey = Convert.ToBase64String(Cert.GetPublicKey());
                            Debug.PrintLine(String.Format(" The public key is: {0}", publicKey));
                            reset = true;
                        }
                        else
                        {
                            reset = false;
                            Debug.PrintLine("Response type is not ok");
                            return;
                        }
                    }
                }
                else
                {
                    DomainInformation domainInfo = (DomainInformation)this.simws.GetDomainInformation(this.Domain);

                    string memberUID = domainInfo.MemberUserID;

                    publicKey = this.ifws.GetDefaultServerPublicKey(this.Domain, memberUID);
                    reset     = true;
                }
                if (reset == true)
                {
                    try
                    {
                        status = domainController.ReSetPassphrase(this.Domain,
                                                                  this.OldPassphrase,
                                                                  this.NewPassphrase,
                                                                  this.RAName, publicKey);

                        //clear the values
                        simws.StorePassPhrase(this.Domain, "", CredentialType.None, false);
                        //set the values

                        simws.StorePassPhrase(this.Domain, this.NewPassphrase, CredentialType.Basic, this.SavePassphrase);
                    }
                    catch (Exception ex)
                    {
                        //add client debug log here
                        throw ex;
                    }
                }
                if (status == false)
                {
                    iFolderMsgDialog dialog = new iFolderMsgDialog(
                        null,
                        iFolderMsgDialog.DialogType.Error,
                        iFolderMsgDialog.ButtonSet.None,
                        Util.GS("Change Passphrase"),
                        Util.GS("Unable to change the Passphrase"),
                        Util.GS("Please try again"));
                    dialog.Run();
                    dialog.Hide();
                    dialog.Destroy();
                    dialog = null;
                }
            }
            catch (Exception e)
            {
                Debug.PrintLine(String.Format("Exception in reset passphrase : {0}", e.Message));
            }
            if (this.GdkWindow != null)
            {
                this.GdkWindow.Cursor = new Gdk.Cursor(Gdk.CursorType.Watch);
            }
        }
Example #28
0
 private bool authenticate()
 {
     bool result = false;
        try
        {
     DomainAuthentication domainAuth =
      new DomainAuthentication(
      "iFolder",
      domainInfo.ID,
      null);
     Status status = domainAuth.Authenticate(simiasManager.WebServiceUri, simiasManager.DataPath);
     switch (status.statusCode)
     {
      case StatusCodes.InvalidCertificate:
       byte[] byteArray = simiasWebService.GetCertificate(domainInfo.Host);
       System.Security.Cryptography.X509Certificates.X509Certificate cert = new System.Security.Cryptography.X509Certificates.X509Certificate(byteArray);
       BeginInvoke( displayMessageDelegate,
        new object[] { string.Format(resourceManager.GetString("verifyCert"), domainInfo.Host), resourceManager.GetString("verifyCertTitle"), cert.ToString(true), MyMessageBoxButtons.YesNo, MyMessageBoxIcon.Question, MyMessageBoxDefaultButton.Button2 } );
       messageEvent.WaitOne();
       if ( messageDialogResult == DialogResult.Yes )
       {
        simiasWebService.StoreCertificate(byteArray, domainInfo.Host);
        result = authenticate();
       }
       break;
      case StatusCodes.Success:
       result = true;
       break;
      case StatusCodes.SuccessInGrace:
       BeginInvoke( displayMessageDelegate,
        new object[] { string.Format(resourceManager.GetString("graceLogin"), status.RemainingGraceLogins),
     resourceManager.GetString("graceLoginTitle"),
     string.Empty,
     MyMessageBoxButtons.OK,
     MyMessageBoxIcon.Information, MyMessageBoxDefaultButton.Button1 } );
       messageEvent.WaitOne();
       result = true;
       break;
      default:
      {
       string userID;
       CredentialType credType = simiasWebService.GetDomainCredentials(domainInfo.ID, out userID, out password);
       if ((credType == CredentialType.Basic) && (password != null))
       {
        domainAuth = new DomainAuthentication("iFolder", domainInfo.ID, password);
        Status authStatus = domainAuth.Authenticate(simiasManager.WebServiceUri, simiasManager.DataPath);
        switch (authStatus.statusCode)
        {
     case StatusCodes.Success:
      result = true;
      break;
     case StatusCodes.SuccessInGrace:
      BeginInvoke( displayMessageDelegate,
       new object[] { string.Format(resourceManager.GetString("graceLogin"), status.RemainingGraceLogins),
        resourceManager.GetString("graceLoginTitle"),
        string.Empty,
        MyMessageBoxButtons.OK,
        MyMessageBoxIcon.Information, MyMessageBoxDefaultButton.Button1 } );
      messageEvent.WaitOne();
      result = true;
      break;
     case StatusCodes.AccountDisabled:
      BeginInvoke( displayMessageDelegate,
       new object[] { resourceManager.GetString("accountDisabled"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 } );
      messageEvent.WaitOne();
      break;
     case StatusCodes.AccountLockout:
      BeginInvoke( displayMessageDelegate,
       new object[] { resourceManager.GetString("accountLockout"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 } );
      messageEvent.WaitOne();
      break;
     case StatusCodes.SimiasLoginDisabled:
      BeginInvoke( displayMessageDelegate,
       new object[] { resourceManager.GetString("iFolderAccountDisabled"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 } );
      messageEvent.WaitOne();
      break;
     case StatusCodes.UnknownUser:
     case StatusCodes.InvalidPassword:
     case StatusCodes.InvalidCredentials:
      simiasWebService.SetDomainCredentials(domainInfo.ID, null, CredentialType.None);
      BeginInvoke( displayMessageDelegate,
       new object[] { resourceManager.GetString("failedAuth"), resourceManager.GetString("serverConnectErrorTitle"), string.Empty, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error, MyMessageBoxDefaultButton.Button1 } );
      messageEvent.WaitOne();
      break;
        }
       }
       break;
      }
     }
        }
        catch {}
        return result;
 }
 private void btnOk_Click(object sender, System.EventArgs e)
 {
     System.Resources.ResourceManager resManager = new System.Resources.ResourceManager(typeof(Connecting));
        if( this.Passphrase.Text == this.RetypePassphrase.Text)
        {
     string publicKey = null;
     string ragent = null;
     if( this.RecoveryAgentCombo.SelectedItem != null && (string)this.RecoveryAgentCombo.SelectedItem != Resource.GetString("NoneText"))
     {
      byte[] CertificateObj = this.simws.GetRACertificateOnClient(this.DomainID, (string)this.RecoveryAgentCombo.SelectedItem);
      System.Security.Cryptography.X509Certificates.X509Certificate cert = new System.Security.Cryptography.X509Certificates.X509Certificate(CertificateObj);
      MyMessageBox mmb = new MyMessageBox( string.Format(resManager.GetString("verifyCert"), (string)this.RecoveryAgentCombo.SelectedItem), resManager.GetString("verifyCertTitle"), cert.ToString(true), MyMessageBoxButtons.YesNo, MyMessageBoxIcon.Question, MyMessageBoxDefaultButton.Button2);
      DialogResult messageDialogResult = mmb.ShowDialog();
      mmb.Dispose();
      mmb.Close();
      if( messageDialogResult != DialogResult.Yes )
       return;
      else
      {
       ragent = (string)this.RecoveryAgentCombo.SelectedItem;
       publicKey = Convert.ToBase64String(cert.GetPublicKey());
      }
     }
     else
     {
      MyMessageBox mmb = new MyMessageBox( resManager.GetString("NoCertWarning"), resManager.GetString("NoCertTitle"), "", MyMessageBoxButtons.YesNo, MyMessageBoxIcon.Question, MyMessageBoxDefaultButton.Button2);
      DialogResult messageDialogResult = mmb.ShowDialog();
      mmb.Dispose();
      mmb.Close();
      if( messageDialogResult != DialogResult.Yes )
       return;
     }
     Status passPhraseStatus = null;
     try
     {
      passPhraseStatus = simws.SetPassPhrase( DomainID, this.Passphrase.Text, ragent, publicKey);
     }
     catch(Exception ex)
     {
      MessageBox.Show( Resource.GetString("IsPassphraseSetException")+ex.Message);
     }
     if(passPhraseStatus.statusCode == StatusCodes.Success)
     {
      simws.StorePassPhrase( DomainID, this.Passphrase.Text, CredentialType.Basic, this.savePassphrase.Checked);
             status = true;
      Novell.iFolderCom.MyMessageBox mmb = new MyMessageBox(Resource.GetString("SetPassphraseSuccess"), resourceManager.GetString("$this.Text"), "", MyMessageBoxButtons.OK, MyMessageBoxIcon.Information);
      mmb.ShowDialog();
      mmb.Dispose();
      this.Dispose();
      this.Close();
     }
     else
     {
      status = false;
      Novell.iFolderCom.MyMessageBox mmb = new MyMessageBox(Resource.GetString("IsPassphraseSetException"), resourceManager.GetString("$this.Text"), "", MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
      mmb.ShowDialog();
      mmb.Dispose();
     }
        }
        else
        {
     status = false;
        }
 }
Example #30
0
 bool jc_OnInvalidCertificate(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
 {
     Log.DebugFormat("Invalid certificate ({0}):\n{1}", sslPolicyErrors.ToString(), certificate != null ? certificate.ToString(true) : string.Empty);
     return(_untrustedOK);
 }