public override BrowserExtensionResponse Handle(BrowserExtensionRequest request)
        {
            var chooseCertificate    = request.Content.ToObject <ChooseIdentityCertificateRequest>();
            var certificateStorePath = _configuration[Constants.ConfigurationNames.CertificateStorePath];
            var path = Path.Combine(certificateStorePath, chooseCertificate.Certificate);

            if (!File.Exists(path))
            {
                return(BuildError(request, "identity certificate doesn't exist"));
            }

            try
            {
                var col = new X509Certificate2Collection();
                col.Import(path, chooseCertificate.Password, X509KeyStorageFlags.Exportable);
            }
            catch
            {
                return(BuildError(request, "password is invalid"));
            }

            UpdateAppSettings(Constants.ConfigurationNames.IdentityCertificateStore, chooseCertificate.Certificate);
            UpdateAppSettings(Constants.ConfigurationNames.IdentityCertificateStorePassword, chooseCertificate.Password);
            return(NoContent(request));
        }
        public override BrowserExtensionResponse Handle(BrowserExtensionRequest request)
        {
            var certificateStorePath = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "Certificates");
            var regexTest            = new Func <string, bool>(i => i.StartsWith("SSIN=", StringComparison.InvariantCultureIgnoreCase));
            var files = Directory.GetFiles(certificateStorePath).Select(_ => Path.GetFileName(_)).Where(regexTest).ToList();

            return(BuildResponse(request, new IdentityCertificatesResponse(_configuration[Constants.ConfigurationNames.IdentityCertificateStore], files)));
        }
Ejemplo n.º 3
0
        protected BrowserExtensionResponse BuildError(BrowserExtensionRequest request, string message)
        {
            var result = new BrowserExtensionResponseGeneric <ErrorResponse>(request.Nonce, "error", new ErrorResponse {
                Message = message
            });

            return(result);
        }
Ejemplo n.º 4
0
        public override BrowserExtensionResponse Handle(BrowserExtensionRequest request)
        {
            var chooseMedicalProfessionRequest = request.Content.ToObject <ChooseMedicalProfessionRequest>();
            var medicalProfessions             = Enumeration.GetAll <MedicalProfessions>();

            if (!medicalProfessions.Any(_ => _.Code == chooseMedicalProfessionRequest.Profession))
            {
                return(BuildError(request, "medical profession doesn't exist"));
            }

            UpdateAppSettings(Constants.ConfigurationNames.Profession, chooseMedicalProfessionRequest.Profession);
            return(NoContent(request));
        }
        public override BrowserExtensionResponse Handle(BrowserExtensionRequest request)
        {
            var professions = Enumeration.GetAll <MedicalProfessions>();

            return(BuildResponse(request, new GetMedicalProfessionsResponse
            {
                CurrentProfession = _configuration[Constants.ConfigurationNames.Profession],
                Professions = professions.Select(_ => new MedicalProfessionResponse
                {
                    Code = _.Value,
                    DisplayName = _.Description,
                    Namespace = _.Code
                }).ToList()
            }));
        }
        public override BrowserExtensionResponse Handle(BrowserExtensionRequest request)
        {
            var sessionService = (ISessionService)_serviceProvider.GetService(typeof(ISessionService));
            SOAPEnvelope <SAMLResponseBody> soapEnv = null;

            try
            {
                soapEnv = sessionService.BuildFallbackSession().Result;
            }
            catch (Exception ex)
            {
                return(BuildError(request, ex.ToString()));
            }

            var assertion = soapEnv.Body.Response.Assertion;

            return(BuildResponse(request, new SAMLAssertionTokenResponse(assertion.Serialize().ToString(), assertion.Conditions.NotBefore, assertion.Conditions.NotOnOrAfter)));
        }
Ejemplo n.º 7
0
        public override BrowserExtensionResponse Handle(BrowserExtensionRequest request)
        {
            var getCertificate       = request.Content.ToObject <GetIdentityCertificateRequest>();
            var certificateStorePath = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "Certificates");
            var path = Path.Combine(certificateStorePath, getCertificate.Certificate);

            if (!File.Exists(path))
            {
                return(BuildError(request, "identity certificate doesn't exist"));
            }

            try
            {
                var col = new X509Certificate2Collection();
                col.Import(path, getCertificate.Password, X509KeyStorageFlags.Exportable);
            }
            catch
            {
                return(BuildError(request, "password is invalid"));
            }

            string location;
            var    apiUrl = _configuration["ApiUrl"];

            using (var httpClient = new HttpClient())
            {
                var httpRequest = new HttpRequestMessage
                {
                    Method     = HttpMethod.Post,
                    RequestUri = new Uri($"{apiUrl}/files/transfer"),
                    Content    = new StringContent(JsonConvert.SerializeObject(new { file = Convert.ToBase64String(File.ReadAllBytes(path)) }), Encoding.UTF8, "application/json")
                };
                var httpResponse = httpClient.SendAsync(httpRequest).Result;
                var json         = httpResponse.Content.ReadAsStringAsync().Result.ToString();
                location = JsonConvert.DeserializeObject <JObject>(json)["location"].ToString();
            }

            return(BuildResponse(request, new GetIdentityCertificateResponse(location, getCertificate.Password, getCertificate.Certificate)));
        }
Ejemplo n.º 8
0
 public override BrowserExtensionResponse Handle(BrowserExtensionRequest request)
 {
     return(BuildResponse(request, new PongResponse(DateTime.UtcNow)));
 }
Ejemplo n.º 9
0
        protected BrowserExtensionResponse NoContent(BrowserExtensionRequest request)
        {
            var result = new BrowserExtensionResponse(request.Nonce, Response);

            return(result);
        }
Ejemplo n.º 10
0
        protected BrowserExtensionResponse BuildResponse <T>(BrowserExtensionRequest request, T content)
        {
            var result = new BrowserExtensionResponseGeneric <T>(request.Nonce, Response, content);

            return(result);
        }
Ejemplo n.º 11
0
 public abstract BrowserExtensionResponse Handle(BrowserExtensionRequest request);