Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

XmlLicenseTransform Class

Represents the license transform algorithm used to normalize XrML licenses for signatures.

System.Object
  System.Security.Cryptography.Xml.Transform
    System.Security.Cryptography.Xml.XmlLicenseTransform

Namespace:  System.Security.Cryptography.Xml
Assembly:  System.Security (in System.Security.dll)

[HostProtectionAttribute(SecurityAction.LinkDemand, MayLeakOnAbort = true)]
public class XmlLicenseTransform : Transform

The XmlLicenseTransform type exposes the following members.

  NameDescription
Public methodXmlLicenseTransformInitializes a new instance of the XmlLicenseTransform class.
Top

  NameDescription
Public propertyAlgorithmGets or sets the Uniform Resource Identifier (URI) that identifies the algorithm performed by the current transform. (Inherited from Transform.)
Public propertyContextGets or sets an XmlElement object that represents the document context under which the current Transform object is running. (Inherited from Transform.)
Public propertyDecryptorGets or sets the decryptor of the current XmlLicenseTransform object.
Public propertyInputTypesGets an array of types that are valid inputs to the OutputTypes method of the current XmlLicenseTransform object. (Overrides Transform.InputTypes.)
Public propertyOutputTypesGets an array of types that are valid outputs from the OutputTypes method of the current XmlLicenseTransform object. (Overrides Transform.OutputTypes.)
Public propertyPropagatedNamespacesGets or sets a Hashtable object that contains the namespaces that are propagated into the signature. (Inherited from Transform.)
Public propertyResolverSets the current XmlResolver object. (Inherited from Transform.)
Top

  NameDescription
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetDigestedOutputWhen overridden in a derived class, returns the digest associated with a Transform object. (Inherited from Transform.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Protected methodGetInnerXmlReturns an XML representation of the parameters of an XmlLicenseTransform object that are suitable to be included as subelements of an XMLDSIG <Transform> element. (Overrides Transform.GetInnerXml().)
Public methodGetOutput()Returns the output of an XmlLicenseTransform object. (Overrides Transform.GetOutput().)
Public methodGetOutput(Type)Returns the output of an XmlLicenseTransform object. (Overrides Transform.GetOutput(Type).)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodGetXmlReturns the XML representation of the current Transform object. (Inherited from Transform.)
Public methodLoadInnerXmlParses the specified XmlNodeList object as transform-specific content of a <Transform> element; this method is not supported because the XmlLicenseTransform object has no inner XML elements. (Overrides Transform.LoadInnerXml(XmlNodeList).)
Public methodLoadInputLoads the specified input into the current XmlLicenseTransform object. (Overrides Transform.LoadInput(Object).)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

The XmlLicenseTransform class represents the license transform algorithm as defined in the MPEG Rights Extension Language (MPEG REL).

Use the XmlLicenseTransform class to transform XrML licenses for signatures.

The Uniform Resource Identifier (URI) that describes the XmlLicenseTransform class is defined by the XmlLicenseTransformUrl field.

NoteNote

The HostProtectionAttribute attribute applied to this type or member has the following Resources property value: MayLeakOnAbort. The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes.

The following code example shows how to validate an XML digital signature using the IRelDecryptor interface and the XmlLicenseTransform class.

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 whitespaces.
    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());
    }

}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2015 Microsoft