diff --git a/CASA/adlib/miCASAEngine.cs b/CASA/adlib/miCASAEngine.cs index 62240bd8..c5f67127 100644 --- a/CASA/adlib/miCASAEngine.cs +++ b/CASA/adlib/miCASAEngine.cs @@ -119,35 +119,34 @@ namespace Novell.CASA.DataEngines value1 = doc.CreateElement(ConstStrings.CCF_VALUE); value1.InnerText = sValue; - key1.AppendChild(value1); - + key1.AppendChild(value1); mi_secret.AppendChild(key1); } - /* - //Time - XmlElement Time1 = doc.CreateElement(ConstStrings.CCF_TIME); + + //Time + XmlElement Time1 = doc.CreateElement(ConstStrings.CCF_TIME); - XmlElement zone1 = doc.CreateElement(ConstStrings.CCF_ZONE); - zone1.InnerText = "IST"; + XmlElement zone1 = doc.CreateElement(ConstStrings.CCF_ZONE); + zone1.InnerText = DateTime.Today.ToString(); - XmlElement cr1 = doc.CreateElement(ConstStrings.CCF_CRTIME); - cr1.InnerText = null; + XmlElement cr1 = doc.CreateElement(ConstStrings.CCF_CRTIME); + cr1.InnerText = secret.GetCreateTime().Ticks.ToString(); - XmlElement mod1 = doc.CreateElement(ConstStrings.CCF_MDTIME); - mod1.InnerText = null; + XmlElement mod1 = doc.CreateElement(ConstStrings.CCF_MDTIME); + mod1.InnerText = secret.GetModifiedTime().Ticks.ToString(); - XmlElement acc1 = doc.CreateElement(ConstStrings.CCF_ACTIME); - acc1.InnerText = null; + //XmlElement acc1 = doc.CreateElement(ConstStrings.CCF_ACTIME); + //acc1.InnerText = null; - Time1.AppendChild(zone1); - Time1.AppendChild(cr1); - Time1.AppendChild(mod1); - Time1.AppendChild(acc1); + Time1.AppendChild(zone1); + Time1.AppendChild(cr1); + Time1.AppendChild(mod1); + //Time1.AppendChild(acc1); - mi_secret.AppendChild(Time1); - */ + mi_secret.AppendChild(Time1); + //Finally Add Secret to Elem keychain.AppendChild(mi_secret); diff --git a/CASA/gui/MiCasa.cs b/CASA/gui/MiCasa.cs index 1a7ab9ac..9c45bd30 100644 --- a/CASA/gui/MiCasa.cs +++ b/CASA/gui/MiCasa.cs @@ -148,14 +148,16 @@ public class MiCasa : Store m_config = config; /// SecretID TreeStore - tvSecretIDMiCasa = (Gtk.TreeView)CasaMain.gxmlMain.GetWidget("tvSecretIDMiCasa"); + tvSecretIDMiCasa = (Gtk.TreeView)CasaMain.gxmlMain.GetWidget("tvSecretIDMiCasa"); tsSecretIDMiCasa = new TreeStore(typeof(string), typeof(string[]), typeof(string[]), typeof(string), typeof(string[]), typeof(string[])); - tvSecretIDMiCasa.AppendColumn("Secret ID",new CellRendererText(),"text",0); + tvSecretIDMiCasa.AppendColumn("Secret ID",new CellRendererText(),"text",0); tvSecretIDMiCasa.Model = tsSecretIDMiCasa; tsSecretIDMiCasa.SetSortColumnId(0, Gtk.SortType.Ascending); tvSecretIDMiCasa.RowActivated += new RowActivatedHandler(OntvSecretIDMiCasaRowActivated); tvSecretIDMiCasa.ButtonReleaseEvent += new ButtonReleaseEventHandler(OnRightClicked); tvSecretIDMiCasa.CursorChanged += new EventHandler(OnCursorChanged); + + /// NativeInfo TreeStore tvNativeInfoMiCasa = (Gtk.TreeView)CasaMain.gxmlMain.GetWidget("tvNativeInfoMiCasa"); tsNativeInfoMiCasa = new TreeStore(typeof(string), typeof(string)); @@ -309,11 +311,14 @@ public class MiCasa : Store cellEditable = new CellRendererText(); cellEditable.Editable = true; cellEditable.Edited += new EditedHandler(OnKeyValueEdited); - /// KEY:0 VALUE:1 VALUE-DUP:2 DIRTY-BIT:3 LINK:4 - tsKeyValue = new TreeStore(typeof(string),typeof(string), typeof(string), typeof(bool), typeof(string)); + /// KEY:0 VALUE:1 VALUE-DUP:2 DIRTY-BIT:3 LINK:4 + tsKeyValue = new TreeStore(typeof(string), typeof(string), typeof(string), typeof(bool), typeof(string), typeof(string), typeof(string)); tvKeyValue.AppendColumn("Key",new CellRendererText(),"text",0); tvKeyValue.AppendColumn("Value",cellEditable,"text",2); - tvKeyValue.AppendColumn("Linked", new CellRendererText(), "text", 4); + tvKeyValue.AppendColumn("Linked", new CellRendererText(), "text", 4); + tvKeyValue.AppendColumn("Created", new CellRendererText(), "text", 5); + tvKeyValue.AppendColumn("Modified", new CellRendererText(), "text", 6); + tvKeyValue.RowActivated += new RowActivatedHandler(tvKeyValue_RowActivated); @@ -325,8 +330,13 @@ public class MiCasa : Store for( int i=0; i< keys.Length; i++ ) { - Secret secret = ss.getSecret(selected); - Hashtable ht = secret.GetLinkedKeys(keys[i]); + Secret secret = ss.getSecret(selected); + + Hashtable ht = secret.GetLinkedKeys(keys[i]); + + DateTime dtCreated = secret.GetCreateTimeForKey(keys[i]); + DateTime dtModified = secret.GetModifiedTimeForKey(keys[i]); + if (ht != null && ht.Count > 0) bHasLinks = true; else @@ -335,12 +345,23 @@ public class MiCasa : Store if( (null != keys[i]) && (null != values[i]) ) if( bHasLinks ) { - tsKeyValue.AppendValues(keys[i], values[i], "********", false, "Yes"); + tsKeyValue.AppendValues(keys[i], + values[i], + "********", + false, + "Yes", + dtCreated.ToShortDateString() + " " + dtCreated.ToShortTimeString(), + dtModified.ToShortDateString() + " " + dtModified.ToShortTimeString()); } else - { - tsKeyValue.AppendValues(keys[i], values[i], "********", false, "No"); - + { + tsKeyValue.AppendValues(keys[i], + values[i], + "********", + false, + "No", + dtCreated.ToShortDateString() + " " + dtCreated.ToShortTimeString(), + dtModified.ToShortDateString() + " " + dtModified.ToShortTimeString()); } } diff --git a/CASA/gui/StoreDataInterface.cs b/CASA/gui/StoreDataInterface.cs index 8d620a10..7e6e3280 100644 --- a/CASA/gui/StoreDataInterface.cs +++ b/CASA/gui/StoreDataInterface.cs @@ -316,11 +316,21 @@ namespace Novell.CASA.GUI { { while( secIter.MoveNext() ) {//Enumerate the Time Nodes of this secret - if( secIter.Current.Name.Equals(CCFXML_ELEMENT_TIME_MODIFIED) ) - {//miCASA-KeyChain-Secret-Key-Value-Time-modified - - modifiedTime = secIter.Current.Value; - + if( secIter.Current.Name.Equals(CCFXML_ELEMENT_TIME_MODIFIED) ) + + //miCASA-KeyChain-Secret-Key-Value-Time-modified + { + string sTicks = secIter.Current.Value; + + try + { + DateTime dt = new DateTime(long.Parse(sTicks)); + modifiedTime = secIter.Current.Value; + } + catch (Exception) + { + modifiedTime = "unknown"; + } } } } @@ -402,11 +412,32 @@ namespace Novell.CASA.GUI { strNativeValueArray[Common.INDEX_NATIVEINFO_SYNC] = synch; strNativeValueArray[Common.INDEX_NATIVEINFO_SYNCTYPE] = synchType; strNativeValueArray[Common.INDEX_NATIVEINFO_MODIFIEDTIME] = modifiedTime; - //Console.WriteLine("folderName="+folderName+"\n"+"typeID="+typeID+"\n"+"synch="+synch+"\n"+"synchType="+synchType+"\n"+"modifiedTime="+modifiedTime); - if ( storeIDentifier == Common.STORE_FIREFOX) - ls.AppendValues(secretID,strKeyArray,strValueArray,storeID,strNativeKeyArray,strNativeValueArray,boolIsPassArray); - else - ls.AppendValues(secretID,strKeyArray,strValueArray,storeID,strNativeKeyArray,strNativeValueArray); + //Console.WriteLine("folderName="+folderName+"\n"+"typeID="+typeID+"\n"+"synch="+synch+"\n"+"synchType="+synchType+"\n"+"modifiedTime="+modifiedTime); + if (storeIDentifier == Common.STORE_FIREFOX) + { + ls.AppendValues(secretID, strKeyArray, strValueArray, storeID, strNativeKeyArray, strNativeValueArray, boolIsPassArray); + } + else if (storeIDentifier == Common.STORE_MICASA) + { + // convert modifiedTime to human readable + DateTime dt; + try + { + dt = new DateTime(long.Parse(modifiedTime)); + strNativeValueArray[Common.INDEX_NATIVEINFO_MODIFIEDTIME] = dt.ToShortDateString() + " " + dt.ToShortTimeString(); + } + catch + { + strNativeValueArray[Common.INDEX_NATIVEINFO_MODIFIEDTIME] = modifiedTime; + } + + ls.AppendValues(secretID, strKeyArray, strValueArray, storeID, strNativeKeyArray, strNativeValueArray); + + } + else + { + ls.AppendValues(secretID, strKeyArray, strValueArray, storeID, strNativeKeyArray, strNativeValueArray); + } //Re-Initialize for next iteration secretID = ""; diff --git a/CASA/micasad/cache/Secret.cs b/CASA/micasad/cache/Secret.cs index 5ee91733..3ceb48e3 100644 --- a/CASA/micasad/cache/Secret.cs +++ b/CASA/micasad/cache/Secret.cs @@ -194,9 +194,14 @@ namespace sscs.cache public string GetKey() { return secretID; + } + + public void SetKeyValue(string key, string value) + { + SetKeyValue(key, value, true); } - public void SetKeyValue(string key, string value) + public void SetKeyValue(string key, string value, bool bUpdateSecretModifiedTime) { KeyValue kv; if (htKeyValues.Contains(key)) @@ -208,8 +213,12 @@ namespace sscs.cache { kv = new KeyValue(key, value); htKeyValues.Add(key, kv); + } + + if (bUpdateSecretModifiedTime) + { + this.ModifiedTime = DateTime.Now; } - this.ModifiedTime = DateTime.Now; } public void SetKeyValue(string key, byte[] baValue) diff --git a/CASA/micasad/lib/communication/MiCasaRequestReply.cs b/CASA/micasad/lib/communication/MiCasaRequestReply.cs index 2f82f34e..c15162ff 100644 --- a/CASA/micasad/lib/communication/MiCasaRequestReply.cs +++ b/CASA/micasad/lib/communication/MiCasaRequestReply.cs @@ -59,7 +59,9 @@ namespace Novell.CASA.MiCasa.Communication public const int VERB_EXPORT_SECRETS = 21; public const int VERB_ADD_XML_SECRETS = 22; public const int VERB_CHANGE_PERSIST_DIR = 23; - public const int VERB_CREATE_POLICY_DIR = 24; + public const int VERB_CREATE_POLICY_DIR = 24; + public const int VERB_GET_CREATE_TIME = 25; + public const int VERB_GET_MODIFIED_TIME = 26; public const int VERB_DUMP_LINKED_KEYS = 96; public const int VERB_CREATE_TEST_SECRETS = 97; diff --git a/CASA/micasad/lss/LocalStorage.cs b/CASA/micasad/lss/LocalStorage.cs index 576bd5a4..81da6d2e 100644 --- a/CASA/micasad/lss/LocalStorage.cs +++ b/CASA/micasad/lss/LocalStorage.cs @@ -490,7 +490,7 @@ namespace sscs.lss xpath = "descendant::" + XmlConsts.keyValueNode; XmlNode keyValNode = keyNode.SelectSingleNode(xpath); string keyValue = keyValNode.InnerText; - secret.SetKeyValue(key, keyValue); + secret.SetKeyValue(key, keyValue, false); // get time attributes on this key/value XmlNode timeNodeKey = keyNode.SelectSingleNode("descendant::" + XmlConsts.timeNode); diff --git a/CASA/micasad/verbs/ObjectSerialization.cs b/CASA/micasad/verbs/ObjectSerialization.cs index b9ea655f..ef3e756b 100644 --- a/CASA/micasad/verbs/ObjectSerialization.cs +++ b/CASA/micasad/verbs/ObjectSerialization.cs @@ -234,7 +234,16 @@ namespace sscs.verbs case MiCasaRequestReply.VERB_CREATE_POLICY_DIR: { return DoCreatePolicyDir(ssStore, wo); - } + } + case MiCasaRequestReply.VERB_GET_CREATE_TIME: + { + return DoGetCreateTime(ssStore, wo); + } + case MiCasaRequestReply.VERB_GET_MODIFIED_TIME: + { + return DoGetModifiedTime(ssStore, wo); + } + default: { @@ -253,8 +262,81 @@ namespace sscs.verbs } return wo; - } - + } + + + private WrappedObject DoGetModifiedTime(SecretStore ssStore, WrappedObject wo) + { + return DoGetTimeStamp(ssStore, wo, false); + } + + private WrappedObject DoGetCreateTime(SecretStore ssStore, WrappedObject wo) + { + return DoGetTimeStamp(ssStore, wo, true); + } + + private WrappedObject DoGetTimeStamp(SecretStore ssStore, WrappedObject wo, bool bGetCreateTime) + { + string keychainID = wo.GetKeychainID(); + string secretID = wo.GetSecretID(); + string keyID = wo.GetKeyID(); + + KeyChain keyChain; + + if (keychainID != null) + keyChain = ssStore.GetKeyChain(keychainID); + else + keyChain = ssStore.GetKeyChainDefault(); + + Secret secret = null; + DateTime dt = new DateTime(0); + + if (keyChain.CheckIfSecretExists(secretID) == false) + { + wo.SetError(constants.RetCodes.FAILURE, "Secret does not exist"); + } + else + { + secret = keyChain.GetSecret(secretID); + if (keyID != null) + { + KeyValue kv = secret.GetKeyValue(keyID); + if (kv != null) + { + if (bGetCreateTime) + { + dt = kv.CreatedTime; + } + else + { + dt = kv.ModifiedTime; + } + } + else + { + wo.SetError(constants.RetCodes.FAILURE, "Secret does not exist"); + } + } + else + { + if (bGetCreateTime) + { + dt = secret.CreatedTime; + } + else + { + dt = secret.ModifiedTime; + } + } + } + + if (dt != null) + { + wo.SetObject(dt); + wo.SetError(constants.RetCodes.SUCCESS, null); + } + return wo; + } private WrappedObject DoCreatePolicyDir(SecretStore ssStore, WrappedObject wo) { diff --git a/CASA/sharp/NSSCSWrapper/Secret.cs b/CASA/sharp/NSSCSWrapper/Secret.cs index 49ad12b8..a37f24c9 100644 --- a/CASA/sharp/NSSCSWrapper/Secret.cs +++ b/CASA/sharp/NSSCSWrapper/Secret.cs @@ -185,17 +185,50 @@ namespace Novell.CASA m_iAccessTime = uiAccessed; } - public uint getCreateTime() + public DateTime GetCreateTime() { - return m_iCreateTime; + // send request for create time + DateTime dt = (DateTime)MiCasaRequestReply.Send(MiCasaRequestReply.VERB_GET_CREATE_TIME, + this.m_keyChainID, + this.m_secretID, + null, + null); + return dt; } - public uint getModifiedTime() + public DateTime GetModifiedTime() { - return m_iModifyTime; + // send request for modified time + DateTime dt = (DateTime)MiCasaRequestReply.Send(MiCasaRequestReply.VERB_GET_MODIFIED_TIME, + this.m_keyChainID, + this.m_secretID, + null, + null); + return dt; } - public uint getAccessTime() + public DateTime GetCreateTimeForKey(string sKey) + { + // send request for create time + DateTime dt = (DateTime)MiCasaRequestReply.Send(MiCasaRequestReply.VERB_GET_CREATE_TIME, + this.m_keyChainID, + this.m_secretID, + sKey, + null); + return dt; + } + + public DateTime GetModifiedTimeForKey(string sKey) + { + // send request for modified time + DateTime dt = (DateTime)MiCasaRequestReply.Send(MiCasaRequestReply.VERB_GET_MODIFIED_TIME, + this.m_keyChainID, + this.m_secretID, + sKey, + null); + return dt; + } + private uint getAccessTime() { return m_iAccessTime; } @@ -212,5 +245,17 @@ namespace Novell.CASA return htLinkedKeys; } + + /* + public DateTime GetKeyModifiedTime(string sKey) + { + return null; + } + + public DateTime GetKeyCreateTime(string sKey) + { + return null; + } + */ } }