Наследование: WhiteCore.Framework.Modules.IDataTransferable, BaseCacheAccount
 /// <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(m_userProfileTable, values.ToArray());
 }
Пример #2
0
        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;
        }
 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$", System.StringComparison.Ordinal) ? 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;
            
            agent = new IAgentInfo();

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

            List<string> query = null;
            try
            {
                QueryFilter filter = new QueryFilter();
                filter.andFilters["ID"] = agentID;
                filter.andFilters["`Key`"] = "AgentInfo";
                query = GD.Query(new string[] {"`Value`"}, m_userProfileTable, 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;
        }
Пример #5
0
        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;
        }
Пример #6
0
        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);
            }

            // TODO: Some TPV's now send their version in the Channel
            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;
        }
        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"]);
            }
            if (map.ContainsKey("FriendOnlineStatuses"))
                FriendOnlineStatuses = ((OSDArray)map["FriendOnlineStatuses"]).ConvertAll<UUID>((o) => { return o; });
            if (map.ContainsKey("Friends"))
                Friends = ((OSDArray)map["Friends"]).ConvertAll<FriendInfo>((o) =>
                {
                    FriendInfo f = new FriendInfo();
                    f.FromOSD((OSDMap)o);
                    return f;
                });
        }
 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(m_userProfileTable, values, null, filter, null, null);
        }