/// <summary>
        /// Event Handlet for OK Button click event
        /// </summary>
        private void btnOk_Click(object sender, System.EventArgs e)
        {
            Status passPhraseStatus = null;

            try
            {
                passPhraseStatus = simws.ValidatePassPhrase(this.DomainID, this.Passphrase.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show(this.resManager.GetString("ValidatePPError") /*"Unable to validate the Passphrase. {0}"*/, ex.Message);
            }
            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();
                }
                else if (passPhraseStatus.statusCode == StatusCodes.Success)
                {
                    try
                    {
                        simws.StorePassPhrase(DomainID, this.Passphrase.Text, CredentialType.Basic, this.savePassphrase.Checked);
                        status = true;
                        this.Dispose();
                        this.Close();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show(Resource.GetString("PassStoreErr"));
                        status = false;
                    }
                }
                else if (passPhraseStatus.statusCode == StatusCodes.ServerUnAvailable)
                {
                    Novell.iFolderCom.MyMessageBox mmb = new MyMessageBox(Resource.GetString("ValidatePPError") /*"Unable to validate the passphrase"*/, Resource.GetString("VerifyPP") /*"Passphrase Invalid"*/, "" /*Resource.GetString("TryAgain")*//*"Please try again"*/, MyMessageBoxButtons.OK, MyMessageBoxIcon.Error);
                    mmb.ShowDialog();
                    mmb.Dispose();
                }
            }
        }
        /// <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);
            }
        }
Exemple #3
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);
        }
 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;
 }
Exemple #5
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;
        }