public static OracleConnection RetornaConexao(OracleCon acesso, bool mensagem) { OracleConnection conexao = new OracleConnection(); try { var conString = "Data Source=" + "(DESCRIPTION=(ADDRESS=(PROTOCOL=" + Cripto.Decrypt(acesso.Protocol) + ")" + "(HOST=" + Cripto.Decrypt(acesso.Host) + ")(PORT=" + Cripto.Decrypt(acesso.Port) + "))" + "(CONNECT_DATA=(SERVICE_NAME=" + Cripto.Decrypt(acesso.ServiceName) + ")));" + "User Id = " + Cripto.Decrypt(acesso.User) + "; Password = "******"; "; conexao.ConnectionString = conString; conexao.Open(); //var retorno = conexao.State.ToString() == "Open" ? conexao : null; } catch (Exception e) { XtraMessageBox.Show("Não foi possível abrir a conexão com o Banco de Dados " + Cripto.Decrypt(acesso.SystemName) + "! \n" + e.Message, "Sem conexão", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (mensagem && conexao.State.ToString() == "Open") { XtraMessageBox.Show("Conexão com o Banco de Dados " + Cripto.Decrypt(acesso.SystemName) + " efetuada com sucesso! \n", "Conexão", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(conexao); }
/* * Método privado que encripta parte del documento con encriptación simétrica * */ private XmlDocument EncriptarParteDelDocumentoSimetrico(XmlDocument doc) { Cripto.EncryptSymmetric(doc, "encripted", this._symmetricKey); return(doc); }
//Constructor para mensajes (no conexion) public PostBox(string source, string destination, string tipoMensaje, string db_name, string db_type, XmlNode body, SymmetricAlgorithm symmetricKey, Cripto keyPair) { this._process = new Process(); this._messageRequest = new Message(source, destination, tipoMensaje, db_name, db_type, body); this._messageResponse = new Message(); this._symmetricKey = symmetricKey; this._keyPair = keyPair; this._publicKeyClient = Cripto.ImportPublicKey(Constants.PathClavePublica(destination)); }
/* * Método privado que desencripta parte del documento con encriptación simétrica * */ private XmlDocument DesencriptarParteDelDocumentoSimetrico(XmlDocument doc) { Cripto.DecryptSymmetric(doc, this._symmetricKey); return(doc); }
public async Task <IActionResult> loginAsync([FromServices] DataContext _ctx, [FromServices] TokenService _tokenService, [FromBody] UserAuthViewModel user) { var cred = await _ctx.Users.AsNoTracking() .FirstOrDefaultAsync(x => x.Email == user.Email && x.Password == Cripto.md5(user.Password)); if (cred == null) { return(NotFound(new { message = "Invalid email or password" })); } var token = _tokenService.GenerateToken(cred); return(StatusCode(200, new { token })); }
public ActionResult UsuarioFrm(string chaveurl) { int idUsuario = 0; string Acao = ""; if (!string.IsNullOrEmpty(chaveurl)) { List <ParametroCriptografia> param = Cripto.DescriptografarUrl(chaveurl, Key); Int32.TryParse(param.First(p => p.Name == "idUsuario").Value, out idUsuario); Acao = param.First(p => p.Name == "Acao").Value; } ViewBag.Acao = Acao; int usuarioId = (int)Geral.PegaAuthTicket("UsuarioId"); int grupoId = (int)Geral.PegaAuthTicket("Grupo"); int contratanteId = (int)Geral.PegaAuthTicket("ContratanteId"); UsuarioAdministracaoModel modelo; ViewBag.CONTRATANTE_ID = new SelectList(contratanteBP.ListarTodos(grupoId), "ID", "RAZAO_SOCIAL", contratanteId); //Incluir if (string.IsNullOrEmpty(Acao)) { modelo = new UsuarioAdministracaoModel(); modelo.SelectedGroupsPapel = new int[0]; modelo.SelectedGroupsPerfil = new int[0]; } else { modelo = Mapper.Map <UsuarioAdministracaoModel>(usuarioBP.BuscarPorId(idUsuario)); if (modelo == null) { return(HttpNotFound()); } modelo.SelectedGroupsPapel = modelo.PapelList.Select(x => x.Id).ToArray(); modelo.SelectedGroupsPerfil = modelo.PerfilList.Select(x => x.Id).ToArray(); } modelo.PapelList = papelBP.ListarTodos(contratanteId) .Where(x => x.PAPEL_TP_ID == null) .Select(x => new PapelAdministracaoModel { Id = x.ID, Selecionado = modelo.SelectedGroupsPapel.Contains(x.ID), Nome = x.PAPEL_NM, Sigla = x.PAPEL_SGL }).ToList(); modelo.PerfilList = perfilBP.ListarTodosPorContratante(contratanteId) .Select(x => new PerfilAdministracaoModel { Id = x.ID, Nome = x.PERFIL_NM, Selecionado = modelo.SelectedGroupsPerfil.Contains(x.ID), }).ToList(); return(View(modelo)); }
public ActionResult PerfilFrm(string chaveurl) { int id; string Acao; if (!string.IsNullOrEmpty(chaveurl)) { List <ParametroCriptografia> param = Cripto.DescriptografarUrl(chaveurl, Key); Int32.TryParse(param.First(p => p.Name == "idPerfil").Value, out id); Acao = param.First(p => p.Name == "Acao").Value; } else { id = 0; Acao = "Incluir"; } ViewBag.Acao = Acao; PerfilAdministracaoModel modelo; int grupoId = (int)Geral.PegaAuthTicket("Grupo"); int ContratanteId = (int)Geral.PegaAuthTicket("ContratanteId"); ViewBag.CONTRATANTE_ID = new SelectList(_contratanteBP.ListarTodos(grupoId), "ID", "RAZAO_SOCIAL", ContratanteId); if (Acao == "Incluir") { modelo = new PerfilAdministracaoModel { FuncaoList = _funcaoBP.ListarTodos(ContratanteId).Select(x => new FuncaoAdministracaoModel() { Id = x.ID, Descricao = x.FUNCAO_DSC, Nome = x.FUNCAO_NM, AplicacaoId = 1, FuncaoList = x.FUNCOES.Select(y => new FuncaoAdministracaoModel() { Id = y.ID, Nome = y.FUNCAO_NM, Tela = y.FUNCAO_TELA, Codigo = y.CODIGO, FuncaoList = y.FUNCOES.Select(z => new FuncaoAdministracaoModel() { Id = z.ID, Nome = z.FUNCAO_NM, Tela = z.FUNCAO_TELA, Codigo = z.CODIGO }).ToList() }).ToList() }).ToList() }; } else { modelo = Mapper.Map <PerfilAdministracaoModel>(_perfilBP.BuscarPorId(id), opt => opt.Items["Url"] = Url); modelo.FuncaoList = _funcaoBP.ListarTodos(ContratanteId).OrderBy(x => x.FUNCAO_NM) .Select(x => new FuncaoAdministracaoModel() { Id = x.ID, Selecionado = modelo.FuncaoList.FirstOrDefault(y => y.Id == x.ID) != null, Nome = x.FUNCAO_NM, Tela = x.FUNCAO_TELA, Codigo = x.CODIGO, FuncaoList = x.FUNCOES.Select(y => new FuncaoAdministracaoModel() { Id = y.ID, Selecionado = modelo.FuncaoList.FirstOrDefault(yy => yy.Id == y.ID) != null, Nome = y.FUNCAO_NM, Tela = y.FUNCAO_TELA, Codigo = y.CODIGO, FuncaoList = y.FUNCOES.Select(z => new FuncaoAdministracaoModel() { Id = z.ID, Selecionado = modelo.FuncaoList.FirstOrDefault(zz => zz.Id == z.ID) != null, Nome = z.FUNCAO_NM, Tela = z.FUNCAO_TELA, Codigo = z.CODIGO }).ToList() }).ToList() }).ToList(); } return(View(modelo)); }
/* * Método privado para leer el fichero de configuración * */ private void ParseConf() { if (File.Exists(Constants.CONF_DATABASES)) { //Archivo a leer StreamReader conFile = File.OpenText(Constants.CONF_DATABASES); string line = conFile.ReadLine(); this._databases = new Dictionary <string, List <Tuple <string, string, string> > >(); //Voy leyendo línea por línea while (line != null) { int i = 0; bool param = true, secondParam = false, thirdParam = false; string parameter = "", valor = "", usuario = "", contrasenia = ""; /* * * database_type=database_name; * * Ejemplos: * mysql*usuarios|pepe*contraseniaEncriptada; * mongodb*empleados; * */ //Leemos el parámetro while (line[i] != ';') { //Ignoramos el igual y lo usamos como marca que separa el parámetro de su valor if (line[i] == '*') { param = false; if (secondParam) { thirdParam = true; } } else if (line[i] == '|') { secondParam = true; param = true; } else if (param && !secondParam && !thirdParam) { parameter += line[i]; } else if (!param && !secondParam && !thirdParam) { valor += line[i]; } else if (param && secondParam && !thirdParam) { usuario += line[i]; } else if (thirdParam) { contrasenia += line[i]; } i++; } if (usuario == "") { usuario = null; } if (contrasenia == "") { contrasenia = null; } else { contrasenia = Cripto.DecryptStringFromBytes(this._symmetric, Convert.FromBase64String(contrasenia)); } if (this._databases.ContainsKey(parameter)) { Tuple <string, string, string> tupla = new Tuple <string, string, string>(valor, usuario, contrasenia); this._databases[parameter].Add(tupla); } else { List <Tuple <string, string, string> > aux = new List <Tuple <string, string, string> >(); Tuple <string, string, string> tupla = new Tuple <string, string, string>(valor, usuario, contrasenia); aux.Add(tupla); this._databases.Add(parameter, aux); } line = conFile.ReadLine(); } conFile.Close(); } else { this._databases = new Dictionary <string, List <Tuple <string, string, string> > >(); } }