/// <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> {agentID, "AgentInfo"};
     IAgentInfo info = new IAgentInfo {PrincipalID = agentID};
     values.Add(OSDParser.SerializeLLSDXmlString(info.ToOSD())); //Value which is a default Profile
     GD.Insert("userdata", values.ToArray());
 }
Exemplo n.º 2
0
        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;
                                                                                                        });
            OfflineMessages = ((OSDArray) map["OfflineMessages"]).ConvertAll<GridInstantMessage>((o) =>
                                                                                                     {
                                                                                                         GridInstantMessage
                                                                                                             group =
                                                                                                                 new GridInstantMessage
                                                                                                                     ();
                                                                                                         group.FromOSD(
                                                                                                             (OSDMap) o);
                                                                                                         return group;
                                                                                                     });
            MuteList = ((OSDArray) map["MuteList"]).ConvertAll<MuteList>((o) =>
                                                                             {
                                                                                 MuteList group = new MuteList();
                                                                                 group.FromOSD((OSDMap) o);
                                                                                 return group;
                                                                             });

            if (map.ContainsKey("Appearance"))
            {
                Appearance = new AvatarAppearance();
                Appearance.FromOSD((OSDMap)map["Appearance"]);
            }
        }
 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)))
     {
         data = "Incorrect password";
         return LLFailedLoginResponse.AuthenticationProblem;
     }
     data = secureSession;
     return null;
 }
        public IAgentInfo GetAgent(UUID agentID)
        {
            IAgentInfo agent = new IAgentInfo();
            if (m_cache.Get(agentID, out agent))
                return agent;
            else
                agent = new IAgentInfo();

            object remoteValue = DoRemote(agentID);
            if (remoteValue != null || m_doRemoteOnly)
            {
                m_cache.Cache(agentID, (IAgentInfo) remoteValue);
                return (IAgentInfo) remoteValue;
            }

            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)
            {
                m_cache.Cache(agentID, null);
                return null; //Couldn't find it, return null then.
            }

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

            agent.FromOSD(agentInfo);
            agent.PrincipalID = agentID;
            m_cache.Cache(agentID, agent);
            return agent;
        }
 public void CacheAgent(IAgentInfo agent)
 {
     m_cache.Cache(agent.PrincipalID, agent);
 }
        /// <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>
        //[CanBeReflected(ThreatLevel = ThreatLevel.Full)]
        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);
        }
        public LoginResponse Login(Hashtable request, UserAccount account, IAgentInfo agentInfo, string authType,
                                   string password, out object data)
        {
            IAgentConnector agentData = Framework.Utilities.DataManager.RequestPlugin<IAgentConnector>();
            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 == "")
            {
                data = "Bad Viewer Connection";
                return new LLFailedLoginResponse(LoginResponseEnum.Indeterminant, data.ToString(), false);
            }

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

            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)
            {
                data = "TOS not accepted";
                return new LLFailedLoginResponse(LoginResponseEnum.ToSNeedsSent, File.ReadAllText(Path.Combine(Environment.CurrentDirectory, m_TOSLocation)), 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);
                data = "Permanently banned";
                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.ToLocalTime().ToShortDateString(),
                                          bannedTime.ToLocalTime().ToLongTimeString());

                    //Check to make sure the time hasn't expired
                    if (bannedTime.Ticks < DateTime.Now.ToUniversalTime().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 {1}.",
                        account.Name, until);
                    data =  string.Format("You are blocked from connecting to this service{0}.", until);
                    return new LLFailedLoginResponse(LoginResponseEnum.Indeterminant,
                                                    data.ToString(), false);
                }
            }
            return null;
        }