Exemple #1
0
        public string BDeCodePassWord(string sCadena, string sKey, string sVector)
        {
            IMDResponse <string> response = new IMDResponse <string>();

            string metodo = nameof(this.BDeCodePassWord);

            //logger.Info(IMDSerialize.Serialize(67823458366888, $"Inicia {metodo}(string sCadena, string sKey, string sVector)", sCadena, sKey, sVector));

            try
            {
                IMDEndec authentication = new IMDEndec();

                response = authentication.BDecrypt(sCadena, sKey, sVector);

                sCadena = response.Result;
            }
            catch (Exception ex)
            {
                response.Code    = 67823458367665;
                response.Message = "Ocurrió un error al intentar verificar la información de seguridad";

                logger.Error(IMDSerialize.Serialize(67823458367665, $"Error en {metodo}(string sCadena, string sKey, string sVector): {ex.Message}", sCadena, sKey, sVector, ex, response));
            }
            return(sCadena);
        }
Exemple #2
0
        public ServOrder()
        {
            urlServicioConektaCrearOrden = ConfigurationManager.AppSettings["CONEKTA_ORDERS"];
            string conektaApiKeyEncriptada = ConfigurationManager.AppSettings["CONEKTA_APIKEY"];

            IMDEndec imdEndec = new IMDEndec();

            conketaApiKey  = imdEndec.BDecrypt(conektaApiKeyEncriptada, "MeditocComercial", "Meditoc1").Result;
            conketaVersion = ConfigurationManager.AppSettings["CONEKTA_VERSION"];
            conektaLocale  = ConfigurationManager.AppSettings["CONEKTA_LOCALE"];
        }
        public async Task AuthenticateAsync(HttpAuthenticationContext httpAuthenticationContext, CancellationToken cancellationToken)
        {
            HttpRequestMessage httpRequestMessage = httpAuthenticationContext.Request;

            AuthenticationHeaderValue authenticationHeaderValue = httpRequestMessage.Headers.Authorization;

            HttpRequestHeaders headers = httpRequestMessage.Headers;

            try
            {
                if (headers.Where(x => x.Key == "AppKey" || x.Key == "appkey").Count() != 1)
                {
                    SetHttpUnauthorized(httpAuthenticationContext);
                    return;
                }

                if (headers.Where(x => x.Key == "AppToken" || x.Key == "apptoken").Count() != 1)
                {
                    SetHttpUnauthorized(httpAuthenticationContext);
                    return;
                }


                string appKey   = headers.GetValues("AppKey").FirstOrDefault();
                string appToken = headers.GetValues("AppToken").FirstOrDefault();

                if (string.IsNullOrWhiteSpace(appKey) || string.IsNullOrWhiteSpace(appToken))
                {
                    appKey   = headers.GetValues("appkey").FirstOrDefault();
                    appToken = headers.GetValues("apptoken").FirstOrDefault();
                    if (string.IsNullOrWhiteSpace(appKey) || string.IsNullOrWhiteSpace(appToken))
                    {
                        SetHttpUnauthorized(httpAuthenticationContext);
                        return;
                    }
                }

                IMDEndec iMDEndec = new IMDEndec();

                IMDResponse <string> resAppKey = iMDEndec.BDecrypt(appKey, "M3dit0cAppKeyV4l", "MeditocK");
                if (resAppKey.Code != 0)
                {
                    SetHttpUnauthorized(httpAuthenticationContext);
                    return;
                }

                IMDResponse <string> resAppToken = iMDEndec.BDecrypt(appToken, "M3dit0cAppToken8", "MeditocT");
                if (resAppKey.Code != 0)
                {
                    SetHttpUnauthorized(httpAuthenticationContext);
                    return;
                }

                if (resAppKey.Result != "MeditocAppKeyAuthenti0WebOK")
                {
                    SetHttpUnauthorized(httpAuthenticationContext);
                    return;
                }

                if (resAppToken.Result != "IMD.Meditoc.CallCenterSTthenticacion2020WebOK")
                {
                    SetHttpUnauthorized(httpAuthenticationContext);
                    return;
                }
            }
            catch (Exception)
            {
                SetHttpUnauthorized(httpAuthenticationContext);
                return;
            }

            GenericIdentity identity = new GenericIdentity("Meditoc");

            string[]         rol       = { "Manager" };
            GenericPrincipal principal = new GenericPrincipal(identity, rol);

            httpAuthenticationContext.Principal = principal;
        }