Share via


Generating and Issuing Licenses

banner art

Previous Next

Generating and Issuing Licenses

The basic process of issuing a license is illustrated in the following diagram.

The process of generating and issuing licenses from a player request

  1. The player sends a request for a license to Windows Media License Service .
  2. The challenge is received and put into the WMRMChallenge object, and the client information and content header information are processed.
  3. The WMRMRights object generates the rights to put into the license.
  4. The content header information is put into the WMRMHeader object to retrieve a key ID .
  5. The key ID and license key seed are put into the WMRMKeys object to generate the key .
  6. The individualization version number and the platform information from the client are determined by using WMRMLicGen.CheckClientCapability and WMRMLicGen.IndividualizedVersion. If the individualized version meets the requirement specified in the content header, the process continues. Otherwise, the process is halted, and a license is not issued.
  7. The client information, the rights, the key ID, and the key are put into the WMRMLicGen object to generate a license. The license is put into the WMRMResponse object to generate a response that is sent back to the requesting client and put into the license store on the consumer's computer.
    • For nonsilent license delivery, the license is sent to the player, and a Web page appears.
    • For silent license delivery , the license is sent back to the digital rights management client.

The following diagram illustrates the process for predelivering licenses.

The process of predelivering licenses

Licenses can be predelivered using the RMGetLicense object:

  • When using the GetSystemInfo method, a hidden form in a Web page sends client information to the Windows Media License Service. The License Service then returns a license and a new Web page to the consumer.

  • When using the GetLicenseFromURL method, a license request is made using a background HTTP post. The License Service returns a license to the consumer. This method is useful for silent license delivery.

    Note   The RMGetLicense object cannot be used to predeliver version 1 licenses.

The following Visual Basic Scripting Edition (VBScript) code examples show how to issue a license for a Windows Media file.

VBScript Example

<%
Response.Buffer = True
Response.Expires = 0

' Declare variables and objects.
Dim seed, contentowner_publickey, silent
Dim strLicenseRequested, varHeader
Dim kid, lResult, varKey, sRights
Dim varLicense, LicenseResponse
Dim strRevinfo, ContainsRevinfo, strClientCRLs
Dim ChallengeObj, HeaderObj, KeysObj
Dim RightsObj, LicGenObj, ResponseObj

do

' Replace XXX with your own values. In real practice, you would
' retrieve these values from a database.
seed = "XXX"  ' License key seed used by the packaging server.
contentowner_publickey = "XXX"  ' Public signing key for the
                                ' packaging server.

' Create objects.
Set ChallengeObj = Server.CreateObject("WMRMobjs.WMRMChallenge")
Set HeaderObj = Server.CreateObject("WMRMobjs.WMRMHeader")
Set KeysObj = Server.CreateObject("WMRMobjs.WMRMKeys")
Set RightsObj = Server.CreateObject("WMRMobjs.WMRMRights")
Set LicGenObj = Server.CreateObject("WMRMobjs.WMRMLicGen")
Set ResponseObj = Server.CreateObject("WMRMobjs.WMRMResponse")

' Find out whether the request is for silent or non-silent delivery.
silent = true
if (request.Form("nonsilent") <> "") then
    silent = false
end if

' Put the license request (challenge) into the Challenge object, and then
' extract the content header and client information from it.
strLicenseRequested = Request.Form("challenge")
ChallengeObj.Challenge = strLicenseRequested
varHeader = ChallengeObj.Header

' Check for revocation information.
strRevinfo = ChallengeObj.RevInfo
ContainsRevinfo = ChallengeObj.RevInfoPresent

' Put the content header into the Header object. Using the public key,
' verify that the content header has not been tampered with. The header
' is valid if the result equals 0.
HeaderObj.Header = varHeader
lResult = HeaderObj.Verify(contentowner_publickey)
if (lResult = 0) then
    ' TODO: Process for a corrupted or modified header.
end if

' Put the required individualization version from the content header
' into the WMRMLicGen object.
indiversion = HeaderObj.IndividualizedVersion
LicGenObj.IndividualizedVersion = indiversion

' Extract the key ID from the content header. Put the key ID and
' license key seed into the Keys object, and then generate the key.
kid = HeaderObj.KeyID
KeysObj.KeyID = kid
KeysObj.Seed = seed
varKey = KeysObj.GenerateKey()

' Get the certificate revocation lists that are supported by the client.
strClientCRLs = LicGenObj.SupportedCRLS

' Set the rights.
RightsObj.MinimumSecurityLevel = 1000
RightsObj.BeginDate = "#20050101Z #"
RightsObj.ExpirationDate =  "#20051231Z #"
RightsObj.AllowBackupRestore = true
RightsObj.AllowCopy = false
RightsObj.AllowTransferToSDMI = false
RightsObj.AllowTransferToNonSDMI = false
RightsObj.DeleteOnClockRollback = false
RightsObj.DisableOnClockRollback = true
SRights = RightsObj.GetAllRights

' Put the license information into the License Generator object.
' Including the following attributes is recommended.
LicGenObj.KeyID = kid
LicGenObj.SetKey "", varKey
LicGenObj.Rights = sRights
LicGenObj.Priority = 10
LicGenObj.Attribute("Copyright") = "copyright statement"
LicGenObj.Attribute("ContentType") = "audio or video"
LicGenObj.Attribute("Author") = "artist name"
LicGenObj.Attribute("ArtistURL") = "https://artist_web_site"
LicGenObj.Attribute("Title") = "title"
LicGenObj.Attribute("LicenseDistributor") = "license issuer"
LicGenObj.Attribute("LicenseDistributorURL") = "https://license_issuer_web_site"
LicGenObj.Attribute("ContentDistributor") = "content distributor"
LicGenObj.Attribute("Rating") = "rating"
LicGenObj.Attribute("Description") = "description"

' Bind the license to the public key, and then generate the license.
LicGenObj.BindToPubKey = contentowner_publickey
varLicense = LicGenObj.GetLicenseToDeliver()

' Use the Response object to deliver the license. If the client does
' not allow silent license delivery, display a page (Silent_ns.asp)
' saying that a license has been delivered.
call ResponseObj.AddLicense("2.0.0.0", varLicense)
call ResponseObj.AddRevocationData(strRevinfo, strClientCRLs, ContainsRevinfo)

if (silent = true) then
    LicenseResponse = ResponseObj.GetLicenseResponse()
    Response.Write LicenseResponse
else
'  ResponseObj.ReplaceQuotesWith = """"""    ' For VBScript
   ResponseObj.ReplaceQuotesWith = "\"""     ' For JavaScript
   LicenseResponse = ResponseObj.GetLicenseResponse()
%>
<!-- #include file="Silent_ns.asp" -->
<%
end if
%>

The following page is used when licenses cannot be issued silently.

Silent_ns.asp

<html>
<head>
<script Language="JavaScript">
function Storev71License(hr)
{
   LicenseObj.StoreLicense( "<%= LicenseResponse %>" );
}
</script>
</head>
<body onload="Storev71License()">
<object classid="clsid:A9FC132B-096D-460B-B7D5-1DB0FAE0C062" height="0"
id="LicenseObj" width="0">
  <embed mayscript type="application/x-drm-v2" hidden="true">
</object>
You have received a license for this song. Click Play.
</body>
</html>

See Also

Previous Next

© 2007 Microsoft Corporation. All rights reserved.