public void Build(ListedCapabilityStatement statement) { foreach (var resource in ModelInfo.SupportedResources) { var resourceType = ModelInfo.FhirTypeNameToResourceType(resource).GetValueOrDefault(); statement.TryAddRestInteraction(resourceType, CapabilityStatement.TypeRestfulInteraction.HistoryType); statement.TryAddRestInteraction(resourceType, CapabilityStatement.TypeRestfulInteraction.HistoryInstance); } var restComponent = statement .Rest .Single(); if (restComponent.Interaction == null) { restComponent.Interaction = new List <CapabilityStatement.SystemInteractionComponent>(); } restComponent.Interaction.Add(new CapabilityStatement.SystemInteractionComponent { Code = CapabilityStatement.SystemRestfulInteraction.HistorySystem, }); }
public void AddExportDetails(ListedCapabilityStatement capabilityStatement) { GetAndAddOperationDefinitionUriToCapabilityStatement(capabilityStatement, OperationsConstants.Export); GetAndAddOperationDefinitionUriToCapabilityStatement(capabilityStatement, OperationsConstants.PatientExport); GetAndAddOperationDefinitionUriToCapabilityStatement(capabilityStatement, OperationsConstants.GroupExport); }
protected override void AddResourceCapability(ListedCapabilityStatement statement, ResourceType resourceType) { statement.TryAddRestInteraction(resourceType, CapabilityStatement.TypeRestfulInteraction.Create); }
protected virtual void AddResourceCapability(ListedCapabilityStatement statement, ResourceType resourceType) { }
public void AddMemberMatchDetails(ListedCapabilityStatement capabilityStatement) { GetAndAddOperationDefinitionUriToCapabilityStatement(capabilityStatement, OperationsConstants.MemberMatch); }
public void AddReindexDetails(ListedCapabilityStatement capabilityStatement) { GetAndAddOperationDefinitionUriToCapabilityStatement(capabilityStatement, OperationsConstants.Reindex); GetAndAddOperationDefinitionUriToCapabilityStatement(capabilityStatement, OperationsConstants.ResourceReindex); }
public void AddAnonymizedExportDetails(ListedCapabilityStatement capabilityStatement) { GetAndAddOperationDefinitionUriToCapabilityStatement(capabilityStatement, OperationsConstants.AnonymizedExport); }
private static void AddOAuthSecurityService(ListedCapabilityStatement statement, string authority, IHttpClientFactory httpClientFactory, ILogger logger) { EnsureArg.IsNotNull(statement, nameof(statement)); EnsureArg.IsNotNull(authority, nameof(authority)); EnsureArg.IsNotNull(httpClientFactory, nameof(httpClientFactory)); ListedRestComponent restComponent = statement.Rest.Server(); SecurityComponent security = restComponent.Security ?? new SecurityComponent(); var codableConceptInfo = new Core.Models.CodableConceptInfo(); security.Service.Add(codableConceptInfo); codableConceptInfo.Coding.Add(Constants.RestfulSecurityServiceOAuth.ToCoding()); var openIdConfigurationUrl = $"{authority}/.well-known/openid-configuration"; HttpResponseMessage openIdConfigurationResponse; using (HttpClient httpClient = httpClientFactory.CreateClient()) { try { openIdConfigurationResponse = httpClient.GetAsync(new Uri(openIdConfigurationUrl)).GetAwaiter().GetResult(); } catch (Exception ex) { logger.LogWarning(ex, $"There was an exception while attempting to read the OpenId Configuration from \"{openIdConfigurationUrl}\"."); throw new OpenIdConfigurationException(); } } if (openIdConfigurationResponse.IsSuccessStatusCode) { JObject openIdConfiguration = JObject.Parse(openIdConfigurationResponse.Content.ReadAsStringAsync().GetAwaiter().GetResult()); string tokenEndpoint, authorizationEndpoint; try { tokenEndpoint = openIdConfiguration["token_endpoint"].Value <string>(); authorizationEndpoint = openIdConfiguration["authorization_endpoint"].Value <string>(); } catch (Exception ex) { logger.LogWarning(ex, $"There was an exception while attempting to read the endpoints from \"{openIdConfigurationUrl}\"."); throw new OpenIdConfigurationException(); } var smartExtension = new { url = Constants.SmartOAuthUriExtension, extension = new[] { new { url = Constants.SmartOAuthUriExtensionToken, valueUri = tokenEndpoint, }, new { url = Constants.SmartOAuthUriExtensionAuthorize, valueUri = authorizationEndpoint, }, }, }; security.Extension.Add(JObject.FromObject(smartExtension)); } else { logger.LogWarning($"The OpenId Configuration request from \"{openIdConfigurationUrl}\" returned an {openIdConfigurationResponse.StatusCode} status code."); throw new OpenIdConfigurationException(); } restComponent.Security = security; }
public void AddConvertDataDetails(ListedCapabilityStatement capabilityStatement) { GetAndAddOperationDefinitionUriToCapabilityStatement(capabilityStatement, OperationsConstants.ConvertData); }
private void AddOAuthSecurityService(ListedCapabilityStatement statement) { ListedRestComponent restComponent = statement.Rest.Server(); SecurityComponent security = restComponent.Security ?? new SecurityComponent(); var codableConceptInfo = new CodableConceptInfo(); security.Service.Add(codableConceptInfo); codableConceptInfo.Coding.Add(_modelInfoProvider.Version == FhirSpecification.Stu3 ? Constants.RestfulSecurityServiceStu3OAuth : Constants.RestfulSecurityServiceOAuth); var openIdConfigurationUrl = $"{_securityConfiguration.Authentication.Authority}/.well-known/openid-configuration"; HttpResponseMessage openIdConfigurationResponse; using (HttpClient httpClient = _httpClientFactory.CreateClient()) { try { openIdConfigurationResponse = httpClient.GetAsync(new Uri(openIdConfigurationUrl)).GetAwaiter().GetResult(); } catch (Exception ex) { _logger.LogWarning(ex, "There was an exception while attempting to read the OpenId Configuration from \"{openIdConfigurationUrl}\".", openIdConfigurationUrl); throw new OpenIdConfigurationException(); } } if (openIdConfigurationResponse.IsSuccessStatusCode) { JObject openIdConfiguration = JObject.Parse(openIdConfigurationResponse.Content.ReadAsStringAsync().GetAwaiter().GetResult()); string tokenEndpoint, authorizationEndpoint; try { tokenEndpoint = openIdConfiguration["token_endpoint"].Value <string>(); authorizationEndpoint = openIdConfiguration["authorization_endpoint"].Value <string>(); } catch (Exception ex) { _logger.LogWarning(ex, "There was an exception while attempting to read the endpoints from \"{openIdConfigurationUrl}\".", openIdConfigurationUrl); throw new OpenIdConfigurationException(); } var smartExtension = new { url = Constants.SmartOAuthUriExtension, extension = new[] { new { url = Constants.SmartOAuthUriExtensionToken, valueUri = tokenEndpoint, }, new { url = Constants.SmartOAuthUriExtensionAuthorize, valueUri = authorizationEndpoint, }, }, }; security.Extension.Add(JObject.FromObject(smartExtension)); } else { _logger.LogWarning("The OpenId Configuration request from \"{openIdConfigurationUrl}\" returned an {statusCode} status code.", openIdConfigurationUrl, openIdConfigurationResponse.StatusCode); throw new OpenIdConfigurationException(); } restComponent.Security = security; }