Exemplo n.º 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);
        }
Exemplo n.º 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"];
        }
Exemplo n.º 3
0
        /// <summary>
        /// Función: Genera un código de cupón aleatorio con la longitud proporcionada
        /// Creado: Cristopher Noh 28/07/2020
        /// Modificado:
        /// </summary>
        /// <param name="piLongitud"></param>
        /// <returns></returns>
        private IMDResponse <string> BGenerarCodigoCupon(int piLongitud)
        {
            IMDResponse <string> response = new IMDResponse <string>();

            string metodo = nameof(this.BGenerarCodigoCupon);

            logger.Info(IMDSerialize.Serialize(67823458194394, $"Inicia {metodo}(int piLongitud)", piLongitud));

            try
            {
                if (piLongitud < 6)
                {
                    response.Code    = 67823458231690;
                    response.Message = "La longitud mínima para un cupón es de 6 caractéres.";
                    return(response);
                }

                IMDResponse <int> respuestaNuevoID = this.BNuevoIdCupon();
                if (respuestaNuevoID.Code != 0)
                {
                    return(respuestaNuevoID.GetResponse <string>());
                }

                IMDEndec iMDEndec = new IMDEndec();

                string sCodigoEncr = iMDEndec.BEncrypt(respuestaNuevoID.Result.ToString(), "abcdefghijklmnop", "abcdefgh")?.Result;

                sCodigoEncr = sCodigoEncr?.Replace("+", "")?.Replace("=", "")?.Replace("/", "");
                sCodigoEncr = sCodigoEncr?.Substring(0, piLongitud > sCodigoEncr.Length ? sCodigoEncr.Length : piLongitud)?.ToUpper();

                if (string.IsNullOrWhiteSpace(sCodigoEncr))
                {
                    response.Code    = 67823458232467;
                    response.Message = "No se pudo generar el código del cupón.";
                    return(response);
                }
                response.Code   = 0;
                response.Result = sCodigoEncr;
            }
            catch (Exception ex)
            {
                response.Code    = 67823458195171;
                response.Message = "Ocurrió un error al generar el cupón.";

                logger.Error(IMDSerialize.Serialize(67823458195171, $"Error en {metodo}(int piLongitud): {ex.Message}", piLongitud, ex, response));
            }
            return(response);
        }
Exemplo n.º 4
0
        public string BEncodePassword(string sCadena, string sKey, string sVector)
        {
            IMDResponse <string> response = new IMDResponse <string>();

            try
            {
                IMDEndec authentication = new IMDEndec();

                response = authentication.BEncrypt(sCadena, sKey, sVector);
            }
            catch (Exception)
            {
                throw;
            }
            return(response.Result);
        }
Exemplo n.º 5
0
        public string BEncodePassword(string sPassWord)
        {
            IMDResponse <string> response;

            try
            {
                IMDEndec authentication = new IMDEndec();

                response = authentication.BEncrypt(sPassWord, "M3diT0cPassword1", "Evector1");
                if (string.IsNullOrWhiteSpace(response.Result))
                {
                    throw new Exception("Ocurrió un error al intentar verificar la información de seguridad");
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(response.Result);
        }
        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;
        }