Export (0) Print
Expand All

LicenseManagement Class

A static class that is used to return licenses from the persistent license store.

System.Object
  System.Windows.Media.LicenseManagement

Namespace:  System.Windows.Media
Assembly:  System.Windows (in System.Windows.dll)

public static class LicenseManagement

The LicenseManagement type exposes the following members.

  NameDescription
Public propertyStatic memberVideoOutputConnectorsGets all the data about connector types from the graphics card, and also gets the output protection schemes for which Silverlight can engage each video output.
Top

  NameDescription
Public methodStatic memberSelectLicenses(Guid)Returns licenses from the persistent license store on the client based on the provided key identifier.
Public methodStatic memberSelectLicenses(Stream)Returns licenses from the persistent license store on the client based on a media stream, which contains a content header.
Top

Licenses that are persisted on the client are stored in a persistent license store, which is created on the client during individualization. For more information, see Digital Rights Management (DRM).

NoteNote:

The overloads of the SelectLicense method do not work unless the user is running the Silverlight application out-of-browser and is using elevated trust.

You can check whether a license or license chain has expired by iterating through all the licenses (MediaLicense objects) on the persistent license store. If any licenses need to be updated, you can add logic to attempt to connect to the licensing server and make necessary updates, prompt the user for payment, and so on.

The following example shows how to check whether a subscription license needs to be renewed.

private void CheckSubscriptionRootForRenewal(Guid parentKeyId,
                                             Uri licenseServerUrl)
{

    DateTime renewalDate = DateTime.Now.AddDays(5);

    // Query the licensemanager to see if we have a usable root license
    IEnumerable<MediaLicense> myLicenses = LicenseManagement.SelectLicenses(parentKeyId);

    bool renewRoot = true;

    foreach (MediaLicense ML in myLicenses)
    {
        // If the license expires within the next 5 days,
        // renew the subscription by requesting a new root license.
        if ((ML.Usable) &&
            (ML.ExpirationDate > renewalDate))
        {
            renewRoot = false;
            break;
        }

    }

    if (renewRoot)
    {
        LicenseAcquirer acquirer = new LicenseAcquirer();
        acquirer.LicenseServerUriOverride = licenseServerUrl;
        acquirer.AcquireLicenseCompleted += new EventHandler<AcquireLicenseCompletedEventArgs>(acquirer_Completed);
        acquirer.AcquireLicenseAsync(parentKeyId, ContentKeyType.Aes128Bit, Guid.Empty);
    }

In this example, you are iterating through all the MediaLicense instances in the persistent license store. A MediaLicense instance can be any of the following:

  • A license chain (leaf plus root).

  • A single simple license.

  • A single leaf license (root does not exist).

  • A single root license (root is queried directly).

The following function can be used to filter the list of content that is shown to the user in a list of possible playback choices, especially if the user is offline and cannot get new licenses. It can also be used to decide whether to get a license before going offline. For a subscription customer, the CheckSubscriptionRootForRenewal function (from the previous example) should be called first if the user is online.

public bool IsUsableLicenseAvailableForContent(System.IO.Stream contentFile)
{
    bool returnValue = false;

    // SelectLicenses works only if the user is running the Silverlight 
    // application offline *and* in elevated trust.
    IEnumerable<MediaLicense> myLicenses = LicenseManagement.SelectLicenses(contentFile);


    foreach (MediaLicense ML in myLicenses)
    {
        if (ML.Usable)
        {
            returnValue = true;
            break;
        }
    }

    return returnValue;
}

Silverlight

Supported in: 5, 4

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

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

Community Additions

Show:
© 2014 Microsoft