Пример #1
0
        private bool ValidateUser(int ssoId)
        {
            ValidateRoles(ssoId);
            SSO sso = _db?.SSOes.FirstOrDefault(item => item.SSOValue.Equals(ssoId));

            return(sso != null && DateTime.Now.AddMinutes(-1 * Settings.SessionExpirationTimeout) < sso.ExpirationDate);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["Contexto"] == null)
                {
                    Response.Redirect(ConfigurationManager.AppSettings.Get("URL_SSO") + ConfigurationManager.AppSettings.Get("TokenApp").Replace("-", ""));
                }

                SSO    usuario = (SSO)Session["Contexto"];
                String RolUsr  = UtilContratosArrto.ObtenerNombreRolUsrApp(usuario.LRol);

                if (!RolUsr.Equals("ADMINISTRADOR DE CONTRATOS", StringComparison.InvariantCultureIgnoreCase))
                //if (!RolUsr.Equals("ADMINISTRADOR", StringComparison.InvariantCultureIgnoreCase))
                {
                    Response.Redirect("~/Principal.aspx", true);
                }



                //this.PoblarDropDownSector();
                this.PoblarDropDownInstitucion();

                this.PoblarDropDownListEntidadFederativa();

                this.PoblarDropDrownUnidadTerDic();

                this.PoblarDropDrownUnidadConsDic();

                this.PoblarDropDrownUnidadRenDic();
            }
        }
Пример #3
0
        //SobreCargado con una lista de Roles
        //Compara 2 listas una con los roles a buscar y la otra con la lista de roles del usuario
        public static bool ValidarDescRolAcceso(List <RolUsr> ListaRolesXBusar, SSO objSSO)
        {
            int intTieneElRol = 0;


            //obtener de la lista de aplicaciones, el objeto Aplicacion que corresponda a este aplicativo
            ModeloNegocio.Aplicacion AppContratos = (from App in objSSO.LAplicaciones
                                                     where App.NombreAplicacion == "ArrendamientoContratos"
                                                     select App).FirstOrDefault();

            //del objeto Aplicacion contiene una propiedad que es una lista de Roles, que se comparara con los roles buscados
            //join entre list Roles de usuario SSO vs ListaRoles Comparacion
            intTieneElRol = (from Item1 in AppContratos.LRol
                             join Item2 in ListaRolesXBusar
                                                                                                         //como se compara contra valores de string, se quitan los espacios
                             on Item1.nombreRol.Replace(" ", "") equals Item2.NombreRol.Replace(" ", "") // join on some property
                             select new { Item1, Item2 }).Count();


            if (objSSO != null)
            {
                //join entre list Roles de usuario SSO vs ListaRoles Comparacion
                intTieneElRol = (from Item1 in objSSO.LRol
                                 join Item2 in ListaRolesXBusar
                                 on Item1.nombreRol equals Item2.NombreRol // join on some property
                                 select new { Item1, Item2 }).Count();
            }
            else
            {
                throw new Exception("Para poder evaluar el Rol del usuario debe autentificarse 1ro en el SSO");
            }


            return(Convert.ToBoolean(intTieneElRol));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["Contexto"] == null)
                {
                    Response.Redirect(ConfigurationManager.AppSettings.Get("URL_SSO") + ConfigurationManager.AppSettings.Get("TokenApp").Replace("-", ""));
                }

                SSO    usuario = (SSO)Session["Contexto"];
                String RolUsr  = UtilContratosArrto.ObtenerNombreRolUsrApp(usuario.LRol);

                if (!RolUsr.Equals("ADMINISTRADOR DE CONTRATOS", StringComparison.InvariantCultureIgnoreCase))
                //if (!RolUsr.Equals("ADMINISTRADOR", StringComparison.InvariantCultureIgnoreCase))
                {
                    //si no eres administrador de contratos te va a regresar a la pagina principal
                    Response.Redirect("~/Principal.aspx", true);
                }
                else
                {
                    //poblar la rejilla, ya que eres administrador de contratos
                    this.PoblarRejillaJustipreciaciones();
                }
            }
        }
Пример #5
0
        public SSO ObtenerUsuario(string usuario)
        {
            ControladorBUS ws_bus = new ControladorBUS();
            SSO            user   = ws_bus.ObtenerUsuario(usuario).FirstOrDefault();

            return(user);
        }
Пример #6
0
        public SSO ObtenerUsuarioXId(int IdUsuario)
        {
            ControladorBUS ws_bus = new ControladorBUS();
            SSO            user   = ws_bus.ObtenerUsuarioXId(IdUsuario).FirstOrDefault();

            return(user);
        }
Пример #7
0
        public void Login(string email, string password)
        {
            int hash = password.GetHashCode();

            email = email.ToLower();
            string result = string.Empty;
            User   user   = _db.Users.FirstOrDefault(item => item.Email.ToLower().Equals(email));

            if (user != null && user.PasswordHash.Equals(hash))
            {
                if (user.IsEnabled == true)
                {
                    SSO sso = _db.SSOes.FirstOrDefault(item => item.UserId.Equals(user.UserId)) ?? new SSO();
                    sso.SSOValue       = SSOUtility.GenerateSSO();
                    sso.ExpirationDate = DateTime.Now.AddMinutes(Settings.SessionExpirationTimeout);
                    sso.User           = user;
                    _db.SSOes.Add(sso);
                    _db.SaveChanges();
                    result = sso.SSOValue.ToString();
                }
                else
                {
                    result = ResourceStrings.UserDeactivatedMessage;
                }
            }
            else
            {
                result = ResourceStrings.UserNotExistMessage;
            }
            WriteResponce(result);
        }
Пример #8
0
        public static String ObtenerNombreUsuarioSSO(int IdUsuario)
        {
            //usuario que registro
            SSO usuario = null;

            if (IdUsuario == 1)
            {
                return("Cargado por proceso de carga inicial");
            }
            else if (IdUsuario != 1)                             //usuario != null
            {
                usuario = new NG().ObtenerUsuarioXId(IdUsuario); //poblar del bus

                if (usuario == null)
                {
                    return("Usuario No Encontrado");
                }
                else
                {
                    return(usuario.Nombre + " " + usuario.ApellidoP + " " + usuario.ApellidoM);
                }
            }
            else
            {
                return("Usuario No Encontrado");
            }
        }
Пример #9
0
        //simular un objeto Contexto del usuario: SSO (desconestado de BUS)
        //Usuario-->lista de Aplciacion --> Lsita de Roles de Aplicacion
        private Boolean SimularUserPromovente_AppSSO()
        {
            SSO     UsrHardCode = null;
            Boolean Ok          = false;

            //crear una lista de roles con un objeto Rol en especifico
            List <ModeloNegocio.Rol> listRolesApp = new List <ModeloNegocio.Rol>()
            {
                new ModeloNegocio.Rol()
                {
                    idRol = 2, nombreRol = "Promovente"
                }
            };

            //Crear una lista de Aplicaciones con un objeto de Aplicacion
            //agregar la lista de roles a la lista de aplicacion
            List <ModeloNegocio.Aplicacion> listAplicaciones = new List <ModeloNegocio.Aplicacion>()
            {
                new  ModeloNegocio.Aplicacion()
                {
                    IdAplicacion = 1, NombreAplicacion = "ArrendamientoInmueble", LRol = listRolesApp
                }
            };


            //****   hardcode de simulacion de usuario SSO   *******
            //se agregan 2 listas al usuario: la lista de aplicaciones y de roles
            UsrHardCode = new SSO()
            {
                ////**** Promovente  *****
                IdUsuario = 30546,
                UserName  = "******",
                Nombre    = "Edwin",
                ApellidoP = "Serrano",
                ApellidoM = "Aguado",
                Cargo     = "DIRECTOR DE INFORMATICA", //real del catalogo de: Cargos= idCargo= 49
                //IdInstitucion =72,
                //IdInstitucion = 76,
                //IdInstitucion = 318,
                IdInstitucion = 135,
                //NombreInstitucion = "COMISIÓN FEDERAL DE TELECOMUNICACIONES", //=72 (para pruebas de Contiuancion o Sustitucion)
                //NombreInstitucion = "PRESIDENCIA DE LA REPÚBLICA", //IdInstitucion = 1
                // NombreInstitucion = "DELEGACIÓN FEDERAL DEL TRABAJO", //IdInstitucion = 387
                // NombreInstitucion = "PROCURADURÍA GENERAL DE LA REPÚBLICA", //IdInstitucion = 2,
                //NombreInstitucion = "COMISIÓN FEDERAL DE ELECTRICIDAD" , //idInstitucion = 318  (para comprobar el secuencial: 4372)
                NombreInstitucion = "LUZ Y FUERZA DEL CENTRO, EN LIQUIDACIÓN", //135
                //NombreInstitucion = "SECRETARÍA DE LA DEFENSA NACIONAL", ////IdInstitucion = 76
                // NombreSector = "PRESIDENCIA DE LA REPÚBLICA",
                LAplicaciones = listAplicaciones,
                LRol          = listRolesApp
            };

            Session["Contexto"] = UsrHardCode;
            Ok = true;

            return(Ok);
        }
Пример #10
0
        public bool ExportSSOApplication(string appName, string filename)
        {
            string itemExtension = Path.GetExtension(filename);

            if (itemExtension == ".sso")
            {
                // TODO We only allow to export to a XML file
                return(false);
            }

            SSO sSO = new SSO(Helpers.BizTalk.BizTalkHelper.CompanyName);

            sSO.SsoEvent += new EventHandler <SSOEventArgs>(SSO_Update);
            string[]      keys          = sSO.GetKeys(appName);
            string[]      values        = sSO.GetValues(appName);
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("<?xml version=\"1.0\" encoding=\"utf-8\" ?><SSOApplicationExport><applicationData>");
            for (int i = 0; i < keys.Length; i++)
            {
                if (keys[i] != null && !(keys[i] == ""))
                {
                    stringBuilder.Append(string.Concat(new string[]
                    {
                        "<add key=\"",
                        keys[i],
                        "\" value=\"",
                        HttpUtility.HtmlEncode(values[i]),
                        "\" />"
                    }));
                }
            }
            stringBuilder.Append("</applicationData></SSOApplicationExport>");
            bool         result       = true;
            StreamWriter streamWriter = new StreamWriter(filename, false);

            try
            {
                streamWriter.Write(stringBuilder.ToString());
                streamWriter.Flush();
                SSO_Update(this, new SSOEventArgs("ExportSSOApplication", string.Format("{0} exported.", filename), false));
            }
            catch (Exception ex)
            {
                SSO_Update(this, new SSOEventArgs("ExportSSOApplication", ex.Message, true));
                result = false;
                return(result);
            }
            finally
            {
                streamWriter.Close();
                streamWriter.Dispose();
            }
            return(result);
        }
Пример #11
0
        //(desconestado de BUS) para sumular un usuario con rol de Administrador de Contratos
        private Boolean SimularUserAdminContratos_AppSSO()
        {
            SSO UsrHardCode = null;

            UserName = "******";
            Token    = "XXXXX";
            Boolean Ok = false;


            //crear una lista de roles con un objeto Rol en especifico
            List <ModeloNegocio.Rol> listRolesApp = new List <ModeloNegocio.Rol>()
            {
                new ModeloNegocio.Rol()
                {
                    //idRol = 0, nombreRol = "Administrador"
                    idRol = 1, nombreRol = "Administrador de Contratos"
                                           //idRol = 2, nombreRol = "Promovente"
                                           //idRol = 3, nombreRol = "OIC"
                }
            };

            //Crear una lista de Aplicaciones con un objeto de Aplicacion
            //agregar la lista de roles a la lista de aplicacion
            List <ModeloNegocio.Aplicacion> listAplicaciones = new List <ModeloNegocio.Aplicacion>()
            {
                new  ModeloNegocio.Aplicacion()
                {
                    IdAplicacion = 1, NombreAplicacion = "ArrendamientoInmueble", LRol = listRolesApp
                }
            };


            //****   hardcode de simulacion de usuario SSO   *******
            //se agregan 2 listas al usuario: la lista de aplicaciones y de roles
            UsrHardCode = new SSO()
            {
                ////**** Administrador de Contratos  ****
                IdUsuario         = 11940,
                UserName          = "******",
                Nombre            = "FERNANDO",
                ApellidoP         = "VALDES",
                ApellidoM         = "LUCIO",
                Cargo             = "Subdirector de Programas Inmobiliarios", //IdCargo=45
                IdInstitucion     = 74,
                NombreInstitucion = "INSTITUTO DE ADMINISTRACIÓN Y AVALÚOS DE BIENES NACIONALES",
                LAplicaciones     = listAplicaciones,
                LRol = listRolesApp
            };

            Session["Contexto"] = UsrHardCode;
            Ok = true;

            return(Ok);
        }
Пример #12
0
        public void Logout(int ssoId)
        {
            User user = GetUserBySSO(ssoId);

            if (user != null)
            {
                SSO sso = _db.SSOes.FirstOrDefault(item => item.UserId.Equals(user.UserId)) ?? new SSO();
                sso.ExpirationDate = DateTime.Now.AddMinutes(-Settings.SessionExpirationTimeout + 1);
                _db.SaveChanges();
            }
        }
Пример #13
0
        private async void GetListOfSsoApplications()
        {
            List <SSOAppInfo> applications = null;
            await Task.Run(() =>
            {
                SSO sso      = new SSO(username, companyName);
                applications = sso.GetListOfApplications();
            });

            SortableBindingList <SSOAppInfo> bindingList = new SortableBindingList <SSOAppInfo>(applications);

            dataGridApplications.DataSource = bindingList;
        }
Пример #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.LabelInfo.Text = string.Empty;

            if (!IsPostBack)
            {
                if (Session["Contexto"] == null)
                {
                    Response.Redirect(ConfigurationManager.AppSettings.Get("URL_SSO") + ConfigurationManager.AppSettings.Get("TokenApp").Replace("-", ""));
                }

                SSO    usuario = (SSO)Session["Contexto"];
                String RolUsr  = UtilContratosArrto.ObtenerNombreRolUsrApp(usuario.LRol);

                if (!RolUsr.Equals("ADMINISTRADOR DE CONTRATOS", StringComparison.InvariantCultureIgnoreCase))
                //if (!RolUsr.Equals("ADMINISTRADOR", StringComparison.InvariantCultureIgnoreCase))
                {
                    //si no eres administrador de contratos te va a regresar a la pagina principal
                    Response.Redirect("~/Principal.aspx", true);
                }
                else
                {
                    try
                    {
                        this.PoblarDropDownListInstitucion();
                        this.PoblarDropDownListPais();
                        this.PoblarDropDownListEstado();
                        this.PoblarDropDownTipoRegistro();
                        this.PoblarDropDownEstatusRUSP();
                    }
                    catch (Exception ex)
                    {
                        Msj = "Ha ocurrido un error iniciar. Contacta al área de sistemas.";
                        this.LabelInfo.Text = "<div class='alert alert-danger'><strong> Error </strong>" + Msj + "</div>";

                        BitacoraExcepcion BitacoraExcepcionAplictivo = new BitacoraExcepcion
                        {
                            CadenaconexionBD = System.Configuration.ConfigurationManager.ConnectionStrings["cnArrendamientoInmueble"].ConnectionString,
                            Aplicacion       = "ContratosArrto",
                            Modulo           = MethodInfo.GetCurrentMethod().DeclaringType.ToString() + ".aspx",
                            Funcion          = MethodBase.GetCurrentMethod().Name + "()",
                            DescExcepcion    = ex.InnerException == null ? ex.Message : ex.InnerException.Message,
                            Usr = ((SSO)Session["Contexto"]).UserName.ToString()
                        };

                        BitacoraExcepcionAplictivo.RegistrarBitacoraExcepcion();
                        BitacoraExcepcionAplictivo = null;
                    }
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string color = ConfigurationManager.AppSettings["Color"];

            string version = ConfigurationManager.AppSettings["Version"];

            if (!string.IsNullOrEmpty(color) && !string.IsNullOrWhiteSpace(version))
            {
                //poner version y color
                this.DivVersion.Style.Add("background-color", color);
                this.DivVersion.InnerText = version;
            }



            if (!IsPostBack)
            {
                try
                {
                    if (Session["Contexto"] != null)
                    {
                        SSO    usuario = (SSO)Session["Contexto"];
                        String RolUsr  = UtilContratosArrto.ObtenerNombreRolUsrApp(usuario.LRol);
                        var    oic     = UtilContratosArrto.Roles.OIC.ToString();

                        if (RolUsr == oic)
                        {
                            ScriptManager.RegisterStartupScript(this, typeof(Page), "soloLectura", "ValidarSoloLectura('none');", true);
                        } //MZT presentar u ocultar menu item
                        //ADMINISTRADOR DE CONTRATOS
                        else if (RolUsr.Equals("ADMINISTRADOR DE CONTRATOS", StringComparison.InvariantCultureIgnoreCase) || RolUsr.Equals("ADMINISTRADOR", StringComparison.InvariantCultureIgnoreCase))
                        {
                            itemJust.Visible = true;
                            //ScriptManager.RegisterStartupScript(this, typeof(Page), "soloLectura", "MuestraJustipreciaciones();", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "soloLectura", "ValidarSoloLectura('none');", true);
                        //ScriptManager.RegisterStartupScript(this, typeof(Page), "alertUsuario", "alert('No se ha podido recuperar el objeto Contexto del usuario firmado, contacte al administrador del sistema.');", true);
                    }
                }
                catch (Exception ex)
                {
                    string msj = ex.InnerException == null ? ex.Message : ex.InnerException.Message;
                    Session["Msj"] = msj;
                    Response.Redirect("Msj.aspx", false);
                }
            }
        }
Пример #16
0
        public void Requesting_item_from_nonexistant_application_from_SSO_should_throw_an_exception()
        {
            var exceptionThrown = false;

            try
            {
                SSO.GetSSOInt32("NonExisting", "missingValue");
            }
            catch (Exception e)
            {
                exceptionThrown = true;
            }
            Assert.IsTrue(exceptionThrown);
        }
Пример #17
0
        public void Requesting_missing_item_from_SSO_should_throw_an_exception()
        {
            var exceptionThrown = false;

            try
            {
                SSO.GetSSOInt32("IKTA.Common", "missingValue");
            }
            catch (Exception e)
            {
                exceptionThrown = true;
            }
            Assert.IsTrue(exceptionThrown);
        }
Пример #18
0
        public ActionResult GoogleLoginCallback()
        {
            var claimsPrincipal = HttpContext.User.Identity as ClaimsIdentity;

            var loginInfo = SSO.GetLoginInfo(claimsPrincipal);

            if (loginInfo == null)
            {
                return(RedirectToAction("Index"));
            }


            ASM_BookEntities db = new ASM_BookEntities(); //DbContext
            var user            = db.Users.FirstOrDefault(x => x.Email == loginInfo.emailaddress);

            if (user == null)
            {
                user = new User
                {
                    Email    = loginInfo.emailaddress,
                    Password = loginInfo.nameidentifier,
                    UserName = loginInfo.givenname,
                };
                db.Users.Add(user);
                db.SaveChanges();
            }

            Session["makh"] = user.MaKH;

            Session["usename"] = loginInfo.givenname;
            var ident = new ClaimsIdentity(
                new[] {
                // adding following 2 claim just for supporting default antiforgery provider
                new Claim(ClaimTypes.NameIdentifier, user.Email),
                new Claim("http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider", "ASP.NET Identity", "http://www.w3.org/2001/XMLSchema#string"),
                new Claim(ClaimTypes.Name, user.UserName),
                new Claim(ClaimTypes.Email, user.Email),
                // optionally you could add roles if any
                new Claim(ClaimTypes.Role, "User"),
            },
                CookieAuthenticationDefaults.AuthenticationType);


            HttpContext.GetOwinContext().Authentication.SignIn(
                new AuthenticationProperties {
                IsPersistent = false
            }, ident);
            return(Redirect("~/"));
        }
Пример #19
0
        //simular un objeto Contexto del usuario: SSO (desconestado de BUS)
        //Usuario-->lista de Aplicacion --> Lsita de Roles de Aplicacion
        private Boolean SimularUserOIC_AppSSO()
        {
            SSO     UsrHardCode = null;
            Boolean Ok          = false;

            //crear una lista de roles con un objeto Rol en especifico
            List <ModeloNegocio.Rol> listRolesApp = new List <ModeloNegocio.Rol>()
            {
                new ModeloNegocio.Rol()
                {
                    idRol = 3, nombreRol = "OIC"
                }
            };

            //Crear una lista de Aplicaciones con un objeto de Aplicacion
            //agregar la lista de roles a la lista de aplicacion
            List <ModeloNegocio.Aplicacion> listAplicaciones = new List <ModeloNegocio.Aplicacion>()
            {
                new  ModeloNegocio.Aplicacion()
                {
                    IdAplicacion = 1, NombreAplicacion = "ArrendamientoInmueble", LRol = listRolesApp
                }
            };


            //****   hardcode de simulacion de usuario SSO   *******
            //se agregan 2 listas al usuario: la lista de aplicaciones y de roles
            UsrHardCode = new SSO()
            {
                //***OIC * ***
                IdUsuario         = 4,
                UserName          = "******",
                Nombre            = "Jose Luis",
                ApellidoP         = "Piña",
                ApellidoM         = "Lara",
                Cargo             = "Coordinador de Desarrollo Institucional",
                IdInstitucion     = 1,
                NombreSector      = "PRESIDENCIA DE LA REPÚBLICA",
                NombreInstitucion = "PRESIDENCIA DE LA REPÚBLICA",
                LAplicaciones     = listAplicaciones,
                LRol = listRolesApp
            };

            Session["Contexto"] = UsrHardCode;
            Ok = true;

            return(Ok);
        }
Пример #20
0
        //recibe el Id del Rol y el objeto SSO
        public static bool ValidarRolAcceso(int IdRol, SSO objSSO)
        {
            int intTieneElRol = 0;


            if (objSSO != null)
            {
                //validar acceso por Rol del usuario
                List <Rol> ListRoles = objSSO.LRol;
                intTieneElRol = (from x in ListRoles
                                 where x.idRol == IdRol
                                 select x.idRol).Count();
            }
            else
            {
                throw new Exception("Para poder evaluar el Rol del usuario debe autentificarse 1ro en el SSO");
            }


            return(Convert.ToBoolean(intTieneElRol));
        }
Пример #21
0
        private async void dataGridApplications_SelectionChanged(object sender, EventArgs e)
        {
            if (dataGridApplications.SelectedRows.Count == 0)
            {
                return;
            }
            int             rowIndex = dataGridApplications.SelectedRows[0].Index;
            DataGridViewRow row      = dataGridApplications.Rows[rowIndex];
            // Get selected application data
            Dictionary <string, string> keyValues = new Dictionary <string, string>();
            string artefactName = string.Empty;
            await Task.Run(() =>
            {
                string appName        = (row.DataBoundItem as SSOAppInfo).Name;
                string appDescription = (row.DataBoundItem as SSOAppInfo).Description;
                SSO sso = new SSO(username, companyName);
                Guid appGuid;
                if (!Guid.TryParse(appName, out appGuid))
                {
                    sso.GetKeyValues((row.DataBoundItem as SSOAppInfo).Name, keyValues);
                }
                else
                {
                    artefactName = sso.GetAdapterConfig(appName, appDescription, keyValues);
                }
            });

            SortableBindingList <SSOKeyValue> bindingList = new SortableBindingList <SSOKeyValue>(
                keyValues.Select(x => new SSOKeyValue {
                Key = x.Key, Value = x.Value
            }).ToList()
                );

            dataGridKeyValues.DataSource = bindingList;
            lblName.Text = artefactName;
        }
Пример #22
0
        public void We_should_be_able_to_get_a_string_from_SSO()
        {
            var value = SSO.GetSSOString("IKTA.Common", "SsoAppUserGroup");

            Assert.AreEqual("BizTalk Application Users", value);
        }
Пример #23
0
        public void We_should_be_able_to_get_an_integer_from_SSO()
        {
            var value = SSO.GetSSOInt32("IKTA.Common", "CommandTimeout");

            Assert.AreEqual(30, value);
        }
Пример #24
0
        //interconexion con el BUS
        private bool InterconectarCredencialesConSSO()
        {
            UserName = Request.QueryString["UserName"];
            Token    = Request.QueryString["Token"];

            if (Request.QueryString["DebugMode"] != null)
            {
                //UserName = "******";
                //Token = "organocontrolinterno01";

                //UserName = "******";
                //Token = "promovente01";

                //UserName = "******";
                //Token = "administrador01";

                //UserName = "******";
                //Token = "desa11";

                //UserName = "******";
                //Token = "desa14";

                //UserName = "******";
                //Token = "*****@*****.**";

                UserName = "******";
                Token    = "desa03";

                //UserName = "******";
                //Token = "genguntza";

                //UserName = "******";
                //Token = "desa10";

                //UserName = "******";
                //Token = "desa04";
            }

            Boolean Ok = false;

            if (String.IsNullOrEmpty(UserName) || String.IsNullOrEmpty(Token))
            {
                redireccionSSO();
            }
            else
            {
                ////interconexion con el BUS para ejecutar metodo
                SSO usuario = null;
                try
                {
                    usuario             = new NG().ObtenerUsuario(UserName);
                    Session["Contexto"] = usuario;

                    if (usuario != null)
                    {
                        String RolUsr = UtilContratosArrto.ObtenerNombreRolUsrApp(usuario.LRol);
                        //if (RolUsr == UtilContratosArrto.Roles.OIC.ToString())
                        //    ScriptManager.RegisterStartupScript(this, typeof(Page), "soloLectura", "ValidarSoloLectura('none');", true);
                    }
                    else
                    {
                        //ScriptManager.RegisterStartupScript(this, typeof(Page), "soloLectura", "ValidarSoloLectura('none');", true);
                        //ScriptManager.RegisterStartupScript(this, typeof(Page), "alertUsuario", "alert('No se ha podido recuperar el objeto Contexto del usuario firmado, contacte al administrador del sistema.');", true);
                    }
                    Ok = true;
                }
                catch (Exception ex)
                {
                    string msj = ex.InnerException == null ? ex.Message : ex.InnerException.Message;
                    Session["Msj"] = msj;
                    Response.Redirect("Msj.aspx", false);
                }
            }
            return(Ok);
        }
Пример #25
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void OnImportSSOCommand(object sender, EventArgs e)
        {
            IVsHierarchy hierarchy = null;
            uint         itemid    = VSConstants.VSITEMID_NIL;

            if (!IsSingleProjectItemSelection(out hierarchy, out itemid))
            {
                return;
            }

            var vsProject = (IVsProject)hierarchy;

            // get the name of the item
            string itemFullPath = null;

            if (ErrorHandler.Failed(vsProject.GetMkDocument(itemid, out itemFullPath)))
            {
                return;
            }

            // Save the project file
            var solution = (IVsSolution)Package.GetGlobalService(typeof(SVsSolution));
            int hr       = solution.SaveSolutionElement((uint)__VSSLNSAVEOPTIONS.SLNSAVEOPT_SaveIfDirty, hierarchy, 0);

            if (hr < 0)
            {
                throw new COMException(string.Format("Failed to add project item", itemFullPath, GetErrorInfo()), hr);
            }

            var selectedProjectItem = GetProjectItemFromHierarchy(hierarchy, itemid);

            if (selectedProjectItem != null)
            {
                string itemFolder    = Path.GetDirectoryName(itemFullPath);
                string itemFilename  = Path.GetFileNameWithoutExtension(itemFullPath);
                string itemExtension = Path.GetExtension(itemFullPath);

                if (itemExtension == ".sso")
                {
                    var dialog = new Dialogs.ImportSSOWithKey(itemFullPath);
                    dialog.ShowDialog();
                    if (!dialog.OK)
                    {
                        return;
                    }
                    // Import the SSO application SSO file
                    SSO sSO = new SSO(Helpers.BizTalk.BizTalkHelper.CompanyName);
                    sSO.SsoEvent += new EventHandler <SSOEventArgs>(SSO_Update);
                    sSO.ImportSSOApplication(dialog.EncryptionKey, itemFilename, new StreamReader(itemFullPath).ReadToEnd());
                }
                else
                {
                    var dialog = new Dialogs.ImportSSO(itemFullPath);
                    dialog.ShowDialog();
                    if (!dialog.OK)
                    {
                        return;
                    }
                    // Import the SSO application XML file
                    SSO sSO = new SSO(Helpers.BizTalk.BizTalkHelper.CompanyName);
                    sSO.SsoEvent += new EventHandler <SSOEventArgs>(SSO_Update);
                    sSO.ImportSSOApplication(itemFilename, itemFullPath);
                }
            }
        }
Пример #26
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //a = int.Parse(Name.Text);
            //b = int.Parse(FName.Text);
            string lname     = Name.Text;
            string fname     = FName.Text;
            string login     = lname + "." + fname;
            string loginnopl = StripText(login);
            string lowlogin  = loginnopl.ToLower();

            LoginG.AppendText(lowlogin);

            string mailadr = loginnopl + "@taurus-ochrona.pl";

            Email.AppendText(mailadr);

            var chars         = "abcdefghijklmnopqrstuvwxyz";
            var numbers       = "0123456789";
            var stringchars   = new Char[3];
            var stringnumbers = new Char[3];
            var random        = new Random();

            for (int i = 0; i < stringchars.Length; i++)
            {
                stringchars[i] = chars[random.Next(chars.Length)];
            }
            var stringcharsfinal = new String(stringchars);

            for (int j = 0; j < stringnumbers.Length; j++)
            {
                stringnumbers[j] = numbers[random.Next(numbers.Length)];
            }
            var stringnumbersfinal = new String(stringnumbers);

            char   zf   = stringcharsfinal[0];
            char   zs   = stringcharsfinal[1];
            char   zt   = stringcharsfinal[2];
            char   lf   = stringnumbersfinal[0];
            char   ls   = stringnumbersfinal[1];
            char   lt   = stringnumbersfinal[2];
            string pass = zf.ToString() + lf.ToString() + zs.ToString() + ls.ToString() + zt.ToString() + lt.ToString();

            PassE.AppendText(pass);

            string sso = "'" + lowlogin + ":" + pass + "' => array(\n    'uid' => array('" + lowlogin + "'),\n    'eduPersonAffiliation' => array('" + lowlogin + "')\n),";

            SSO.AppendText(sso);

            string firstn     = fname.Substring(0, 1);
            string firstl     = lname.Substring(0, 2);
            string enovalogin = firstl.ToUpper() + firstn.ToUpper();

            LoginEn.AppendText(enovalogin);

            string enovapass = PassD.Text;

            PassEn.AppendText(enovapass);


            //MessageBox.Show(lowlogin);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            int  IdInmuebleArrendamiento = 0;
            SSO  SSO           = new SSO();
            bool rolGeneracion = true;

            try
            {
                string IdInmueble = Request.QueryString["IdInmueble"];
                string folio      = Request.QueryString["IdContrato"];
                int    IdUsuario  = 0;
                int.TryParse(IdInmueble, out IdInmuebleArrendamiento);

                if (!IsPostBack)
                {
                    if (Session["Contexto"] == null)
                    {
                        Response.Redirect(ConfigurationManager.AppSettings.Get("URL_SSO") + ConfigurationManager.AppSettings.Get("TokenApp").Replace("-", ""));
                    }

                    IdUsuario = ((SSO)Session["Contexto"]).IdUsuario == null ? 0 : ((SSO)Session["Contexto"]).IdUsuario.Value;

                    if (IdUsuario == 0)
                    {
                        Response.Redirect(ConfigurationManager.AppSettings.Get("URL_SSO") + ConfigurationManager.AppSettings.Get("TokenApp").Replace("-", ""));
                    }

                    if (UtilContratosArrto.ValidarRolAcceso("OIC", (SSO)Session["Contexto"]))
                    {
                        rolGeneracion = false;
                    }

                    if (!rolGeneracion)
                    {
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "PostBack", "MarcarErrorPagina('Permiso');", true);
                        return;
                    }

                    objInmuebleArrto = new NG_InmuebleArrto().ObtenerInmuebleArrto(IdInmuebleArrendamiento);

                    hdnFolio.Value                 = folio;
                    hdnIdPais.Value                = objInmuebleArrto.IdPais.ToString();
                    hdnIdEstado.Value              = objInmuebleArrto.IdEstado.ToString();
                    hdnIdMunicipio.Value           = objInmuebleArrto.IdMunicipio.ToString();
                    hdnIdInmueble.Value            = IdInmueble;
                    hdnInstitucionPromovente.Value = QuitarAcentosTexto(((SSO)Session["Contexto"]).NombreInstitucion);
                    hdnIdUsuario.Value             = IdUsuario.ToString();
                }

                ScriptManager.RegisterStartupScript(this, typeof(Page), "PostBack", "CargaPaginaRegistroConvenio();", true);
            }

            catch (Exception ex)
            {
                BitacoraExcepcion BitacoraExcepcionAplictivo = new BitacoraExcepcion
                {
                    CadenaconexionBD = ConfigurationManager.ConnectionStrings["cnArrendamientoInmueble"].ConnectionString,
                    Aplicacion       = "ContratosArrto",
                    Modulo           = MethodInfo.GetCurrentMethod().DeclaringType.ToString() + ".aspx",
                    Funcion          = MethodBase.GetCurrentMethod().Name + "()",
                    DescExcepcion    = ex.InnerException == null ? ex.Message : ex.InnerException.Message,
                    Usr = ((SSO)Session["Contexto"]).UserName.ToString()
                };

                BitacoraExcepcionAplictivo.RegistrarBitacoraExcepcion();
                BitacoraExcepcionAplictivo = null;
            }
        }
Пример #28
0
 public static bool UsersAdmin(Guid?applicationId)
 {
     return(!SSO.Enabled(applicationId) &&
            get_value(applicationId, RVSettingsItem.ReauthenticationForUsersAdminPage).ToLower() == "true");
 }
Пример #29
0
 private void LoginToCharacterToolStripMenuItem_Click(object sender, EventArgs e)
 {
     SSO.StartRequest();
 }
Пример #30
0
 public static T[] ToMany <T>(this string text, string?separator = "\n", SSO splitOptions = SSO.TrimEntries | SSO.RemoveEmptyEntries) => text.SplitAtNewLines(separator, splitOptions).Select(line => line.To <T>()).ToArray();