Import/Export changes
This commit is contained in:
parent
3e261ca152
commit
f7ce95ae97
@ -111,7 +111,12 @@ namespace Novell.CASA.GUI
|
||||
m_config.WriteConfig();
|
||||
|
||||
// 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);
|
||||
|
||||
// write em out.
|
||||
@ -121,6 +126,7 @@ namespace Novell.CASA.GUI
|
||||
fs.Write(theSecrets, 0, theSecrets.Length);
|
||||
fs.Flush();
|
||||
fs.Close();
|
||||
*/
|
||||
|
||||
CommonGUI.DisplayMessage(MessageType.Info, "Secrets saved to: \r\n" + sFileName);
|
||||
|
||||
|
@ -13,6 +13,7 @@ namespace Novell.CASA.GUI
|
||||
{
|
||||
Config m_config = null;
|
||||
public MiCasa m_objMiCasa = null;
|
||||
string sFile = null;
|
||||
byte[] buffer = null;
|
||||
|
||||
[Glade.Widget]
|
||||
@ -32,8 +33,7 @@ namespace Novell.CASA.GUI
|
||||
{
|
||||
String sHintDir = m_config.GetConfigSetting(CommonGUI.HINT_DIR, null);;
|
||||
String sHintFilename = m_config.GetConfigSetting(CommonGUI.HINT_FILENAME, null);
|
||||
string sFile = null;
|
||||
|
||||
|
||||
FileChooser fc = new FileChooser(FileChooser.ACTION_OPEN);
|
||||
sFile = fc.GetFile(sHintDir, sHintFilename);
|
||||
|
||||
@ -71,7 +71,7 @@ namespace Novell.CASA.GUI
|
||||
// check for clear text secrets
|
||||
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);
|
||||
CommonGUI.DisplayMessage(Gtk.MessageType.Info, "Import complete");
|
||||
}
|
||||
@ -134,7 +134,7 @@ namespace Novell.CASA.GUI
|
||||
{
|
||||
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);
|
||||
|
||||
if (dialogImport != null)
|
||||
|
@ -11,14 +11,21 @@ namespace Novell.CASA.MiCasa.Common
|
||||
{
|
||||
private string m_sMasterPassword = 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;
|
||||
|
||||
if (sPassphrase != null)
|
||||
{
|
||||
m_sPassphrase = sPassphrase;
|
||||
}
|
||||
|
||||
if (sFilePath != null)
|
||||
{
|
||||
m_sFilePath = sFilePath;
|
||||
}
|
||||
}
|
||||
|
||||
public string GetMasterPassword()
|
||||
@ -30,5 +37,10 @@ namespace Novell.CASA.MiCasa.Common
|
||||
{
|
||||
return m_sPassphrase;
|
||||
}
|
||||
|
||||
public string GetFilePath()
|
||||
{
|
||||
return m_sFilePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,11 +12,16 @@ namespace Novell.CASA.MiCasa.Common
|
||||
private string m_MasterPassword = null;
|
||||
private byte[] m_XmlSecrets = null;
|
||||
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_XmlSecrets = XmlSecrets;
|
||||
if (sFilePath != null)
|
||||
{
|
||||
m_sFilePath = sFilePath;
|
||||
}
|
||||
}
|
||||
|
||||
public string GetMasterPasssword()
|
||||
@ -29,6 +34,11 @@ namespace Novell.CASA.MiCasa.Common
|
||||
return m_XmlSecrets;
|
||||
}
|
||||
|
||||
public string GetFilePath()
|
||||
{
|
||||
return m_sFilePath;
|
||||
}
|
||||
|
||||
public void SetStatus(string s)
|
||||
{
|
||||
m_sStatus = s;
|
||||
|
@ -248,27 +248,53 @@ namespace sscs.verbs
|
||||
{
|
||||
ImportXMLSecrets addSecrets = (ImportXMLSecrets)wo.GetObject();
|
||||
string sMasterPassword = addSecrets.GetMasterPasssword();
|
||||
byte[] baXMLSecrets = addSecrets.GetXmlSecrets();
|
||||
|
||||
try
|
||||
string sFilePath = addSecrets.GetFilePath();
|
||||
byte[] baXMLSecrets = null;
|
||||
try
|
||||
{
|
||||
if (sMasterPassword != null)
|
||||
{
|
||||
// decrypt secrets if possible
|
||||
ssStore.MergeXMLSecrets(baXMLSecrets, sMasterPassword);
|
||||
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();
|
||||
}
|
||||
else
|
||||
{
|
||||
// do the merge now.
|
||||
ssStore.MergeXMLSecrets(baXMLSecrets);
|
||||
}
|
||||
addSecrets.SetStatus("Success");
|
||||
wo.SetError(constants.RetCodes.SUCCESS, "");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
addSecrets.SetStatus(e.ToString());
|
||||
wo.SetError(constants.RetCodes.FAILURE, e.ToString());
|
||||
return wo;
|
||||
}
|
||||
|
||||
//byte[] baXMLSecrets = addSecrets.GetXmlSecrets();
|
||||
|
||||
if (baXMLSecrets != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (sMasterPassword != null)
|
||||
{
|
||||
// decrypt secrets if possible
|
||||
ssStore.MergeXMLSecrets(baXMLSecrets, sMasterPassword);
|
||||
}
|
||||
else
|
||||
{
|
||||
// do the merge now.
|
||||
ssStore.MergeXMLSecrets(baXMLSecrets);
|
||||
}
|
||||
addSecrets.SetStatus("Success");
|
||||
wo.SetError(constants.RetCodes.SUCCESS, "");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
addSecrets.SetStatus(e.ToString());
|
||||
wo.SetError(constants.RetCodes.FAILURE, e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
return wo;
|
||||
@ -293,7 +319,21 @@ namespace sscs.verbs
|
||||
string sEncrpyptionPassphrase = secrets.GetPassphrase();
|
||||
|
||||
// get all secrets
|
||||
wo.SetObject(ssStore.GetSecrets(sEncrpyptionPassphrase));
|
||||
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.SetError(constants.RetCodes.SUCCESS, "");
|
||||
return wo;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user