(WP7) WindowsPhone and ChallengeCustomData in LicenseAcquirer

Apr 5, 2012 at 11:29 AM



On WP7 there is no ChallengeCustomData in LicenseAcquirer. We need this because our LicenseServer requires it. Right now we created custom LicenseAcquirer but we need to know how to add this CustomData and how to calculate message signature.

Can anyone help us with this problem?


Kind regards


Nov 4, 2012 at 1:27 PM
Edited Oct 23, 2013 at 2:26 PM
Sorry Guys,

I had to make my blog private so i removed its address from here and replaced this entry.
The solution was to include the customdata outside the signed part of the license request before it goes out. Look up the ManualLicenseAcquirer on silverlight license acquisition.

But you still have to have access to the playready server and expect the customdata in the request on thet specific place. It wont work with an ordinary PlayReady server.
Oct 23, 2013 at 2:14 PM
Hi Gabriel / Mateusz,

I could not access the link

as this wordpess blog is private and locked. I had requested for access but no reply yet.

Can you please give some idea as how we can send challengecustomData in WP7.

Best Regards,
Nov 7, 2013 at 6:04 PM
Hi kierepka and amitmathur1,

The simplest solution is to write your own CustomLicenseAcquirer class by deriving from the Systems.Windows.Media.LicenseAcquirer class, and override the OnAcquireLicense method. In essence you try to inject the custom data in the SOAP message that is being sent to the PlayReady licensing server. A very simple implementation is listed below based on the code referred to by lorddg, but you should of course replace the challengeString.Replace (...) statement with more profound XML writing.

Once your CustomLicenseAcquirer class is available, you can use it by setting LicenseAcquirer properrty on your Microsoft.PlayerFramework.MediaPlayer object..

I didn't try this my self, but I hope it helps.

class CustomLicenseAcquirer : LicenseAcquirer
    private string _CustomData;

    public string CustomData
        get { return _CustomData; }
        set { _CustomData = value; }

    // http://smf.codeplex.com/discussions/351294
    // Inject CustomData: http://support.ooyala.com/developers/documentation/concepts/player_v3dev_playreadyexample.html
    private string challengeString;

    protected override void OnAcquireLicense(System.IO.Stream licenseChallenge, Uri licenseServerUri)
        //base.OnAcquireLicense(licenseChallenge, licenseServerUri);

        StreamReader sr = new StreamReader(licenseChallenge);
        challengeString = sr.ReadToEnd();

        // Need to resolve the URI for the License Server -- make sure it is correct
        // and store that correct URI as resolvedLicenseServerUri.
        Uri resolvedLicenseServerUri;
        if (LicenseServerUriOverride == null)
            resolvedLicenseServerUri = licenseServerUri;
            resolvedLicenseServerUri = LicenseServerUriOverride;

        // Make a HttpWebRequest to the License Server.
        HttpWebRequest request = WebRequest.Create(resolvedLicenseServerUri) as HttpWebRequest;
        request.Method = "POST";

        // Set ContentType through property    
        request.ContentType = "application/xml";

        // The headers below are necessary so that error handling and redirects are handled 
        // properly via the Silverlight client.
        request.Headers["msprdrm_server_redirect_compat"] = "false";
        request.Headers["msprdrm_server_exception_compat"] = "false";

        //  Initiate getting request stream  
        IAsyncResult asyncResult = request.BeginGetRequestStream(new AsyncCallback(RequestStreamCallback), request);

    // This method is called when the asynchronous operation completes.
    void RequestStreamCallback(IAsyncResult ar)
        HttpWebRequest request = ar.AsyncState as HttpWebRequest;

        // populate request stream  
        request.ContentType = "text/xml";
        Stream requestStream = request.EndGetRequestStream(ar);
        StreamWriter streamWriter = new StreamWriter(requestStream, System.Text.Encoding.UTF8);

        // ********** TODO: Use real XML document reader/writer to add the CustomData xml tag in the request. **********
        challengeString = challengeString.Replace("</LA>", string.Format("<CustomData>{0}</CustomData></LA>", _CustomData));


        // Make async call for response  
        request.BeginGetResponse(new AsyncCallback(ResponseCallback), request);

    private void ResponseCallback(IAsyncResult ar)
        HttpWebRequest request = ar.AsyncState as HttpWebRequest;
        WebResponse response = request.EndGetResponse(ar);