XmlLicenseTransform 类

定义

表示用于规范化签名的 XrML 许可证的许可证转换算法。

public ref class XmlLicenseTransform : System::Security::Cryptography::Xml::Transform
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("XmlDsigXsltTransform uses XslCompiledTransform which requires dynamic code.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The algorithm implementations referenced in the XML payload might be removed. Ensure the required algorithm implementations are preserved in your application.")]
public class XmlLicenseTransform : System.Security.Cryptography.Xml.Transform
public class XmlLicenseTransform : System.Security.Cryptography.Xml.Transform
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("XmlDsigXsltTransform uses XslCompiledTransform which requires dynamic code.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The algorithm implementations referenced in the XML payload might be removed. Ensure the required algorithm implementations are preserved in your application.")>]
type XmlLicenseTransform = class
    inherit Transform
type XmlLicenseTransform = class
    inherit Transform
Public Class XmlLicenseTransform
Inherits Transform
继承
XmlLicenseTransform
属性

示例

下面的代码示例演示如何使用 IRelDecryptor 接口和 XmlLicenseTransform 类验证 XML 数字签名。

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());
    }
}
    Public Shared Sub CheckSignatureWithEncryptedGrant(ByVal fileName As String, ByVal decryptor As IRelDecryptor)
        ' Create a new XML document.
        Dim xmlDocument As New XmlDocument()
        Dim nsManager As 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.
        Dim nodeList As XmlNodeList = xmlDocument.SelectNodes("//dsig:Signature", nsManager)

        Dim count = nodeList.Count

        For i As Integer = 0 To count - 1
            Dim clone As XmlDocument = xmlDocument.Clone()
           
            Dim signatures As XmlNodeList = clone.SelectNodes("//dsig:Signature", nsManager)

            ' Create a new SignedXml object and pass into it the XML document clone.
            Dim signedXml As New SignedXml(clone)

            ' Load the signature node.
            signedXml.LoadXml(CType(signatures(i), XmlElement))

            ' Set the context for license transform
            Dim trans As Transform = CType(signedXml.SignedInfo.References(0), Reference).TransformChain(0)

            If TypeOf trans Is XmlLicenseTransform Then

                ' Decryptor is used to decrypt encryptedGrant elements.
                If Not (decryptor Is Nothing) Then
                    CType(trans, XmlLicenseTransform).Decryptor = decryptor
                End If

            End If

            ' Check the signature and display the result.
            Dim result As Boolean = signedXml.CheckSignature()

            If result Then
                Console.WriteLine("SUCCESS: CheckSignatureWithEncryptedGrant - issuer index #" + i.ToString())
            Else
                Console.WriteLine("FAILURE: CheckSignatureWithEncryptedGrant - issuer index #" + i.ToString())
            End If
        Next i

    End Sub
End Class

注解

XmlLicenseTransform 类表示在 MPEG 权限扩展语言(MPEG REL)中定义的许可证转换算法。

使用该 XmlLicenseTransform 类转换签名的 XrML 许可证。

描述类的 XmlLicenseTransform 统一资源标识符(URI)由 XmlLicenseTransformUrl 字段定义。

构造函数

名称 说明
XmlLicenseTransform()

初始化 XmlLicenseTransform 类的新实例。

属性

名称 说明
Algorithm

获取或设置标识当前转换执行的算法的统一资源标识符(URI)。

(继承自 Transform)
Context

获取或设置一个 XmlElement 对象,该对象表示当前 Transform 对象正在运行的文档上下文。

(继承自 Transform)
Decryptor

获取或设置当前 XmlLicenseTransform 对象的解密器。

InputTypes

获取一个类型数组,这些类型是当前OutputTypes对象的方法的有效输入XmlLicenseTransform

OutputTypes

获取一个类型数组,这些类型是当前OutputTypes对象方法的有效输出XmlLicenseTransform

PropagatedNamespaces

获取或设置一个 Hashtable 对象,该对象包含传播到签名中的命名空间。

(继承自 Transform)
Resolver

设置当前 XmlResolver 对象。

(继承自 Transform)

方法

名称 说明
Equals(Object)

确定指定的对象是否等于当前对象。

(继承自 Object)
GetDigestedOutput(HashAlgorithm)

在派生类中重写时,返回与 Transform 对象关联的摘要。

(继承自 Transform)
GetHashCode()

用作默认哈希函数。

(继承自 Object)
GetInnerXml()

返回适合作为 XMLDSIG XmlLicenseTransform 元素的子元素包含的对象参数<Transform>的 XML 表示形式。

GetOutput()

返回对象的 XmlLicenseTransform 输出。

GetOutput(Type)

返回对象的 XmlLicenseTransform 输出。

GetType()

获取当前实例的 Type

(继承自 Object)
GetXml()

返回当前 Transform 对象的 XML 表示形式。

(继承自 Transform)
LoadInnerXml(XmlNodeList)

将指定的 XmlNodeList 对象分析为元素的转换特定内容 <Transform> ;此方法不受支持,因为 XmlLicenseTransform 对象没有内部 XML 元素。

LoadInput(Object)

将指定的输入加载到当前 XmlLicenseTransform 对象中。

MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
ToString()

返回一个表示当前对象的字符串。

(继承自 Object)

适用于