本文整理汇总了C#中System.Security.Cryptography.Xml.IRelDecryptor接口的典型用法代码示例。如果您正苦于以下问题:C# IRelDecryptor接口的具体用法?C# IRelDecryptor怎么用?C# IRelDecryptor使用的例子?那么恭喜您, 这里精选的接口代码示例或许可以为您提供帮助。
IRelDecryptor接口属于System.Security.Cryptography.Xml命名空间,在下文中一共展示了IRelDecryptor接口的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckSignatureWithEncryptedGrant
public static void CheckSignatureWithEncryptedGrant(string fileName, IRelDecryptor decryptor)
{
// Create a new XML document.
XmlDocument xmlDocument = new XmlDocument();
XmlNamespaceManager nsManager = new XmlNamespaceManager(xmlDocument.NameTable);
// Format using white spaces.
xmlDocument.PreserveWhitespace = true;
// Load the passed XML file into the document.
xmlDocument.Load(fileName);
nsManager.AddNamespace("dsig", SignedXml.XmlDsigNamespaceUrl);
// Find the "Signature" node and create a new XmlNodeList object.
XmlNodeList nodeList = xmlDocument.SelectNodes("//dsig:Signature", nsManager);
for (int i = 0, count = nodeList.Count; i < count; i++)
{
XmlDocument clone = xmlDocument.Clone() as XmlDocument;
XmlNodeList signatures = clone.SelectNodes("//dsig:Signature", nsManager);
// Create a new SignedXml object and pass into it the XML document clone.
SignedXml signedXml = new SignedXml(clone);
// Load the signature node.
signedXml.LoadXml((XmlElement)signatures[i]);
// Set the context for license transform
Transform trans = ((Reference)signedXml.SignedInfo.References[0]).TransformChain[0];
if (trans is XmlLicenseTransform)
{
// Decryptor is used to decrypt encryptedGrant elements.
if (decryptor != null)
(trans as XmlLicenseTransform).Decryptor = decryptor;
}
// Check the signature and display the result.
bool result = signedXml.CheckSignature();
if (result)
Console.WriteLine("SUCCESS: CheckSignatureWithEncryptedGrant - issuer index #" +
i.ToString());
else
Console.WriteLine("FAILURE: CheckSignatureWithEncryptedGrant - issuer index #" +
i.ToString());
}
}