Exemple #1
0
        public string getIdDispositivoParaLog(string imei)
        {
            idTokenFCM = MyFirebaseIIDService.SendRegistrationToServer();
            if (idTokenFCM != null)
            {
                nombreArchivo = "app-bco_security_enrolamiento.sqlite";
                rutaCarpeta   = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
                ruta          = System.IO.Path.Combine(rutaCarpeta, nombreArchivo);
                tokenFCM      = new List <Contenido>();
                tokenFCM      = DatabaseHelper.sqliteTokenFCM(ruta);

                foreach (var token in tokenFCM)
                {
                    if (token.Id == 1)
                    {
                        idDispositivoTokenFCM = token.Password;
                        break;
                    }
                }
                idDispositivoLogLogin = imei + relleno + idDispositivoTokenFCM;
            }
            else
            {
                idDispositivoLogLogin = string.Empty;
            }
            return(idDispositivoLogLogin);
        }
Exemple #2
0
 protected override void OnCreate(Bundle savedInstanceState)
 {
     ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(WebServiceSecurity.CertificadoSecurity.ValidateServerCertificate);
     base.OnCreate(savedInstanceState);
     if (!IsPlayServicesAvailable())
     {
         DialogoErrorActivity.mostrarViewError(this);
     }
     nombreArchivo        = "app-bco_security_enrolamiento.sqlite";
     rutaCarpeta          = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
     ruta                 = System.IO.Path.Combine(rutaCarpeta, nombreArchivo);
     myFirebaseIIDService = new MyFirebaseIIDService();
     myFirebaseIIDService.OnTokenRefresh();
     parametriaLogUtil = new ParametriaLogUtil();
 }
Exemple #3
0
        protected override void OnResume()
        {
            //DialogoLoadingBcoSecurityActivity.mostrarViewLoadingSecurity(this);
            base.OnResume();
            try
            {
                ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(WebServiceSecurity.CertificadoSecurity.ValidateServerCertificate);

                if (isNetDisponible())
                {
                    try
                    {
                        Task startupWork = new Task(() =>
                        {
                            Task.Delay(3000);
                        });

                        startupWork.ContinueWith(async t => {
                            try
                            {
                                JsonValue jsonResponseAccessToken = await WebServiceSecurity.ServiciosSecurity.CallRESTaccessToken();
                                JsonValue jt = jsonResponseAccessToken["access_token"];

                                idTokenFCM = MyFirebaseIIDService.SendRegistrationToServer();

                                var key = new Contenido()
                                {
                                    Password = idTokenFCM
                                };
                                string imei = this.getIMEI();
                                string idDispositivoLogConsultaEnrolado;
                                if (idTokenFCM != null)
                                {
                                    DatabaseHelper.Insertar(ref key, ruta);
                                    tokenFCM = new List <Contenido>();
                                    tokenFCM = DatabaseHelper.sqliteTokenFCM(ruta);

                                    foreach (var token in tokenFCM)
                                    {
                                        if (token.Id == 1)
                                        {
                                            idDispositivoTokenFCM = token.Password;
                                            break;
                                        }
                                    }
                                }
                                else
                                {
                                    idDispositivoTokenFCM = string.Empty;
                                }
                                idDispositivoLogConsultaEnrolado       = parametriaLogUtil.getIdDispositivoParaLog(imei);
                                string ipDisposiivoLogConsultaEnrolado = ParametriaLogUtil.GetIpLocal();
                                string idDispositivoConsultaEnrolado   = imei + relleno + idDispositivoTokenFCM;

                                JsonValue jsonResponseConsultaEnrrolado = await WebServiceSecurity.ServiciosSecurity.CallRESTConsultaEnrrolado(jt, idDispositivoConsultaEnrolado, SecurityEndpoints.SISTEMA_ANDROID, RUT, idDispositivoConsultaEnrolado, ipDisposiivoLogConsultaEnrolado);
                                string jce = jsonResponseConsultaEnrrolado["statusCode"];
                                if (jce.Equals("BusinessException"))
                                {
                                    Intent iLogin = new Intent(this, typeof(LoginActivity));
                                    StartActivity(iLogin);
                                    return;
                                }

                                jceNombre = jsonResponseConsultaEnrrolado["nombre"];
                                jceRut    = jsonResponseConsultaEnrrolado["rut"];

                                if (jce.Equals("Success"))
                                {
                                    Intent iLoginConocido = new Intent(this, typeof(LoginConocidoActivity));
                                    StartActivity(iLoginConocido);
                                }
                            }
                            catch (Exception xe)
                            {
                                Console.WriteLine(xe.ToString());
                                ExceptionGeneric();
                            }
                        }, TaskScheduler.FromCurrentSynchronizationContext());

                        startupWork.Start();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                        ExceptionGeneric();
                    }
                }
                else
                {
                    ExceptionNetwork();
                }
            }
            catch (System.Net.Sockets.SocketException ex)
            {
                Console.WriteLine("Sin conexion  a internet: " + ex);
                ExceptionNetwork();
            }
            catch (Exception x)
            {
                Console.WriteLine(x);
                ExceptionGeneric();
            }
        }
Exemple #4
0
        /// <summary>
        /// metodo el cual contiene el evento click del boton ingresar.
        /// </summary>
        private async void BtnIniciaSesion_Click(object sender, EventArgs e)
        {
            dialogoLoadingBcoSecurityActivity.mostrarViewLoadingSecurity();
            if (string.IsNullOrEmpty(txtUsername.Text) && string.IsNullOrEmpty(txtClave.Text))
            {
                lblMensaje.Text = "Error al ingresar los datos";
                lineTxtUsername.BackgroundTintList = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                lineTxtClave.BackgroundTintList    = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                DialogoLoadingBcoSecurityActivity.ocultarLoadingSecurity();
            }
            else if (validarRut(txtUsername.Text) == false && txtUsername.Text.Trim().Length >= 1 && txtClave.Text.Trim().Length == 8)
            {
                lineTxtUsername.BackgroundTintList = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                lineTxtClave.BackgroundTintList    = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.green);
                lblMensaje.Text = "Error al ingresar los datos";
                DialogoLoadingBcoSecurityActivity.ocultarLoadingSecurity();
            }

            else if (txtClave.Text.Trim().Length >= 1 && txtClave.Text.Trim().Length < 8 && validarRut(txtUsername.Text) == true)
            {
                lineTxtUsername.BackgroundTintList = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.green);
                lineTxtClave.BackgroundTintList    = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                lblMensaje.Text = "Clave incorrecta";
                DialogoLoadingBcoSecurityActivity.ocultarLoadingSecurity();
            }
            else if (string.IsNullOrEmpty(txtClave.Text) && validarRut(txtUsername.Text) == true)
            {
                lineTxtUsername.BackgroundTintList = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.green);
                lineTxtClave.BackgroundTintList    = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                lblMensaje.Text = "Clave incorrecta";
                DialogoLoadingBcoSecurityActivity.ocultarLoadingSecurity();
            }
            else if (string.IsNullOrEmpty(txtUsername.Text) && txtClave.Text.Trim().Length == 8)
            {
                lineTxtUsername.BackgroundTintList = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                lineTxtClave.BackgroundTintList    = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.green);

                lblMensaje.Text = "Error al ingresar los datos";
                DialogoLoadingBcoSecurityActivity.ocultarLoadingSecurity();
            }
            else if (txtClave.Text.Trim().Length <= 8 && !validarRut(txtUsername.Text))
            {
                lineTxtUsername.BackgroundTintList = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                lineTxtClave.BackgroundTintList    = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                lblMensaje.Text = "Error al ingresar los datos";
                DialogoLoadingBcoSecurityActivity.ocultarLoadingSecurity();
            }

            else if (txtClave.Text.Trim().Length < 8 && validarRut(txtUsername.Text))
            {
                lineTxtUsername.BackgroundTintList = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                lineTxtClave.BackgroundTintList    = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                lblMensaje.Text = "Clave incorrecta";
                DialogoLoadingBcoSecurityActivity.ocultarLoadingSecurity();
            }
            else
            {
                lineTxtUsername.BackgroundTintList = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.green);
                lineTxtClave.BackgroundTintList    = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.green);
                //lblMensaje.Text = "Cargando datos...";

                try
                {
                    idTokenFCM = MyFirebaseIIDService.SendRegistrationToServer();
                    var key = new Contenido()
                    {
                        Password = idTokenFCM
                    };

                    if (idTokenFCM != null)
                    {
                        DatabaseHelper.Insertar(ref key, ruta);
                    }
                    string    imei = this.getIMEI();
                    string    idDispositivoLogLogin   = parametriaLogUtil.getIdDispositivoParaLog(imei);
                    string    ipDisposiivoLogLogin    = ParametriaLogUtil.GetIpLocal();
                    JsonValue jsonResponseAccessToken = await WebServiceSecurity.ServiciosSecurity.CallRESTaccessToken();

                    JsonValue jt = jsonResponseAccessToken["access_token"];

                    string    rutServicio       = MascarasEditText.limpiaRut(txtUsername.Text);
                    JsonValue jsonResponseLogin = await WebServiceSecurity.ServiciosSecurity.CallRESTlogin(jt, rutServicio, txtClave.Text, SecurityEndpoints.userTypeWS_LOGIN, SecurityEndpoints.channelNameWS_LOGIN, idDispositivoLogLogin, ipDisposiivoLogLogin);

                    string jl = jsonResponseLogin["statusCode"];
                    if (jl.Equals("Success"))
                    {
                        string operationResult = jsonResponseLogin["operationResult"];
                        if (operationResult.Equals("Success_1"))
                        {
                            Intent i = new Intent(this, typeof(TerminoYCondicionesActivity));
                            StartActivity(i);
                        }
                        else if (operationResult.Equals("ErrorInvalidUser_4") ||
                                 operationResult.Equals("ErrorUserDeleted_7") ||
                                 operationResult.Equals("ErrorGenericError_8") ||
                                 operationResult.Equals("ErrorDocumentNumberWithInvalidFormat_9") ||
                                 operationResult.Equals("ErrorUserAndPasswordDoNotMatch_10") ||
                                 operationResult.Equals("InvalidChannel_11") ||
                                 operationResult.Equals("InvalidPassword_12") ||
                                 operationResult.Equals("NotMatchUserAndUserType_13") ||
                                 operationResult.Equals("ErrorCredentialNotAvailable_14") ||
                                 operationResult.Equals("SuccessPendingValidatePIN_15")
                                 )
                        {
                            CleaningEntryLogin();
                            DialogoLoadingBcoSecurityActivity.ocultarLoadingSecurity();
                            lineTxtUsername.BackgroundTintList = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                            lineTxtClave.BackgroundTintList    = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                            lblMensaje.Text = "Estimado cliente, usuario ingresado es invalido. Por favor ingréselo nuevamente.";
                        }
                        else if (operationResult.Equals("ErrorUserBlockedByPassword_5") ||
                                 operationResult.Equals("ErrorUserBlockedByAdministrator_6") ||
                                 operationResult.Equals("ErrorUserBlockedBySecurityQuestion_16") ||
                                 operationResult.Equals("ErrorUserBlockedByAttemptsPinActivation_17")
                                 )
                        {
                            CleaningEntryLogin();
                            DialogoLoadingBcoSecurityActivity.ocultarLoadingSecurity();
                            lineTxtUsername.BackgroundTintList = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                            lineTxtClave.BackgroundTintList    = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                            lblMensaje.Text = "Estimado Cliente, su clave se encuentra bloqueada. Por favor contáctese con el Servicio Atención Clientes Security +56 2 2222 2222.";
                        }
                        else
                        {
                            ExceptionGeneric();
                        }
                    }
                    else
                    {
                        lineTxtUsername.BackgroundTintList = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                        lineTxtClave.BackgroundTintList    = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                        lblMensaje.Text = "Error al ingresar los datos";
                        DialogoLoadingBcoSecurityActivity.ocultarLoadingSecurity();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    ExceptionGeneric();
                }
            }
        }