private async Task <ActionResult <ZServiceResponse> > SaveAccept(
            string idAplicacion,
            string opcion,
            int?log,
            object objectBuffer,
            System.Web.Mvc.HttpVerbs methodVerb
            )
        {
            var zClaims = GetZClaims();


            Execute.Command command = new Execute.Command
            {
                Tkna            = zClaims.Tkna,
                IdAplication    = idAplicacion,
                Opcion          = opcion,
                Cmd             = ZCommandConst.CM_EJECSERVICIO,
                Log             = log ?? 0,
                ObjectBuffer    = objectBuffer,
                HttpMethod      = methodVerb,
                RemoteIpAddress = Request.HttpContext.Connection.RemoteIpAddress.ToString()
            };

            _logHandler.Debug($"Request: {JsonConvert.SerializeObject(command)}");

            var zResponse = await _mediator.Send(command);

            Response.StatusCode = (int)zResponse.Status;

            _logHandler.Debug($"Response: {JsonConvert.SerializeObject(zResponse)}");
            return(zResponse);
        }
Example #2
0
        public async Task <ActionResult <string> > AceptarLogin(Execute.Command command,
                                                                [FromRoute] int?enc)
        {
            if (enc != null)
            {
                command.Buffer = _zCryptography.GetCipherText(command.Buffer);
            }
            command.RemoteIpAddress = Request.HttpContext.Connection.RemoteIpAddress;

            string response = await _mediator.Send(command);

            return(response);
        }
Example #3
0
        public async Task <ActionResult <string> > Execute(
            [FromRoute] string idAplicacion,
            [FromRoute] int?enc,
            [FromBody] Execute.Command command)
        {
            if (enc != null)
            {
                command.Buffer = _zCryptography.GetCipherText(command.Buffer);
            }

            var zClaims = GetZClaims();

            command.IdAplication    = idAplicacion;
            command.Tkna            = zClaims.Tkna;
            command.RemoteIpAddress = Request.HttpContext.Connection.RemoteIpAddress;

            //return await _mediator.Send(command);

            if (!string.IsNullOrEmpty(command.TokenJWT))
            {
                var     handler   = new JwtSecurityTokenHandler();
                var     jsonToken = handler.ReadToken(command.TokenJWT);
                var     tokenS    = jsonToken as JwtSecurityToken;
                var     jti       = tokenS.Claims.First(claim => claim.Type == "ZClaims").Value;
                dynamic data      = JObject.Parse(jti);

                command.TokenJWT = data.Tkns;
            }

            if (!string.IsNullOrEmpty(zClaims.Tkns))
            {
                command.TokenJWT = zClaims.Tkns;
            }

            try
            {
                return(await _mediator.Send(command));
            }
            catch (ZSessionEndedException)
            {
                return(StatusCode((int)HttpStatusCode.Unauthorized, "Oopss!!!!"));
            }
        }