Changes to allow encryption
This commit is contained in:
parent
b6bcd7aff2
commit
3136228e76
@ -81,7 +81,7 @@ namespace EduNetworkBuilder
|
|||||||
EncryptedData ed = new EncryptedData();
|
EncryptedData ed = new EncryptedData();
|
||||||
|
|
||||||
// Specify the namespace URI for XML encryption elements.
|
// Specify the namespace URI for XML encryption elements.
|
||||||
ed.Type = EncryptedXml.XmlEncElementUrl;
|
ed.Type = Element + " " + EncryptedXml.XmlEncElementUrl;
|
||||||
|
|
||||||
// Specify the namespace URI for the TrippleDES algorithm.
|
// Specify the namespace URI for the TrippleDES algorithm.
|
||||||
ed.EncryptionMethod = new EncryptionMethod(EncryptedXml.XmlEncTripleDESUrl);
|
ed.EncryptionMethod = new EncryptionMethod(EncryptedXml.XmlEncTripleDESUrl);
|
||||||
@ -96,11 +96,23 @@ namespace EduNetworkBuilder
|
|||||||
EncryptedXml.ReplaceElement(inputElement, ed, false);
|
EncryptedXml.ReplaceElement(inputElement, ed, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Decrypt()
|
XmlElement ChooseBestElement(string preferType)
|
||||||
|
{
|
||||||
|
XmlNodeList xnl = docValue.GetElementsByTagName("EncryptedData");
|
||||||
|
foreach (XmlElement one in xnl.OfType<XmlElement>())
|
||||||
|
{
|
||||||
|
string TypeAttr = one.GetAttribute("Type");
|
||||||
|
if (TypeAttr != null && TypeAttr.StartsWith(preferType))
|
||||||
|
return one;
|
||||||
|
}
|
||||||
|
return xnl[0] as XmlElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Decrypt(string preferType)
|
||||||
{
|
{
|
||||||
|
|
||||||
// XmlElement object.
|
// XmlElement object.
|
||||||
XmlElement encryptedElement = docValue.GetElementsByTagName("EncryptedData")[0] as XmlElement;
|
XmlElement encryptedElement = ChooseBestElement(preferType);
|
||||||
|
|
||||||
// If the EncryptedData element was not found, throw an exception.
|
// If the EncryptedData element was not found, throw an exception.
|
||||||
if (encryptedElement == null)
|
if (encryptedElement == null)
|
||||||
|
Loading…
Reference in New Issue
Block a user