Пример #1
0
        public void EnsureEnvelopeKeyDeliveryUrlForCommonKeyFails()
        {
            IContentKey contentKey = null;
            IContentKeyAuthorizationPolicy       contentKeyAuthorizationPolicy = null;
            IContentKeyAuthorizationPolicyOption policyOption = null;

            PlayReadyLicenseResponseTemplate responseTemplate = new PlayReadyLicenseResponseTemplate();

            responseTemplate.LicenseTemplates.Add(new PlayReadyLicenseTemplate());
            string licenseTemplate = MediaServicesLicenseTemplateSerializer.Serialize(responseTemplate);

            try
            {
                contentKey = CreateTestKey(_mediaContext, ContentKeyType.CommonEncryption);

                policyOption = ContentKeyAuthorizationPolicyOptionTests.CreateOption(_mediaContext, String.Empty, ContentKeyDeliveryType.PlayReadyLicense, null, licenseTemplate, ContentKeyRestrictionType.Open);

                List <IContentKeyAuthorizationPolicyOption> options = new List <IContentKeyAuthorizationPolicyOption>
                {
                    policyOption
                };

                contentKeyAuthorizationPolicy = CreateTestPolicy(_mediaContext, String.Empty, options, ref contentKey);

                Uri keyDeliveryServiceUri = contentKey.GetKeyDeliveryUrl(ContentKeyDeliveryType.BaselineHttp);
            }
            finally
            {
                CleanupKeyAndPolicy(contentKey, contentKeyAuthorizationPolicy, policyOption);
            }
        }
        private static string AddFairPlayTokenRestrictedAuthorizationPolicyFairPlay(IContentKey contentKey)
        {
            string tokenTemplateString = DRMHelper.GenerateTokenRequirementsString(_tokenPrimaryVerificationKey, _tokenAlternativeVerificationKey, _tokenScope, _tokenIssuer, true);

            List <ContentKeyAuthorizationPolicyRestriction> restrictions = new List <ContentKeyAuthorizationPolicyRestriction>
            {
                new ContentKeyAuthorizationPolicyRestriction
                {
                    Name = "FairPlay Token Authorization Policy",
                    KeyRestrictionType = (int)ContentKeyRestrictionType.TokenRestricted,
                    Requirements       = tokenTemplateString,
                }
            };

            // Configure FairPlay policy option.
            string FairPlayConfiguration = ConfigureFairPlayPolicyOptions();

            IContentKeyAuthorizationPolicyOption FairPlayPolicy = _context.ContentKeyAuthorizationPolicyOptions.Create("FairPlay token option", ContentKeyDeliveryType.FairPlay, restrictions, FairPlayConfiguration);
            IContentKeyAuthorizationPolicy       contentKeyAuthorizationPolicy = _context.ContentKeyAuthorizationPolicies.CreateAsync("Deliver CBC Content Key with token restrictions").Result;

            contentKeyAuthorizationPolicy.Options.Add(FairPlayPolicy);

            // Associate the content key authorization policy with the content key
            contentKey.AuthorizationPolicyId = contentKeyAuthorizationPolicy.Id;
            contentKey = contentKey.UpdateAsync().Result;

            return(tokenTemplateString);
        }
        private static string AddPlayReadyAndWidevineTokenRestrictedAuthorizationPolicy(IContentKey contentKey)
        {
            string tokenTemplateString = DRMHelper.GenerateTokenRequirementsString(_tokenPrimaryVerificationKey, _tokenAlternativeVerificationKey, _tokenScope, _tokenIssuer, true);

            List <ContentKeyAuthorizationPolicyRestriction> restrictions = new List <ContentKeyAuthorizationPolicyRestriction>
            {
                new ContentKeyAuthorizationPolicyRestriction
                {
                    Name = "Playready and Widevine Token Authorization Policy",
                    KeyRestrictionType = (int)ContentKeyRestrictionType.TokenRestricted,
                    Requirements       = tokenTemplateString,
                }
            };

            // Configure PlayReady and Widevine license templates.
            string PlayReadyLicenseTemplate = ConfigurePlayReadyLicenseTemplate();
            string WidevineLicenseTemplate  = ConfigureWidevineLicenseTemplate();

            IContentKeyAuthorizationPolicyOption PlayReadyPolicy = _context.ContentKeyAuthorizationPolicyOptions.Create("PlayReady token option", ContentKeyDeliveryType.PlayReadyLicense, restrictions, PlayReadyLicenseTemplate);
            IContentKeyAuthorizationPolicyOption WidevinePolicy  = _context.ContentKeyAuthorizationPolicyOptions.Create("Widevine token option", ContentKeyDeliveryType.Widevine, restrictions, WidevineLicenseTemplate);
            IContentKeyAuthorizationPolicy       contentKeyAuthorizationPolicy = _context.ContentKeyAuthorizationPolicies.CreateAsync("Deliver Common Content Key with token restrictions").Result;

            contentKeyAuthorizationPolicy.Options.Add(PlayReadyPolicy);
            contentKeyAuthorizationPolicy.Options.Add(WidevinePolicy);

            // Associate the content key authorization policy with the content key
            contentKey.AuthorizationPolicyId = contentKeyAuthorizationPolicy.Id;
            contentKey = contentKey.UpdateAsync().Result;

            return(tokenTemplateString);
        }
Пример #4
0
        public void EnsureNoneKeyDeliveryUrlFails()
        {
            IContentKey contentKey = null;
            IContentKeyAuthorizationPolicy       contentKeyAuthorizationPolicy = null;
            IContentKeyAuthorizationPolicyOption policyOption = null;

            try
            {
                contentKey = CreateTestKey(_mediaContext, ContentKeyType.EnvelopeEncryption);

                policyOption = ContentKeyAuthorizationPolicyOptionTests.CreateOption(_mediaContext, String.Empty, ContentKeyDeliveryType.BaselineHttp, null, null, ContentKeyRestrictionType.Open);

                List <IContentKeyAuthorizationPolicyOption> options = new List <IContentKeyAuthorizationPolicyOption>
                {
                    policyOption
                };

                contentKeyAuthorizationPolicy = CreateTestPolicy(_mediaContext, String.Empty, options, ref contentKey);

                Uri keyDeliveryServiceUri = contentKey.GetKeyDeliveryUrl(ContentKeyDeliveryType.None);
            }
            finally
            {
                CleanupKeyAndPolicy(contentKey, contentKeyAuthorizationPolicy, policyOption);
            }
        }
Пример #5
0
        static public void AddOpenAuthorizationPolicy(IContentKey contentKey)
        {
            // Create ContentKeyAuthorizationPolicy with Open restrictions
            // and create authorization policy

            List <ContentKeyAuthorizationPolicyRestriction> restrictions = new List <ContentKeyAuthorizationPolicyRestriction>
            {
                new ContentKeyAuthorizationPolicyRestriction
                {
                    Name = "Open",
                    KeyRestrictionType = (int)ContentKeyRestrictionType.Open,
                    Requirements       = null
                }
            };

            // Configure PlayReady license template.
            string newLicenseTemplate = ConfigurePlayReadyLicenseTemplate();

            IContentKeyAuthorizationPolicyOption policyOption =
                _context.ContentKeyAuthorizationPolicyOptions.Create("",
                                                                     ContentKeyDeliveryType.PlayReadyLicense,
                                                                     restrictions, newLicenseTemplate);

            IContentKeyAuthorizationPolicy contentKeyAuthorizationPolicy = _context.
                                                                           ContentKeyAuthorizationPolicies.
                                                                           CreateAsync("Deliver Common Content Key with no restrictions").
                                                                           Result;


            contentKeyAuthorizationPolicy.Options.Add(policyOption);

            // Associate the content key authorization policy with the content key.
            contentKey.AuthorizationPolicyId = contentKeyAuthorizationPolicy.Id;
            contentKey = contentKey.UpdateAsync().Result;
        }
        static public void AddOpenAuthorizationPolicy(IContentKey contentKey)
        {
            // Create ContentKeyAuthorizationPolicy with Open restrictions and create authorization policy
            IContentKeyAuthorizationPolicy policy = context.ContentKeyAuthorizationPolicies.CreateAsync("Open Authorization Policy").Result;

            List <ContentKeyAuthorizationPolicyRestriction> restrictions = new List <ContentKeyAuthorizationPolicyRestriction>();
            ContentKeyAuthorizationPolicyRestriction        restriction  =
                new ContentKeyAuthorizationPolicyRestriction
            {
                Name = "HLS Open Authorization Policy",
                KeyRestrictionType = (int)ContentKeyRestrictionType.Open,
                Requirements       = null // no requirements needed for HLS
            };

            restrictions.Add(restriction);

            IContentKeyAuthorizationPolicyOption policyOption =
                context.ContentKeyAuthorizationPolicyOptions.Create(
                    "policy",
                    ContentKeyDeliveryType.BaselineHttp,
                    restrictions,
                    "");

            policy.Options.Add(policyOption);

            // Add ContentKeyAutorizationPolicy to ContentKey
            contentKey.AuthorizationPolicyId = policy.Id;
            IContentKey updatedKey = contentKey.UpdateAsync().Result;
        }
Пример #7
0
        public void GetPlayReadyLicenseDeliveryUrl()
        {
            IContentKey contentKey = null;
            IContentKeyAuthorizationPolicy       contentKeyAuthorizationPolicy = null;
            IContentKeyAuthorizationPolicyOption policyOption = null;

            try
            {
                contentKey = CreateTestKey(_mediaContext, ContentKeyType.CommonEncryption);

                PlayReadyLicenseResponseTemplate responseTemplate = new PlayReadyLicenseResponseTemplate();
                responseTemplate.LicenseTemplates.Add(new PlayReadyLicenseTemplate());
                string licenseTemplate = MediaServicesLicenseTemplateSerializer.Serialize(responseTemplate);

                policyOption = ContentKeyAuthorizationPolicyOptionTests.CreateOption(_mediaContext, String.Empty, ContentKeyDeliveryType.PlayReadyLicense, null, licenseTemplate, ContentKeyRestrictionType.Open);

                List <IContentKeyAuthorizationPolicyOption> options = new List <IContentKeyAuthorizationPolicyOption>
                {
                    policyOption
                };

                contentKeyAuthorizationPolicy = CreateTestPolicy(_mediaContext, String.Empty, options, ref contentKey);

                Uri keyDeliveryServiceUri = contentKey.GetKeyDeliveryUrl(ContentKeyDeliveryType.PlayReadyLicense);

                Assert.IsNotNull(keyDeliveryServiceUri);
                Assert.IsTrue(0 == String.Compare(keyDeliveryServiceUri.AbsolutePath, "/PlayReady/", StringComparison.OrdinalIgnoreCase));
            }
            finally
            {
                CleanupKeyAndPolicy(contentKey, contentKeyAuthorizationPolicy, policyOption);
            }
        }
Пример #8
0
        public string[] GetProtectionTypes(IAsset asset)
        {
            List <string>        protectionTypes = new List <string>();
            IAssetDeliveryPolicy deliveryPolicy  = asset.DeliveryPolicies.Where(p => p.AssetDeliveryPolicyType == AssetDeliveryPolicyType.DynamicEnvelopeEncryption).SingleOrDefault();

            if (deliveryPolicy != null)
            {
                protectionTypes.Add(MediaProtection.AES.ToString());
            }
            deliveryPolicy = asset.DeliveryPolicies.Where(p => p.AssetDeliveryPolicyType == AssetDeliveryPolicyType.DynamicCommonEncryption).SingleOrDefault();
            if (deliveryPolicy != null)
            {
                IContentKey contentKey = asset.ContentKeys.Where(k => k.ContentKeyType == ContentKeyType.CommonEncryption).SingleOrDefault();
                if (contentKey != null)
                {
                    IContentKeyAuthorizationPolicy authPolicy = GetEntityById(MediaEntity.ContentKeyAuthPolicy, contentKey.AuthorizationPolicyId) as IContentKeyAuthorizationPolicy;
                    if (authPolicy != null)
                    {
                        IContentKeyAuthorizationPolicyOption policyOption = authPolicy.Options.Where(o => o.KeyDeliveryType == ContentKeyDeliveryType.PlayReadyLicense).SingleOrDefault();
                        if (policyOption != null)
                        {
                            protectionTypes.Add(MediaProtection.PlayReady.ToString());
                        }
                        policyOption = authPolicy.Options.Where(o => o.KeyDeliveryType == ContentKeyDeliveryType.Widevine).SingleOrDefault();
                        if (policyOption != null)
                        {
                            protectionTypes.Add(MediaProtection.Widevine.ToString());
                        }
                    }
                }
            }
            return(protectionTypes.ToArray());
        }
        public static IContentKeyAuthorizationPolicyOption AddTokenRestrictedAuthorizationPolicyPlayReady(IContentKey contentKey, string Audience, string Issuer, IList <TokenClaim> tokenclaimslist, bool AddContentKeyIdentifierClaim, TokenType tokentype, ExplorerTokenType detailedtokentype, TokenVerificationKey mytokenverificationkey, CloudMediaContext _context, string newLicenseTemplate, string openIdDiscoveryPath = null)
        {
            string tokenTemplateString = GenerateTokenRequirements(tokentype, Audience, Issuer, tokenclaimslist, AddContentKeyIdentifierClaim, mytokenverificationkey, openIdDiscoveryPath);
            string tname = detailedtokentype.ToString();

            List <ContentKeyAuthorizationPolicyRestriction> restrictions = new List <ContentKeyAuthorizationPolicyRestriction>
            {
                new ContentKeyAuthorizationPolicyRestriction
                {
                    Name = tname + " Token Authorization Policy",
                    KeyRestrictionType = (int)ContentKeyRestrictionType.TokenRestricted,
                    Requirements       = tokenTemplateString,
                }
            };

            IContentKeyAuthorizationPolicyOption policyOption =
                _context.ContentKeyAuthorizationPolicyOptions.Create(tname + "Token option",
                                                                     ContentKeyDeliveryType.PlayReadyLicense,
                                                                     restrictions, newLicenseTemplate);

            IContentKeyAuthorizationPolicy contentKeyAuthorizationPolicy = _context.
                                                                           ContentKeyAuthorizationPolicies.
                                                                           CreateAsync("Deliver Common Content Key with no restrictions").
                                                                           Result;


            return(policyOption);
        }
        public static void RemoveContentKeyAuthorizationPolicy(string id)
        {
            IContentKeyAuthorizationPolicy policy = _context.ContentKeyAuthorizationPolicies.Where(p => p.Id == id).FirstOrDefault();

            if (policy != null)
            {
                try
                {
                    string pId   = policy.Id;
                    string pName = policy.Name;
                    if (_context.ContentKeys.Where(p => p.AuthorizationPolicyId == pId).Count() != 0)
                    {
                        Console.WriteLine("ContentKey associated : Not deleting ContentKey Authorization Policy {0} : {1}", pId, pName);
                        return;
                    }
                    List <IContentKeyAuthorizationPolicyOption> options = new List <IContentKeyAuthorizationPolicyOption>(policy.Options);
                    policy.Delete();
                    Console.WriteLine("Deleted ContentKey Authorization Policy {0} : {1}", pId, pName);
                    foreach (IContentKeyAuthorizationPolicyOption option in options)
                    {
                        RemoveContentKeyAuthorizationPolicyOption(option.Id);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error on deleting ContentKey Authorization Policy {0} : {1}", id, e.ToString());
                }
            }
            else
            {
                Console.WriteLine("Error: ContentKey Authorization Policy {0} Not Found", id);
            }
            return;
        }
Пример #11
0
        /// <summary>
        /// This is a helper method to setup a Content Key for delivery from Azure Media Services
        /// </summary>
        /// <param name="context">The CloudMediaContext instance used to communicate with Azure Media Services</param>
        /// <param name="restrictions">One or more restrictions to add to the ContentKeyAuthorizationPolicy associated with the ContentKey</param>
        /// <returns>A ContentKey that is configured for delivery to clients</returns>
        private static IContentKey SetupContentKey(CloudMediaContext context, List <ContentKeyAuthorizationPolicyRestriction> restrictions)
        {
            //
            //  Create the ContentKeyAuthorizationPolicyOption
            //
            IContentKeyAuthorizationPolicyOption option =
                context.ContentKeyAuthorizationPolicyOptions.Create("Option with Token Restriction",
                                                                    ContentKeyDeliveryType.BaselineHttp,
                                                                    restrictions,
                                                                    null);

            //
            //  Create the ContentKeyAuthorizationPolicy and add the option from above
            //
            IContentKeyAuthorizationPolicy policy = context.ContentKeyAuthorizationPolicies.CreateAsync("Policy to illustrate integration with ACS").Result;

            policy.Options.Add(option);

            //
            //  Create the ContentKey and associate the policy from above
            //
            byte[]      keyValue   = GetRandomKeyValue();
            Guid        keyId      = Guid.NewGuid();
            IContentKey contentKey = context.ContentKeys.Create(keyId, keyValue, "Test Key", ContentKeyType.EnvelopeEncryption);

            contentKey.AuthorizationPolicyId = policy.Id;
            contentKey.Update();

            return(contentKey);
        }
Пример #12
0
        static public IContentKeyAuthorizationPolicy AddOpenAuthorizationPolicy(IContentKey contentKey, ContentKeyDeliveryType contentkeydeliverytype, string keydeliveryconfig, CloudMediaContext _context)
        {
            // Create ContentKeyAuthorizationPolicy with Open restrictions
            // and create authorization policy
            List <ContentKeyAuthorizationPolicyRestriction> restrictions = new List <ContentKeyAuthorizationPolicyRestriction>
            {
                new ContentKeyAuthorizationPolicyRestriction
                {
                    Name = "Open",
                    KeyRestrictionType = (int)ContentKeyRestrictionType.Open,
                    Requirements       = null
                }
            };

            IContentKeyAuthorizationPolicyOption policyOption =
                _context.ContentKeyAuthorizationPolicyOptions.Create(
                    "policy",
                    contentkeydeliverytype,
                    restrictions,
                    keydeliveryconfig);

            IContentKeyAuthorizationPolicy contentKeyAuthorizationPolicy = _context.
                                                                           ContentKeyAuthorizationPolicies.
                                                                           CreateAsync("Open Authorization Policy").Result;

            contentKeyAuthorizationPolicy.Options.Add(policyOption);

            // Associate the content key authorization policy with the content key.
            contentKey.AuthorizationPolicyId = contentKeyAuthorizationPolicy.Id;
            contentKey = contentKey.UpdateAsync().Result;

            return(contentKeyAuthorizationPolicy);
        }
        private void DoMenuRenamePolicy()
        {
            var policies = ReturnSelectedAuthPolicies();

            if (policies.Count == 1)
            {
                IContentKeyAuthorizationPolicy AuthPol = policies.FirstOrDefault();

                string value = AuthPol.Name;

                if (Program.InputBox("Policy rename", string.Format("Enter the new name for policy '{0}' :", AuthPol.Name), ref value) == DialogResult.OK)
                {
                    try
                    {
                        AuthPol.Name = value;
                        AuthPol.Update();
                        ListPolicies();
                    }
                    catch
                    {
                        MessageBox.Show("There is a problem when renaming the policy.");
                        return;
                    }
                }
            }
        }
        private void FetchKeyWithSWTToken(string audience, string issuer)
        {
            IContentKey contentKey = null;
            IContentKeyAuthorizationPolicy       contentKeyAuthorizationPolicy = null;
            IContentKeyAuthorizationPolicyOption policyOption = null;

            try
            {
                byte[] expectedKey = null;
                contentKey = CreateTestKey(_mediaContext, ContentKeyType.EnvelopeEncryption, out expectedKey);

                var contentKeyId = Guid.Parse(contentKey.Id.Replace("nb:kid:UUID:", String.Empty));

                TokenRestrictionTemplate tokenRestrictionTemplate = new TokenRestrictionTemplate(TokenType.SWT);
                tokenRestrictionTemplate.PrimaryVerificationKey = new SymmetricVerificationKey();
                // the default constructor automatically generates a random key

                tokenRestrictionTemplate.Audience  = audience;
                tokenRestrictionTemplate.Issuer    = issuer;
                tokenRestrictionTemplate.TokenType = TokenType.SWT;
                tokenRestrictionTemplate.RequiredClaims.Add(new TokenClaim(TokenClaim.ContentKeyIdentifierClaimType,
                                                                           contentKeyId.ToString()));

                string optionName   = "GetHlsKeyDeliveryUrlAndFetchKeyWithSWTAuthentication";
                string requirements = TokenRestrictionTemplateSerializer.Serialize(tokenRestrictionTemplate);
                ContentKeyRestrictionType restrictionType = ContentKeyRestrictionType.TokenRestricted;
                var _testOption = ContentKeyAuthorizationPolicyOptionTests.CreateOption(_mediaContext, optionName,
                                                                                        ContentKeyDeliveryType.BaselineHttp, requirements, null, restrictionType);

                List <IContentKeyAuthorizationPolicyOption> options = new List <IContentKeyAuthorizationPolicyOption>
                {
                    _testOption
                };

                contentKeyAuthorizationPolicy = CreateTestPolicy(_mediaContext, String.Empty, options, ref contentKey);


                Uri keyDeliveryServiceUri = contentKey.GetKeyDeliveryUrl(ContentKeyDeliveryType.BaselineHttp);

                Assert.IsNotNull(keyDeliveryServiceUri);

                Assert.IsTrue(keyDeliveryServiceUri.Host.StartsWith(_mediaContext.Credentials.ClientId));

                KeyDeliveryServiceClient keyClient = new KeyDeliveryServiceClient(RetryPolicy.DefaultFixed);
                string swtTokenString = TokenRestrictionTemplateSerializer.GenerateTestToken(tokenRestrictionTemplate,
                                                                                             tokenRestrictionTemplate.PrimaryVerificationKey, contentKeyId, DateTime.Now.AddDays(2));
                byte[] key = keyClient.AcquireHlsKeyWithBearerHeader(keyDeliveryServiceUri, swtTokenString);

                string expectedString = GetString(expectedKey);
                string fetchedString  = GetString(key);
                Assert.AreEqual(expectedString, fetchedString);
            }
            finally
            {
                CleanupKeyAndPolicy(contentKey, contentKeyAuthorizationPolicy, policyOption);
            }
        }
        public void CreateContentKeyAuthorizationPolicy()
        {
            ContentKeyAuthorizationPolicyCollection collection = _mediaContext.ContentKeyAuthorizationPolicies;
            IContentKeyAuthorizationPolicy          policy     = collection.CreateAsync("Test").Result;

            Assert.IsNotNull(policy.Id);
            Assert.IsNotNull(policy.Name);
            Assert.IsNotNull(policy.Options);
        }
        private void FetchKeyWithJWTAuth(string audience, string issuer)
        {
            IContentKey contentKey = null;
            IContentKeyAuthorizationPolicy       contentKeyAuthorizationPolicy = null;
            IContentKeyAuthorizationPolicyOption policyOption = null;

            try
            {
                byte[] expectedKey = null;
                contentKey = CreateTestKey(_mediaContext, ContentKeyType.EnvelopeEncryption, out expectedKey);

                var templatex509Certificate2 = new X509Certificate2("amscer.pfx", "AMSGIT");
                SigningCredentials cred      = new X509SigningCredentials(templatex509Certificate2);

                TokenRestrictionTemplate tokenRestrictionTemplate = new TokenRestrictionTemplate(TokenType.JWT);
                tokenRestrictionTemplate.PrimaryVerificationKey = new X509CertTokenVerificationKey(templatex509Certificate2);
                tokenRestrictionTemplate.Audience = audience;
                tokenRestrictionTemplate.Issuer   = issuer;

                string optionName   = "GetHlsKeyDeliveryUrlAndFetchKeyWithJWTAuthentication";
                string requirements = TokenRestrictionTemplateSerializer.Serialize(tokenRestrictionTemplate);
                policyOption = ContentKeyAuthorizationPolicyOptionTests.CreateOption(_mediaContext, optionName,
                                                                                     ContentKeyDeliveryType.BaselineHttp, requirements, null, ContentKeyRestrictionType.TokenRestricted);

                JwtSecurityToken token = new JwtSecurityToken(issuer: tokenRestrictionTemplate.Issuer,
                                                              audience: tokenRestrictionTemplate.Audience, notBefore: DateTime.Now.AddMinutes(-5),
                                                              expires: DateTime.Now.AddMinutes(5), signingCredentials: cred);

                JwtSecurityTokenHandler handler = new JwtSecurityTokenHandler();
                string jwtTokenString           = handler.WriteToken(token);

                List <IContentKeyAuthorizationPolicyOption> options = new List <IContentKeyAuthorizationPolicyOption>
                {
                    policyOption
                };

                contentKeyAuthorizationPolicy = CreateTestPolicy(_mediaContext, String.Empty, options, ref contentKey);

                Uri keyDeliveryServiceUri = contentKey.GetKeyDeliveryUrl(ContentKeyDeliveryType.BaselineHttp);

                Assert.IsNotNull(keyDeliveryServiceUri);

                // Enable once all accounts are enabled for per customer Key Delivery Urls
                //Assert.IsTrue(keyDeliveryServiceUri.Host.StartsWith(_mediaContext.Credentials.ClientId));

                KeyDeliveryServiceClient keyClient = new KeyDeliveryServiceClient(RetryPolicy.DefaultFixed);
                byte[] key = keyClient.AcquireHlsKeyWithBearerHeader(keyDeliveryServiceUri, jwtTokenString);

                string expectedString = GetString(expectedKey);
                string fetchedString  = GetString(key);
                Assert.AreEqual(expectedString, fetchedString);
            }
            finally
            {
                CleanupKeyAndPolicy(contentKey, contentKeyAuthorizationPolicy, policyOption);
            }
        }
        public void CreateAndDeleteContentKeyAuthorizationPolicy()
        {
            ContentKeyAuthorizationPolicyCollection collection = _mediaContext.ContentKeyAuthorizationPolicies;
            IContentKeyAuthorizationPolicy          policy     = collection.CreateAsync(testRun).Result;

            Assert.IsNotNull(policy.Id);
            Assert.IsNotNull(policy.Name);
            Assert.IsNotNull(policy.Options);
            IMediaDataServiceResponse response = policy.DeleteAsync().Result;
        }
        private void DoDeleteAutPol()
        {
            if (listViewPolicies.SelectedIndices.Count > 0)
            {
                string question;
                int    nbError    = 0;
                string messagestr = "";

                if (listViewPolicies.SelectedIndices.Count == 1)
                {
                    question = "Are you sure that you want to DELETE this policy from the Azure Media Services account ?";
                }
                else
                {
                    question = string.Format("Are you sure that you want to DELETE these {0} policies from the Azure Media Services account ?", listViewPolicies.SelectedIndices.Count);
                }

                if (MessageBox.Show(question, "Authorization policy deletion", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    this.Cursor = Cursors.WaitCursor;
                    foreach (var ind in listViewPolicies.SelectedIndices)
                    {
                        IContentKeyAuthorizationPolicy AuthPol = autPolicies.Skip((int)ind).Take(1).FirstOrDefault();

                        if (AuthPol != null)
                        {
                            try
                            {
                                AuthPol.Delete();
                            }
                            catch (Exception e)
                            {
                                nbError++;
                                if (e.InnerException != null)
                                {
                                    messagestr = Program.GetErrorMessage(e);
                                }
                            }
                        }
                    }
                    this.Cursor = Cursors.Default;

                    if (nbError > 0)
                    {
                        messagestr = string.Format("Error when deleting {0} authorization policies.", nbError) + Constants.endline + messagestr;
                        MessageBox.Show(messagestr);
                    }

                    ListPolicies();
                }
            }
        }
        public void QueryContentKeyBYAuthorizationPolicyId()
        {
            IContentKeyAuthorizationPolicy policy = _mediaContext.ContentKeyAuthorizationPolicies.CreateAsync(testRun).Result;
            IContentKey contentKey = _mediaContext.ContentKeys.CreateAsync(Guid.NewGuid(), new byte[16]).Result;

            contentKey.AuthorizationPolicyId = policy.Id;
            contentKey.Update();
            IContentKey updatedKey = _mediaContext.ContentKeys.Where(c => c.AuthorizationPolicyId == policy.Id).FirstOrDefault();

            Assert.IsNotNull(updatedKey.AuthorizationPolicyId);

            contentKey.Delete();
        }
        static public IContentKeyAuthorizationPolicy CreateAuthorizationPolicyCommonType(string policyName)
        {
            List <ContentKeyAuthorizationPolicyRestriction> restrictions;
            string PlayReadyOptionName;
            string WidevineOptionName;

            if (_isTokenRestricted)
            {
                string tokenTemplateString = GenerateTokenRequirements();
                restrictions = new List <ContentKeyAuthorizationPolicyRestriction>
                {
                    new ContentKeyAuthorizationPolicyRestriction
                    {
                        Name = "Token Authorization Policy",
                        KeyRestrictionType = (int)ContentKeyRestrictionType.TokenRestricted,
                        Requirements       = tokenTemplateString,
                    }
                };
                PlayReadyOptionName = "TokenRestricted PlayReady Option 1";
                WidevineOptionName  = "TokenRestricted Widevine Option 1";
            }
            else
            {
                restrictions = new List <ContentKeyAuthorizationPolicyRestriction>
                {
                    new ContentKeyAuthorizationPolicyRestriction
                    {
                        Name = "Open",
                        KeyRestrictionType = (int)ContentKeyRestrictionType.Open,
                        Requirements       = null
                    }
                };
                PlayReadyOptionName = "Open PlayReady Option 1";
                WidevineOptionName  = "Open Widevine Option 1";
            }

            // Configure PlayReady and Widevine license templates.
            string PlayReadyLicenseTemplate = ConfigurePlayReadyPolicyOptions();
            string WidevineLicenseTemplate  = ConfigureWidevinePolicyOptions();

            IContentKeyAuthorizationPolicyOption PlayReadyPolicy =
                _context.ContentKeyAuthorizationPolicyOptions.Create(PlayReadyOptionName, ContentKeyDeliveryType.PlayReadyLicense, restrictions, PlayReadyLicenseTemplate);
            IContentKeyAuthorizationPolicyOption WidevinePolicy =
                _context.ContentKeyAuthorizationPolicyOptions.Create(WidevineOptionName, ContentKeyDeliveryType.Widevine, restrictions, WidevineLicenseTemplate);
            IContentKeyAuthorizationPolicy contentKeyAuthorizationPolicy = _context.ContentKeyAuthorizationPolicies.CreateAsync(policyName).Result;

            contentKeyAuthorizationPolicy.Options.Add(PlayReadyPolicy);
            contentKeyAuthorizationPolicy.Options.Add(WidevinePolicy);

            return(contentKeyAuthorizationPolicy);
        }
Пример #21
0
        private void SetContentKeyAuthPolicy(IContentKey contentKey, ContentProtection contentProtection)
        {
            string policyName = string.Concat(contentKey.Name, Constants.Media.ContentProtection.AuthPolicyName);
            IContentKeyAuthorizationPolicy authPolicy = GetEntityByName(MediaEntity.ContentKeyAuthPolicy, policyName, true) as IContentKeyAuthorizationPolicy;

            if (authPolicy == null)
            {
                authPolicy = CreateContentKeyAuthPolicy(policyName, contentKey, contentProtection);
            }
            if (contentKey.AuthorizationPolicyId != authPolicy.Id)
            {
                contentKey.AuthorizationPolicyId = authPolicy.Id;
                contentKey.Update();
            }
        }
        public static IContentKeyAuthorizationPolicy CreateMultiDrmAuthorizationPolicyCommonCBCType()
        {
            // ContentKeyType.CommonEncryptionCbcs
            IContentKeyAuthorizationPolicy pol =
                _context.ContentKeyAuthorizationPolicies.Where(p => p.Name == _authPolicyNameContentKeyCommonCBC).FirstOrDefault();

            if (pol != null)
            {
                Console.WriteLine("Already exist Token Restricted CENC cbcs Type Policy: Id = {0}, Name = {1}", pol.Id, pol.Name);
                return(pol);
            }
            pol = CreateAuthorizationPolicyCommonCBCType(_authPolicyNameContentKeyCommonCBC);
            Console.WriteLine("Created Token Restricted CENC cbcs Type Policy: Id = {0}, Name = {1}", pol.Id, pol.Name);
            return(pol);
        }
        private List <IContentKeyAuthorizationPolicy> ReturnSelectedAuthPolicies()
        {
            List <IContentKeyAuthorizationPolicy> Selection = new List <IContentKeyAuthorizationPolicy>();

            foreach (int selectedindex in listViewPolicies.SelectedIndices)
            {
                IContentKeyAuthorizationPolicy DP = autPolicies.Where(pol => pol.Id == listViewPolicies.Items[selectedindex].SubItems[1].Text).FirstOrDefault();

                if (DP != null)
                {
                    Selection.Add(DP);
                }
            }
            return(Selection);
        }
        private void buttonUseExistingAutpolicy_Click(object sender, EventArgs e)
        {
            var form = new SelectAutPolicy(_context, _form1.GetContentKeyType);

            if (form.ShowDialog() == DialogResult.OK)
            {
                var pol = form.SelectedPolicy;
                if (pol != null)
                {
                    _existingAuthorizationPolicy = pol;
                    TextBoxAutPolicyId.Text      = string.Format("{0} ({1})", pol.Name, pol.Id);
                    ValidateButtonOk();
                }
            }
        }
Пример #25
0
        public static IContentKeyAuthorizationPolicy CreateTestPolicy(CloudMediaContext mediaContext, string name, List <IContentKeyAuthorizationPolicyOption> policyOptions, ref IContentKey contentKey)
        {
            IContentKeyAuthorizationPolicy contentKeyAuthorizationPolicy = mediaContext.ContentKeyAuthorizationPolicies.CreateAsync(name).Result;

            foreach (IContentKeyAuthorizationPolicyOption option in policyOptions)
            {
                contentKeyAuthorizationPolicy.Options.Add(option);
            }

            // Associate the content key authorization policy with the content key
            contentKey.AuthorizationPolicyId = contentKeyAuthorizationPolicy.Id;
            contentKey = contentKey.UpdateAsync().Result;

            return(contentKeyAuthorizationPolicy);
        }
        public void CreateAndUpdateContentKeyAuthorizationPolicy()
        {
            ContentKeyAuthorizationPolicyCollection collection = _mediaContext.ContentKeyAuthorizationPolicies;
            string name        = testRun + "_CreateAndUpdateContentKeyAuthorizationPolicy_OriginalName";
            string updatedname = testRun + "_CreateAndUpdateContentKeyAuthorizationPolicy_UpdatedName";
            IContentKeyAuthorizationPolicy policy = collection.CreateAsync(name).Result;

            Assert.IsNotNull(policy.Id);
            Assert.IsNotNull(policy.Name);
            Assert.IsNotNull(policy.Options);
            Assert.AreEqual(name, policy.Name);
            policy.Name = updatedname;
            IContentKeyAuthorizationPolicy policyAfterUpdate = policy.UpdateAsync().Result;

            Assert.AreEqual(updatedname, policyAfterUpdate.Name);
            Assert.AreEqual(policy.Id, policyAfterUpdate.Id);
        }
        public static void ApplyMultiDrmAuthorizationPolicyToAsset(string id)
        {
            IAsset asset = _context.Assets.Where(a => a.Id == id).FirstOrDefault();

            if (asset == null)
            {
                Console.WriteLine("Error: Asset {0} Not Found", id);
            }
            else
            {
                System.Console.WriteLine("Asset Name = {0}", asset.Name);
                DeleteMultiDrmAuthorizationPolicyToAsset(id);

                IContentKey keyCENC = CreateContentKeyCommonType(asset);
                Console.WriteLine("Created CENC key {0} for the asset {1} ", keyCENC.Id, asset.Id);
                Console.WriteLine("PlayReady License Key delivery URL: {0}", keyCENC.GetKeyDeliveryUrl(ContentKeyDeliveryType.PlayReadyLicense));
                Console.WriteLine("Widevine License Key delivery URL: {0}", keyCENC.GetKeyDeliveryUrl(ContentKeyDeliveryType.Widevine));
                IContentKey keyCENCcbcs = CreateContentKeyCommonCBCType(asset);
                Console.WriteLine("Created CENC-cbcs key {0} for the asset {1} ", keyCENCcbcs.Id, asset.Id);
                Console.WriteLine("FairPlay License Key delivery URL: {0}", keyCENCcbcs.GetKeyDeliveryUrl(ContentKeyDeliveryType.FairPlay));
                Console.WriteLine();

                IContentKeyAuthorizationPolicy policyCENC = CreateMultiDrmAuthorizationPolicyCommonType();
                keyCENC.AuthorizationPolicyId = policyCENC.Id;
                keyCENC = keyCENC.UpdateAsync().Result;
                Console.WriteLine("Added authorization policy to CENC Key: {0}", keyCENC.AuthorizationPolicyId);

                IContentKeyAuthorizationPolicy policyCENCcbcs = CreateMultiDrmAuthorizationPolicyCommonCBCType();
                keyCENCcbcs.AuthorizationPolicyId = policyCENCcbcs.Id;
                keyCENCcbcs = keyCENCcbcs.UpdateAsync().Result;
                Console.WriteLine("Added authorization policy to CENC-cbcs Key: {0}", keyCENCcbcs.AuthorizationPolicyId);
                Console.WriteLine();

                CreateAssetDeliveryPolicyCenc(asset, keyCENC);
                CreateAssetDeliveryPolicyCencCbcs(asset, keyCENCcbcs);
                Console.WriteLine("Created asset delivery policy.\n");

                string url = GetStreamingOriginLocator(asset);
                Console.WriteLine("Created locator.");
                Console.WriteLine("Encrypted Smooth+PlayReady URL: {0}/manifest", url);
                Console.WriteLine("Encrypted MPEG-DASH URL: {0}/manifest(format=mpd-time-csf)", url);
                Console.WriteLine("Encrypted HLS+FairPlay URL: {0}/manifest(format=m3u8-aapl)", url);
            }
        }
Пример #28
0
        public static string AddTokenRestrictedAuthorizationPolicy(IContentKey contentKey)
        {
            string tokenTemplateString = GenerateTokenRequirements();

            List <ContentKeyAuthorizationPolicyRestriction> restrictions =
                new List <ContentKeyAuthorizationPolicyRestriction>
            {
                new ContentKeyAuthorizationPolicyRestriction
                {
                    Name = "Token Authorization Policy",
                    KeyRestrictionType = (int)ContentKeyRestrictionType.TokenRestricted,
                    Requirements       = tokenTemplateString,
                }
            };

            // Configure PlayReady and Widevine license templates.
            string PlayReadyLicenseTemplate = ConfigurePlayReadyLicenseTemplate();

            string WidevineLicenseTemplate = ConfigureWidevineLicenseTemplate();

            IContentKeyAuthorizationPolicyOption PlayReadyPolicy =
                _context.ContentKeyAuthorizationPolicyOptions.Create("Token option",
                                                                     ContentKeyDeliveryType.PlayReadyLicense,
                                                                     restrictions, PlayReadyLicenseTemplate);

            IContentKeyAuthorizationPolicyOption WidevinePolicy =
                _context.ContentKeyAuthorizationPolicyOptions.Create("Token option",
                                                                     ContentKeyDeliveryType.Widevine,
                                                                     restrictions, WidevineLicenseTemplate);

            IContentKeyAuthorizationPolicy contentKeyAuthorizationPolicy = _context.
                                                                           ContentKeyAuthorizationPolicies.
                                                                           CreateAsync("Deliver Common Content Key with token restrictions").
                                                                           Result;

            contentKeyAuthorizationPolicy.Options.Add(PlayReadyPolicy);
            contentKeyAuthorizationPolicy.Options.Add(WidevinePolicy);

            // Associate the content key authorization policy with the content key
            contentKey.AuthorizationPolicyId = contentKeyAuthorizationPolicy.Id;
            contentKey = contentKey.UpdateAsync().Result;

            return(tokenTemplateString);
        }
        static public IContentKeyAuthorizationPolicy CreateAuthorizationPolicyCommonCBCType(string policyName)
        {
            List <ContentKeyAuthorizationPolicyRestriction> restrictions;
            string FairPlayOptionName;

            if (_isTokenRestricted)
            {
                string tokenTemplateString = GenerateTokenRequirements();
                restrictions = new List <ContentKeyAuthorizationPolicyRestriction>
                {
                    new ContentKeyAuthorizationPolicyRestriction
                    {
                        Name = "Token Authorization Policy",
                        KeyRestrictionType = (int)ContentKeyRestrictionType.TokenRestricted,
                        Requirements       = tokenTemplateString,
                    }
                };
                FairPlayOptionName = "TokenRestricted FairPlay Option 1";
            }
            else
            {
                restrictions = new List <ContentKeyAuthorizationPolicyRestriction>
                {
                    new ContentKeyAuthorizationPolicyRestriction
                    {
                        Name = "Open",
                        KeyRestrictionType = (int)ContentKeyRestrictionType.Open,
                        Requirements       = null
                    }
                };
                FairPlayOptionName = "Open FairPlay Option 1";
            }

            // Configure FairPlay policy option.
            string FairPlayConfiguration = ConfigureFairPlayPolicyOptions();

            IContentKeyAuthorizationPolicyOption FairPlayPolicy =
                _context.ContentKeyAuthorizationPolicyOptions.Create(FairPlayOptionName, ContentKeyDeliveryType.FairPlay, restrictions, FairPlayConfiguration);
            IContentKeyAuthorizationPolicy contentKeyAuthorizationPolicy = _context.ContentKeyAuthorizationPolicies.CreateAsync(policyName).Result;

            contentKeyAuthorizationPolicy.Options.Add(FairPlayPolicy);

            return(contentKeyAuthorizationPolicy);
        }
Пример #30
0
        private void CleanupKeyAndPolicy(IContentKey contentKey, IContentKeyAuthorizationPolicy contentKeyAuthorizationPolicy, IContentKeyAuthorizationPolicyOption policyOption)
        {
            if (contentKey != null)
            {
                contentKey.Delete();
            }

            if (contentKeyAuthorizationPolicy != null)
            {
                contentKeyAuthorizationPolicy.Delete();
            }

            /*
             * if (policyOption != null)
             * {
             *  policyOption.Delete();
             * }
             */
        }
Пример #31
0
        private void DoDisplayKeyPropertiesAndAutOptions()
        {
            buttonRemoveAuthPolOption.Enabled = false;
            buttonRemoveAuthPol.Enabled = false;
            buttonGetTestToken.Enabled = false;

            if (listViewKeys.SelectedItems.Count > 0)
            {
                IContentKey key = myAsset.ContentKeys.Skip(listViewKeys.SelectedIndices[0]).Take(1).FirstOrDefault();
                dataGridViewKeys.Rows.Clear();
                dataGridViewKeys.Rows.Add("Name", key.Name != null ? key.Name : "<no name>");
                dataGridViewKeys.Rows.Add("Id", key.Id);
                dataGridViewKeys.Rows.Add("Content key type", key.ContentKeyType);
                dataGridViewKeys.Rows.Add("Checksum", key.Checksum);
                dataGridViewKeys.Rows.Add("Created", key.Created.ToLocalTime().ToString("G"));
                dataGridViewKeys.Rows.Add("Last modified", key.LastModified.ToLocalTime().ToString("G"));
                dataGridViewKeys.Rows.Add("Protection key Id", key.ProtectionKeyId);
                dataGridViewKeys.Rows.Add("Protection key type", key.ProtectionKeyType);
                int i = dataGridViewKeys.Rows.Add("Clear Key Value", "see clear key");
                DataGridViewButtonCell btn = new DataGridViewButtonCell();
                dataGridViewKeys.Rows[i].Cells[1] = btn;
                dataGridViewKeys.Rows[i].Cells[1].Value = "See clear key";
                dataGridViewKeys.Rows[i].Cells[1].Tag = Convert.ToBase64String(key.GetClearKeyValue());

                listViewAutPolOptions.Items.Clear();
                dataGridViewAutPolOption.Rows.Clear();

                if (key.AuthorizationPolicyId != null)
                {
                    dataGridViewKeys.Rows.Add("Authorization Policy Id", key.AuthorizationPolicyId);
                    myAuthPolicy = myContext.ContentKeyAuthorizationPolicies.Where(p => p.Id == key.AuthorizationPolicyId).FirstOrDefault();
                    if (myAuthPolicy != null)
                    {
                        buttonRemoveAuthPol.Enabled = true;
                        dataGridViewKeys.Rows.Add("Authorization Policy Name", myAuthPolicy.Name);
                        listViewAutPolOptions.BeginUpdate();
                        foreach (var option in myAuthPolicy.Options)
                        {
                            ListViewItem item = new ListViewItem((string.IsNullOrEmpty(option.Name) ? "<no name>" : option.Name), 0);
                            listViewAutPolOptions.Items.Add(item);
                        }
                        listViewAutPolOptions.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
                        listViewAutPolOptions.EndUpdate();
                        if (listViewAutPolOptions.Items.Count > 0) listViewAutPolOptions.Items[0].Selected = true;
                    }
                }
                else
                {
                    myAuthPolicy = null;
                }
            }
            else
            {
                myAuthPolicy = null;
            }
        }
        private void CleanupKeyAndPolicy(IContentKey contentKey, IContentKeyAuthorizationPolicy contentKeyAuthorizationPolicy, IContentKeyAuthorizationPolicyOption policyOption)
        {
            if (contentKey != null)
            {
                contentKey.Delete();
            }

            if (contentKeyAuthorizationPolicy != null)
            {
                contentKeyAuthorizationPolicy.Delete();
            }

            /*
            if (policyOption != null)
            {
                policyOption.Delete();
            }
            */
        }
        private void DoDisplayKeyProperties()
        {
            if (listViewKeys.SelectedItems.Count > 0)
            {
                IContentKey key = myAsset.ContentKeys.Skip(listViewKeys.SelectedIndices[0]).Take(1).FirstOrDefault();
                dataGridViewKeys.Rows.Clear();
                dataGridViewKeys.Rows.Add("Name", key.Name != null ? key.Name : "<no name>");
                dataGridViewKeys.Rows.Add("Id", key.Id);
                dataGridViewKeys.Rows.Add("Content key type", key.ContentKeyType);
                dataGridViewKeys.Rows.Add("Checksum", key.Checksum);
                dataGridViewKeys.Rows.Add("Created", key.Created.ToLocalTime().ToString("G"));
                dataGridViewKeys.Rows.Add("Las modified", key.LastModified.ToLocalTime().ToString("G"));
                dataGridViewKeys.Rows.Add("Protection key Id", key.ProtectionKeyId);
                dataGridViewKeys.Rows.Add("Protection key type", key.ProtectionKeyType);
                int i = dataGridViewKeys.Rows.Add("Clear Key Value", "see clear key");
                DataGridViewButtonCell btn = new DataGridViewButtonCell();
                dataGridViewKeys.Rows[i].Cells[1] = btn;
                dataGridViewKeys.Rows[i].Cells[1].Value = "See clear key";
                dataGridViewKeys.Rows[i].Cells[1].Tag = Convert.ToBase64String(key.GetClearKeyValue());

                listViewAutPolOptions.Items.Clear();
                dataGridViewAutPolOption.Rows.Clear();

                if (key.AuthorizationPolicyId != null)
                {
                    dataGridViewKeys.Rows.Add("Authorization Policy Id", key.AuthorizationPolicyId);
                    myAuthPolicy = myContext.ContentKeyAuthorizationPolicies.Where(p => p.Id == key.AuthorizationPolicyId).FirstOrDefault();
                    if (myAuthPolicy != null)
                    {
                        dataGridViewKeys.Rows.Add("Authorization Policy Name", myAuthPolicy.Name);
                        listViewAutPolOptions.BeginUpdate();
                        foreach (var option in myAuthPolicy.Options)
                        {
                            ListViewItem item = new ListViewItem((string.IsNullOrEmpty(myAuthPolicy.Name) ? "<no name>" : myAuthPolicy.Name) + " / " + (string.IsNullOrEmpty(option.Name) ? "<no name>" : option.Name), 0);
                            listViewAutPolOptions.Items.Add(item);
                        }
                        listViewAutPolOptions.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
                        listViewAutPolOptions.EndUpdate();
                        if (listViewAutPolOptions.Items.Count > 0) listViewAutPolOptions.Items[0].Selected = true;
                    }
                }
                else
                {
                    myAuthPolicy = null;
                }
                /* // No need for this
                switch (key.ContentKeyType)
                {

                    case ContentKeyType.CommonEncryption:
                        string DelUrl;
                        try
                        {
                            DelUrl = key.GetKeyDeliveryUrl(ContentKeyDeliveryType.PlayReadyLicense).OriginalString;
                        }
                        catch (Exception e) // Perhaps PlayReady license delivery has been activated
                        {
                            if (e.InnerException == null)
                            {
                                DelUrl = e.Message;
                            }
                            else
                            {
                                DelUrl = string.Format("{0} ({1})", e.Message, Program.GetErrorMessage(e));
                            }
                        }
                        dataGridViewKeys.Rows.Add("GetkeyDeliveryUrl", DelUrl);
                        break;

                    case ContentKeyType.EnvelopeEncryption:
                        dataGridViewKeys.Rows.Add("GetkeyDeliveryUrl", key.GetKeyDeliveryUrl(ContentKeyDeliveryType.BaselineHttp).OriginalString);
                        break;


                    default:
                        break;

                }*/
            }
            else
            {
                myAuthPolicy = null;
            }
        }