protected override void LAServiceRequestCompleted(IPlayReadyLicenseAcquisitionServiceRequest sender, Exception hrCompletionStatus)
        {
            TestLogger.LogMessage("Enter LAAndReportResult.LAServiceRequestCompleted()");

            if (hrCompletionStatus == null)
            {
                TestLogger.LogImportantMessage("***License acquisition succeeded***");
                _reportResult(true, sampleDataItem);
            }
            else
            {
                if (PerformEnablingActionIfRequested(hrCompletionStatus) || HandleExpectedError(hrCompletionStatus))
                {
                    TestLogger.LogMessage("Exception handled.");
                }
                else
                {
                    TestLogger.LogError("LAServiceRequestCompleted ERROR: " + hrCompletionStatus.ToString());
                    TestLogger.LogError("hrCompletionStatus.HResult=" + hrCompletionStatus.HResult.ToString());
                    _reportResult(false, sampleDataItem);
                }
            }

            TestLogger.LogMessage("Leave LAAndReportResult.LAServiceRequestCompleted()");
        }
 void HandleServiceRequest()
 {
     if (_serviceRequest is PlayReadyIndividualizationServiceRequest)
     {
         HandleIndivServiceRequest((PlayReadyIndividualizationServiceRequest)_serviceRequest);
     }
     else if (_serviceRequest is PlayReadyLicenseAcquisitionServiceRequest)
     {
         HandleLicenseAcquisitionServiceRequest((PlayReadyLicenseAcquisitionServiceRequest)_serviceRequest);
     }
     else if (_serviceRequest is PlayReadyDomainJoinServiceRequest)
     {
         HandleDomainJoinServiceRequest((PlayReadyDomainJoinServiceRequest)_serviceRequest);
     }
     else if (_serviceRequest is PlayReadyDomainLeaveServiceRequest)
     {
         HandleDomainLeaveServiceRequest((PlayReadyDomainLeaveServiceRequest)_serviceRequest);
     }
     else if (_serviceRequest is PlayReadyRevocationServiceRequest)
     {
         HandleRevocationServiceRequest((PlayReadyRevocationServiceRequest)_serviceRequest);
     }
     else
     {
         TestLogger.LogError("ERROR: Unsupported serviceRequest " + _serviceRequest.GetType());
     }
 }
        protected virtual void MeteringServiceRequestCompleted(PlayReadyMeteringReportServiceRequest sender, Exception hrCompletionStatus)
        {
            TestLogger.LogImportantMessage("MeteringServiceRequestCompleted");

            if (hrCompletionStatus != null)
            {
                TestLogger.LogError("MeteringServiceRequestCompleted failed with " + hrCompletionStatus.HResult);
            }
        }
        public void  AcquireLicenseProactively()
        {
            IPlayReadyLicenseAcquisitionServiceRequest licenseRequest;

            try
            {
                PlayReadyContentHeader contentHeader = new PlayReadyContentHeader(0,
                                                                                  RequestConfigData.KeyIds,
                                                                                  null,
                                                                                  RequestConfigData.EncryptionAlgorithm,
                                                                                  null,
                                                                                  null,
                                                                                  String.Empty,
                                                                                  RequestConfigData.DomainServiceId);

                TestLogger.LogMessage("Creating license acquisition service request...");

                if (bPersistent)
                {   // persistent license
                    licenseRequest = (IPlayReadyLicenseAcquisitionServiceRequest) new PlayReadyLicenseAcquisitionServiceRequest();
                }
                else
                {
                    if (this.licenseSession == null)
                    {
                        throw new ArgumentNullException("licenseSession can not be null");
                    }

                    //in-memory license, use license session to create a license service request
                    //this way, the acquired license will be tied to the media session associated with the license session
                    licenseRequest = this.licenseSession.CreateLAServiceRequest();
                }
                licenseRequest.ContentHeader = contentHeader;
                licenseRequest.Uri           = RequestConfigData.Uri;
                AcquireLicenseReactively(licenseRequest);
            }
            catch (Exception ex)
            {
                if (ex.HResult == ServiceRequest.MSPR_E_NEEDS_INDIVIDUALIZATION)
                {
                    PlayReadyIndividualizationServiceRequest indivServiceRequest = new PlayReadyIndividualizationServiceRequest();

                    RequestChain requestChain = new RequestChain(indivServiceRequest);
                    requestChain.FinishAndReportResult(new ReportResultDelegate(HandleIndivServiceRequest_Finished));
                }
                else
                {
                    //TestLogger.LogImportantMessage("AcquireLicenseProactively failed:" + ex.HResult);
                    TestLogger.LogError("AcquireLicenseProactively failed:" + ex.HResult);
                    licenseRequest = (IPlayReadyLicenseAcquisitionServiceRequest) new PlayReadyLicenseAcquisitionServiceRequest();
                    LAServiceRequestCompleted(licenseRequest, ex);
                }
            }
        }
Ejemplo n.º 5
0
        protected override void SecureStopServiceRequestCompleted(PlayReadySecureStopServiceRequest SecureStopRequest, Exception hrCompletionStatus)
        {
            TestLogger.LogMessage("Enter SecureStopAndReportResult.SecureStopServiceRequestCompleted()");

            if (hrCompletionStatus != null)
            {
                if (PerformEnablingActionIfRequested(hrCompletionStatus) || HandleExpectedError(hrCompletionStatus))
                {
                    TestLogger.LogMessage("Exception handled.");
                }
                else
                {
                    TestLogger.LogError("SecureStopServiceRequestCompleted ERROR: " + hrCompletionStatus.ToString());
                    _reportResult(false, null);
                }
            }

            TestLogger.LogMessage("Leave SecureStopAndReportResult.SecureStopServiceRequestCompleted()");
        }
Ejemplo n.º 6
0
        private void TestActionFinished(bool bResult, object context)
        {
            if (_meteringAndReportResult != null)
            {
                if (GlobalData.g_itemPage.bMeteringOrSecureStopButtonClicked == true)
                {
                    TestLogger.LogMeteringData("MeterData(" + _meteringAndReportResult.PlayCount.ToString() + ")");
                }
            }

            if (bResult)
            {
                TestLogger.LogImportantMessage("TestActionFinished successfully");
            }
            else
            {
                TestLogger.LogError("TestActionFinished with error!!!");
            }
        }
Ejemplo n.º 7
0
        protected override void DomainLeaveServiceRequestCompleted(PlayReadyDomainLeaveServiceRequest sender, Exception hrCompletionStatus)
        {
            TestLogger.LogMessage("Enter DomainLeaveAndReportResult.DomainLeaveServiceRequestCompleted()");

            if (hrCompletionStatus == null)
            {
                TestLogger.LogImportantMessage("***Domain Leave succeeded***");
                _reportResult(true, null);
            }
            else
            {
                if (!PerformEnablingActionIfRequested(hrCompletionStatus))
                {
                    TestLogger.LogError("DomainLeaveServiceRequestCompleted ERROR: " + hrCompletionStatus.ToString());
                    _reportResult(false, null);
                }
            }

            TestLogger.LogMessage("Leave DomainLeaveAndReportResult.DomainLeaveServiceRequestCompleted()");
        }
        private void ProvactiveActionFinished(bool bResult, object resultContext)
        {
            SampleDataItem item = (SampleDataItem)resultContext;

            if (bResult)
            {
                TestLogger.LogImportantMessage("ActionFinished successfully");
            }
            else
            {
                TestLogger.LogError("ActionFinished with error!!!");
                return;
            }

            if (item.IsRootLicense == false &&
                item.IsLDL == false &&
                playbackContents != null)
            {
                playbackContents[item.PlayerIndex].Play(item.Content);
            }
        }
        protected override void IndivServiceRequestCompleted(PlayReadyIndividualizationServiceRequest sender, Exception hrCompletionStatus)
        {
            TestLogger.LogMessage("Enter IndivAndReportResult.IndivServiceRequestCompleted()");

            if (hrCompletionStatus == null)
            {
                TestLogger.LogImportantMessage("***Indiv succeeded***");
                TestLogger.LogImportantMessage("PlayReady security version " + Windows.Media.Protection.PlayReady.PlayReadyStatics.PlayReadySecurityVersion);
                _reportResult(true, null);
            }
            else
            {
                //needed for LA revoke->Re-Indiv->LA sequence
                if (!PerformEnablingActionIfRequested(hrCompletionStatus))
                {
                    TestLogger.LogError("IndivServiceRequestCompleted ERROR: " + hrCompletionStatus.ToString());
                    _reportResult(false, null);
                }
            }

            TestLogger.LogMessage("Leave IndivAndReportResult.IndivServiceRequestCompleted()");
        }
        protected override void MeteringServiceRequestCompleted(PlayReadyMeteringReportServiceRequest meteringRequest, Exception hrCompletionStatus)
        {
            TestLogger.LogMessage("Enter MeteringAndReportResult.MeteringServiceRequestCompleted()");

            if (hrCompletionStatus == null)
            {
                string strMeteringReportXml = XmlConvert.DecodeName(meteringRequest.ResponseCustomData);
                TestLogger.LogMessage("Metering report Xml = " + strMeteringReportXml);

                uint actualPlayCount = 0;
                bool bFound          = false;

                if (strMeteringReportXml.Contains("meteringRecord"))
                {
                    //ResponseCustomData format on server http://playready.directtaps.net
                    string [] dataList = strMeteringReportXml.Split(' ');
                    foreach (var data in dataList)
                    {
                        if (data.Contains("Play:"))
                        {
                            bFound = true;
                            string strplayCount = data.Trim().Substring(5);
                            actualPlayCount = Convert.ToUInt32(Regex.Match(strplayCount, @"\d+").Value);
                        }
                    }
                }
                else
                {
                    //otherwise, ResponseCustomData format on server http://capprsvr05/I90playreadymain/rightsmanager.asmx
                    XElement xElement = XElement.Parse(strMeteringReportXml);
                    actualPlayCount = (from item in xElement.Descendants("Action")
                                       where (string)item.Attribute("Name") == "Play"
                                       select(uint) item.Attribute("Value")
                                       ).First();
                    bFound = true;
                }

                if (!bFound)
                {
                    throw new Exception("unrecoganized meteringRequest.ResponseCustomData");
                }

                PlayCount = actualPlayCount;

                if (actualPlayCount == _expectedPlayCount)
                {
                    TestLogger.LogMessage("Actual PlayCount = " + actualPlayCount + " from  metering processed report.");
                    TestLogger.LogMessage("************************************    MeteringReport succeeded       ****************************************");
                    _reportResult(true, null);
                }
                else
                {
                    TestLogger.LogMessage("!!!!!!Actual PlayCount = " + actualPlayCount + "but expected = " + _expectedPlayCount);
                    _reportResult(false, null);
                }
            }
            else
            {
                if (PerformEnablingActionIfRequested(hrCompletionStatus) || HandleExpectedError(hrCompletionStatus))
                {
                    TestLogger.LogMessage("Exception handled.");
                }
                else
                {
                    TestLogger.LogError("MeteringServiceRequestCompleted ERROR: " + hrCompletionStatus.ToString());
                    _reportResult(false, null);
                }
            }

            TestLogger.LogMessage("Leave MeteringAndReportResult.MeteringServiceRequestCompleted()");
        }