XmlLicenseTransform Classe

Definição

Representa o algoritmo de transformação de licença usado para normalizar licenças XrML para assinaturas.

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
Herança
XmlLicenseTransform
Atributos

Exemplos

O exemplo de código a seguir mostra como validar uma assinatura digital XML usando a IRelDecryptor interface e a XmlLicenseTransform classe.

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

Comentários

A XmlLicenseTransform classe representa o algoritmo de transformação de licença, conforme definido no MPEG Rights Extension Language (MPEG REL).

Use a XmlLicenseTransform classe para transformar licenças XrML para assinaturas.

O URI (Uniform Resource Identifier) que descreve a XmlLicenseTransform classe é definido pelo XmlLicenseTransformUrl campo.

Construtores

Nome Description
XmlLicenseTransform()

Inicializa uma nova instância da classe XmlLicenseTransform.

Propriedades

Nome Description
Algorithm

Obtém ou define o URI (Uniform Resource Identifier) que identifica o algoritmo executado pela transformação atual.

(Herdado de Transform)
Context

Obtém ou define um XmlElement objeto que representa o contexto do documento no qual o objeto atual Transform está em execução.

(Herdado de Transform)
Decryptor

Obtém ou define o descriptografador do objeto atual XmlLicenseTransform .

InputTypes

Obtém uma matriz de tipos que são entradas válidas para o OutputTypes método do objeto atual XmlLicenseTransform .

OutputTypes

Obtém uma matriz de tipos que são saídas válidas do OutputTypes método do objeto atual XmlLicenseTransform .

PropagatedNamespaces

Obtém ou define um Hashtable objeto que contém os namespaces propagados para a assinatura.

(Herdado de Transform)
Resolver

Define o objeto atual XmlResolver .

(Herdado de Transform)

Métodos

Nome Description
Equals(Object)

Determina se o objeto especificado é igual ao objeto atual.

(Herdado de Object)
GetDigestedOutput(HashAlgorithm)

Quando substituído em uma classe derivada, retorna o resumo associado a um Transform objeto.

(Herdado de Transform)
GetHashCode()

Serve como a função de hash padrão.

(Herdado de Object)
GetInnerXml()

Retorna uma representação XML dos parâmetros de um XmlLicenseTransform objeto que são adequados para serem incluídos como subelementos de um elemento XMLDSIG <Transform> .

GetOutput()

Retorna a saída de um XmlLicenseTransform objeto.

GetOutput(Type)

Retorna a saída de um XmlLicenseTransform objeto.

GetType()

Obtém o Type da instância atual.

(Herdado de Object)
GetXml()

Retorna a representação XML do objeto atual Transform .

(Herdado de Transform)
LoadInnerXml(XmlNodeList)

Analisa o objeto especificado XmlNodeList como conteúdo específico da transformação de um <Transform> elemento; esse método não tem suporte porque o XmlLicenseTransform objeto não tem elementos XML internos.

LoadInput(Object)

Carrega a entrada especificada no objeto atual XmlLicenseTransform .

MemberwiseClone()

Cria uma cópia superficial do Objectatual.

(Herdado de Object)
ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.

(Herdado de Object)

Aplica-se a