Bug 243906. Base64 encode binary values when persisting them.
This commit is contained in:
parent
8f70c27fb2
commit
0778dad12d
13
CASA/micasad/cache/Secret.cs
vendored
13
CASA/micasad/cache/Secret.cs
vendored
@ -221,7 +221,12 @@ namespace sscs.cache
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetKeyValue(string key, byte[] baValue)
|
public void SetKeyValue(string key, byte[] baValue)
|
||||||
|
{
|
||||||
|
SetKeyValue(key, baValue, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetKeyValue(string key, byte[] baValue, bool bUpdateModifiedTime)
|
||||||
{
|
{
|
||||||
KeyValue kv;
|
KeyValue kv;
|
||||||
if (htKeyValues.Contains(key))
|
if (htKeyValues.Contains(key))
|
||||||
@ -234,7 +239,11 @@ namespace sscs.cache
|
|||||||
kv = new KeyValue(key, baValue);
|
kv = new KeyValue(key, baValue);
|
||||||
htKeyValues.Add(key, kv);
|
htKeyValues.Add(key, kv);
|
||||||
}
|
}
|
||||||
this.ModifiedTime = DateTime.Now;
|
|
||||||
|
if (bUpdateModifiedTime)
|
||||||
|
{
|
||||||
|
this.ModifiedTime = DateTime.Now;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeyValue GetKeyValue(string key)
|
public KeyValue GetKeyValue(string key)
|
||||||
|
@ -503,14 +503,20 @@ namespace sscs.lss
|
|||||||
xpath = "descendant::" + XmlConsts.keyValueNode;
|
xpath = "descendant::" + XmlConsts.keyValueNode;
|
||||||
XmlNode keyValNode = keyNode.SelectSingleNode(xpath);
|
XmlNode keyValNode = keyNode.SelectSingleNode(xpath);
|
||||||
string keyValue = keyValNode.InnerText;
|
string keyValue = keyValNode.InnerText;
|
||||||
secret.SetKeyValue(key, keyValue, false);
|
|
||||||
|
|
||||||
// set binary type if set
|
// set binary type if set
|
||||||
if ((sIsBinary != null) && (sIsBinary.Equals("true")))
|
if ((sIsBinary != null) && (sIsBinary.Equals("true")))
|
||||||
{
|
{
|
||||||
|
byte[] baDec = Convert.FromBase64String(keyValue);
|
||||||
|
secret.SetKeyValue(key, baDec, false);
|
||||||
|
|
||||||
KeyValue kv = secret.GetKeyValue(key);
|
KeyValue kv = secret.GetKeyValue(key);
|
||||||
kv.SetValueType(KeyValue.VALUE_TYPE_BINARY);
|
kv.SetValueType(KeyValue.VALUE_TYPE_BINARY);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
secret.SetKeyValue(key, keyValue, false);
|
||||||
|
}
|
||||||
|
|
||||||
// get time attributes on this key/value
|
// get time attributes on this key/value
|
||||||
XmlNode timeNodeKey = keyNode.SelectSingleNode("descendant::" + XmlConsts.timeNode);
|
XmlNode timeNodeKey = keyNode.SelectSingleNode("descendant::" + XmlConsts.timeNode);
|
||||||
@ -799,7 +805,16 @@ namespace sscs.lss
|
|||||||
writer.WriteStartElement(XmlConsts.keyValueNode);
|
writer.WriteStartElement(XmlConsts.keyValueNode);
|
||||||
|
|
||||||
if (bSaveValues)
|
if (bSaveValues)
|
||||||
writer.WriteString(value);
|
{
|
||||||
|
if (kv.GetValueType() == KeyValue.VALUE_TYPE_BINARY)
|
||||||
|
{
|
||||||
|
writer.WriteString(Convert.ToBase64String(kv.GetValueAsBytes()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
writer.WriteString(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
writer.WriteString("");
|
writer.WriteString("");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user