Save and Restore timestamps on Secrets/KeyValue objects.

This commit is contained in:
Jim Norman 2006-11-29 05:54:02 +00:00
parent 3bab43861a
commit 33ca5ca168
7 changed files with 149 additions and 54 deletions

View File

@ -139,6 +139,10 @@ namespace sscs.cache
get
{
return m_created;
}
set
{
m_created = value;
}
}
@ -148,6 +152,10 @@ namespace sscs.cache
get
{
return m_modified;
}
set
{
m_modified = value;
}
}

View File

@ -86,6 +86,7 @@ namespace sscs.init
base.Dispose( disposing );
}
[STAThreadAttribute]
static void Main(string[] args)
{
string opt = null ;
@ -274,6 +275,7 @@ namespace sscs.init
return RetCodes.SUCCESS;
}
private static void MainInternal(string[] args)
{
CSSSLogger.ExecutionTrace(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

View File

@ -407,7 +407,7 @@ namespace sscs.lss
XmlNode createdTimeNode = timeAttribCol.GetNamedItem(XmlConsts.createdTimeNode);
if (createdTimeNode != null)
{
//Console.WriteLine("KeyChain create time:" + new DateTime(long.Parse(createdTimeNode.Value)));
//Console.WriteLine("KeyChain create time:" + new DateTime(long.Parse(createdTimeNode.Value)));
}
else
{
@ -444,6 +444,7 @@ namespace sscs.lss
if (createdTimeNode != null)
{
//Console.WriteLine("Secret create time:" + new DateTime(long.Parse(createdTimeNode.Value)));
secret.CreatedTime = new DateTime(long.Parse(createdTimeNode.Value));
}
else
{
@ -454,6 +455,7 @@ namespace sscs.lss
if (modifiedTimeNode != null)
{
//Console.WriteLine("Secret mod time:" + new DateTime(long.Parse(modifiedTimeNode.Value)));
secret.ModifiedTime = new DateTime(long.Parse(modifiedTimeNode.Value));
}
else
{
@ -488,7 +490,40 @@ namespace sscs.lss
xpath = "descendant::" + XmlConsts.keyValueNode;
XmlNode keyValNode = keyNode.SelectSingleNode(xpath);
string keyValue = keyValNode.InnerText;
secret.SetKeyValue(key, keyValue);
secret.SetKeyValue(key, keyValue);
// get time attributes on this key/value
XmlNode timeNodeKey = keyNode.SelectSingleNode("descendant::" + XmlConsts.timeNode);
if (timeNodeKey != null)
{
// get the key value we just set
KeyValue kv = secret.GetKeyValue(key);
XmlAttributeCollection timeAttribCol = timeNodeKey.Attributes;
if (timeAttribCol != null)
{
XmlNode createdTimeNode = timeAttribCol.GetNamedItem(XmlConsts.createdTimeNode);
if (createdTimeNode != null)
{
kv.CreatedTime = new DateTime(long.Parse(createdTimeNode.Value));
}
else
{
//Console.WriteLine("Create time not found");
}
XmlNode modifiedTimeNode = timeAttribCol.GetNamedItem(XmlConsts.modifiedTimeNode);
if (modifiedTimeNode != null)
{
kv.ModifiedTime = new DateTime(long.Parse(modifiedTimeNode.Value));
}
else
{
//Console.WriteLine("mod time not found");
}
}
}
// add linked keys
xpath = "descendant::" + XmlConsts.linkedKeyNode;
@ -721,7 +756,7 @@ namespace sscs.lss
// If we need to store time
writer.WriteStartElement(XmlConsts.timeNode);
writer.WriteAttributeString(XmlConsts.createdTimeNode, secret.CreatedTime.Ticks.ToString());
writer.WriteAttributeString("LazyTime", secret.CreatedTime.ToShortDateString());
//writer.WriteAttributeString("LazyTime", secret.CreatedTime.ToShortDateString());
writer.WriteAttributeString(XmlConsts.modifiedTimeNode, secret.ModifiedTime.Ticks.ToString());
writer.WriteEndElement();

View File

@ -49,6 +49,8 @@ namespace sscs.winforms
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.label7 = new System.Windows.Forms.Label();
this.Created = new System.Windows.Forms.ColumnHeader();
this.Modified = new System.Windows.Forms.ColumnHeader();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
@ -74,7 +76,7 @@ namespace sscs.winforms
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label3.Location = new System.Drawing.Point(9, 93);
this.label3.Location = new System.Drawing.Point(14, 69);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(65, 13);
this.label3.TabIndex = 2;
@ -83,14 +85,16 @@ namespace sscs.winforms
// tbSecretID
//
this.tbSecretID.Enabled = false;
this.tbSecretID.Location = new System.Drawing.Point(13, 110);
this.tbSecretID.Location = new System.Drawing.Point(18, 86);
this.tbSecretID.Name = "tbSecretID";
this.tbSecretID.Size = new System.Drawing.Size(364, 20);
this.tbSecretID.TabIndex = 3;
//
// groupBox1
//
this.groupBox1.AutoSize = true;
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.groupBox1.BackColor = System.Drawing.SystemColors.ControlDark;
this.groupBox1.Controls.Add(this.listViewKeyValues);
@ -102,26 +106,31 @@ namespace sscs.winforms
this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.groupBox1.Location = new System.Drawing.Point(15, 143);
this.groupBox1.Location = new System.Drawing.Point(15, 141);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(361, 223);
this.groupBox1.Size = new System.Drawing.Size(437, 236);
this.groupBox1.TabIndex = 4;
this.groupBox1.TabStop = false;
//
// listViewKeyValues
//
this.listViewKeyValues.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listViewKeyValues.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.listViewKeyValues.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.Key,
this.Value,
this.Linked});
this.Linked,
this.Created,
this.Modified});
this.listViewKeyValues.FullRowSelect = true;
this.listViewKeyValues.GridLines = true;
this.listViewKeyValues.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.listViewKeyValues.LabelEdit = true;
this.listViewKeyValues.Location = new System.Drawing.Point(3, 93);
this.listViewKeyValues.Location = new System.Drawing.Point(18, 93);
this.listViewKeyValues.Name = "listViewKeyValues";
this.listViewKeyValues.Size = new System.Drawing.Size(312, 111);
this.listViewKeyValues.Size = new System.Drawing.Size(359, 130);
this.listViewKeyValues.Sorting = System.Windows.Forms.SortOrder.Ascending;
this.listViewKeyValues.TabIndex = 12;
this.listViewKeyValues.UseCompatibleStateImageBehavior = false;
@ -131,10 +140,12 @@ namespace sscs.winforms
// Key
//
this.Key.Text = "Key";
this.Key.Width = 64;
//
// Value
//
this.Value.Text = "Value";
this.Value.Width = 62;
//
// Linked
//
@ -142,8 +153,9 @@ namespace sscs.winforms
//
// button2
//
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button2.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button2.Location = new System.Drawing.Point(321, 92);
this.button2.Location = new System.Drawing.Point(384, 117);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(34, 31);
this.button2.TabIndex = 11;
@ -153,8 +165,9 @@ namespace sscs.winforms
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button1.Location = new System.Drawing.Point(321, 31);
this.button1.Location = new System.Drawing.Point(384, 33);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(34, 31);
this.button1.TabIndex = 10;
@ -166,7 +179,7 @@ namespace sscs.winforms
//
this.label6.AutoSize = true;
this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label6.Location = new System.Drawing.Point(6, 71);
this.label6.Location = new System.Drawing.Point(17, 71);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(99, 13);
this.label6.TabIndex = 8;
@ -174,23 +187,23 @@ namespace sscs.winforms
//
// tbNewValue
//
this.tbNewValue.Location = new System.Drawing.Point(163, 33);
this.tbNewValue.Location = new System.Drawing.Point(194, 33);
this.tbNewValue.Name = "tbNewValue";
this.tbNewValue.Size = new System.Drawing.Size(152, 20);
this.tbNewValue.Size = new System.Drawing.Size(168, 20);
this.tbNewValue.TabIndex = 7;
//
// tbNewKey
//
this.tbNewKey.Location = new System.Drawing.Point(9, 33);
this.tbNewKey.Location = new System.Drawing.Point(20, 33);
this.tbNewKey.Name = "tbNewKey";
this.tbNewKey.Size = new System.Drawing.Size(148, 20);
this.tbNewKey.Size = new System.Drawing.Size(163, 20);
this.tbNewKey.TabIndex = 5;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label5.Location = new System.Drawing.Point(161, 16);
this.label5.Location = new System.Drawing.Point(191, 16);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(43, 13);
this.label5.TabIndex = 6;
@ -200,7 +213,7 @@ namespace sscs.winforms
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label4.Location = new System.Drawing.Point(6, 16);
this.label4.Location = new System.Drawing.Point(17, 16);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(32, 13);
this.label4.TabIndex = 5;
@ -210,7 +223,7 @@ namespace sscs.winforms
//
this.checkBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(21, 385);
this.checkBox1.Location = new System.Drawing.Point(21, 401);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(145, 17);
this.checkBox1.TabIndex = 5;
@ -222,7 +235,7 @@ namespace sscs.winforms
//
this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button3.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button3.Location = new System.Drawing.Point(209, 400);
this.button3.Location = new System.Drawing.Point(267, 398);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(87, 31);
this.button3.TabIndex = 12;
@ -234,7 +247,7 @@ namespace sscs.winforms
//
this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button4.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button4.Location = new System.Drawing.Point(302, 400);
this.button4.Location = new System.Drawing.Point(360, 398);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(87, 31);
this.button4.TabIndex = 13;
@ -250,12 +263,23 @@ namespace sscs.winforms
this.label7.Size = new System.Drawing.Size(442, 13);
this.label7.TabIndex = 14;
this.label7.Text = "To change a value, click the key you want to change and enter a new value";
this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// Created
//
this.Created.Text = "Created";
this.Created.Width = 79;
//
// Modified
//
this.Modified.Text = "Modiified";
this.Modified.Width = 90;
//
// EditSecretForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(409, 441);
this.ClientSize = new System.Drawing.Size(467, 448);
this.Controls.Add(this.label7);
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
@ -300,5 +324,7 @@ namespace sscs.winforms
private System.Windows.Forms.ColumnHeader Linked;
private System.Windows.Forms.ColumnHeader Value;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.ColumnHeader Created;
private System.Windows.Forms.ColumnHeader Modified;
}
}

View File

@ -55,7 +55,7 @@ namespace sscs.winforms
ArrayList al = secret.GetKeyList();
for (int i = 0; i < al.Count; i++)
{
string[] stuff = new string[3];
string[] stuff = new string[5];
string sKey = (string)al[i];
stuff[0] = sKey;
@ -80,6 +80,11 @@ namespace sscs.winforms
stuff[2] = "No";
}
// get keyvalue timestamps
stuff[3] = kv.CreatedTime.ToShortDateString() + " " + kv.CreatedTime.ToLongTimeString();
stuff[4] = kv.ModifiedTime.ToShortDateString() + " " + kv.ModifiedTime.ToLongTimeString();
ListViewItem item = new ListViewItem(stuff);
listViewKeyValues.Items.Add(item);
}

View File

@ -76,6 +76,9 @@ namespace sscs.winforms
this.preferencesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator();
this.policyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.profilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.newToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator10 = new System.Windows.Forms.ToolStripSeparator();
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.contentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.aboutCasaToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -94,9 +97,6 @@ namespace sscs.winforms
this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator();
this.deleteToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
this.profilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.newToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator10 = new System.Windows.Forms.ToolStripSeparator();
this.contextMenuStripNotify.SuspendLayout();
this.menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
@ -428,6 +428,27 @@ namespace sscs.winforms
this.policyToolStripMenuItem.Size = new System.Drawing.Size(207, 22);
this.policyToolStripMenuItem.Text = "Policies";
//
// profilesToolStripMenuItem
//
this.profilesToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.newToolStripMenuItem2,
this.toolStripSeparator10});
this.profilesToolStripMenuItem.Name = "profilesToolStripMenuItem";
this.profilesToolStripMenuItem.Size = new System.Drawing.Size(54, 20);
this.profilesToolStripMenuItem.Text = "Profiles";
this.profilesToolStripMenuItem.Visible = false;
//
// newToolStripMenuItem2
//
this.newToolStripMenuItem2.Name = "newToolStripMenuItem2";
this.newToolStripMenuItem2.Size = new System.Drawing.Size(106, 22);
this.newToolStripMenuItem2.Text = "New";
//
// toolStripSeparator10
//
this.toolStripSeparator10.Name = "toolStripSeparator10";
this.toolStripSeparator10.Size = new System.Drawing.Size(103, 6);
//
// helpToolStripMenuItem
//
this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -476,17 +497,25 @@ namespace sscs.winforms
this.listViewNative.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2});
this.listViewNative.GridLines = true;
this.listViewNative.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.listViewNative.Location = new System.Drawing.Point(13, 377);
this.listViewNative.Name = "listViewNative";
this.listViewNative.Size = new System.Drawing.Size(434, 86);
this.listViewNative.TabIndex = 9;
this.listViewNative.UseCompatibleStateImageBehavior = false;
this.listViewNative.View = System.Windows.Forms.View.List;
this.listViewNative.View = System.Windows.Forms.View.Details;
this.listViewNative.Visible = false;
//
// columnHeader1
//
this.columnHeader1.Text = "";
this.columnHeader1.Text = "Attribute";
this.columnHeader1.Width = 121;
//
// columnHeader2
//
this.columnHeader2.Text = "Value";
this.columnHeader2.Width = 190;
//
// openFileDialog1
//
@ -562,27 +591,6 @@ namespace sscs.winforms
//
this.saveFileDialog.CheckFileExists = true;
//
// profilesToolStripMenuItem
//
this.profilesToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.newToolStripMenuItem2,
this.toolStripSeparator10});
this.profilesToolStripMenuItem.Name = "profilesToolStripMenuItem";
this.profilesToolStripMenuItem.Size = new System.Drawing.Size(54, 20);
this.profilesToolStripMenuItem.Text = "Profiles";
this.profilesToolStripMenuItem.Visible = false;
//
// newToolStripMenuItem2
//
this.newToolStripMenuItem2.Name = "newToolStripMenuItem2";
this.newToolStripMenuItem2.Size = new System.Drawing.Size(158, 22);
this.newToolStripMenuItem2.Text = "New";
//
// toolStripSeparator10
//
this.toolStripSeparator10.Name = "toolStripSeparator10";
this.toolStripSeparator10.Size = new System.Drawing.Size(149, 6);
//
// MiCasaForm
//
this.AcceptButton = this.button1;

View File

@ -107,14 +107,19 @@ namespace sscs.winforms
}
if (WinCommon.VerifyMasterPassword(m_ss, "Enter your Master Password for:"+profiledir))
{
if (WinCommon.VerifyMasterPassword(m_ss, "Enter your Master Password for:" + profiledir))
{
server = CommunicationFactory.CreateCommunicationEndPoint();
listeningThread = new Thread(new ThreadStart(StartServer));
listeningThread.Start();
button1.Text = "Stop";
EnumKeyChains();
}
this.Text = "MiCasa - " + profiledir;
}
else
{
this.Text = "MiCasa";
}
}
void MiCasaForm_Click(object sender, EventArgs e)
@ -143,6 +148,11 @@ namespace sscs.winforms
if (sPassword == null)
{
currSelectedMenuItem.Checked = false;
this.Text = "MiCasa";
}
else
{
this.Text = "MiCasa - " + profiledir;
}
mSelectedKeyChainID = null;
@ -347,6 +357,7 @@ namespace sscs.winforms
// set master password
WinCommon.GetMasterPasswordFromUser(m_ss, true, "Enter your Master Password for:" + profiledir);
mSelectedKeyChainID = null;
RefreshStore();