Bug 243906. Base64 encode binary values when persisting them.

This commit is contained in:
Jim Norman 2007-02-13 00:12:29 +00:00
parent 8f70c27fb2
commit 0778dad12d
2 changed files with 31 additions and 7 deletions

View File

@ -219,9 +219,14 @@ namespace sscs.cache
{
this.ModifiedTime = DateTime.Now;
}
}
public void SetKeyValue(string key, byte[] baValue)
{
SetKeyValue(key, baValue, true);
}
public void SetKeyValue(string key, byte[] baValue)
public void SetKeyValue(string key, byte[] baValue, bool bUpdateModifiedTime)
{
KeyValue kv;
if (htKeyValues.Contains(key))
@ -233,8 +238,12 @@ namespace sscs.cache
{
kv = new KeyValue(key, baValue);
htKeyValues.Add(key, kv);
}
this.ModifiedTime = DateTime.Now;
}
if (bUpdateModifiedTime)
{
this.ModifiedTime = DateTime.Now;
}
}
public KeyValue GetKeyValue(string key)

View File

@ -502,15 +502,21 @@ namespace sscs.lss
xpath = "descendant::" + XmlConsts.keyValueNode;
XmlNode keyValNode = keyNode.SelectSingleNode(xpath);
string keyValue = keyValNode.InnerText;
secret.SetKeyValue(key, keyValue, false);
string keyValue = keyValNode.InnerText;
// set binary type if set
if ((sIsBinary != null) && (sIsBinary.Equals("true")))
{
{
byte[] baDec = Convert.FromBase64String(keyValue);
secret.SetKeyValue(key, baDec, false);
KeyValue kv = secret.GetKeyValue(key);
kv.SetValueType(KeyValue.VALUE_TYPE_BINARY);
}
else
{
secret.SetKeyValue(key, keyValue, false);
}
// get time attributes on this key/value
XmlNode timeNodeKey = keyNode.SelectSingleNode("descendant::" + XmlConsts.timeNode);
@ -799,7 +805,16 @@ namespace sscs.lss
writer.WriteStartElement(XmlConsts.keyValueNode);
if (bSaveValues)
writer.WriteString(value);
{
if (kv.GetValueType() == KeyValue.VALUE_TYPE_BINARY)
{
writer.WriteString(Convert.ToBase64String(kv.GetValueAsBytes()));
}
else
{
writer.WriteString(value);
}
}
else
writer.WriteString("");