/// <inheritdoc /> public void AcceptVisitor(ISearchValueVisitor visitor) { EnsureArg.IsNotNull(visitor, nameof(visitor)); visitor.Visit(this); }
public IFtpClientConnection Create(Uri uri, NetworkCredential credentials) { EnsureArg.IsNotNull(uri); EnsureArg.IsNotNull(credentials); return(new SystemNetFtpClientConnection(uri, credentials)); }
public PassportValidationController(IMapper mapper, PassportValidator validator) { this.mapper = EnsureArg.IsNotNull(mapper, nameof(mapper)); this.validator = EnsureArg.IsNotNull(validator, nameof(validator)); }
protected internal virtual async Task ExecuteResultAsync(HttpContext context, IActionResult result) { EnsureArg.IsNotNull(context, nameof(context)); EnsureArg.IsNotNull(result, nameof(result)); await result.ExecuteResultAsync(new ActionContext { HttpContext = context }); }
public override TOutput AcceptVisitor <TContext, TOutput>(IExpressionVisitor <TContext, TOutput> visitor, TContext context) { EnsureArg.IsNotNull(visitor, nameof(visitor)); return(visitor.VisitInclude(this, context)); }
/// <summary> /// Adds an in-process identity provider if enabled in configuration. /// </summary> /// <param name="services">The services collection.</param> /// <param name="configuration">The configuration root. The "DevelopmentIdentityProvider" section will be used to populate configuration values.</param> /// <returns>The same services collection.</returns> public static IServiceCollection AddDevelopmentIdentityProvider(this IServiceCollection services, IConfiguration configuration) { EnsureArg.IsNotNull(services, nameof(services)); EnsureArg.IsNotNull(configuration, nameof(configuration)); var authorizationConfiguration = new AuthorizationConfiguration(); configuration.GetSection("DicomServer:Security:Authorization").Bind(authorizationConfiguration); var developmentIdentityProviderConfiguration = new DevelopmentIdentityProviderConfiguration(); configuration.GetSection("DevelopmentIdentityProvider").Bind(developmentIdentityProviderConfiguration); services.AddSingleton(Options.Create(developmentIdentityProviderConfiguration)); if (developmentIdentityProviderConfiguration.Enabled) { services.AddIdentityServer() .AddDeveloperSigningCredential() .AddInMemoryApiScopes(new[] { new ApiScope(DevelopmentIdentityProviderConfiguration.Audience), new ApiScope(WrongAudienceClient), }) .AddInMemoryApiResources(new[] { new ApiResource( DevelopmentIdentityProviderConfiguration.Audience, userClaims: new[] { authorizationConfiguration.RolesClaim }) { Scopes = { DevelopmentIdentityProviderConfiguration.Audience }, }, new ApiResource( WrongAudienceClient, userClaims: new[] { authorizationConfiguration.RolesClaim }) { Scopes = { WrongAudienceClient }, }, }) .AddTestUsers(developmentIdentityProviderConfiguration.Users?.Select(user => new TestUser { Username = user.Id, Password = user.Id, IsActive = true, SubjectId = user.Id, Claims = user.Roles.Select(r => new Claim(authorizationConfiguration.RolesClaim, r)).ToList(), }).ToList()) .AddInMemoryClients( developmentIdentityProviderConfiguration.ClientApplications.Select( applicationConfiguration => new Client { ClientId = applicationConfiguration.Id, // client credentials and ROPC for testing AllowedGrantTypes = GrantTypes.ResourceOwnerPasswordAndClientCredentials, // secret for authentication ClientSecrets = { new Secret(applicationConfiguration.Id.Sha256()) }, // scopes that client has access to AllowedScopes = { DevelopmentIdentityProviderConfiguration.Audience, WrongAudienceClient }, // app roles that the client app may have Claims = applicationConfiguration.Roles.Select(r => new ClientClaim(authorizationConfiguration.RolesClaim, r)).Concat(new[] { new ClientClaim("appid", applicationConfiguration.Id), }).ToList(), ClientClaimsPrefix = string.Empty, })); } return(services); }
public TokenStringCompositeSearchParamsTableBulkCopyDataGenerator(ITableValuedParameterRowGenerator <IReadOnlyList <ResourceWrapper>, BulkTokenStringCompositeSearchParamTableTypeV1Row> searchParamGenerator) { EnsureArg.IsNotNull(searchParamGenerator, nameof(searchParamGenerator)); _searchParamGenerator = searchParamGenerator; }
public HomeController(ILogger <HomeController> logger) { Logger = EnsureArg.IsNotNull(logger); }
/// <summary> /// Initializes a new instance of the <see cref="NaosReadOnlyRepositoryControllerBase{TEntity, TRepo}"/> class. /// </summary> /// <param name="repository">The repository.</param> public NaosReadOnlyRepositoryControllerBase(TRepo repository) { EnsureArg.IsNotNull(repository, nameof(repository)); this.Repository = repository; }
/// <summary> /// Initializes a new instance of the <see cref="Manager"/> class. /// </summary> /// <param name="logger">The logger.</param> protected Manager(ILogger logger) { EnsureArg.IsNotNull(logger, nameof(logger)); Logger = logger; }
protected internal override void AcceptVisitor(IExpressionVisitor visitor) { EnsureArg.IsNotNull(visitor, nameof(visitor)); visitor.Visit(this); }
public Uri ResolveResourceWrapperUrl(ResourceWrapper resource, bool includeVersion = false) { EnsureArg.IsNotNull(resource, nameof(resource)); return(ResolveResourceUrl(resource.ResourceId, resource.ResourceTypeName, resource.Version, includeVersion)); }
public Uri ResolveResourceUrl(IResourceElement resource, bool includeVersion = false) { EnsureArg.IsNotNull(resource, nameof(resource)); return(ResolveResourceUrl(resource.Id, resource.InstanceType, resource.VersionId, includeVersion)); }
public ValidateCapabilityPreProcessor(IConformanceProvider conformanceProvider) { EnsureArg.IsNotNull(conformanceProvider, nameof(conformanceProvider)); _conformanceProvider = conformanceProvider; }
/// <inheritdoc /> public void Load(IServiceCollection services) { EnsureArg.IsNotNull(services, nameof(services)); var jsonParser = new FhirJsonParser(DefaultParserSettings.Settings); var jsonSerializer = new FhirJsonSerializer(); var xmlParser = new FhirXmlParser(); var xmlSerializer = new FhirXmlSerializer(); services.AddSingleton(jsonParser); services.AddSingleton(jsonSerializer); services.AddSingleton(xmlParser); services.AddSingleton(xmlSerializer); services.AddSingleton <BundleSerializer>(); FhirPathCompiler.DefaultSymbolTable.AddFhirExtensions(); ResourceElement SetMetadata(Resource resource, string versionId, DateTimeOffset lastModified) { resource.VersionId = versionId; resource.Meta.LastUpdated = lastModified; return(resource.ToResourceElement()); } services.AddSingleton <IReadOnlyDictionary <FhirResourceFormat, Func <string, string, DateTimeOffset, ResourceElement> > >(_ => { return(new Dictionary <FhirResourceFormat, Func <string, string, DateTimeOffset, ResourceElement> > { { FhirResourceFormat.Json, (str, version, lastModified) => { var resource = jsonParser.Parse <Resource>(str); return SetMetadata(resource, version, lastModified); } }, { FhirResourceFormat.Xml, (str, version, lastModified) => { var resource = xmlParser.Parse <Resource>(str); return SetMetadata(resource, version, lastModified); } }, }); }); services.Add <ResourceDeserializer>() .Singleton() .AsSelf() .AsService <IResourceDeserializer>(); services.Add <FormatterConfiguration>() .Singleton() .AsSelf() .AsService <IPostConfigureOptions <MvcOptions> >(); services.AddSingleton <IFormatParametersValidator, FormatParametersValidator>(); services.AddSingleton <OperationOutcomeExceptionFilterAttribute>(); services.AddSingleton <ValidateFormatParametersAttribute>(); services.AddSingleton <ValidateExportRequestFilterAttribute>(); services.AddSingleton <ValidateReindexRequestFilterAttribute>(); // Support for resolve() FhirPathCompiler.DefaultSymbolTable.AddFhirExtensions(); services.Add <FhirJsonInputFormatter>() .Singleton() .AsSelf() .AsService <TextInputFormatter>(); services.Add <FhirJsonOutputFormatter>() .Singleton() .AsSelf() .AsService <TextOutputFormatter>(); services.Add <FhirRequestContextAccessor>() .Singleton() .AsSelf() .AsService <RequestContextAccessor <IFhirRequestContext> >(); services.AddSingleton <CorrelationIdProvider>(_ => () => Guid.NewGuid().ToString()); // Add conformance provider for implementation metadata. services.Add <SystemConformanceProvider>() .Singleton() .AsSelf() .AsImplementedInterfaces(); services.TypesInSameAssembly(KnownAssemblies.All) .AssignableTo <IProvideCapability>() .Transient() .AsService <IProvideCapability>(); services.AddSingleton <IClaimsExtractor, PrincipalClaimsExtractor>(); ModelExtensions.SetModelInfoProvider(); services.Add(_ => ModelInfoProvider.Instance).Singleton().AsSelf().AsImplementedInterfaces(); // Register a factory to resolve a scope that returns all components that provide capabilities services.AddFactory <IScoped <IEnumerable <IProvideCapability> > >(); // Register pipeline behavior to intercept create/update requests and check presence of provenace header. services.Add <ProvenanceHeaderBehavior>().Scoped().AsSelf().AsImplementedInterfaces(); services.Add <ProvenanceHeaderState>().Scoped().AsSelf().AsImplementedInterfaces(); // Register pipeline behavior to check service permission for CUD actions on StructuredDefinition,ValueSet,CodeSystem, ConceptMap. services.Add <ProfileResourcesBehaviour>().Singleton().AsSelf().AsImplementedInterfaces(); services.AddLazy(); services.AddScoped(); }
public NearestLocationsFinderServiceV2(ILocationsKdTree locationsKdTree) { EnsureArg.IsNotNull(locationsKdTree, nameof(locationsKdTree)); _locationsKdTree = locationsKdTree; }
/// <summary> /// Initializes a new instance of the <see cref="EntityUpdateDomainEventHandler"/> class. /// </summary> /// <param name="logger">The logger.</param> public EntityUpdateDomainEventHandler(ILogger <EntityUpdateDomainEventHandler> logger) { EnsureArg.IsNotNull(logger, nameof(logger)); this.logger = logger; }
public ITypedElement ToTypedElement(ISourceNode sourceNode) { EnsureArg.IsNotNull(sourceNode); return(sourceNode.ToTypedElement(StructureDefinitionSummaryProvider)); }
public GetCapabilitiesResponse(CapabilityStatement capabilityStatement) { EnsureArg.IsNotNull(capabilityStatement, nameof(capabilityStatement)); CapabilityStatement = capabilityStatement; }
public StoreResponseBuilder(IUrlResolver urlResolver) { EnsureArg.IsNotNull(urlResolver, nameof(urlResolver)); _urlResolver = urlResolver; }
public GetExtendedQueryTagErrorsResponse(IReadOnlyCollection <ExtendedQueryTagError> extendedQueryTagErrors) { ExtendedQueryTagErrors = EnsureArg.IsNotNull(extendedQueryTagErrors); }
public SearchParameterToSearchValueTypeMap(SupportedSearchParameterDefinitionManagerResolver searchParameterDefinitionManagerResolver) { EnsureArg.IsNotNull(searchParameterDefinitionManagerResolver, nameof(searchParameterDefinitionManagerResolver)); _searchParameterDefinitionManager = searchParameterDefinitionManagerResolver(); }
public NarrativeValidator(INarrativeHtmlSanitizer narrativeHtmlSanitizer) { EnsureArg.IsNotNull(narrativeHtmlSanitizer, nameof(narrativeHtmlSanitizer)); _narrativeHtmlSanitizer = narrativeHtmlSanitizer; }
public SecurityModule(FhirServerConfiguration fhirServerConfiguration) { EnsureArg.IsNotNull(fhirServerConfiguration, nameof(fhirServerConfiguration)); _securityConfiguration = fhirServerConfiguration.Security; }
public IFtpClientConnection Create(string host, NetworkCredential credentials) { EnsureArg.IsNotEmpty(host); EnsureArg.IsNotNull(credentials); return(new SystemNetFtpClientConnection(host, credentials)); }
/// <inheritdoc /> public async Task ExecuteAsync(ReindexJobRecord reindexJobRecord, WeakETag weakETag, CancellationToken cancellationToken) { EnsureArg.IsNotNull(reindexJobRecord, nameof(reindexJobRecord)); EnsureArg.IsNotNull(weakETag, nameof(weakETag)); if (_reindexJobRecord != null) { throw new NotSupportedException($"{nameof(ReindexJobTask)} can work only on one {nameof(reindexJobRecord)}. Please create new {nameof(ReindexJobTask)} to process this instance of {nameof(reindexJobRecord)}"); } _reindexJobRecord = reindexJobRecord; _weakETag = weakETag; _jobSemaphore = new SemaphoreSlim(1, 1); _cancellationToken = cancellationToken; var originalRequestContext = _contextAccessor.RequestContext; try { // Add a request context so Datastore consumption can be added var fhirRequestContext = new FhirRequestContext( method: OperationsConstants.Reindex, uriString: "$reindex", baseUriString: "$reindex", correlationId: _reindexJobRecord.Id, requestHeaders: new Dictionary <string, StringValues>(), responseHeaders: new Dictionary <string, StringValues>()) { IsBackgroundTask = true, AuditEventType = OperationsConstants.Reindex, }; _contextAccessor.RequestContext = fhirRequestContext; if (reindexJobRecord.TargetDataStoreUsagePercentage != null && reindexJobRecord.TargetDataStoreUsagePercentage > 0) { using (IScoped <IFhirDataStore> store = _fhirDataStoreFactory.Invoke()) { var provisionedCapacity = await store.Value.GetProvisionedDataStoreCapacityAsync(_cancellationToken); _throttleController.Initialize(_reindexJobRecord, provisionedCapacity); } } else { _throttleController.Initialize(_reindexJobRecord, null); } // If we are resuming a job, we can detect that by checking the progress info from the job record. // If no queries have been added to the progress then this is a new job if (_reindexJobRecord.QueryList?.Count == 0) { if (!await TryPopulateNewJobFields()) { return; } } if (_reindexJobRecord.Status != OperationStatus.Running || _reindexJobRecord.StartTime == null) { // update job record to running _reindexJobRecord.Status = OperationStatus.Running; _reindexJobRecord.StartTime = Clock.UtcNow; await UpdateJobAsync(); } await ProcessJob(); await _jobSemaphore.WaitAsync(_cancellationToken); try { await CheckJobCompletionStatus(); } finally { _jobSemaphore.Release(); } } catch (JobConflictException) { // The reindex job was updated externally. _logger.LogInformation("The job was updated by another process."); } catch (OperationCanceledException) { _logger.LogInformation("The reindex job was canceled."); } catch (Exception ex) { await HandleException(ex); } finally { _jobSemaphore.Dispose(); _contextAccessor.RequestContext = originalRequestContext; } }
public TransactionBundleValidator(ResourceReferenceResolver referenceResolver) { EnsureArg.IsNotNull(referenceResolver, nameof(referenceResolver)); _referenceResolver = referenceResolver; }
public FhirModule(FhirServerConfiguration fhirServerConfiguration) { EnsureArg.IsNotNull(fhirServerConfiguration, nameof(fhirServerConfiguration)); _featureConfiguration = fhirServerConfiguration.Features; }
public ControlPlaneModule(FhirServerConfiguration fhirServerConfiguration) { EnsureArg.IsNotNull(fhirServerConfiguration, nameof(fhirServerConfiguration)); }
public DeleteHandler(IAuthorizationService <DataActions> authorizationService, IDeleteService deleteService) : base(authorizationService) { _deleteService = EnsureArg.IsNotNull(deleteService, nameof(deleteService)); }