/// <summary> /// Intenta obtener el token del soap header del web service /// </summary> /// <returns></returns> public bool traerDatosToken() { bool bRta = false; try { byte[] data = new byte[Convert.ToInt32(System.Web.HttpContext.Current.Request.InputStream.Length)]; System.Web.HttpContext.Current.Request.InputStream.Position = 0; System.Web.HttpContext.Current.Request.InputStream.Read(data, 0, Convert.ToInt32(System.Web.HttpContext.Current.Request.InputStream.Length)); UTF8Encoding encoding = new UTF8Encoding(); string decodedString = encoding.GetString(data); // cargo el soap xml XmlDataDocument myXmlDocument = new XmlDataDocument(); myXmlDocument.LoadXml(decodedString); XmlNodeList xmlToken = myXmlDocument.GetElementsByTagName("token"); // genero el token SSOEncodedToken encToken = new SSOEncodedToken(); encToken.Token = xmlToken.Item(0).InnerText; token = Credencial.ObtenerCredencialEnWs(encToken); bRta = true; } catch (Exception ex) { bRta = false; } return(bRta); }
public User ObtenerDatosToken(Microsoft.AspNetCore.Http.IHeaderDictionary header, string tag) { try { var user = new User(); var tokenEnviado = new SSOEncodedToken(); tokenEnviado.Token = header.ContainsKey(tag) ? Convert.ToString(header[tag]) : string.Empty; if (!string.IsNullOrEmpty(tokenEnviado.Token) && tokenEnviado.Token.Length > 0) { credenciales = Credencial.ObtenerCredencialEnWs(tokenEnviado); if (credenciales != null) { //Entity - CUIT user.Entity = credenciales.Operation.Login.Entity; // user.HasToken = true; user.Sistema = credenciales.Operation.Login.System; //Perfil user.Perfil = credenciales.Operation.Login.Groups[0].Name; //Cuil user.CUIL = credenciales.Operation.Login.CUIL; //Legajo - Uid user.UserId = credenciales.Operation.Login.UId; //verificamos el grupo y la info //****************************** user.UserName = credenciales.Operation.Login.UserName; //deteccion del cuil - para CVSS en el campo UId estara el CUIL de la persona. //Para aplicaciones internas el UId tendra el Usuario del operador try { user.Cuip = string.IsNullOrEmpty(credenciales.Operation.Login.UId) ? 0 : long.Parse(credenciales.Operation.Login.UId); } catch { user.Cuip = 0; user.UserName = credenciales.Operation.Login.UId; } //Nombre user.Nombre = credenciales.Operation.Login.UserName; for (int i = 0; i < credenciales.Operation.Login.Info.Length; i++) { switch (credenciales.Operation.Login.Info[i].Name) { case "nombre": user.Nombre = credenciales.Operation.Login.Info[i].Value; break; case "ip": user.IP = credenciales.Operation.Login.Info[i].Value; break; case "oficina": user.Oficina = credenciales.Operation.Login.Info[i].Value; break; case "oficinadesc": user.OficinaDetalle = credenciales.Operation.Login.Info[i].Value; break; default: break; } } return(user); } throw new Exception("Ha ocurrido un error al obtener las credenciales del usuario, por favor verifique que ha enviado el token con sus credenciales"); } throw new Exception("Ha ocurrido un error al obtener el token, por favor verifique que el mismo fue enviado"); } catch (Exception ex) { log.Error("Credenciales - " + ex.Message); throw ex; } return(null); }