コード例 #1
0
        public IAgentInfo GetAgent(UUID PrincipalID)
        {
            NameValueCollection requestArgs = new NameValueCollection
                                                  {
                                                      {"RequestMethod", "GetUser"},
                                                      {"UserID", PrincipalID.ToString()}
                                                  };

            OSDMap result = PostData(PrincipalID, requestArgs);

            if (result == null)
                return null;

            if (result.ContainsKey("AgentInfo"))
            {
                OSDMap agentmap = (OSDMap) OSDParser.DeserializeJson(result["AgentInfo"].AsString());

                IAgentInfo agent = new IAgentInfo();
                agent.FromOSD(agentmap);

                return agent;
            }

            return null;
        }
コード例 #2
0
        public IAgentInfo GetAgent(UUID agentID)
        {
            /*object remoteValue = DoRemoteForUser(agentID, agentID);
            if (remoteValue != null)
                return (IAgentInfo)remoteValue;*/
            IAgentInfo agent = new IAgentInfo();
            List<string> query = null;
            try
            {
                QueryFilter filter = new QueryFilter();
                filter.andFilters["ID"] = agentID;
                filter.andFilters["`Key`"] = "AgentInfo";
                query = GD.Query(new string[1] { "`Value`" }, "userdata", filter, null, null, null);
            }
            catch
            {
            }

            if (query == null || query.Count == 0)
            {
                return null; //Couldn't find it, return null then.
            }

            OSDMap agentInfo = (OSDMap) OSDParser.DeserializeLLSDXml(query[0]);

            agent.FromOSD(agentInfo);
            agent.PrincipalID = agentID;
            return agent;
        }
コード例 #3
0
ファイル: BanCheck.cs プロジェクト: samiam123/Aurora-Sim
        public LoginResponse Login(Hashtable request, UserAccount account, IAgentInfo agentInfo, string authType, string password, out object data)
        {
            data = null;

            string ip = "";
            string version = "";
            string platform = "";
            string mac = "";
            string id0 = "";

            if (request != null)
            {
                ip = request.ContainsKey("ip") ? (string)request["ip"] : "";
                version = request.ContainsKey("version") ? (string)request["version"] : "";
                platform = request.ContainsKey("platform") ? (string)request["platform"] : "";
                mac = request.ContainsKey("mac") ? (string)request["mac"] : "";
                id0 = request.ContainsKey("id0") ? (string)request["id0"] : "";
            }

            string message;
            if(!m_module.CheckUser(account.PrincipalID, ip,
                version,
                platform,
                mac,
                id0, out message))
            {
                return new LLFailedLoginResponse(LoginResponseEnum.Indeterminant, message, false);
            }
            return null;
        }
コード例 #4
0
        /// <summary>
        /// Gets the info about the agent (TOS data, maturity info, language, etc)
        /// </summary>
        /// <param name="agentID"></param>
        /// <returns></returns>
        public IAgentInfo GetAgent(UUID agentID)
		{
			IAgentInfo agent = new IAgentInfo();
            List<string> query = null;
            try
            {
                query = GD.Query(new string[] { "ID", "`Key`" }, new object[] { agentID, "AgentInfo" }, "userdata", "Value");
            }
            catch
            {
            }
            if (query == null || query.Count == 0)
                return null; //Couldn't find it, return null then.

            OSDMap agentInfo = (OSDMap)OSDParser.DeserializeLLSDXml(query[0]);

            agent.PrincipalID = agentID;
            agent.AcceptTOS = agentInfo["AcceptTOS"].AsInteger() == 1;
            agent.Flags = (IAgentFlags)agentInfo["AcceptTOS"].AsUInteger();
            agent.MaturityRating = agentInfo["MaturityRating"].AsInteger();
            agent.MaxMaturity = agentInfo["MaxMaturity"].AsInteger();
            agent.Language = agentInfo["Language"].AsString();
            agent.LanguageIsPublic = agentInfo["LanguageIsPublic"].AsInteger() == 1;
			return agent;
		}
コード例 #5
0
        public IAgentInfo GetAgent(UUID PrincipalID)
        {
            IAgentInfo agent;
            if (!m_cache.TryGetValue(PrincipalID, out agent))
                return agent;
                        
            Dictionary<string, object> sendData = new Dictionary<string, object>();

            sendData["PRINCIPALID"] = PrincipalID.ToString();
            sendData["METHOD"] = "getagent";

            string reqString = WebUtils.BuildQueryString(sendData);

            try
            {
                foreach (string m_ServerURI in m_ServerURIs)
                {
                    string reply = SynchronousRestFormsRequester.MakeRequest("POST",
                            m_ServerURI + "/auroradata",
                            reqString);
                    if (reply != string.Empty)
                    {
                        Dictionary<string, object> replyData = WebUtils.ParseXmlResponse(reply);

                        if (replyData != null)
                        {
                            if (!replyData.ContainsKey("result"))
                                return null;

                            Dictionary<string, object>.ValueCollection replyvalues = replyData.Values;
                            foreach (object f in replyvalues)
                            {
                                if (f is Dictionary<string, object>)
                                {
                                    agent = new IAgentInfo();
                                    agent.FromKVP((Dictionary<string, object>)f);
                                    m_cache.AddOrUpdate(PrincipalID, agent, new TimeSpan(0, 30, 0));
                                }
                                else
                                    m_log.DebugFormat("[AuroraRemoteAgentConnector]: GetAgent {0} received invalid response type {1}",
                                        PrincipalID, f.GetType());
                            }
                            // Success
                            return agent;
                        }

                        else
                            m_log.DebugFormat("[AuroraRemoteAgentConnector]: GetAgent {0} received null response",
                                PrincipalID);
                    }
                }
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[AuroraRemoteAgentConnector]: Exception when contacting server: {0}", e.ToString());
            }

            return null;
        }
コード例 #6
0
        public void UpdateAgent(IAgentInfo agent)
        {
            NameValueCollection requestArgs = new NameValueCollection
            {
                { "RequestMethod", "AddUserData" },
                { "UserID", agent.PrincipalID.ToString() },
                { "AgentInfo", OSDParser.SerializeJsonString(agent.ToOSD()) }
            };

            PostData(agent.PrincipalID, requestArgs);
        }
コード例 #7
0
ファイル: LocalAgentConnector.cs プロジェクト: kow/Aurora-Sim
        /// <summary>
        /// Updates the language and maturity params of the agent.
        /// Note: we only allow for this on the grid side
        /// </summary>
        /// <param name="agent"></param>
        public void UpdateAgent(IAgentInfo agent)
		{
            List<object> SetValues = new List<object>();
            List<string> SetRows = new List<string>();
            SetRows.Add("Value");
            SetValues.Add(OSDParser.SerializeLLSDXmlString(agent.ToOSD()));
            
            
            List<object> KeyValue = new List<object>();
            List<string> KeyRow = new List<string>();
            KeyRow.Add("ID");
            KeyValue.Add(agent.PrincipalID);
            KeyRow.Add("`Key`");
            KeyValue.Add("AgentInfo");
            GD.Update("userdata", SetValues.ToArray(), SetRows.ToArray(), KeyRow.ToArray(), KeyValue.ToArray());
		}
コード例 #8
0
 public LoginResponse Login(Hashtable request, UserAccount account, IAgentInfo agentInfo, string authType, string password, out object data)
 {
     data = null;
     //
     // Authenticate this user
     //
     if (authType == "UserAccount")
     {
         password = password.StartsWith("$1$") ? password.Remove(0, 3) : Util.Md5Hash(password); //remove $1$
     }
     string token = m_AuthenticationService.Authenticate(account.PrincipalID, authType, password, 30);
     UUID secureSession = UUID.Zero;
     if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out secureSession)))
         return LLFailedLoginResponse.AuthenticationProblem;
     data = secureSession;
     return null;
 }
コード例 #9
0
        public IAgentInfo GetAgent(UUID PrincipalID)
        {
            NameValueCollection requestArgs = new NameValueCollection
            {
                { "RequestMethod", "GetUser" },
                { "AgentID", PrincipalID.ToString() }
            };

            OSDMap result = PostData(PrincipalID, requestArgs);

            if (result == null)
                return null;

            Dictionary<string, object> dresult = Util.OSDToDictionary(result);
            IAgentInfo agent = new IAgentInfo(dresult);

            return agent;
        }
コード例 #10
0
        /// <summary>
        /// Gets the info about the agent (TOS data, maturity info, language, etc)
        /// </summary>
        /// <param name="agentID"></param>
        /// <returns></returns>
        public IAgentInfo GetAgent(UUID agentID)
		{
			IAgentInfo agent = new IAgentInfo();
            List<string> query = null;
            try
            {
                query = GD.Query(new string[] { "ID", "`Key`" }, new object[] { agentID, "AgentInfo" }, "userdata", "Value");
            }
            catch
            {
            }
            if (query == null || query.Count == 0)
                return null; //Couldn't find it, return null then.

            OSDMap agentInfo = (OSDMap)OSDParser.DeserializeLLSDXml(query[0]);

            agent.FromOSD(agentInfo);
			return agent;
		}
コード例 #11
0
ファイル: ISimulationService.cs プロジェクト: Gnu32/Silverfin
 public override void FromOSD(OSDMap map)
 {
     AgentInfo = new IAgentInfo();
     AgentInfo.FromOSD((OSDMap)(map["AgentInfo"]));
     UserAccount = new UserAccount();
     UserAccount.FromOSD((OSDMap)(map["UserAccount"]));
     if (!map.ContainsKey("ActiveGroup"))
         ActiveGroup = null;
     else
     {
         ActiveGroup = new GroupMembershipData();
         ActiveGroup.FromOSD((OSDMap)(map["ActiveGroup"]));
     }
     GroupMemberships = ((OSDArray)map["GroupMemberships"]).ConvertAll<GroupMembershipData>((o) => 
         {
             GroupMembershipData group = new GroupMembershipData();
             group.FromOSD((OSDMap)o);
             return group;
         });
 }
コード例 #12
0
        public void UpdateAgent(IAgentInfo agent)
        {
            CacheAgent(agent);
            object remoteValue = DoRemoteForUser(agent.PrincipalID, agent.ToOSD());
            if (remoteValue != null || m_doRemoteOnly)
                return;

            Dictionary<string, object> values = new Dictionary<string, object>(1);
            values["Value"] = OSDParser.SerializeLLSDXmlString(agent.ToOSD());

            QueryFilter filter = new QueryFilter();
            filter.andFilters["ID"] = agent.PrincipalID;
            filter.andFilters["`Key`"] = "AgentInfo";

            GD.Update("userdata", values, null, filter, null, null);
        }
コード例 #13
0
        public void UpdateAgent(IAgentInfo agent)
        {
            /*object remoteValue = DoRemoteForUser(agent.PrincipalID, agent.ToOSD());
            if (remoteValue != null)
                return;*/

            List<object> SetValues = new List<object> {OSDParser.SerializeLLSDXmlString(agent.ToOSD())};
            List<string> SetRows = new List<string> {"Value"};


            List<object> KeyValue = new List<object> {agent.PrincipalID, "AgentInfo"};

            List<string> KeyRow = new List<string> {"ID", "`Key`"};

            GD.Update("userdata", SetValues.ToArray(), SetRows.ToArray(), KeyRow.ToArray(), KeyValue.ToArray());
        }
コード例 #14
0
        public IAgentInfo GetAgent(UUID PrincipalID)
        {
            IAgentInfo agent;
            if (!m_cache.TryGetValue(PrincipalID, out agent))
                return agent;

            Dictionary<string, object> sendData = new Dictionary<string, object>();

            sendData["PRINCIPALID"] = PrincipalID.ToString();
            sendData["METHOD"] = "getagent";

            string reqString = WebUtils.BuildQueryString(sendData);

            try
            {
                List<string> m_ServerURIs =
                    m_registry.RequestModuleInterface<IConfigurationService>().FindValueOf(PrincipalID.ToString(),
                                                                                           "RemoteServerURI");
                foreach (Dictionary<string, object> replyData in from m_ServerURI in m_ServerURIs select SynchronousRestFormsRequester.MakeRequest("POST",
                                                                                                                                   m_ServerURI + "/auroradata",
                                                                                                                                   reqString) into reply where reply != string.Empty select WebUtils.ParseXmlResponse(reply))
                {
                    if (replyData != null)
                    {
                        if (!replyData.ContainsKey("result"))
                            return null;

                        Dictionary<string, object>.ValueCollection replyvalues = replyData.Values;
                        foreach (object f in replyvalues)
                        {
                            if (f is Dictionary<string, object>)
                            {
                                agent = new IAgentInfo();
                                agent.FromKVP((Dictionary<string, object>) f);
                                m_cache.AddOrUpdate(PrincipalID, agent, new TimeSpan(0, 30, 0));
                            }
                            else
                                MainConsole.Instance.DebugFormat(
                                    "[AuroraRemoteAgentConnector]: GetAgent {0} received invalid response type {1}",
                                    PrincipalID, f.GetType());
                        }
                        // Success
                        return agent;
                    }

                    else
                        MainConsole.Instance.DebugFormat("[AuroraRemoteAgentConnector]: GetAgent {0} received null response",
                                          PrincipalID);
                }
            }
            catch (Exception e)
            {
                MainConsole.Instance.DebugFormat("[AuroraRemoteAgentConnector]: Exception when contacting server: {0}", e);
            }

            return null;
        }
コード例 #15
0
 public void UpdateAgent(IAgentInfo agent)
 {
     try
     {
         List<string> serverURIs =
             m_registry.RequestModuleInterface<IConfigurationService>().FindValueOf(
                 agent.PrincipalID.ToString(), "RemoteServerURI");
         foreach (string url in serverURIs)
         {
             OpenMetaverse.StructuredData.OSDMap map = new OpenMetaverse.StructuredData.OSDMap();
             map["Method"] = "updateagent";
             map["Agent"] = agent.ToOSD();
             WebUtils.PostToService(url + "osd", map, false, false);
         }
     }
     catch (Exception e)
     {
         MainConsole.Instance.DebugFormat("[AuroraRemoteAgentConnector]: Exception when contacting server: {0}", e);
     }
 }
コード例 #16
0
        public LoginResponse Login(Hashtable request, UserAccount account, IAgentInfo agentInfo, string authType, string password, out object data)
        {
            data = null;

            if (request == null)
                return null;//If its null, its just a verification request, allow them to see things even if they are banned

            bool tosExists = false;
            string tosAccepted = "";
            if (request.ContainsKey("agree_to_tos"))
            {
                tosExists = true;
                tosAccepted = request["agree_to_tos"].ToString();
            }

            //MAC BANNING START
            string mac = (string)request["mac"];
            if (mac == "")
                return new LLFailedLoginResponse(LoginResponseEnum.Indeterminant, "Bad Viewer Connection", false);

            string channel = "Unknown";
            if (request.Contains("channel") && request["channel"] != null)
                channel = request["channel"].ToString();

            IAgentConnector agentData = Aurora.DataManager.DataManager.RequestPlugin<IAgentConnector>();
            if (mac != "")
            {
                string reason = "";
                if (!agentData.CheckMacAndViewer(mac, channel, out reason))
                    return new LLFailedLoginResponse(LoginResponseEnum.Indeterminant,
                        reason, false);
            }
            bool AcceptedNewTOS = false;
            //This gets if the viewer has accepted the new TOS
            if (!agentInfo.AcceptTOS && tosExists)
            {
                if (tosAccepted == "0")
                    AcceptedNewTOS = false;
                else if (tosAccepted == "1")
                    AcceptedNewTOS = true;
                else
                    AcceptedNewTOS = bool.Parse(tosAccepted);

                if (agentInfo.AcceptTOS != AcceptedNewTOS)
                {
                    agentInfo.AcceptTOS = AcceptedNewTOS;
                    agentData.UpdateAgent(agentInfo);
                }
            }
            if (!AcceptedNewTOS && !agentInfo.AcceptTOS && m_UseTOS)
            {
                StreamReader reader = new StreamReader(Path.Combine(Environment.CurrentDirectory, m_TOSLocation));
                string TOS = reader.ReadToEnd();
                reader.Close();
                reader.Dispose();
                return new LLFailedLoginResponse(LoginResponseEnum.ToSNeedsSent, TOS, false);
            }

            if ((agentInfo.Flags & IAgentFlags.PermBan) == IAgentFlags.PermBan)
            {
                MainConsole.Instance.InfoFormat("[LLOGIN SERVICE]: Login failed for user {0}, reason: user is permanently banned.", account.Name);
                return LLFailedLoginResponse.PermanentBannedProblem;
            }

            if ((agentInfo.Flags & IAgentFlags.TempBan) == IAgentFlags.TempBan)
            {
                bool IsBanned = true;
                string until = "";

                if (agentInfo.OtherAgentInformation.ContainsKey("TemperaryBanInfo"))
                {
                    DateTime bannedTime = agentInfo.OtherAgentInformation["TemperaryBanInfo"].AsDate();
                    until = string.Format(" until {0} {1}", bannedTime.ToShortDateString(), bannedTime.ToLongTimeString());

                    //Check to make sure the time hasn't expired
                    if (bannedTime.Ticks < DateTime.Now.Ticks)
                    {
                        //The banned time is less than now, let the user in.
                        IsBanned = false;
                    }
                }

                if (IsBanned)
                {
                    MainConsole.Instance.InfoFormat("[LLOGIN SERVICE]: Login failed for user {0}, reason: user is temporarily banned {0}.", until, account.Name);
                    return new LLFailedLoginResponse(LoginResponseEnum.Indeterminant, string.Format("You are blocked from connecting to this service{0}.", until), false);
                }
            }
            return null;
        }
コード例 #17
0
ファイル: BanCheck.cs プロジェクト: samiam123/Aurora-Sim
 public LoginResponse Login(Hashtable request, UserAccount account, IAgentInfo agentInfo, string authType, string password, out object data)
 {
     data = null;
     string ip = request != null && request.ContainsKey("ip") ? (string)request["ip"] : "127.0.0.1";
     ip = ip.Split(':')[0];//Remove the port
     IPAddress userIP = IPAddress.Parse(ip);
     if (IPBans.Contains(userIP))
         return new LLFailedLoginResponse(LoginResponseEnum.Indeterminant, "Your account cannot be accessed on this computer.", false);
     foreach (string ipRange in IPRangeBans)
     {
         string[] split = ipRange.Split('-');
         if (split.Length != 2)
             continue;
         IPAddress low = IPAddress.Parse(ip);
         IPAddress high = IPAddress.Parse(ip);
         NetworkUtils.IPAddressRange range = new NetworkUtils.IPAddressRange(low, high);
         if (range.IsInRange(userIP))
             return new LLFailedLoginResponse(LoginResponseEnum.Indeterminant, "Your account cannot be accessed on this computer.", false);
     }
     return null;
 }
コード例 #18
0
 public void UpdateAgent(IAgentInfo agent)
 {
     //No creating from sims!
 }
コード例 #19
0
        public byte[] UpdateAgent(OSDMap request)
        {
            IAgentInfo UserProfile = new IAgentInfo();
            UserProfile.FromOSD((OSDMap)request["Agent"]);
            IAgentInfo oldAgent = AgentConnector.GetAgent(UserProfile.PrincipalID);
            foreach (KeyValuePair<string, OSD> kvp in UserProfile.OtherAgentInformation)
                if (!oldAgent.OtherAgentInformation.ContainsKey(kvp.Key))
                    oldAgent.OtherAgentInformation[kvp.Key] = kvp.Value;
            AgentConnector.UpdateAgent(oldAgent);
            OSDMap result = new OSDMap();
            result["result"] = "Successful";

            string xmlString = OSDParser.SerializeJsonString(result);
            //MainConsole.Instance.DebugFormat("[AuroraDataServerPostHandler]: resp string: {0}", xmlString);
            UTF8Encoding encoding = new UTF8Encoding();
            return encoding.GetBytes(xmlString);
        }
コード例 #20
0
        /// <summary>
        /// Updates the language and maturity params of the agent.
        /// Note: we only allow for this on the grid side
        /// </summary>
        /// <param name="agent"></param>
        public void UpdateAgent(IAgentInfo agent)
		{
            Dictionary<string, object> Values = new Dictionary<string, object>();
            Values.Add("AcceptTOS", agent.AcceptTOS ? 1 : 0);
            //Values.Add("Flags", agent.Flags); Don't allow regions to set this
            Values.Add("MaturityRating", agent.MaturityRating);
            Values.Add("MaxMaturity", agent.MaxMaturity);
            Values.Add("Language", agent.Language);
            Values.Add("LanguageIsPublic", agent.LanguageIsPublic ? 1 : 0);
            
            
            List<object> SetValues = new List<object>();
            List<string> SetRows = new List<string>();
            SetRows.Add("Value");

            OSDMap map = Util.DictionaryToOSD(Values);
            SetValues.Add(OSDParser.SerializeLLSDXmlString(map));
            
            
            List<object> KeyValue = new List<object>();
            List<string> KeyRow = new List<string>();
            KeyRow.Add("ID");
            KeyValue.Add(agent.PrincipalID);
            KeyRow.Add("`Key`");
            KeyValue.Add("AgentInfo");
            GD.Update("userdata", SetValues.ToArray(), SetRows.ToArray(), KeyRow.ToArray(), KeyValue.ToArray());
		}
コード例 #21
0
 public override IDataTransferable Duplicate()
 {
     IAgentInfo m = new IAgentInfo();
     m.FromOSD(ToOSD());
     return m;
 }
コード例 #22
0
        public void CreateNewAgent(UUID PrincipalID)
        {
            IAgentInfo info = new IAgentInfo {PrincipalID = PrincipalID};

            NameValueCollection requestArgs = new NameValueCollection
                                                  {
                                                      {"RequestMethod", "AddUserData"},
                                                      {"UserID", info.PrincipalID.ToString()},
                                                      {"AgentInfo", OSDParser.SerializeJsonString(info.ToOSD())}
                                                  };

            PostData(info.PrincipalID, requestArgs);
        }
コード例 #23
0
        /// <summary>
        /// Creates a new database entry for the agent.
        /// Note: we only allow for this on the grid side
        /// </summary>
        /// <param name="agentID"></param>
        public void CreateNewAgent(UUID agentID)
		{
            List<object> values = new List<object>();
            values.Add(agentID);
            values.Add("AgentInfo");
            IAgentInfo info = new IAgentInfo();
            info.PrincipalID = agentID;
            values.Add(OSDParser.SerializeLLSDXmlString(info.ToOSD())); //Value which is a default Profile
            GD.Insert("userdata", values.ToArray());
		}
コード例 #24
0
 public void CacheAgent(IAgentInfo agent)
 {
     m_cache.Cache(agent.PrincipalID, agent);
 }
コード例 #25
0
        /// <summary>
        /// Updates the language and maturity params of the agent.
        /// Note: we only allow for this on the grid side
        /// </summary>
        /// <param name="agent"></param>
        public void UpdateAgent(IAgentInfo agent)
		{
            List<object> SetValues = new List<object> {OSDParser.SerializeLLSDXmlString(agent.ToOSD())};
            List<string> SetRows = new List<string> {"Value"};
           
            
            
            List<object> KeyValue = new List<object> {agent.PrincipalID, "AgentInfo"};

            List<string> KeyRow = new List<string> {"ID", "`Key`"};

            GD.Update("userdata", SetValues.ToArray(), SetRows.ToArray(), KeyRow.ToArray(), KeyValue.ToArray());
		}