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; }
/// <summary> /// Show Verify Passphrase Dialog /// </summary> /// <param name="DomainID">Domain ID</param> /// <param name="simws">Simias WebService</param> /// <returns>true on success</returns> private 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); } // 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.Cancel || result == (int)ResponseType.DeleteEvent) { break; } 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 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) { status = false; simws.StorePassPhrase(DomainID, "", CredentialType.None, false); /* Testing purpose * string uid, passphrasecheck; * simws.GetPassPhrase(DomainID, out uid, out passphrasecheck); */ } 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); }