private static IContentKeyAuthorizationPolicyOption GetTokenRestrictedAuthorizationPolicyOption(CloudMediaContext context, byte[] tokenSecret, ContentKeyDeliveryType ckdTypes, TokenType tokenType, string audience, string issuer, TokenClaim[] tokenClaims, string keyDeliveryConfiguration) { string tokenTemplateString = GenerateTokenRequirements(tokenSecret, tokenType, audience, issuer, tokenClaims); List <ContentKeyAuthorizationPolicyRestriction> restrictions = new List <ContentKeyAuthorizationPolicyRestriction> { new ContentKeyAuthorizationPolicyRestriction { Name = "Token Authorization Policy", KeyRestrictionType = (int)ContentKeyRestrictionType.TokenRestricted, Requirements = tokenTemplateString, } }; string name; switch (ckdTypes) { case ContentKeyDeliveryType.PlayReadyLicense: name = "Playready License"; break; case ContentKeyDeliveryType.Widevine: name = "Widevine License"; break; case ContentKeyDeliveryType.FairPlay: name = "FairPlay License"; break; default: throw new NotSupportedException("We do not support " + ckdTypes.ToString()); } return(context.ContentKeyAuthorizationPolicyOptions.Create(name, ckdTypes, restrictions, keyDeliveryConfiguration)); }
public static IContentKeyAuthorizationPolicyOption AddTokenRestrictedAuthorizationPolicyCENC(ContentKeyDeliveryType deliveryType, 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 " + deliveryType.ToString(), deliveryType, restrictions, newLicenseTemplate); return(policyOption); }