共用方式為


WMRMLicenseRevocationResponse.GenerateSignedResponse

banner art

Previous Next

WMRMLicenseRevocationResponse.GenerateSignedResponse

The GenerateSignedResponse method generates the license revocation response, which must then be sent to the client.

Syntax

  String = WMRMLicenseRevocationResponse
  .GenerateSignedResponse(
  bstrLGPrivateKey
  , bstrMachinePublicKey)

Parameters

bstrLGPrivateKey

[in] A String containing the private key for license revocation.

bstrMachinePublicKey

[in] A String containing the public key of the client computer.

Return Values

If the method succeeds, it returns a String containing the license revocation response. If it fails, it returns a number in the error object.

Remarks

Public-private key pairs are used to ensure secure communications. The license revocation response is signed with the license revocation private key, and verified on the client computer with the license revocation public key (this key pair is generated by the license issuer). The license revocation response is encrypted using the public key of the client computer, and is decrypted using the client's private key.

Example Code

'"""""""""""""""""""""""""""""""""""""""""""""""""""""
' Declare variables.
'"""""""""""""""""""""""""""""""""""""""""""""""""""""
Dim LRChallengeObj       ' WMRMLicenseRevocationChallenge object
Dim LRResponseObj        ' WMRMLicenseRevocationResponse object

Dim LRChallString        ' License revocation challenge string
Dim ClientMachineID      ' Value that identifies the client computer
Dim CustomDataArray      ' Array to hold the custom data
Dim CustomDataItem       ' Counter
Dim UIDValue             ' User ID value
Dim KIDValue             ' Key ID value
Dim ChallTransID         ' Transaction ID in the challenge
Dim ClientPubkey         ' Public key of the client computer
Dim CustomDataString     ' Custom data included by the client plug-in
Dim KeyID                ' Key ID identifying the licenses to revoke
Dim LRPubkey             ' Public key for license revocation
Dim LRPrivkey            ' Private key for license revocation
Dim LRResponseString     ' License revocation response string

'"""""""""""""""""""""""""""""""""""""""""""""""""""""
' Set variables.
'"""""""""""""""""""""""""""""""""""""""""""""""""""""
LRChallString = "<Replace this with a challenge string>"
LRPubkey = "<Replace this with the license revocation public key>"
LRPrivkey = "<Replace this with the license revocation private key>"


'"""""""""""""""""""""""""""""""""""""""""""""""""""""
' Set the license revocation challenge into the WMRMLicenseRevocationChallenge object.
' Retrieve the client computer ID, public key, transaction ID, and custom data.
'"""""""""""""""""""""""""""""""""""""""""""""""""""""
Set LRChallengeObj = Server.CreateObject("WMRMObjs.WMRMLicenseRevocationChallenge")
Call LRChallengeObj.Initialize(LRChallString)
ClientMachineID = LRChallengeObj.GetMachineId
ChallTransID = LRChallengeObj.GetTransactionId
ClientPubkey = LRChallengeObj.GetMachinePublicKey

' B64Decode is a custom function to decode the base64-encoded string.
CustomDataString = B64Decode(LRChallengeObj.GetCustomData())

'"""""""""""""""""""""""""""""""""""""""""""""""""""""
' Create the license revocation response. 
'"""""""""""""""""""""""""""""""""""""""""""""""""""""
Set LRResponseObj = Server.CreateObject("WMRMObjs.WMRMLicenseRevocationResponse")

'"""""""""""""""""""""""""""""""""""""""""""""""""""""
' Process your custom data and follow your business logic 
' to determine which licenses to delete. 
' In this sample, assume the custom data specified a user ID
' (UID) of 123 and a key ID (KID) of 456; the custom data string
' would be "UID=123;KID=456;"
' So, in this sample, if a user ID is present, set it into
' the CustomData property. 
' If a key ID is present, set it into the KeyId property. 
' If both values are specified, only licenses with both
' values will be revoked.
'"""""""""""""""""""""""""""""""""""""""""""""""""""""
CustomDataArray = Split(CustomDataString, ";")
For Each CustomDataItem in CustomDataArray
    If InStr(CustomDataItem, "UID=") > 0 then      ' Specify a user ID
        UIDValue = right(CustomDataItem, Len(CustomDataItem)-Len("UID:"))
        LRResponseObj.CustomData = UIDValue
    Elseif InStr(CustomDataItem, "KID=") > 0 then  ' Specify a key ID
        KIDValue = right(CustomDataItem, Len(CustomDataItem) - Len("KID:"))
        LRResponseObj.KeyId = KIDValue 
    End If
Next

'"""""""""""""""""""""""""""""""""""""""""""""""""""""
' Specify the license revocation public key and the transaction ID.
' Generate the license revocation response.
'"""""""""""""""""""""""""""""""""""""""""""""""""""""
LRResponseObj.RevocationPublicKey = LRPubkey
LRResponseObj.TransactionId = ChallTransID    
LRResponseString = LRResponseObj.GenerateSignedResponse(LRPrivkey, ClientPubkey)

Requirements

Version: Windows Media Rights Manager 10 SDK or later

Reference: wmrmobjs 1.0 Type Library

Library: wmrmobjs.dll

Platform: Windows Server 2003

See Also

Previous Next

© 2007 Microsoft Corporation. All rights reserved.