Code needed for Change Master Password
This commit is contained in:
		
							
								
								
									
										12
									
								
								c_micasad/cache/SecretStore.cs
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								c_micasad/cache/SecretStore.cs
									
									
									
									
										vendored
									
									
								
							| @@ -597,6 +597,18 @@ namespace sscs.cache | |||||||
|            return true;  |            return true;  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  | 		internal bool ChangeMasterPassword(string sCurrentPWD, string sNewPWD) | ||||||
|  | 		{ | ||||||
|  | 			string sMasterFilePath = GetPasscodeByMasterPasswdFilePath(); | ||||||
|  | 			byte[] baPasscode = CASACrypto.GetMasterPasscodeUsingMasterPasswd(sCurrentPWD, sMasterFilePath); | ||||||
|  | 			if (baPasscode != null) | ||||||
|  | 			{ | ||||||
|  | 				CASACrypto.EncryptAndStoreMasterPasscodeUsingString(baPasscode, sNewPWD, sMasterFilePath); | ||||||
|  | 				return true; | ||||||
|  | 			} | ||||||
|  | 			return false; | ||||||
|  | 		} | ||||||
|  |  | ||||||
|         internal string GetDesktopPasswd() |         internal string GetDesktopPasswd() | ||||||
|         {  |         {  | ||||||
|             try |             try | ||||||
|   | |||||||
| @@ -113,6 +113,11 @@ | |||||||
|                     SubType = "Code" |                     SubType = "Code" | ||||||
|                     BuildAction = "Compile" |                     BuildAction = "Compile" | ||||||
|                 /> |                 /> | ||||||
|  |                 <File | ||||||
|  |                     RelPath = "common\ResetMasterPassword.cs" | ||||||
|  |                     SubType = "Code" | ||||||
|  |                     BuildAction = "Compile" | ||||||
|  |                 /> | ||||||
|                 <File |                 <File | ||||||
|                     RelPath = "common\WrappedObject.cs" |                     RelPath = "common\WrappedObject.cs" | ||||||
|                     SubType = "Code" |                     SubType = "Code" | ||||||
|   | |||||||
							
								
								
									
										22
									
								
								c_micasad/lib/common/ResetMasterPassword.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								c_micasad/lib/common/ResetMasterPassword.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | |||||||
|  | using System; | ||||||
|  |  | ||||||
|  | namespace Novell.CASA.MiCasa.Common | ||||||
|  | { | ||||||
|  | 	/// <summary> | ||||||
|  | 	/// Summary description for ResetMasterPassword. | ||||||
|  | 	/// </summary> | ||||||
|  | 	/// 	 | ||||||
|  | 	[Serializable] | ||||||
|  | 	public class ResetMasterPassword | ||||||
|  | 	{ | ||||||
|  | 		public string m_currentPassword; | ||||||
|  | 		public string m_newPassword; | ||||||
|  | 		public int rcode = 0; | ||||||
|  | 		 | ||||||
|  | 		public ResetMasterPassword(string currentPassword, string newPassword) | ||||||
|  | 		{ | ||||||
|  | 			m_currentPassword = currentPassword; | ||||||
|  | 			m_newPassword = newPassword; | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | } | ||||||
| @@ -30,6 +30,7 @@ namespace Novell.CASA.MiCasa.Communication | |||||||
| 		public const int VERB_REMOVE_KEY = 15; | 		public const int VERB_REMOVE_KEY = 15; | ||||||
| 		public const int VERB_READ_KEY = 16; | 		public const int VERB_READ_KEY = 16; | ||||||
| 		public const int VERB_GET_KEY_LIST = 17; | 		public const int VERB_GET_KEY_LIST = 17; | ||||||
|  | 		public const int VERB_RESET_MASTER_PASSWORD = 18; | ||||||
|  |  | ||||||
| 		public const int VERB_DUMP_LINKED_KEYS = 96; | 		public const int VERB_DUMP_LINKED_KEYS = 96; | ||||||
| 		public const int VERB_CREATE_TEST_SECRETS = 97; | 		public const int VERB_CREATE_TEST_SECRETS = 97; | ||||||
| @@ -129,7 +130,10 @@ namespace Novell.CASA.MiCasa.Communication | |||||||
| 					reply = (WrappedObject)formatter.Deserialize(ms);				 | 					reply = (WrappedObject)formatter.Deserialize(ms);				 | ||||||
| 					 | 					 | ||||||
| 					if (reply.GetReturnCode() != 0) | 					if (reply.GetReturnCode() != 0) | ||||||
|  | 					{ | ||||||
|  | 						ipcChannel.Close(); | ||||||
| 						throw new Exception(reply.GetReturnCode().ToString());															 | 						throw new Exception(reply.GetReturnCode().ToString());															 | ||||||
|  | 					} | ||||||
|  |  | ||||||
| 				} | 				} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -2,6 +2,7 @@ OBJS=\ | |||||||
| 	AssemblyInfo \ | 	AssemblyInfo \ | ||||||
| 	common/LinkedKeyInfo \ | 	common/LinkedKeyInfo \ | ||||||
| 	common/Ping \ | 	common/Ping \ | ||||||
|  | 	common/ResetMasterPassword \ | ||||||
| 	common/WrappedObject \ | 	common/WrappedObject \ | ||||||
| 	common/MiCASAStore \ | 	common/MiCASAStore \ | ||||||
| 	communication/IClientChannel \ | 	communication/IClientChannel \ | ||||||
|   | |||||||
| @@ -2,6 +2,7 @@ SRC=\ | |||||||
| 	AssemblyInfo.cs \ | 	AssemblyInfo.cs \ | ||||||
| 	common/LinkedKeyInfo.cs \ | 	common/LinkedKeyInfo.cs \ | ||||||
| 	common/Ping.cs \ | 	common/Ping.cs \ | ||||||
|  | 	common/ResetMasterPassword.cs \ | ||||||
| 	common/WrappedObject.cs \ | 	common/WrappedObject.cs \ | ||||||
| 	common/MiCASAStore.cs \ | 	common/MiCASAStore.cs \ | ||||||
| 	communication/IClientChannel.cs \ | 	communication/IClientChannel.cs \ | ||||||
|   | |||||||
| @@ -183,6 +183,11 @@ namespace sscs.verbs | |||||||
| 						{ | 						{ | ||||||
| 							return DoGetKeyList(ssStore, wo); | 							return DoGetKeyList(ssStore, wo); | ||||||
| 						} | 						} | ||||||
|  | 						case MiCasaRequestReply.VERB_RESET_MASTER_PASSWORD: | ||||||
|  | 						{ | ||||||
|  | 							return DoResetMasterPassword(ssStore, wo); | ||||||
|  | 						} | ||||||
|  |  | ||||||
| 						default: | 						default: | ||||||
| 						{ | 						{ | ||||||
| 							wo.SetError(constants.RetCodes.FAILURE, "Verb Not Supported"); | 							wo.SetError(constants.RetCodes.FAILURE, "Verb Not Supported"); | ||||||
| @@ -654,6 +659,39 @@ namespace sscs.verbs | |||||||
| 			return wo; | 			return wo; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  |  | ||||||
|  | 		private WrappedObject DoResetMasterPassword(SecretStore ssStore, WrappedObject wo) | ||||||
|  | 		{ | ||||||
|  | 			ResetMasterPassword rmp = (ResetMasterPassword)wo.GetObject();				 | ||||||
|  | 			// verify current master password | ||||||
|  | 			try  | ||||||
|  | 			{ | ||||||
|  | 				string sMasterPassword = rmp.m_currentPassword; | ||||||
|  | 				ssStore.UnlockStore(null, sMasterPassword); | ||||||
|  | 			} | ||||||
|  | 			catch (Exception e) | ||||||
|  | 			{ | ||||||
|  | 				wo.SetError(constants.RetCodes.FAILURE, e.ToString()); | ||||||
|  | 				return wo; | ||||||
|  | 			} | ||||||
|  |  | ||||||
|  | 			// change master master password | ||||||
|  | 			string sNewPassword =  rmp.m_newPassword; | ||||||
|  | 			if (sNewPassword == null || sNewPassword.Length < 8) | ||||||
|  | 			{ | ||||||
|  | 				wo.SetError(constants.RetCodes.FAILURE, null); | ||||||
|  | 				return wo; | ||||||
|  | 			} | ||||||
|  |  | ||||||
|  | 			if (!ssStore.ChangeMasterPassword(rmp.m_currentPassword, rmp.m_newPassword)) | ||||||
|  | 				wo.SetError(constants.RetCodes.FAILURE, null);	 | ||||||
|  | 			else | ||||||
|  | 				wo.SetError(constants.RetCodes.SUCCESS, null); | ||||||
|  |  | ||||||
|  |  | ||||||
|  | 			return wo; | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 		private WrappedObject DoPing(WrappedObject wo) | 		private WrappedObject DoPing(WrappedObject wo) | ||||||
| 		{ | 		{ | ||||||
| 			//Console.WriteLine("MICASAD received Ping from Client"); | 			//Console.WriteLine("MICASAD received Ping from Client"); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user