Пример #1
0
        private static CloudStorageAccount GetAccount(string authToken, string accountName, out string accountKey)
        {
            accountKey = string.Empty;
            string storageAccount = string.Empty;

            string[] accountNames = AuthToken.GetClaimValues(authToken, Constants.UserAttribute.StorageAccountName);
            string[] accountKeys  = AuthToken.GetClaimValues(authToken, Constants.UserAttribute.StorageAccountKey);
            int      accountIndex = GetAccountIndex(accountNames, accountName);

            accountKey     = accountKeys[accountIndex];
            storageAccount = string.Format(Constants.Storage.Account.Connection, accountName, accountKeys[accountIndex]);
            return(string.IsNullOrEmpty(storageAccount) ? null : CloudStorageAccount.Parse(storageAccount));
        }
Пример #2
0
        private void AddStorageAccount(Dictionary <string, string> storageAccounts, string nameClaimType, string keyClaimType, int i)
        {
            string[] claimValues = AuthToken.GetClaimValues(_authToken, nameClaimType);
            if (claimValues != null)
            {
                string storageAccountName = claimValues[i];
                string storageAccountKey  = string.Empty;

                claimValues = AuthToken.GetClaimValues(_authToken, keyClaimType);
                if (claimValues != null)
                {
                    storageAccountKey = claimValues[i];
                }

                storageAccounts.Add(storageAccountName, storageAccountKey);
            }
        }
Пример #3
0
        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();
        }