Import/Export changes
This commit is contained in:
		| @@ -111,7 +111,12 @@ namespace Novell.CASA.GUI | |||||||
| 					m_config.WriteConfig(); | 					m_config.WriteConfig(); | ||||||
| 			 | 			 | ||||||
| 					// call our daemon to get the users secrets | 					// call our daemon to get the users secrets | ||||||
| 					ExportXMLSecrets exportSecrets = new ExportXMLSecrets(sMasterPWD, sEncryptString); | 					ExportXMLSecrets exportSecrets = new ExportXMLSecrets(sMasterPWD, sEncryptString, sFileName); | ||||||
|  |  | ||||||
|  | 					object obj = Novell.CASA.MiCasa.Communication.MiCasaRequestReply.Send(MiCasaRequestReply.VERB_EXPORT_SECRETS, null, null, null, exportSecrets); | ||||||
|  | 					 | ||||||
|  | 				 | ||||||
|  | 					/* | ||||||
| 					byte[] theSecrets = (byte[])Novell.CASA.MiCasa.Communication.MiCasaRequestReply.Send(MiCasaRequestReply.VERB_EXPORT_SECRETS, null, null, null, exportSecrets); | 					byte[] theSecrets = (byte[])Novell.CASA.MiCasa.Communication.MiCasaRequestReply.Send(MiCasaRequestReply.VERB_EXPORT_SECRETS, null, null, null, exportSecrets); | ||||||
|  |  | ||||||
| 					// write em out. | 					// write em out. | ||||||
| @@ -121,6 +126,7 @@ namespace Novell.CASA.GUI | |||||||
| 					fs.Write(theSecrets, 0, theSecrets.Length); | 					fs.Write(theSecrets, 0, theSecrets.Length); | ||||||
| 					fs.Flush(); | 					fs.Flush(); | ||||||
| 					fs.Close(); | 					fs.Close(); | ||||||
|  | 					*/ | ||||||
|  |  | ||||||
| 					CommonGUI.DisplayMessage(MessageType.Info, "Secrets saved to: \r\n" + sFileName); | 					CommonGUI.DisplayMessage(MessageType.Info, "Secrets saved to: \r\n" + sFileName); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -13,6 +13,7 @@ namespace Novell.CASA.GUI | |||||||
| 	{ | 	{ | ||||||
| 		Config m_config = null; | 		Config m_config = null; | ||||||
| 		public MiCasa m_objMiCasa	= null;  | 		public MiCasa m_objMiCasa	= null;  | ||||||
|  | 		string sFile = null; | ||||||
| 		byte[] buffer = null; | 		byte[] buffer = null; | ||||||
|  |  | ||||||
| 		[Glade.Widget]  | 		[Glade.Widget]  | ||||||
| @@ -32,7 +33,6 @@ namespace Novell.CASA.GUI | |||||||
| 		{ | 		{ | ||||||
| 			String sHintDir = m_config.GetConfigSetting(CommonGUI.HINT_DIR, null);; | 			String sHintDir = m_config.GetConfigSetting(CommonGUI.HINT_DIR, null);; | ||||||
| 			String sHintFilename = m_config.GetConfigSetting(CommonGUI.HINT_FILENAME, null); | 			String sHintFilename = m_config.GetConfigSetting(CommonGUI.HINT_FILENAME, null); | ||||||
| 			string sFile = null; |  | ||||||
| 			 | 			 | ||||||
| 			FileChooser fc = new FileChooser(FileChooser.ACTION_OPEN); | 			FileChooser fc = new FileChooser(FileChooser.ACTION_OPEN); | ||||||
| 			sFile = fc.GetFile(sHintDir, sHintFilename); | 			sFile = fc.GetFile(sHintDir, sHintFilename); | ||||||
| @@ -71,7 +71,7 @@ namespace Novell.CASA.GUI | |||||||
| 					// check for clear text secrets | 					// check for clear text secrets | ||||||
| 					if (data.StartsWith("<?xml")) | 					if (data.StartsWith("<?xml")) | ||||||
| 					{ | 					{ | ||||||
| 						ImportXMLSecrets addSecrets = new ImportXMLSecrets(null, buffer); | 						ImportXMLSecrets addSecrets = new ImportXMLSecrets(null, null, sFile); | ||||||
| 						MiCasaRequestReply.Send(MiCasaRequestReply.VERB_ADD_XML_SECRETS, null, null, null, addSecrets); | 						MiCasaRequestReply.Send(MiCasaRequestReply.VERB_ADD_XML_SECRETS, null, null, null, addSecrets); | ||||||
| 						CommonGUI.DisplayMessage(Gtk.MessageType.Info, "Import complete"); | 						CommonGUI.DisplayMessage(Gtk.MessageType.Info, "Import complete"); | ||||||
| 					} | 					} | ||||||
| @@ -134,7 +134,7 @@ namespace Novell.CASA.GUI | |||||||
| 		{ | 		{ | ||||||
| 			if (entryMasterPassword != null) | 			if (entryMasterPassword != null) | ||||||
| 			{ | 			{ | ||||||
| 				ImportXMLSecrets addSecrets = new ImportXMLSecrets(entryMasterPassword.Text, buffer); | 				ImportXMLSecrets addSecrets = new ImportXMLSecrets(entryMasterPassword.Text, null, sFile); | ||||||
| 				addSecrets = (ImportXMLSecrets)MiCasaRequestReply.Send(MiCasaRequestReply.VERB_ADD_XML_SECRETS, null, null, null, addSecrets);									 | 				addSecrets = (ImportXMLSecrets)MiCasaRequestReply.Send(MiCasaRequestReply.VERB_ADD_XML_SECRETS, null, null, null, addSecrets);									 | ||||||
|  |  | ||||||
| 				if (dialogImport != null) | 				if (dialogImport != null) | ||||||
|   | |||||||
| @@ -11,14 +11,21 @@ namespace Novell.CASA.MiCasa.Common | |||||||
| 	{ | 	{ | ||||||
| 		private string m_sMasterPassword = null; | 		private string m_sMasterPassword = null; | ||||||
| 		private string m_sPassphrase = null; | 		private string m_sPassphrase = null; | ||||||
|  | 		private string m_sFilePath = null; | ||||||
|  |  | ||||||
| 		public ExportXMLSecrets(string sMasterPassword, string sPassphrase) | 		public ExportXMLSecrets(string sMasterPassword, string sPassphrase, string sFilePath) | ||||||
| 		{ | 		{ | ||||||
| 			m_sMasterPassword = sMasterPassword; | 			m_sMasterPassword = sMasterPassword; | ||||||
|  |  | ||||||
| 			if (sPassphrase != null) | 			if (sPassphrase != null) | ||||||
| 			{ | 			{ | ||||||
| 				m_sPassphrase = sPassphrase; | 				m_sPassphrase = sPassphrase; | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | 			if (sFilePath != null) | ||||||
|  | 			{ | ||||||
|  | 				m_sFilePath = sFilePath; | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		public string GetMasterPassword() | 		public string GetMasterPassword() | ||||||
| @@ -30,5 +37,10 @@ namespace Novell.CASA.MiCasa.Common | |||||||
| 		{ | 		{ | ||||||
| 			return m_sPassphrase; | 			return m_sPassphrase; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		public string GetFilePath() | ||||||
|  | 		{ | ||||||
|  | 			return m_sFilePath; | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -12,11 +12,16 @@ namespace Novell.CASA.MiCasa.Common | |||||||
| 		private string m_MasterPassword = null; | 		private string m_MasterPassword = null; | ||||||
| 		private byte[] m_XmlSecrets = null; | 		private byte[] m_XmlSecrets = null; | ||||||
| 		private string m_sStatus = ""; | 		private string m_sStatus = ""; | ||||||
|  | 		private string m_sFilePath = null; | ||||||
|  |  | ||||||
| 		public ImportXMLSecrets(string sMasterPassword, byte[] XmlSecrets) | 		public ImportXMLSecrets(string sMasterPassword, byte[] XmlSecrets, string sFilePath) | ||||||
| 		{ | 		{ | ||||||
| 			m_MasterPassword = sMasterPassword; | 			m_MasterPassword = sMasterPassword; | ||||||
| 			m_XmlSecrets = XmlSecrets; | 			m_XmlSecrets = XmlSecrets; | ||||||
|  | 			if (sFilePath != null) | ||||||
|  | 			{ | ||||||
|  | 				m_sFilePath = sFilePath; | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		public string GetMasterPasssword() | 		public string GetMasterPasssword() | ||||||
| @@ -29,6 +34,11 @@ namespace Novell.CASA.MiCasa.Common | |||||||
| 			return m_XmlSecrets; | 			return m_XmlSecrets; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		public string GetFilePath() | ||||||
|  | 		{ | ||||||
|  | 			return m_sFilePath; | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 		public void SetStatus(string s) | 		public void SetStatus(string s) | ||||||
| 		{ | 		{ | ||||||
| 			m_sStatus = s; | 			m_sStatus = s; | ||||||
|   | |||||||
| @@ -248,8 +248,33 @@ namespace sscs.verbs | |||||||
| 		{ | 		{ | ||||||
| 			ImportXMLSecrets addSecrets = (ImportXMLSecrets)wo.GetObject(); | 			ImportXMLSecrets addSecrets = (ImportXMLSecrets)wo.GetObject(); | ||||||
| 			string sMasterPassword = addSecrets.GetMasterPasssword(); | 			string sMasterPassword = addSecrets.GetMasterPasssword(); | ||||||
| 			byte[] baXMLSecrets = addSecrets.GetXmlSecrets(); |  | ||||||
|  |  | ||||||
|  | 			string sFilePath = addSecrets.GetFilePath(); | ||||||
|  | 			byte[] baXMLSecrets = null; | ||||||
|  | 			try | ||||||
|  | 			{ | ||||||
|  | 				if (File.Exists(sFilePath)) | ||||||
|  | 				{									 | ||||||
|  | 					 | ||||||
|  | 					// let's read it | ||||||
|  | 					FileStream fs = new FileStream(sFilePath, FileMode.Open); | ||||||
|  | 					baXMLSecrets = new byte[fs.Length]; | ||||||
|  |  | ||||||
|  | 					int iBytes = fs.Read(baXMLSecrets, 0, (int)fs.Length);				 | ||||||
|  | 					fs.Flush(); | ||||||
|  | 					fs.Close(); | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 			catch (Exception e) | ||||||
|  | 			{ | ||||||
|  | 				wo.SetError(constants.RetCodes.FAILURE, e.ToString()); | ||||||
|  | 				return wo; | ||||||
|  | 			} | ||||||
|  | 			 | ||||||
|  | 			//byte[] baXMLSecrets = addSecrets.GetXmlSecrets(); | ||||||
|  |  | ||||||
|  | 			if (baXMLSecrets != null) | ||||||
|  | 			{ | ||||||
| 				try  | 				try  | ||||||
| 				{ | 				{ | ||||||
| 					if (sMasterPassword != null) | 					if (sMasterPassword != null) | ||||||
| @@ -270,6 +295,7 @@ namespace sscs.verbs | |||||||
| 					addSecrets.SetStatus(e.ToString()); | 					addSecrets.SetStatus(e.ToString()); | ||||||
| 					wo.SetError(constants.RetCodes.FAILURE, e.ToString()); | 					wo.SetError(constants.RetCodes.FAILURE, e.ToString()); | ||||||
| 				} | 				} | ||||||
|  | 			} | ||||||
| 						 | 						 | ||||||
| 			return wo; | 			return wo; | ||||||
| 		} | 		} | ||||||
| @@ -293,7 +319,21 @@ namespace sscs.verbs | |||||||
| 			string sEncrpyptionPassphrase = secrets.GetPassphrase(); | 			string sEncrpyptionPassphrase = secrets.GetPassphrase(); | ||||||
|  |  | ||||||
| 			// get all secrets | 			// get all secrets | ||||||
|  | 			byte[] baSecrets = ssStore.GetSecrets(sEncrpyptionPassphrase); | ||||||
|  | 			string sFilePath = secrets.GetFilePath(); | ||||||
|  | 			if (sFilePath != null) | ||||||
|  | 			{ | ||||||
|  | 				// write em out | ||||||
|  | 				FileStream fs = new FileStream(sFilePath, FileMode.Create); | ||||||
|  | 				fs.Write(baSecrets, 0, baSecrets.Length); | ||||||
|  | 				fs.Flush(); | ||||||
|  | 				fs.Close(); | ||||||
|  | 			} | ||||||
|  | 			else | ||||||
|  | 			{ | ||||||
| 				wo.SetObject(ssStore.GetSecrets(sEncrpyptionPassphrase)); | 				wo.SetObject(ssStore.GetSecrets(sEncrpyptionPassphrase)); | ||||||
|  | 			} | ||||||
|  |  | ||||||
| 			wo.SetError(constants.RetCodes.SUCCESS, ""); | 			wo.SetError(constants.RetCodes.SUCCESS, ""); | ||||||
| 			return wo; | 			return wo; | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user