public void MakeTheCurlRequestWithCipher(GpConnectInteraction interaction) { _httpContext.HttpRequestConfiguration = _httpSteps.GetRequestBody(interaction, _httpContext.HttpRequestConfiguration); _httpContext.HttpRequestConfiguration.RequestHeaders.ReplaceHeader(HttpConst.Headers.kAuthorization, _jwtHelper.GetBearerToken()); var headers = _httpContext.HttpRequestConfiguration.RequestHeaders; var url = _httpContext.HttpRequestConfiguration.EndpointAddress + '/' + _httpContext.HttpRequestConfiguration.RequestUrl; var cipher = _securityContext.Cipher; Curl.GlobalInit(CurlInitFlag.All); var curlHeaders = GetHeaders(headers); var curlEasy = GetCurlEasy(url, cipher, curlHeaders); MakeCurlRequest(curlEasy); }
public void MakeRequest(GpConnectInteraction interaction) { if (interaction.Equals(GpConnectInteraction.AppointmentCreate)) { TeardownSteps.AppointmentCreated(); } _httpContext.HttpRequestConfiguration = GetRequestBody(interaction, _httpContext.HttpRequestConfiguration); _httpContext.HttpRequestConfiguration.RequestHeaders.ReplaceHeader(HttpConst.Headers.kAuthorization, jwtHelper.GetBearerToken()); var httpRequest = new HttpContextRequest(_httpContext, _securityContext); httpRequest.MakeRequest(); }
public void SetTheJwtRequestedScopeTo(string requestedScope) { _jwtHelper.RequestedScope = requestedScope; _headerHelper.ReplaceHeader(HttpConst.Headers.kAuthorization, _jwtHelper.GetBearerToken()); }
public Resource GetResourceForRelativeUrl(GpConnectInteraction gpConnectInteraction, string relativeUrl) { var httpRequestConfiguration = new HttpRequestConfiguration(); var httpContextFactory = new HttpRequestConfigurationFactory(gpConnectInteraction, httpRequestConfiguration); httpContextFactory.GetHttpRequestConfiguration(); var jwtHelper = new JwtHelper(); var jwtFactory = new JwtFactory(gpConnectInteraction); jwtFactory.ConfigureJwt(jwtHelper); if (relativeUrl.Contains("Patient")) { var patient = relativeUrl.ToLower().Replace("/", string.Empty); try { jwtHelper.RequestedPatientNHSNumber = GlobalContext.PatientNhsNumberMap[patient]; } catch (Exception) { Patient patientResource = _fhirResourceRepository.Patient; var nhsNumber = patientResource.Identifier[0].Value; jwtHelper.RequestedPatientNHSNumber = nhsNumber; } } if (relativeUrl.Contains("Organization")) { var organizationId = relativeUrl.Split('/')[1]; jwtHelper.RequestedOrganizationId = organizationId; } httpRequestConfiguration.RequestUrl = relativeUrl; _securitySteps.ConfigureServerCertificatesAndSsl(); var requestFactory = new RequestFactory(gpConnectInteraction, _fhirResourceRepository); requestFactory.ConfigureBody(httpRequestConfiguration); httpRequestConfiguration.RequestHeaders.ReplaceHeader(HttpConst.Headers.kAuthorization, jwtHelper.GetBearerToken()); var httpRequest = new HttpResourceRequest(httpRequestConfiguration, _securityContext); return(httpRequest.MakeRequest().Resource); }