private static Services.TpmContext GetCloudTpmContext(IntegrationServiceDetails integrationServiceDetails)
        {
            var partnerManagementDataServiceUrl =
                new Uri(new Uri(integrationServiceDetails.DeploymentURL), PartnerManagementDataServicePath);

            Services.TpmContext context = new Services.TpmContext(partnerManagementDataServiceUrl);
            context.SaveChangesDefaultOptions = SaveChangesOptions.Batch;
            context.SendingRequest           += (sender, args) => OnSendingRequest(args, AcsHelper.GetAcsToken(integrationServiceDetails));
            return(context);
        }
        public override void Initialize(IApplicationContext applicationContext)
        {
            base.Initialize(applicationContext);
            statusBarViewModel = this.ApplicationContext.GetService <StatusBarViewModel>();

            var cachedintegrationAccountDetails = this.ApplicationContext.GetService <IntegrationAccountDetails>();
            var cachedintegrationServiceDetails = this.ApplicationContext.GetService <IntegrationServiceDetails>();

            AzureLoginButtonClickCommand = new RelayCommand(o => AzureLoginButtonClick("AzureLoginButton"));

            if (cachedintegrationAccountDetails != null)
            {
                UserSubscriptions       = this.ApplicationContext.GetProperty("Subscriptions") as ObservableCollection <Subscription.RootObject>;
                UserResourceGroups      = this.ApplicationContext.GetProperty("ResourceGroups") as ObservableCollection <ResourceGroup.RootObject>;
                UserIntegrationAccounts = this.ApplicationContext.GetProperty("IntegrationAccounts") as ObservableCollection <IntegrationAccount.RootObject>;
                UserKeyVaults           = this.ApplicationContext.GetProperty("KeyVaults") as ObservableCollection <KeyVault.RootObject>;

                SelectedSubscription       = UserSubscriptions.Where(x => x.SubscriptionId == cachedintegrationAccountDetails.SubscriptionId).First();
                SelectedResourceGroup      = UserResourceGroups.Where(x => x.Name == cachedintegrationAccountDetails.ResourceGroupName).First();
                SelectedIntegrationAccount = UserIntegrationAccounts.Where(x => x.Name == cachedintegrationAccountDetails.IntegrationAccountName).First();
                if (!string.IsNullOrEmpty(cachedintegrationAccountDetails.KeyVaultName))
                {
                    SelectedKeyVault = UserKeyVaults.Where(x => x.Name == cachedintegrationAccountDetails.KeyVaultName).First();
                }
                IsLoginButttonEnabled = false;
                SubscriptionVisible   = true;
            }
            else
            {
                UserSubscriptions       = new ObservableCollection <Subscription.RootObject>();
                UserResourceGroups      = new ObservableCollection <ResourceGroup.RootObject>();
                UserIntegrationAccounts = new ObservableCollection <IntegrationAccount.RootObject>();
                UserKeyVaults           = new ObservableCollection <KeyVault.RootObject>();

                IsLoginButttonEnabled     = true;
                SubscriptionVisible       = false;
                ResourceGroupVisible      = false;
                IntegrationAccountVisible = false;
                KeyVaultVisible           = false;
            }
            if (cachedintegrationServiceDetails != null)
            {
                this.integrationServiceDetails = cachedintegrationServiceDetails;
            }
            else
            {
                this.integrationServiceDetails = new IntegrationServiceDetails();
                this.ApplicationContext.AddService(this.integrationServiceDetails);
            }
        }
Example #3
0
        public static string GetAcsToken(IntegrationServiceDetails integrationServiceDetails)
        {
            var        address = integrationServiceDetails.DeploymentURL;
            UriBuilder integrationDeploymentBaseUrl = new UriBuilder(address);

            integrationDeploymentBaseUrl.Scheme = "http";

            if (integrationDeploymentBaseUrl.Port == 443)
            {
                integrationDeploymentBaseUrl.Port = -1;
            }

            var partnerManagementDataServiceUrl = new Uri(integrationDeploymentBaseUrl.Uri, PartnerManagementDataServicePath);
            var token = AcsHelper.GetAcsToken(integrationServiceDetails.AcsNamespace, integrationServiceDetails.IssuerName, integrationServiceDetails.IssuerKey, partnerManagementDataServiceUrl.ToString());

            return(token);
        }