XmlLicenseTransform Klasa

Definicja

Reprezentuje algorytm przekształcania licencji używany do normalizacji licencji XrML dla podpisów.

public ref class XmlLicenseTransform : System::Security::Cryptography::Xml::Transform
public class XmlLicenseTransform : System.Security.Cryptography.Xml.Transform
type XmlLicenseTransform = class
    inherit Transform
Public Class XmlLicenseTransform
Inherits Transform
Dziedziczenie
XmlLicenseTransform

Przykłady

Poniższy przykład kodu pokazuje, jak zweryfikować podpis cyfrowy XML przy użyciu interfejsu IRelDecryptorXmlLicenseTransform i klasy.

void CheckSignatureWithEncryptedGrant(
    String^ fileName, IRelDecryptor^ decryptor)
{
    // Create a new XML document.
    XmlDocument^ sourceDocument = gcnew XmlDocument();
    XmlNamespaceManager^ namespaceManager =
        gcnew XmlNamespaceManager(sourceDocument->NameTable);

    // Format using white spaces.
    sourceDocument->PreserveWhitespace = true;

    // Load the passed XML file into the document.
    sourceDocument->Load(fileName);
    namespaceManager->AddNamespace("dsig",
        SignedXml::XmlDsigNamespaceUrl);

    // Find the "Signature" node and create a new
    // XmlNodeList object.
    XmlNodeList^ nodeList = 
        sourceDocument->SelectNodes("//dsig:Signature", namespaceManager);

    for (int i = 0, count = nodeList->Count; i < count; i++)
    {
        XmlDocument^ clone = (XmlDocument^) sourceDocument->Clone();
        XmlNodeList^ signatures =
            clone->SelectNodes("//dsig:Signature", namespaceManager);

        // Create a new SignedXml object and pass into it the
        // XML document clone.
        SignedXml^ signedDocument = gcnew SignedXml(clone);

        // Load the signature node.
        signedDocument->LoadXml((XmlElement^)signatures[i]);

        // Set the context for license transform
        Transform^ licenseTransform = ((Reference^)signedDocument->
            SignedInfo->References[0])->TransformChain[0];

        if ((licenseTransform::typeid == XmlLicenseTransform::typeid) 
            && (decryptor != nullptr))
        {
            // Decryptor is used to decrypt encryptedGrant
            // elements.
            ((XmlLicenseTransform^) licenseTransform)->Decryptor = decryptor;
        }

        // Check the signature and display the result.
        if (signedDocument->CheckSignature())
        {
            Console::WriteLine("SUCCESS: " +
                "CheckSignatureWithEncryptedGrant - issuer index #" + i);
        }
        else
        {
            Console::WriteLine("FAILURE: " +
                "CheckSignatureWithEncryptedGrant - issuer index #" + i);
        }
    }
}
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

Uwagi

Klasa XmlLicenseTransform reprezentuje algorytm przekształcania licencji zdefiniowany w języku MPEG Rights Extension Language (MPEG REL).

XmlLicenseTransform Użyj klasy , aby przekształcić licencje XrML na potrzeby podpisów.

Identyfikator URI (Uniform Resource Identifier), który opisuje klasę XmlLicenseTransform , jest definiowany XmlLicenseTransformUrl przez pole .

Konstruktory

XmlLicenseTransform()

Inicjuje nowe wystąpienie klasy XmlLicenseTransform.

Właściwości

Algorithm

Pobiera lub ustawia identyfikator URI (Uniform Resource Identifier), który identyfikuje algorytm wykonywany przez bieżącą transformację.

(Odziedziczone po Transform)
Context

Pobiera lub ustawia XmlElement obiekt reprezentujący kontekst dokumentu, w którym jest uruchomiony bieżący Transform obiekt.

(Odziedziczone po Transform)
Decryptor

Pobiera lub ustawia odszyfrowywanie bieżącego XmlLicenseTransform obiektu.

InputTypes

Pobiera tablicę typów, które są prawidłowymi danymi wejściowymi OutputTypes metody bieżącego XmlLicenseTransform obiektu.

OutputTypes

Pobiera tablicę typów, które są prawidłowymi danymi wyjściowymi z OutputTypes metody bieżącego XmlLicenseTransform obiektu.

PropagatedNamespaces

Pobiera lub ustawia Hashtable obiekt zawierający przestrzenie nazw, które są propagowane do podpisu.

(Odziedziczone po Transform)
Resolver

Ustawia bieżący XmlResolver obiekt.

(Odziedziczone po Transform)

Metody

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetDigestedOutput(HashAlgorithm)

Gdy przesłonięć w klasie pochodnej, zwraca skrót skojarzony z obiektem Transform .

(Odziedziczone po Transform)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetInnerXml()

Zwraca reprezentację XML parametrów XmlLicenseTransform obiektu, które są odpowiednie do dołączenia jako podelementy elementu XMLDSIG <Transform> .

GetOutput()

Zwraca dane wyjściowe XmlLicenseTransform obiektu.

GetOutput(Type)

Zwraca dane wyjściowe XmlLicenseTransform obiektu.

GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
GetXml()

Zwraca reprezentację XML bieżącego Transform obiektu.

(Odziedziczone po Transform)
LoadInnerXml(XmlNodeList)

Analizuje określony XmlNodeList obiekt jako zawartość specyficzną <Transform> dla przekształcenia elementu; ta metoda nie jest obsługiwana, ponieważ XmlLicenseTransform obiekt nie ma wewnętrznych elementów XML.

LoadInput(Object)

Ładuje określone dane wejściowe do bieżącego XmlLicenseTransform obiektu.

MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Dotyczy