private static bool IsValid(HttpRequestMessage request) { var header = request.Headers; if (header.Authorization != null && header.Authorization.Scheme.Equals(SCHEME)) { var credentials = header.Authorization.Parameter; if (!string.IsNullOrWhiteSpace(credentials)) { var decodedCredentials = Encoding.UTF8.GetString(Convert.FromBase64String(credentials)); string[] split = decodedCredentials.Split(':'); string username = split[0].Trim(); string password = split[1].Trim(); CFG_UsuarioAPI userAPI = CFG_UsuarioAPIBO.SelecionaAtivos().FirstOrDefault(p => p.uap_username.Equals(username)); if (userAPI != null) { return(userAPI.uap_password.Equals(password)); } } } return(false); }
protected void grvUsuarioAPI_DataBinding(object sender, EventArgs e) { try { GridView grv = ((GridView)sender); if (grv.DataSource == null) { VS_ltUsuarioAPI = CFG_UsuarioAPIBO.SelecionaAtivos(); grv.DataSource = VS_ltUsuarioAPI; } } catch (Exception ex) { ApplicationWEB._GravaErro(ex); lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar carregar usuários API.", UtilBO.TipoMensagem.Erro); updMessage.Update(); } }