NSL Support, expose Create and Modify Timestamp info thru miCASAWrapper.
This commit is contained in:
parent
f2b89108b9
commit
d81e894996
@ -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);
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 = "";
|
||||
|
13
CASA/micasad/cache/Secret.cs
vendored
13
CASA/micasad/cache/Secret.cs
vendored
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user