diff --git a/CASA/micasad/cache/SecretStore.cs b/CASA/micasad/cache/SecretStore.cs index 93bf2ae2..97269a17 100644 --- a/CASA/micasad/cache/SecretStore.cs +++ b/CASA/micasad/cache/SecretStore.cs @@ -730,14 +730,26 @@ namespace sscs.cache byte[] baPasscode = CASACrypto.GetMasterPasscodeUsingMasterPasswd(sCurrentPWD, sMasterFilePath, false); if (baPasscode != null) { - mpWatcher.pauseWatcher(); + PauseFileWatcher(); CASACrypto.EncryptAndStoreMasterPasscodeUsingString(baPasscode, sNewPWD, sMasterFilePath); - mpWatcher.resumeWatcher(); + ResumeFileWatcher(); return true; } return false; } + internal void PauseFileWatcher() + { + if (mpWatcher != null) + mpWatcher.pauseWatcher(); + } + + internal void ResumeFileWatcher() + { + if (mpWatcher != null) + mpWatcher.resumeWatcher(); + } + internal string GetDesktopPasswd() { try diff --git a/CASA/micasad/lss/CASACrypto.cs b/CASA/micasad/lss/CASACrypto.cs index c8427d27..a7ccad63 100644 --- a/CASA/micasad/lss/CASACrypto.cs +++ b/CASA/micasad/lss/CASACrypto.cs @@ -431,10 +431,9 @@ namespace sscs.crypto FileStream fsEncrypt = null; CryptoStream csEncrypt = null; try - { - // NOTE: removed the delete call because the MPFileWatcher would replace it. - //if(File.Exists(fileName)) - // File.Delete(fileName); + { + if(File.Exists(fileName)) + File.Delete(fileName); byte[] baKey = Generate16ByteKeyFromString(passwd, null, false); //Get an encryptor. @@ -667,10 +666,9 @@ namespace sscs.crypto byte[] baIV = theRiManaged.IV; try - { - // NOTE: removed the delete call because the MPFileWatcher would replace it. - //if (File.Exists(sFileName + ".IV")) - // File.Delete(sFileName + ".IV"); + { + if (File.Exists(sFileName + ".IV")) + File.Delete(sFileName + ".IV"); // now save this FileStream fs = new FileStream(sFileName + ".IV", FileMode.Create); diff --git a/CASA/micasad/verbs/ObjectSerialization.cs b/CASA/micasad/verbs/ObjectSerialization.cs index 1408a7fb..5cbde52c 100644 --- a/CASA/micasad/verbs/ObjectSerialization.cs +++ b/CASA/micasad/verbs/ObjectSerialization.cs @@ -122,6 +122,7 @@ namespace sscs.verbs { SecretStore ssStore = SessionManager.CreateUserSession(userId); + ssStore.PauseFileWatcher(); try { @@ -230,7 +231,7 @@ namespace sscs.verbs wo.SetError(constants.RetCodes.FAILURE, e.ToString()); } - + ssStore.ResumeFileWatcher(); return wo; } diff --git a/CASA/micasad/verbs/SetMasterPasscode.cs b/CASA/micasad/verbs/SetMasterPasscode.cs index 1b0e3b41..43725f22 100644 --- a/CASA/micasad/verbs/SetMasterPasscode.cs +++ b/CASA/micasad/verbs/SetMasterPasscode.cs @@ -87,10 +87,12 @@ namespace sscs.verbs { SecretStore ssStore = null; ssStore = SessionManager.GetUserSecretStore(userId); + ssStore.PauseFileWatcher(); if(ssStore.SetMasterPasscode(passcode)) retCode = IPCRetCodes.SSCS_REPLY_SUCCESS; else retCode = IPCRetCodes.SSCS_E_SETTING_PASSCODE_FAILED; + ssStore.ResumeFileWatcher(); } catch(UserNotInSessionException) { diff --git a/CASA/micasad/verbs/SetMasterPassword.cs b/CASA/micasad/verbs/SetMasterPassword.cs index da6ad585..20334271 100644 --- a/CASA/micasad/verbs/SetMasterPassword.cs +++ b/CASA/micasad/verbs/SetMasterPassword.cs @@ -95,10 +95,14 @@ namespace sscs.verbs { SecretStore ssStore = null; ssStore = SessionManager.GetUserSecretStore(userId); + ssStore.PauseFileWatcher(); + if(ssStore.SetMasterPassword(passwd)) retCode = IPCRetCodes.SSCS_REPLY_SUCCESS; else retCode = IPCRetCodes.SSCS_E_SETTING_PASSCODE_FAILED; + + ssStore.ResumeFileWatcher(); } catch(UserNotInSessionException) {