private Dictionary <string, string> GetStorageAccounts(string authToken) { Dictionary <string, string> storageAccounts = new Dictionary <string, string>(); string claimType = Constant.UserAttribute.StorageAccount1Name; string storageAccountName = AuthToken.GetClaimValue(authToken, claimType); claimType = Constant.UserAttribute.StorageAccount1Key; string storageAccountKey = AuthToken.GetClaimValue(authToken, claimType); storageAccounts.Add(storageAccountName, storageAccountKey); claimType = Constant.UserAttribute.StorageAccount2Name; storageAccountName = AuthToken.GetClaimValue(authToken, claimType); claimType = Constant.UserAttribute.StorageAccount2Key; storageAccountKey = AuthToken.GetClaimValue(authToken, claimType); storageAccounts.Add(storageAccountName, storageAccountKey); claimType = Constant.UserAttribute.StorageAccount3Name; storageAccountName = AuthToken.GetClaimValue(authToken, claimType); claimType = Constant.UserAttribute.StorageAccount3Key; storageAccountKey = AuthToken.GetClaimValue(authToken, claimType); storageAccounts.Add(storageAccountName, storageAccountKey); return(storageAccounts); }
public MediaClient(string authToken) { string attributeName = Constants.UserAttribute.MediaAccountName; string accountName = AuthToken.GetClaimValue(authToken, attributeName); attributeName = Constants.UserAttribute.MediaAccountKey; string accountKey = AuthToken.GetClaimValue(authToken, attributeName); BindContext(accountName, accountKey); }
private string GetMediaAccountEndpointUrl() { string endpointUrl = AuthToken.GetClaimValue(_authToken, Constant.UserAttribute.MediaAccountEndpointUrl); if (string.IsNullOrEmpty(endpointUrl)) { string settingKey = Constant.AppSettingKey.DirectoryMediaAccountEndpointUrl; endpointUrl = AppSetting.GetValue(settingKey); } return(endpointUrl); }
private string GetMediaAccountDomainName() { string accountDomain = AuthToken.GetClaimValue(_authToken, Constant.UserAttribute.MediaAccountDomainName); if (string.IsNullOrEmpty(accountDomain)) { string settingKey = Constant.AppSettingKey.DirectoryMediaAccountTenantDomain; accountDomain = AppSetting.GetValue(settingKey); } return(accountDomain); }
public User(string authToken) { _authToken = authToken; MediaAccount = new MediaAccount() { Name = AuthToken.GetClaimValue(_authToken, Constant.UserAttribute.MediaAccountName), SubscriptionId = AuthToken.GetClaimValue(_authToken, Constant.UserAttribute.MediaAccountSubscriptionId), ResourceGroupName = AuthToken.GetClaimValue(_authToken, Constant.UserAttribute.MediaAccountResourceGroupName), DirectoryTenantId = AuthToken.GetClaimValue(_authToken, Constant.UserAttribute.MediaAccountDirectoryTenantId), ServicePrincipalId = AuthToken.GetClaimValue(_authToken, Constant.UserAttribute.MediaAccountServicePrincipalId), ServicePrincipalKey = AuthToken.GetClaimValue(_authToken, Constant.UserAttribute.MediaAccountServicePrincipalKey), VideoIndexerRegion = AuthToken.GetClaimValue(_authToken, Constant.UserAttribute.MediaAccountVideoIndexerRegion), VideoIndexerKey = AuthToken.GetClaimValue(_authToken, Constant.UserAttribute.MediaAccountVideoIndexerKey), StorageAccounts = GetStorageAccounts(_authToken) }; MediaAccount.ResourceId = string.Format(Constant.Media.AccountResourceId, MediaAccount.SubscriptionId, MediaAccount.ResourceGroupName, MediaAccount.Name); }
internal static void TrackJob(string authToken, IJob job, string storageAccount, ContentProtection[] contentProtections) { string attributeName = Constants.UserAttribute.MediaAccountName; string accountName = AuthToken.GetClaimValue(authToken, attributeName); attributeName = Constants.UserAttribute.MediaAccountKey; string accountKey = AuthToken.GetClaimValue(authToken, attributeName); attributeName = Constants.UserAttribute.UserId; string userId = AuthToken.GetClaimValue(authToken, attributeName); attributeName = Constants.UserAttribute.MobileNumber; string mobileNumber = AuthToken.GetClaimValue(authToken, attributeName); JobPublish jobPublish = new JobPublish(); jobPublish.PartitionKey = accountName; jobPublish.RowKey = job.Id; jobPublish.MediaAccountKey = accountKey; jobPublish.StorageAccountName = storageAccount; jobPublish.StorageAccountKey = Storage.GetUserAccountKey(authToken, storageAccount); jobPublish.UserId = userId; jobPublish.MobileNumber = mobileNumber; EntityClient entityClient = new EntityClient(); string tableName = Constants.Storage.TableName.JobPublish; entityClient.InsertEntity(tableName, jobPublish); tableName = Constants.Storage.TableName.JobPublishProtection; foreach (ContentProtection contentProtection in contentProtections) { contentProtection.PartitionKey = jobPublish.PartitionKey; contentProtection.RowKey = jobPublish.RowKey; entityClient.InsertEntity(tableName, contentProtection); } }
public AsperaClient(string authToken) { string attributeName = Constants.UserAttribute.AsperaServiceGateway; _serviceNode = AuthToken.GetClaimValue(authToken, attributeName); if (!_serviceNode.StartsWith("http", StringComparison.InvariantCultureIgnoreCase)) { _serviceNode = string.Concat("https://", _serviceNode); } string[] serviceInfo = _serviceNode.Split('.'); serviceInfo[0] = string.Concat(serviceInfo[0], Constants.Storage.Partner.AsperaWorker); _serviceStats = string.Join(".", serviceInfo); if (!_serviceStats.StartsWith("http", StringComparison.InvariantCultureIgnoreCase)) { _serviceStats = string.Concat("https://", _serviceStats); } attributeName = Constants.UserAttribute.AsperaAccountId; _accountId = AuthToken.GetClaimValue(authToken, attributeName); attributeName = Constants.UserAttribute.AsperaAccountKey; _accountKey = AuthToken.GetClaimValue(authToken, attributeName); string apiVersion = string.Empty; _serviceClient = new WebClient(_accountId, _accountKey, apiVersion); string settingKey = Constants.AppSettingKey.AsperaTransferInfo; string transferInfo = AppSetting.GetValue(settingKey); string transferApi = string.Concat(_serviceStats, transferInfo); HttpWebRequest webRequest = _serviceClient.GetRequest(transferApi, "GET", null); JObject transfer = _serviceClient.GetResponse <JObject>(webRequest); _iterationToken = transfer["info_result"]["iteration_token"].ToString(); }
public User(string authToken) { _authToken = authToken; string[] accountNames = AuthToken.GetClaimValues(_authToken, Constant.UserAttribute.MediaAccountName); string[] resourceGroupNames = AuthToken.GetClaimValues(_authToken, Constant.UserAttribute.MediaAccountResourceGroupName); string subscriptionId = AuthToken.GetClaimValue(_authToken, Constant.UserAttribute.MediaAccountSubscriptionId); string directoryTenantId = AuthToken.GetClaimValue(_authToken, Constant.UserAttribute.MediaAccountDirectoryTenantId); string[] servicePrincipalIds = AuthToken.GetClaimValues(_authToken, Constant.UserAttribute.MediaAccountServicePrincipalId); string[] servicePrincipalKeys = AuthToken.GetClaimValues(_authToken, Constant.UserAttribute.MediaAccountServicePrincipalKey); string[] videoIndexerIds = AuthToken.GetClaimValues(_authToken, Constant.UserAttribute.MediaAccountVideoIndexerId); string[] videoIndexerKeys = AuthToken.GetClaimValues(_authToken, Constant.UserAttribute.MediaAccountVideoIndexerKey); string[] videoIndexerRegions = AuthToken.GetClaimValues(_authToken, Constant.UserAttribute.MediaAccountVideoIndexerRegion); List <MediaAccount> mediaAccounts = new List <MediaAccount>(); for (int i = 0; i < accountNames.Length; i++) { MediaAccount mediaAccount = new MediaAccount() { Name = accountNames[i], ResourceGroupName = resourceGroupNames[i], SubscriptionId = subscriptionId, DirectoryTenantId = directoryTenantId, ServicePrincipalId = servicePrincipalIds[i], ServicePrincipalKey = servicePrincipalKeys[i], VideoIndexerId = videoIndexerIds == null || i >= videoIndexerIds.Length ? null : videoIndexerIds[i], VideoIndexerKey = videoIndexerKeys == null || i >= videoIndexerKeys.Length ? null : videoIndexerKeys[i], VideoIndexerRegion = videoIndexerRegions == null || i >= videoIndexerRegions.Length ? null : videoIndexerRegions[i], StorageAccounts = GetStorageAccounts(i) }; mediaAccounts.Add(mediaAccount); } _mediaAccounts = mediaAccounts.ToArray(); }
public CacheClient(string authToken) { _partitionId = AuthToken.GetClaimValue(authToken, Constants.UserAttribute.MediaAccountName); }
private string GetMediaAccountIndexerKey() { return(AuthToken.GetClaimValue(_authToken, Constant.UserAttribute.VideoIndexerKey)); }
private string GetMediaAccountClientKey() { return(AuthToken.GetClaimValue(_authToken, Constant.UserAttribute.MediaAccountClientKey)); }