/// <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 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;
            }
        }
Beispiel #3
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";
                }
            }
        }
Beispiel #4
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;
        }