/// <summary>
 /// Event Handler for cancel Button click event
 /// </summary>
 private void btnCancel_Click(object sender, System.EventArgs e)
 {
     simws.StorePassPhrase(DomainID, "", CredentialType.None, false);
     status = false;
     this.Dispose();
     this.Close();
 }
        /// <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);
            }
        }
 private static bool SetPassPhrase( EnterPassPhraseDialog epd, string DomainID, string publicKey, SimiasWebService simws )
 {
     bool status;
     Status passPhraseStatus = null;
       if(epd.RecoveryAgent != null && epd.RecoveryAgent != Util.GS("Server_Default"))
      passPhraseStatus = simws.SetPassPhrase( DomainID, epd.PassPhrase, epd.RecoveryAgent, publicKey);
      else
        passPhraseStatus = simws.SetPassPhrase( DomainID, epd.PassPhrase, "DEFAULT", publicKey);
     if(passPhraseStatus.statusCode == StatusCodes.Success)
     {
     status = true;
     simws.StorePassPhrase( DomainID, epd.PassPhrase, CredentialType.Basic, epd.ShouldSavePassPhrase);
     }
     else
     {
     status = false;
     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;
     }
     return status;
 }
 public static bool ShowVerifyDialog(string DomainID, SimiasWebService simws)
 {
     bool status = false;
        int result;
        Status passPhraseStatus= null;
        VerifyPassPhraseDialog vpd = new VerifyPassPhraseDialog();
        if (!Util.RegisterModalWindow(vpd))
        {
     vpd.Destroy();
     vpd = null;
     return false;
        }
        try
        {
        do
        {
     result = vpd.Run();
     vpd.Hide();
     if( result == (int)ResponseType.Ok)
      passPhraseStatus = simws.ValidatePassPhrase(DomainID, vpd.PassPhrase);
     if( passPhraseStatus != null)
     {
      if( passPhraseStatus.statusCode == StatusCodes.PassPhraseInvalid)
      {
       Debug.PrintLine("Invalid Passphrase");
       iFolderMsgDialog dialog = new iFolderMsgDialog(
        null,
        iFolderMsgDialog.DialogType.Error,
        iFolderMsgDialog.ButtonSet.None,
        Util.GS("Invalid Passphrase"),
        Util.GS("The Passphrase entered is invalid"),
        Util.GS("Please enter the passphrase again"));
        dialog.Run();
        dialog.Hide();
        dialog.Destroy();
        dialog = null;
       passPhraseStatus = null;
      }
      else if(passPhraseStatus.statusCode == StatusCodes.Success)
       break;
     }
        }while( result != (int)ResponseType.Cancel && result !=(int)ResponseType.DeleteEvent);
        if( result == (int)ResponseType.Cancel || result == (int)ResponseType.DeleteEvent)
        {
     try
     {
      simws.StorePassPhrase(DomainID, "", CredentialType.None, false);
      status = false;
     }
     catch(Exception)
     {
      return false;
     }
        }
        else if( passPhraseStatus != null && passPhraseStatus.statusCode == StatusCodes.Success)
        {
     try
     {
      simws.StorePassPhrase( DomainID, vpd.PassPhrase, CredentialType.Basic, vpd.ShouldSavePassPhrase);
      status = true;
     }
     catch(Exception)
     {
      return false;
     }
        }
        }
        catch(Exception)
        {
     return false;
        }
        return status;
 }
 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;
 }
 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;
 }
Exemple #7
0
        ///<summary>
        /// Show password verify dialog
        ///</summary>
        ///<param name="DomainID">ID of the domain</param>
        ///<param name="simws">Reference to simias web service</param>
        ///<returns>Status else false</returns>
        private static bool ShowVerifyDialog(string DomainID, SimiasWebService simws)
        {
            bool   status = false;
            int    result;
            Status passPhraseStatus    = null;
            VerifyPassPhraseDialog vpd = new VerifyPassPhraseDialog();

            // vpd.TransientFor = this;
            try
            {
                do
                {
                    result = vpd.Run();
                    vpd.Hide();
                    // Verify PassPhrase..  If correct store passphrase and set a local property..
                    if (result == (int)ResponseType.Ok)
                    {
                        passPhraseStatus = simws.ValidatePassPhrase(DomainID, vpd.PassPhrase);
                    }
                    if (passPhraseStatus != null)
                    {
                        if (passPhraseStatus.statusCode == StatusCodes.PassPhraseInvalid)                  // check for invalid passphrase
                        {
                            // Display an error Message
                            Console.WriteLine("Invalid Passphrase");
                            iFolderMsgDialog dialog = new iFolderMsgDialog(
                                null,
                                iFolderMsgDialog.DialogType.Error,
                                iFolderMsgDialog.ButtonSet.None,
                                Util.GS("Invalid Passphrase"),
                                Util.GS("The Passphrase entered is invalid"),
                                Util.GS("Please re-enter the passphrase"));
                            dialog.Run();
                            dialog.Hide();
                            dialog.Destroy();
                            dialog           = null;
                            passPhraseStatus = null;
                        }
                        else if (passPhraseStatus.statusCode == StatusCodes.Success)
                        {
                            break;
                        }
                    }
                }while(result != (int)ResponseType.Cancel && result != (int)ResponseType.DeleteEvent);
                if (result == (int)ResponseType.Cancel || result == (int)ResponseType.DeleteEvent)
                {
                    try
                    {
                        simws.StorePassPhrase(DomainID, "", CredentialType.None, false);
                        status = false;
                    }
                    catch (Exception e)
                    {
                        return(false);
                    }
                }
                else if (passPhraseStatus != null && passPhraseStatus.statusCode == StatusCodes.Success)
                {
                    try
                    {
                        simws.StorePassPhrase(DomainID, vpd.PassPhrase, CredentialType.Basic, vpd.ShouldSavePassPhrase);
                        status = true;
                    }
                    catch (Exception ex)
                    {
                        return(false);
                    }
                }
            }
            catch (Exception e)
            {
                return(false);
            }
            return(status);
        }
Exemple #8
0
        ///<summary>
        /// Display enter passphrase dialog
        ///</summary>
        ///<param name="DomainID">ID of the domain</param>
        ///<param name="simws">Reference to simias web service</param>
        ///<returns>Status else false</returns>
        private static bool ShowEnterPassPhraseDialog(string DomainID, SimiasWebService simws)
        {
            bool status = false;
            int  result;
            EnterPassPhraseDialog epd = new EnterPassPhraseDialog(DomainID, simws);

            try
            {
                do
                {
                    result = epd.Run();
                    epd.Hide();
                    if (result == (int)ResponseType.Cancel || result == (int)ResponseType.DeleteEvent)
                    {
                        break;
                    }
                    if (epd.PassPhrase != epd.RetypedPassPhrase)
                    {
                        Console.WriteLine("PassPhrases do not match");
                        // show an error message
                        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("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)
                {
                    status = false;
                    simws.StorePassPhrase(DomainID, "", CredentialType.None, false);
                }

                else if (epd.PassPhrase == epd.RetypedPassPhrase)
                {
                    // Check the recovery agent
                    string publicKey        = "";
                    Status passPhraseStatus = simws.SetPassPhrase(DomainID, epd.PassPhrase, epd.RecoveryAgent, publicKey);
                    if (passPhraseStatus.statusCode == StatusCodes.Success)
                    {
                        status = true;
                        simws.StorePassPhrase(DomainID, epd.PassPhrase, CredentialType.Basic, epd.ShouldSavePassPhrase);
                    }
                    else
                    {
                        // error setting the passphrase
                        status = false;
                        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("Try again"));
                        dialog.Run();
                        dialog.Hide();
                        dialog.Destroy();
                        dialog = null;
                    }
                }
            }
            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;
                return(false);
            }
            return(status);
        }
Exemple #9
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;
        }