/// <summary> /// Retrieves the tenant with the specified Id and ensures it is of the correct type. /// </summary> /// <param name="tenantStore">The tenant store.</param> /// <param name="tenantId">The Id of the tenant to retrieve.</param> /// <param name="allowableTenantTypes">The list of valid types for the tenant.</param> /// <returns>The client tenant.</returns> /// <exception cref="TenantNotFoundException">There is no tenant with the specified Id.</exception> /// <exception cref="InvalidMarainTenantTypeException">The tenant Id provided is not for a tenant with the specified type.</exception> public static async Task <ITenant> GetTenantOfTypeAsync(this ITenantStore tenantStore, string tenantId, params MarainTenantType[] allowableTenantTypes) { ITenant tenant = await tenantStore.GetTenantAsync(tenantId).ConfigureAwait(false); tenant.EnsureTenantIsOfType(allowableTenantTypes); return(tenant); }
public TenantResolver(IEnumerable <ITenantStrategy> strategies, ITenantStore store, ICacheService cache, ILogger logger) { _store = store.NotNull(); _strategies = strategies.NotNull().OrderByDescending(s => s.Priority); _cache = cache.NotNull(); _logger = logger.NotNull(); }
/// <summary> /// Constructs a new instance of <see cref="TenantManager{TTenant}"/>. /// </summary> /// <param name="store">The persistence store the manager will operate over.</param> /// <param name="optionsAccessor">The accessor used to access the <see cref="TenancyOptions"/>.</param> /// <param name="tenantValidators">A collection of <see cref="ITenantValidator{TTenant}"/> to validate tenants against.</param> /// <param name="keyNormalizer">The <see cref="ILookupNormalizer"/> to use when generating index keys for tenants.</param> /// <param name="errors">The <see cref="TenancyErrorDescriber"/> used to provider error messages.</param> /// <param name="services">The <see cref="IServiceProvider"/> used to resolve services.</param> /// <param name="logger">The logger used to log messages, warnings and errors.</param> public TenantManager(ITenantStore <TTenant> store, IOptions <TenancyOptions> optionsAccessor, IEnumerable <ITenantValidator <TTenant> > tenantValidators, ILookupNormalizer keyNormalizer, TenancyErrorDescriber errors, IServiceProvider services, ILogger <TenantManager <TTenant> > logger) { ArgCheck.NotNull(nameof(store), store); Store = store; Options = optionsAccessor?.Value ?? new TenancyOptions(); KeyNormalizer = keyNormalizer; ErrorDescriber = errors; Logger = logger; if (tenantValidators != null) { foreach (var v in tenantValidators) { TenantValidators.Add(v); } } _services = services; }
public TenantAccessService( ITenantResolutionResolver tenantResolutionResolver, ITenantStore <T> tenantStore) { _tenantResolutionResolver = tenantResolutionResolver; _tenantStore = tenantStore; }
/// <summary> /// Creates a new instance of the <see cref="AddOrUpdateStorageConfigurationCommand"/> class. /// </summary> /// <param name="tenantStore">The tenant store.</param> /// <param name="serializerSettingsProvider"> /// The <see cref="IJsonSerializerSettingsProvider"/> to use when reading manifest files. /// </param> public AddOrUpdateStorageConfigurationCommand( ITenantStore tenantStore, IJsonSerializerSettingsProvider serializerSettingsProvider) : base("add-storage-config", "Adds arbitrary storage configuration for the client.") { this.tenantStore = tenantStore; this.serializerSettingsProvider = serializerSettingsProvider; var tenantId = new Argument <string>("tenantId") { Description = "The Id of the tenant.", Arity = ArgumentArity.ExactlyOne, }; this.AddArgument(tenantId); var configFile = new Argument <FileInfo>("configFile") { Description = "JSON configuration file path.", Arity = ArgumentArity.ExactlyOne, }; this.AddArgument(configFile); this.Handler = CommandHandler.Create( (string tenantId, FileInfo configFile) => this.HandleCommand(tenantId, configFile)); }
public DomainTenantResolveContributor( IWebMultiTenancyConfiguration multiTenancyConfiguration, ITenantStore tenantStore) { _multiTenancyConfiguration = multiTenancyConfiguration; _tenantStore = tenantStore; }
public MultiTenantController( ITenantResolutionResolver tenantResolutionResolver, ITenantStore <Tenant> tenantStore) { _tenantResolutionResolver = tenantResolutionResolver; _tenantStore = tenantStore; }
public void TestLoggingInterception() { ITenantStore tenantStore = Container.Resolve <ITenantStore>(); DateTime serverTime = tenantStore.GetTime("a"); Assert.AreNotEqual(DateTime.MinValue, serverTime); }
/// <summary> /// Enrolls the specified tenant in the service. /// </summary> /// <param name="tenantStore">The <see cref="ITenantStore"/>.</param> /// <param name="enrollingTenantId">The Id of the tenant to enroll.</param> /// <param name="serviceTenantId">The Id of the service to enroll in.</param> /// <param name="configurationItems">Configuration for the enrollment.</param> /// <returns>A task which completes when the enrollment has finished.</returns> public static async Task EnrollInServiceAsync( this ITenantStore tenantStore, string enrollingTenantId, string serviceTenantId, EnrollmentConfigurationItem[] configurationItems) { if (string.IsNullOrWhiteSpace(enrollingTenantId)) { throw new ArgumentException(nameof(enrollingTenantId)); } if (string.IsNullOrWhiteSpace(serviceTenantId)) { throw new ArgumentException(nameof(serviceTenantId)); } if (configurationItems == null) { throw new ArgumentNullException(nameof(configurationItems)); } // Enrolling tenant can be either a Client tenant or a Delegated tenant. ITenant enrollingTenant = await tenantStore.GetTenantOfTypeAsync( enrollingTenantId, MarainTenantType.Client, MarainTenantType.Delegated).ConfigureAwait(false); ITenant serviceTenant = await tenantStore.GetServiceTenantAsync(serviceTenantId).ConfigureAwait(false); await tenantStore.EnrollInServiceAsync(enrollingTenant, serviceTenant, configurationItems).ConfigureAwait(false); }
public async Task ThenTheTenancyProviderContainsTenantsAsChildrenOfTheRootTenant(int expectedTenantCount) { ITenantStore tenantStore = ContainerBindings.GetServiceProvider(this.scenarioContext).GetRequiredService <ITenantStore>(); TenantCollectionResult rootTenantChildren = await tenantStore.GetChildrenAsync(tenantStore.Root.Id).ConfigureAwait(false); Assert.AreEqual(expectedTenantCount, rootTenantChildren.Tenants.Count); }
public async Task GivenIHaveUsedTheTenantStoreToCreateANewClientTenantCalled(string clientName) { ITenantStore service = ContainerBindings.GetServiceProvider(this.scenarioContext).GetRequiredService <ITenantStore>(); ITenant newTenant = await service.CreateClientTenantAsync(clientName).ConfigureAwait(false); this.scenarioContext.Set(newTenant.Id, clientName); }
/// <summary> /// Constructs the handler. /// </summary> /// <param name="tenantStore"></param> /// <param name="tenantAccessor"></param> /// <param name="cache"></param> /// <param name="logger"></param> public BeTenantMemberHandler(ITenantStore <TTenant> tenantStore, ITenantAccessor <TTenant> tenantAccessor, IDistributedCache cache, ILogger <BeTenantMemberHandler <TTenant> > logger) { _tenantStore = tenantStore ?? throw new ArgumentNullException(nameof(tenantStore)); _tenantAccessor = tenantAccessor ?? throw new ArgumentNullException(nameof(tenantAccessor)); _cache = cache ?? throw new ArgumentNullException(nameof(cache)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public TransferSurveysToSqlAzureCommand(ISurveyAnswerStore surveyAnswerStore, ISurveyStore surveyStore, ITenantStore tenantStore, ISurveySqlStore surveySqlStore) { this.surveyAnswerStore = surveyAnswerStore; this.surveyStore = surveyStore; this.tenantStore = tenantStore; this.surveySqlStore = surveySqlStore; }
public async Task InvokeAsync(HttpContext httpContext, ITenantStore tenantStore) { async Task <TenantInfo> FindTenantAsync(string tenantIdOrName) { return(await tenantStore.FindAsync(tenantIdOrName)); } var resolveResult = _tenantResolver.ResolveTenantIdOrName(); _tenantResolveResultAccessor.Result = resolveResult; TenantInfo tenant = null; if (resolveResult.TenantIdOrName != null) { tenant = await FindTenantAsync(resolveResult.TenantIdOrName); if (tenant == null) { //TODO: A better exception? throw new LinFxException("There is no tenant with given tenant id or name: " + resolveResult.TenantIdOrName); } } using (_currentTenant.Change(tenant?.Id, tenant?.Name)) { await _next(httpContext); } }
private async Task EnrollTenantForService( string enrollingTenantName, string serviceTenantName, string?enrollmentConfigurationName = null) { ITenantStore managementService = ContainerBindings.GetServiceProvider(this.scenarioContext).GetRequiredService <ITenantStore>(); ITenantProvider tenantProvider = ContainerBindings.GetServiceProvider(this.scenarioContext).GetRequiredService <ITenantProvider>(); ITenant enrollingTenant = await tenantProvider.GetTenantAsync(this.scenarioContext.Get <string>(enrollingTenantName)).ConfigureAwait(false); ITenant serviceTenant = await tenantProvider.GetTenantAsync(this.scenarioContext.Get <string>(serviceTenantName)).ConfigureAwait(false); List <EnrollmentConfigurationItem> enrollmentConfiguration = string.IsNullOrEmpty(enrollmentConfigurationName) ? new List <EnrollmentConfigurationItem>() : this.scenarioContext.Get <List <EnrollmentConfigurationItem> >(enrollmentConfigurationName); await CatchException.AndStoreInScenarioContextAsync( this.scenarioContext, () => managementService.EnrollInServiceAsync( enrollingTenant, serviceTenant, enrollmentConfiguration.ToArray())).ConfigureAwait(false); }
private Func <ValueTask <ITenant> > GetTenante(ITenantStore store, string identfier, CancellationToken cancellationToken) { return(async() => { return await store.GetByIdentifier(identfier, cancellationToken).ConfigureAwait(false); }); }
/// <summary> /// Creates a new instance of the <see cref="EnrollCommand"/> class. /// </summary> /// <param name="tenantStore">The tenant store.</param> /// <param name="serializerSettingsProvider"> /// The <see cref="IJsonSerializerSettingsProvider"/> to use when reading manifest files. /// </param> public EnrollCommand( ITenantStore tenantStore, IJsonSerializerSettingsProvider serializerSettingsProvider) : base("enroll", "Enrolls the specified client for the service.") { this.tenantStore = tenantStore; this.serializerSettingsProvider = serializerSettingsProvider; var clientTenantId = new Argument <string>("clientTenantId") { Description = "The Id of the client tenant.", Arity = ArgumentArity.ExactlyOne, }; this.AddArgument(clientTenantId); var serviceName = new Argument <string>("serviceTenantId") { Description = "The Id of the service tenant.", Arity = ArgumentArity.ExactlyOne, }; this.AddArgument(serviceName); var configFile = new Option <FileInfo>("--config") { Description = "JSON configuration file to use when enrolling.", }; this.AddOption(configFile); this.Handler = CommandHandler.Create( (string clientTenantId, string serviceTenantId, FileInfo? config) => this.HandleCommand(clientTenantId, serviceTenantId, config)); }
public TenantStoreBasedIssuerNameRegistry() { using (var container = new UnityContainer()) { ContainerBootstraper.RegisterTypes(container); this.tenantStore = container.Resolve<ITenantStore>(); } }
public TenantSwitchModalModel( ITenantStore tenantStore, IOptions <AbpAspNetCoreMultiTenancyOptions> options) { TenantStore = tenantStore; Options = options.Value; LocalizationResourceType = typeof(AbpUiMultiTenancyResource); }
public Task WhenIUseTheTenantStoreToInitialiseTheTenancyProviderUsingTheForceOption() { ITenantStore service = ContainerBindings.GetServiceProvider(this.scenarioContext).GetRequiredService <ITenantStore>(); return(CatchException.AndStoreInScenarioContextAsync( this.scenarioContext, () => service.InitialiseTenancyProviderAsync(true))); }
public TenantStoreBasedIssuerNameRegistry() { using (var container = new UnityContainer()) { ContainerBootstraper.RegisterTypes(container); this.tenantStore = container.Resolve <ITenantStore>(); } }
public TenantSwitchViewComponent( ITenantStore tenantStore, ICurrentTenant currentTenant, ICurrentUser currentUser) { TenantStore = tenantStore; CurrentTenant = currentTenant; CurrentUser = currentUser; }
public FederationSecurityTokenService(SecurityTokenServiceConfiguration configuration) : base(configuration) { using (var container = new UnityContainer()) { ContainerBootstraper.RegisterTypes(container); this.tenantStore = container.Resolve <ITenantStore>(); } }
public SurveysController( ISurveyStore surveyStore, ISurveyAnswerStore surveyAnswerStore, ITenantStore tenantStore) { this.surveyStore = surveyStore; this.surveyAnswerStore = surveyAnswerStore; this.tenantStore = tenantStore; }
public MultiTenancyMiddleware( ITenantResolver tenantResolver, ITenantStore tenantStore, ICurrentTenant currentTenant) { this.tenantResolver = tenantResolver; this.tenantStore = tenantStore; this.currentTenant = currentTenant; }
public TenantConfigurationProvider( ITenantResolver tenantResolver, ITenantStore tenantStore, ITenantResolveResultAccessor tenantResolveResultAccessor) { TenantResolver = tenantResolver; TenantStore = tenantStore; TenantResolveResultAccessor = tenantResolveResultAccessor; }
public FederationSecurityTokenService(SecurityTokenServiceConfiguration configuration) : base(configuration) { using (var container = new UnityContainer()) { ContainerBootstraper.RegisterTypes(container); this.tenantStore = container.Resolve<ITenantStore>(); } }
public AppUrlProvider( IOptions <AppUrlOptions> options, ICurrentTenant currentTenant, ITenantStore tenantStore) { CurrentTenant = currentTenant; TenantStore = tenantStore; Options = options.Value; }
public Task WhenIValidateTheServiceManifestCalled(string manifestName) { ITenantStore store = ContainerBindings.GetServiceProvider(this.scenarioContext).GetRequiredService <ITenantStore>(); ServiceManifest manifest = this.scenarioContext.Get <ServiceManifest>(manifestName); return(CatchException.AndStoreInScenarioContextAsync( this.scenarioContext, () => manifest.ValidateAndThrowAsync(store))); }
public async Task GivenTheTenancyProviderContainsTenantsAsChildrenOfTheRootTenant(int tenantCount) { ITenantStore tenantStore = ContainerBindings.GetServiceProvider(this.scenarioContext).GetRequiredService <ITenantStore>(); for (int i = 0; i < tenantCount; i++) { await tenantStore.CreateChildTenantAsync(tenantStore.Root.Id, Guid.NewGuid().ToString()).ConfigureAwait(false); } }
public DomainTenantResolveContributor( IHttpContextAccessor httpContextAccessor, IWebMultiTenancyConfiguration multiTenancyConfiguration, ITenantStore tenantStore) { _httpContextAccessor = httpContextAccessor; _multiTenancyConfiguration = multiTenancyConfiguration; _tenantStore = tenantStore; }
public AccountController(ITenantStore tenantStore, IUDFDictionary udfDictionary) : base(tenantStore) { this.udfDictionary = udfDictionary; this.extendableTypes = new Dictionary <string, Type>() { { "SurveyRow", typeof(SurveyRow) } }; }
public SurveyAnswerStore( ITenantStore tenantStore, ISurveyAnswerContainerFactory surveyAnswerContainerFactory, IAzureQueue<SurveyAnswerStoredMessage> standardSurveyAnswerStoredQueue, IAzureQueue<SurveyAnswerStoredMessage> premiumSurveyAnswerStoredQueue, IAzureBlobContainer<List<string>> surveyAnswerIdsListContainer) { this.tenantStore = tenantStore; this.surveyAnswerContainerFactory = surveyAnswerContainerFactory; this.standardSurveyAnswerStoredQueue = standardSurveyAnswerStoredQueue; this.premiumSurveyAnswerStoredQueue = premiumSurveyAnswerStoredQueue; this.surveyAnswerIdsListContainer = surveyAnswerIdsListContainer; }
public SurveyAnswerStore( ITenantStore tenantStore, ISurveyAnswerContainerFactory surveyAnswerContainerFactory, IMessageQueue<SurveyAnswerStoredMessage> standardSurveyAnswerStoredQueue, IMessageQueue<SurveyAnswerStoredMessage> premiumSurveyAnswerStoredQueue, IBlobContainer<List<string>> surveyAnswerIdsListContainer) { Trace.WriteLine(string.Format("Called constructor in SurveyAnswerStore"), "UNITY"); this.tenantStore = tenantStore; this.surveyAnswerContainerFactory = surveyAnswerContainerFactory; this.standardSurveyAnswerStoredQueue = standardSurveyAnswerStoredQueue; this.premiumSurveyAnswerStoredQueue = premiumSurveyAnswerStoredQueue; this.surveyAnswerIdsListContainer = surveyAnswerIdsListContainer; }
public SurveysController( ISurveyStore surveyStore, ISurveyAnswerStore surveyAnswerStore, ISurveyAnswersSummaryStore surveyAnswersSummaryStore, ITenantStore tenantStore, ISurveyTransferStore surveyTransferStore, IUDFDictionary udfDictionary) : base(tenantStore) { this.surveyStore = surveyStore; this.surveyAnswerStore = surveyAnswerStore; this.surveyAnswersSummaryStore = surveyAnswersSummaryStore; this.surveyTransferStore = surveyTransferStore; this.udfDictionary = udfDictionary; }
public AccountController(ITenantStore tenantStore, IUDFDictionary udfDictionary) : base(tenantStore) { this.udfDictionary = udfDictionary; this.extendableTypes = new Dictionary<string, Type>() { { "SurveyRow", typeof(SurveyRow) } }; }
public IssuerController(ITenantStore tenantStore) { this.tenantStore = tenantStore; }
public ManagementController(ITenantStore tenantStore) { this.tenantStore = tenantStore; }
private static void SetLogo(string tenant, ITenantStore tenantStore, Bitmap logo) { if (string.IsNullOrWhiteSpace(tenantStore.GetTenant(tenant).Logo)) { using (var stream = new MemoryStream()) { logo.Save(stream, ImageFormat.Png); tenantStore.UploadLogo(tenant, stream.ToArray()); } } }
public OnBoardingController(ITenantStore tenantStore) { this.tenantStore = tenantStore; }