Exemplo n.º 1
0
 public SecureProvider(ApiSecurityMode mode, IServiceProvider provider, Type typeresponse, ApiTargetPlatform targetPlatform)
 {
     _securemode   = mode;
     _serviceImpl  = provider;
     _typeresponse = typeresponse;
     _target       = targetPlatform;
 }
Exemplo n.º 2
0
        //Crea el componente que implmente una ejecucion segura y la invoca
        private K ResolveSecureRequest(T request, ApiTargetPlatform targetPlatform, ApiServiceName serviceName)
        {
            //bandera para determinar si hubo error de la clase
            bool opok = false;

            try
            {
                if (ConfigurationManager.AppSettings["ProcessMigration"].ToLower() == "true")
                {
                    if (request.AuthenticationData != null)
                    {
                        if (GetCustomDefaultPlatform(request.AuthenticationData.Username) == "1")
                        {
                            targetPlatform = ApiTargetPlatform.Kinacu;
                        }
                    }
                }

                if (HttpContext.Current.Session != null)
                {
                    if (HttpContext.Current.Session["LOG_PREFIX"] == null)
                    {
                        HttpContext.Current.Session.Add("LOG_PREFIX", "[" + new Random(DateTime.Now.Millisecond * 9).Next(100000000, 999999999) + "] [" + serviceName.ToString() + "] ");
                    }
                }

                ISecureServiceProvider serviceImpl = ServiceProviderFactory.GetServiceProviderSecure(targetPlatform, serviceName);

                //se pudo ejecutar hasta este punto el codigo
                opok = true;

                return((K)serviceImpl.PerformSecureOperation(request));
            }

            catch (Exception ex)
            {
                K resultError = Reflection.FactoryObject <K>();
                resultError.ResponseCode = UtilResut.ResponseCode(ex);

                if (ex.Message.IndexOf("[API UNEXCEPTED ERROR]", StringComparison.Ordinal) < 0)
                {
                    resultError.ResponseMessage = String.Concat("[API UNEXCEPTED ERROR]-[", ex.Message, "]");
                }
                else
                {
                    resultError.ResponseMessage = ex.Message;
                }

                //si es un error interno del la clase se debe
                if (!opok)
                {
                    logger.Fatal(String.Concat(resultError.ResponseCode, "-", resultError.ResponseMessage, "-", ex.StackTrace), ex);
                }

                return(resultError);
            }
        }
Exemplo n.º 3
0
        public override K ResolveRequest(T request, ApiTargetPlatform targetPlatform, ApiServiceName serviceName)
        {
            //TODO herencia
            // BeginResolveRequest(request, ref targetPlatform, serviceName);

            IServiceProvider serviceImpl = ServiceProviderFactory.GetServiceProvider(targetPlatform, serviceName);

            SecureProvider secureprovider = new SecureProvider(_securemode, serviceImpl, typeof(K), targetPlatform);

            return((K)secureprovider.PerformOperation(request));
        }
Exemplo n.º 4
0
 /// <summary>
 /// Ejecuta la validacion del cokie monster ,  en caso de ser correcta
 /// continua con el despliegue del componente
 /// </summary>
 /// <param name="request"></param>
 /// <param name="targetPlatform"></param>
 /// <param name="serviceName"></param>
 /// <returns></returns>
 public K ResolveRequestService(T request, ApiTargetPlatform targetPlatform, ApiServiceName serviceName)
 {
     // llamar a la validacion de seguridad del api
     //
     if (ApiConfiguration.API_SECURE_OPTIMIZATION)
     {
         return(ResolveSecureRequest(request, targetPlatform, serviceName));
     }
     else
     {
         return(ResolveRequest(request, targetPlatform, serviceName));
     }
 }
Exemplo n.º 5
0
        public static ISecureServiceProvider GetServiceProviderSecure(ApiTargetPlatform targetPlatform, ApiServiceName serviceName)
        {
            ISecureServiceProvider serviceProviderImpl = null;

            if (_registeredProviders.ContainsKey(targetPlatform))
            {
                var registeredServicerForPlatform = _registeredProviders[targetPlatform];
                if (registeredServicerForPlatform.ContainsKey(serviceName))
                {
                    Type providerType = registeredServicerForPlatform[serviceName];
                    serviceProviderImpl = (ISecureServiceProvider)Activator.CreateInstance(providerType);
                }
            }
            return(serviceProviderImpl);
        }
Exemplo n.º 6
0
        public static void RegisterServiceProviderClass(ApiTargetPlatform targetPlatform, ApiServiceName serviceName, Type implementingType)
        {
            Dictionary <ApiServiceName, Type> platformList;

            if (_registeredProviders.ContainsKey(targetPlatform))
            {
                platformList = _registeredProviders[targetPlatform];
            }
            else
            {
                platformList = new Dictionary <ApiServiceName, Type>();
                _registeredProviders.Add(targetPlatform, platformList);
            }
            platformList.Add(serviceName, implementingType);
        }
Exemplo n.º 7
0
        public SecureProvider(ApiSecurityMode mode, IServiceProvider provider, Type typeresponse, string platform)
        {
            _securemode   = mode;
            _serviceImpl  = provider;
            _typeresponse = typeresponse;
            switch (platform)
            {
            case "1":
                _target = ApiTargetPlatform.Kinacu;
                break;

            case "2":
                _target = ApiTargetPlatform.Utiba;
                break;
            }
        }