/// <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")); }
private System.Security.Cryptography.RSAParameters ConvertPublicKeyToRsaInfo() { System.Security.Cryptography.RSAParameters RSAKeyInfo; using (var cerStream = Application.GetResourceStream(new Uri("/RSAEncryptDemo;component/Files/DemoPublicKey.cer", UriKind.RelativeOrAbsolute)).Stream) { byte[] cerBuffer = new byte[cerStream.Length]; cerStream.Read(cerBuffer, 0, cerBuffer.Length); System.Security.Cryptography.X509Certificates.X509Certificate cer = new System.Security.Cryptography.X509Certificates.X509Certificate(cerBuffer); RSAKeyInfo = X509PublicKeyParser.GetRSAPublicKeyParameters(cer.GetPublicKey()); } return(RSAKeyInfo); }
/// <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 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; }
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)); } }
/// <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"; } } }
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"); } } }
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; }
/// <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; } }
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; } }
/// <include file='doc\PublisherMembershipCondition.uex' path='docs/doc[@for="PublisherMembershipCondition.ToString"]/*' /> public override String ToString() { if (m_certificate == null && m_element != null) { ParseCertificate(); } if (m_certificate == null) { return(Environment.GetResourceString("Publisher_ToString")); } else { String name = m_certificate.GetName(); if (name != null) { return(String.Format(Environment.GetResourceString("Publisher_ToStringArg"), System.Security.Util.Hex.EncodeHexString(m_certificate.GetPublicKey()))); } else { return(Environment.GetResourceString("Publisher_ToString")); } } }
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; } }
/// <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; }
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; } }
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; } }
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; } }
public static AsymmetricKeyParameter GetPublicKeyFromX509Cert(System.Security.Cryptography.X509Certificates.X509Certificate cert) { return(PublicKeyFactory.CreateKey(cert.GetPublicKey())); }