Example #1
0
        private byte[] ProcessUpdateAgentInfo(Stream request, UUID agentID)
        {
            OSD    r        = OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request));
            OSDMap rm       = (OSDMap)r;
            OSDMap access   = (OSDMap)rm["access_prefs"];
            string Level    = access["max"].AsString();
            int    maxLevel = 0;

            if (Level == "PG")
            {
                maxLevel = 0;
            }
            if (Level == "M")
            {
                maxLevel = 1;
            }
            if (Level == "A")
            {
                maxLevel = 2;
            }
            IAgentConnector data = Framework.Utilities.DataManager.RequestPlugin <IAgentConnector>();

            if (data != null)
            {
                IAgentInfo agent = data.GetAgent(agentID);
                agent.MaturityRating = maxLevel;
                data.UpdateAgent(agent);
            }
            return(MainServer.BlankResponse);
        }
        OSDMap Authenticated(OSDMap map)
        {
            IUserAccountService accountService = m_registry.RequestModuleInterface <IUserAccountService> ();
            UserAccount         user           = accountService.GetUserAccount(null, map ["UUID"].AsUUID());

            bool   Verified = user != null;
            OSDMap resp     = new OSDMap();

            resp ["Verified"] = OSD.FromBoolean(Verified);

            if (Verified)
            {
                user.UserLevel = 0;
                accountService.StoreUserAccount(user);
                IAgentConnector con   = DataPlugins.RequestPlugin <IAgentConnector> ();
                IAgentInfo      agent = con.GetAgent(user.PrincipalID);
                if (agent != null && agent.OtherAgentInformation.ContainsKey("WebUIActivationToken"))
                {
                    agent.OtherAgentInformation.Remove("WebUIActivationToken");
                    con.UpdateAgent(agent);
                }
            }

            return(resp);
        }
Example #3
0
        private Hashtable ProcessUpdateAgentLanguage(Hashtable m_dhttpMethod, UUID agentID)
        {
            Hashtable responsedata = new Hashtable();

            responsedata["int_response_code"]   = 200; //501; //410; //404;
            responsedata["content_type"]        = "text/plain";
            responsedata["keepalive"]           = false;
            responsedata["str_response_string"] = "";

            OSD r = OSDParser.DeserializeLLSDXml((string)m_dhttpMethod["requestbody"]);

            if (!(r is OSDMap))
            {
                return(responsedata);
            }
            OSDMap          rm            = (OSDMap)r;
            IAgentConnector AgentFrontend = DataManager.RequestPlugin <IAgentConnector>();

            if (AgentFrontend != null)
            {
                IAgentInfo IAI = AgentFrontend.GetAgent(agentID);
                if (IAI == null)
                {
                    return(responsedata);
                }
                IAI.Language         = rm["language"].AsString();
                IAI.LanguageIsPublic = int.Parse(rm["language_is_public"].AsString()) == 1;
                AgentFrontend.UpdateAgent(IAI);
            }
            return(responsedata);
        }
Example #4
0
        OSDMap EditUser(OSDMap map)
        {
            bool   editRLInfo = (map.ContainsKey("RLName") && map.ContainsKey("RLAddress") && map.ContainsKey("RLZip") && map.ContainsKey("RLCity") && map.ContainsKey("RLCountry"));
            OSDMap resp       = new OSDMap();

            resp ["agent"]   = OSD.FromBoolean(!editRLInfo); // if we have no RLInfo, editing account is assumed to be successful.
            resp ["account"] = OSD.FromBoolean(false);
            UUID principalID = map ["UserID"].AsUUID();
            var  acctService = m_registry.RequestModuleInterface <IUserAccountService> ();

            if (acctService == null)
            {
                return(resp);
            }

            UserAccount userAcct = acctService.GetUserAccount(null, principalID);

            if (userAcct.Valid)
            {
                userAcct.Email = map ["Email"];
                if (acctService.GetUserAccount(null, map ["Name"].AsString()) == null)
                {
                    userAcct.Name = map ["Name"];
                }

                if (editRLInfo)
                {
                    IAgentConnector agentConnector = DataPlugins.RequestPlugin <IAgentConnector> ();
                    IAgentInfo      agent          = agentConnector.GetAgent(userAcct.PrincipalID);
                    if (agent == null)
                    {
                        agentConnector.CreateNewAgent(userAcct.PrincipalID);
                        agent = agentConnector.GetAgent(userAcct.PrincipalID);
                    }
                    if (agent != null)
                    {
                        agent.OtherAgentInformation ["RLName"]    = map ["RLName"];
                        agent.OtherAgentInformation ["RLAddress"] = map ["RLAddress"];
                        agent.OtherAgentInformation ["RLZip"]     = map ["RLZip"];
                        agent.OtherAgentInformation ["RLCity"]    = map ["RLCity"];
                        agent.OtherAgentInformation ["RLCountry"] = map ["RLCountry"];
                        agentConnector.UpdateAgent(agent);
                        resp ["agent"] = OSD.FromBoolean(true);
                    }
                }
                resp ["account"] = OSD.FromBoolean(acctService.StoreUserAccount(userAcct));
            }
            return(resp);
        }
        void CacheUserInfo(IScene scene, CachedUserInfo cache)
        {
            if (cache == null)
            {
                return;
            }
            IAgentConnector conn = Framework.Utilities.DataManager.RequestPlugin <IAgentConnector> ();

            if (conn != null)
            {
                conn.CacheAgent(cache.AgentInfo);
            }
            scene.UserAccountService.CacheAccount(cache.UserAccount);

            scene.EventManager.TriggerOnUserCachedData(cache.UserAccount.PrincipalID, cache);
        }
Example #6
0
        private MessengerEngine(IIoC ioc)
        {
            _msg2failureHandler = new Dictionary<Type, Action<comm.IoMsg>> {
                {typeof(comm.PublishMsg), msg => update_failure_counters((comm.PublishMsg) msg)},
                {typeof(comm.FilterInfo), msg => update_failure_counters((comm.FilterInfo) msg)},
                {typeof(comm.TopicFilterMsg), msg => update_failure_counters((comm.TopicFilterMsg) msg)},
                {typeof(comm.HeartbeatMsg), msg => update_failure_counters((comm.HeartbeatMsg) msg)}
            };

            _counters = new Counters();
            _configRa = ioc.Resolve<ISignalsConfigRa>();

            var config = _configRa.Values;
            _cachedConfig = config;
            _log = ThrottledLog.NewSync(config.ThrottledLogTtl, ioc.Resolve<ILogFile>());

            _hubUri = _configRa.MakeHubUri();
            _connector = ioc.Resolve<IAgentConnector>();
            _agents = AgentsRepo.NewSync();
        }
        OSDMap ActivateAccount(OSDMap map)
        {
            OSDMap resp = new OSDMap();

            resp ["Verified"] = OSD.FromBoolean(false);

            if (map.ContainsKey("UserName") && map.ContainsKey("PasswordHash") && map.ContainsKey("ActivationToken"))
            {
                IUserAccountService accountService = m_registry.RequestModuleInterface <IUserAccountService> ();
                UserAccount         user           = accountService.GetUserAccount(null, map ["UserName"].ToString());
                if (user != null)
                {
                    IAgentConnector con   = DataPlugins.RequestPlugin <IAgentConnector> ();
                    IAgentInfo      agent = con.GetAgent(user.PrincipalID);
                    if (agent != null && agent.OtherAgentInformation.ContainsKey("WebUIActivationToken"))
                    {
                        UUID   activationToken      = map ["ActivationToken"];
                        string WebUIActivationToken = agent.OtherAgentInformation ["WebUIActivationToken"];
                        string PasswordHash         = map ["PasswordHash"];
                        if (!PasswordHash.StartsWith("$1$"))
                        {
                            PasswordHash = "$1$" + Util.Md5Hash(PasswordHash);
                        }
                        PasswordHash = PasswordHash.Remove(0, 3);  //remove $1$

                        bool verified = Utils.MD5String(activationToken.ToString() + ":" + PasswordHash) == WebUIActivationToken;
                        resp ["Verified"] = verified;
                        if (verified)
                        {
                            user.UserLevel = 0;
                            accountService.StoreUserAccount(user);
                            agent.OtherAgentInformation.Remove("WebUIActivationToken");
                            con.UpdateAgent(agent);
                        }
                    }
                }
            }

            return(resp);
        }
Example #8
0
        private byte[] ProcessUpdateAgentLanguage(Stream request, UUID agentID)
        {
            OSDMap rm = OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request)) as OSDMap;

            if (rm == null)
            {
                return(MainServer.BadRequest);
            }
            IAgentConnector AgentFrontend = Framework.Utilities.DataManager.RequestPlugin <IAgentConnector>();

            if (AgentFrontend != null)
            {
                IAgentInfo IAI = AgentFrontend.GetAgent(agentID);
                if (IAI == null)
                {
                    return(MainServer.BadRequest);
                }
                IAI.Language         = rm["language"].AsString();
                IAI.LanguageIsPublic = int.Parse(rm["language_is_public"].AsString()) == 1;
                AgentFrontend.UpdateAgent(IAI);
            }
            return(MainServer.BlankResponse);
        }
Example #9
0
        private Hashtable ProcessUpdateAgentInfo(Hashtable mDhttpMethod, UUID agentID)
        {
            OSD    r        = OSDParser.DeserializeLLSDXml((string)mDhttpMethod["requestbody"]);
            OSDMap rm       = (OSDMap)r;
            OSDMap access   = (OSDMap)rm["access_prefs"];
            string Level    = access["max"].AsString();
            int    maxLevel = 0;

            if (Level == "PG")
            {
                maxLevel = 0;
            }
            if (Level == "M")
            {
                maxLevel = 1;
            }
            if (Level == "A")
            {
                maxLevel = 2;
            }
            IAgentConnector data = DataManager.RequestPlugin <IAgentConnector>();

            if (data != null)
            {
                IAgentInfo agent = data.GetAgent(agentID);
                agent.MaturityRating = maxLevel;
                data.UpdateAgent(agent);
            }
            Hashtable cancelresponsedata = new Hashtable();

            cancelresponsedata["int_response_code"]   = 200; //501; //410; //404;
            cancelresponsedata["content_type"]        = "text/plain";
            cancelresponsedata["keepalive"]           = false;
            cancelresponsedata["str_response_string"] = "";
            return(cancelresponsedata);
        }
Example #10
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);
        }
Example #11
0
        private bool OnAllowedIncomingTeleport(UUID userID, IScene scene, Vector3 Position, uint TeleportFlags,
                                               out Vector3 newPosition, out string reason)
        {
            newPosition = Position;
            UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.AllScopeIDs, userID);

            IScenePresence Sp = scene.GetScenePresence(userID);

            if (account == null)
            {
                reason = "Failed authentication.";
                return(false); //NO!
            }


            //Make sure that this user is inside the region as well
            if (Position.X < -2f || Position.Y < -2f ||
                Position.X > scene.RegionInfo.RegionSizeX + 2 || Position.Y > scene.RegionInfo.RegionSizeY + 2)
            {
                MainConsole.Instance.DebugFormat(
                    "[EstateService]: AllowedIncomingTeleport was given an illegal position of {0} for avatar {1}, {2}. Clamping",
                    Position, Name, userID);
                bool changedX = false;
                bool changedY = false;
                while (Position.X < 0)
                {
                    Position.X += scene.RegionInfo.RegionSizeX;
                    changedX    = true;
                }
                while (Position.X > scene.RegionInfo.RegionSizeX)
                {
                    Position.X -= scene.RegionInfo.RegionSizeX;
                    changedX    = true;
                }

                while (Position.Y < 0)
                {
                    Position.Y += scene.RegionInfo.RegionSizeY;
                    changedY    = true;
                }
                while (Position.Y > scene.RegionInfo.RegionSizeY)
                {
                    Position.Y -= scene.RegionInfo.RegionSizeY;
                    changedY    = true;
                }

                if (changedX)
                {
                    Position.X = scene.RegionInfo.RegionSizeX - Position.X;
                }
                if (changedY)
                {
                    Position.Y = scene.RegionInfo.RegionSizeY - Position.Y;
                }
            }

            IAgentConnector AgentConnector = Framework.Utilities.DataManager.RequestPlugin <IAgentConnector>();
            IAgentInfo      agentInfo      = null;

            if (AgentConnector != null)
            {
                agentInfo = AgentConnector.GetAgent(userID);
            }

            ILandObject             ILO = null;
            IParcelManagementModule parcelManagement = scene.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                ILO = parcelManagement.GetLandObject(Position.X, Position.Y);
            }

            if (ILO == null)
            {
                if (Sp != null)
                {
                    Sp.ClearSavedVelocity(); //If we are moving the agent, clear their velocity
                }
                //Can't find land, give them the first parcel in the region and find a good position for them
                ILO      = parcelManagement.AllParcels()[0];
                Position = parcelManagement.GetParcelCenterAtGround(ILO);
            }

            //parcel permissions
            if (ILO.IsBannedFromLand(userID)) //Note: restricted is dealt with in the next block
            {
                if (Sp != null)
                {
                    Sp.ClearSavedVelocity(); //If we are moving the agent, clear their velocity
                }
                if (Sp == null)
                {
                    reason = "Banned from this parcel.";
                    return(false);
                }

                if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
                {
                }
            }
            //Move them out of banned parcels
            ParcelFlags parcelflags = (ParcelFlags)ILO.LandData.Flags;

            if ((parcelflags & ParcelFlags.UseAccessGroup) == ParcelFlags.UseAccessGroup &&
                (parcelflags & ParcelFlags.UseAccessList) == ParcelFlags.UseAccessList &&
                (parcelflags & ParcelFlags.UsePassList) == ParcelFlags.UsePassList)
            {
                if (Sp != null)
                {
                    Sp.ClearSavedVelocity(); //If we are moving the agent, clear their velocity
                }
                //One of these is in play then
                if ((parcelflags & ParcelFlags.UseAccessGroup) == ParcelFlags.UseAccessGroup)
                {
                    if (Sp == null)
                    {
                        reason = "Banned from this parcel.";
                        return(false);
                    }
                    if (Sp.ControllingClient.ActiveGroupId != ILO.LandData.GroupID)
                    {
                        if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
                        {
                        }
                    }
                }
                else if ((parcelflags & ParcelFlags.UseAccessList) == ParcelFlags.UseAccessList)
                {
                    if (Sp == null)
                    {
                        reason = "Banned from this parcel.";
                        return(false);
                    }
                    //All but the people on the access list are banned
                    if (ILO.IsRestrictedFromLand(userID))
                    {
                        if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
                        {
                        }
                    }
                }
                else if ((parcelflags & ParcelFlags.UsePassList) == ParcelFlags.UsePassList)
                {
                    if (Sp == null)
                    {
                        reason = "Banned from this parcel.";
                        return(false);
                    }
                    //All but the people on the pass/access list are banned
                    if (ILO.IsRestrictedFromLand(Sp.UUID))
                    {
                        if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
                        {
                        }
                    }
                }
            }

            EstateSettings      ES             = scene.RegionInfo.EstateSettings;
            TeleportFlags       tpflags        = (TeleportFlags)TeleportFlags;
            const TeleportFlags allowableFlags =
                OpenMetaverse.TeleportFlags.ViaLandmark | OpenMetaverse.TeleportFlags.ViaHome |
                OpenMetaverse.TeleportFlags.ViaLure |
                OpenMetaverse.TeleportFlags.ForceRedirect |
                OpenMetaverse.TeleportFlags.Godlike | OpenMetaverse.TeleportFlags.NineOneOne;

            //If the user wants to force landing points on crossing, we act like they are not crossing, otherwise, check the child property and that the ViaRegionID is set
            bool isCrossing = !ForceLandingPointsOnCrossing && (Sp != null && Sp.IsChildAgent &&
                                                                ((tpflags & OpenMetaverse.TeleportFlags.ViaRegionID) ==
                                                                 OpenMetaverse.TeleportFlags.ViaRegionID));

            //Move them to the nearest landing point
            if (!((tpflags & allowableFlags) != 0) && !isCrossing && !ES.AllowDirectTeleport)
            {
                if (Sp != null)
                {
                    Sp.ClearSavedVelocity(); //If we are moving the agent, clear their velocity
                }
                if (!scene.Permissions.IsGod(userID))
                {
                    Telehub telehub = RegionConnector.FindTelehub(scene.RegionInfo.RegionID,
                                                                  scene.RegionInfo.RegionHandle);
                    if (telehub != null)
                    {
                        if (telehub.SpawnPos.Count == 0)
                        {
                            Position = new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ);
                        }
                        else
                        {
                            int LastTelehubNum = 0;
                            if (!LastTelehub.TryGetValue(scene.RegionInfo.RegionID, out LastTelehubNum))
                            {
                                LastTelehubNum = 0;
                            }
                            Position = telehub.SpawnPos[LastTelehubNum] +
                                       new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ);
                            LastTelehubNum++;
                            if (LastTelehubNum == telehub.SpawnPos.Count)
                            {
                                LastTelehubNum = 0;
                            }
                            LastTelehub[scene.RegionInfo.RegionID] = LastTelehubNum;
                        }
                    }
                }
            }
            else if (!((tpflags & allowableFlags) != 0) && !isCrossing &&
                     !scene.Permissions.GenericParcelPermission(userID, ILO, (ulong)GroupPowers.None))
            //Telehubs override parcels
            {
                if (Sp != null)
                {
                    Sp.ClearSavedVelocity();                           //If we are moving the agent, clear their velocity
                }
                if (ILO.LandData.LandingType == (int)LandingType.None) //Blocked, force this person off this land
                {
                    //Find a new parcel for them
                    List <ILandObject> Parcels = parcelManagement.ParcelsNearPoint(Position);
                    if (Parcels.Count > 1)
                    {
                        newPosition = parcelManagement.GetNearestRegionEdgePosition(Sp);
                    }
                    else
                    {
                        bool found = false;
                        //We need to check here as well for bans, can't toss someone into a parcel they are banned from
                        foreach (ILandObject Parcel in Parcels.Where(Parcel => !Parcel.IsBannedFromLand(userID)))
                        {
                            //Now we have to check their userloc
                            if (ILO.LandData.LandingType == (int)LandingType.None)
                            {
                                continue; //Blocked, check next one
                            }
                            else if (ILO.LandData.LandingType == (int)LandingType.LandingPoint)
                            {
                                //Use their landing spot
                                newPosition = Parcel.LandData.UserLocation;
                            }
                            else //They allow for anywhere, so dump them in the center at the ground
                            {
                                newPosition = parcelManagement.GetParcelCenterAtGround(Parcel);
                            }
                            found = true;
                        }

                        if (!found) //Dump them at the edge
                        {
                            if (Sp != null)
                            {
                                newPosition = parcelManagement.GetNearestRegionEdgePosition(Sp);
                            }
                            else
                            {
                                reason = "Banned from this parcel.";
                                return(false);
                            }
                        }
                    }
                }
                else if (ILO.LandData.LandingType == (int)LandingType.LandingPoint)  //Move to tp spot
                {
                    newPosition = ILO.LandData.UserLocation != Vector3.Zero
                                      ? ILO.LandData.UserLocation
                                      : parcelManagement.GetNearestRegionEdgePosition(Sp);
                }
            }

            //We assume that our own region isn't null....
            if (agentInfo != null)
            {
                //Can only enter prelude regions once!
                if (scene.RegionInfo.RegionFlags != -1 &&
                    ((scene.RegionInfo.RegionFlags & (int)RegionFlags.Prelude) == (int)RegionFlags.Prelude) &&
                    agentInfo != null)
                {
                    if (agentInfo.OtherAgentInformation.ContainsKey("Prelude" + scene.RegionInfo.RegionID))
                    {
                        reason = "You may not enter this region as you have already been to this prelude region.";
                        return(false);
                    }
                    else
                    {
                        agentInfo.OtherAgentInformation.Add("Prelude" + scene.RegionInfo.RegionID,
                                                            OSD.FromInteger((int)IAgentFlags.PastPrelude));
                        AgentConnector.UpdateAgent(agentInfo);
                    }
                }
                if (agentInfo.OtherAgentInformation.ContainsKey("LimitedToEstate"))
                {
                    int LimitedToEstate = agentInfo.OtherAgentInformation["LimitedToEstate"];
                    if (scene.RegionInfo.EstateSettings.EstateID != LimitedToEstate)
                    {
                        reason = "You may not enter this reason, as it is outside of the estate you are limited to.";
                        return(false);
                    }
                }
            }


            if ((ILO.LandData.Flags & (int)ParcelFlags.DenyAnonymous) != 0)
            {
                if (account != null &&
                    (account.UserFlags & (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile) ==
                    (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile)
                {
                    reason = "You may not enter this region.";
                    return(false);
                }
            }

            if ((ILO.LandData.Flags & (uint)ParcelFlags.DenyAgeUnverified) != 0 && agentInfo != null)
            {
                if ((agentInfo.Flags & IAgentFlags.Minor) == IAgentFlags.Minor)
                {
                    reason = "You may not enter this region.";
                    return(false);
                }
            }

            //Check that we are not underground as well
            ITerrainChannel chan = scene.RequestModuleInterface <ITerrainChannel>();

            if (chan != null)
            {
                float posZLimit = chan[(int)newPosition.X, (int)newPosition.Y] + (float)1.25;

                if (posZLimit >= (newPosition.Z) && !(Single.IsInfinity(posZLimit) || Single.IsNaN(posZLimit)))
                {
                    newPosition.Z = posZLimit;
                }
            }

            reason = "";
            return(true);
        }
Example #12
0
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters,
                                                ITranslator translator, out string response)
        {
            response = null;
            var vars     = new Dictionary <string, object>();
            var settings = webInterface.GetWebUISettings();

            bool adminUser         = Authenticator.CheckAdminAuthentication(httpRequest, Constants.USER_GOD_CUSTOMER_SERVICE);
            bool allowRegistration = settings.WebRegistration;
            bool anonymousLogins;

            // allow configuration to override the web settings
            IConfig config = webInterface.Registry.RequestModuleInterface <ISimulationBase>().ConfigSource.Configs ["LoginService"];

            if (config != null)
            {
                anonymousLogins   = config.GetBoolean("AllowAnonymousLogin", allowRegistration);
                allowRegistration = (allowRegistration || anonymousLogins);
            }

            if (!adminUser && !allowRegistration)
            {
                vars.Add("ErrorMessage", "");
                vars.Add("RegistrationText", translator.GetTranslatedString("RegistrationText"));
                vars.Add("RegistrationsDisabled", translator.GetTranslatedString("RegistrationsDisabled"));
                vars.Add("Registrations", false);
                vars.Add("NoRegistrations", true);
                return(vars);
            }

            if (requestParameters.ContainsKey("Submit"))
            {
                string AvatarName          = requestParameters["AvatarName"].ToString();
                string AvatarPassword      = requestParameters["AvatarPassword"].ToString();
                string AvatarPasswordCheck = requestParameters["AvatarPassword2"].ToString();
                string FirstName           = requestParameters["FirstName"].ToString();
                string LastName            = requestParameters["LastName"].ToString();
                //removed - greythane - deemed not used
                //string UserAddress = requestParameters["UserAddress"].ToString();
                //string UserZip = requestParameters["UserZip"].ToString();
                string UserCity       = requestParameters["UserCity"].ToString();
                string UserEmail      = requestParameters["UserEmail"].ToString();
                string UserHomeRegion = requestParameters["UserHomeRegion"].ToString();
                string UserDOBMonth   = requestParameters["UserDOBMonth"].ToString();
                string UserDOBDay     = requestParameters["UserDOBDay"].ToString();
                string UserDOBYear    = requestParameters["UserDOBYear"].ToString();
                string AvatarArchive  = requestParameters.ContainsKey("AvatarArchive")
                                           ? requestParameters["AvatarArchive"].ToString()
                                           : "";
                bool ToSAccept = requestParameters.ContainsKey("ToSAccept") &&
                                 requestParameters["ToSAccept"].ToString() == "Accepted";

                string UserType = requestParameters.ContainsKey("UserType")         // only admins can set membership
                    ? requestParameters ["UserType"].ToString()
                    : "Resident";

                // revise UserDOBMonth to a number
                UserDOBMonth = ShortMonthToNumber(UserDOBMonth);

                // revise Type flags
                int UserFlags = webInterface.UserTypeToUserFlags(UserType);

                // a bit of idiot proofing
                if (AvatarName == "")
                {
                    response = "<h3>" + translator.GetTranslatedString("AvatarNameError") + "</h3>";
                    return(null);
                }
                if ((AvatarPassword == "") || (AvatarPassword != AvatarPasswordCheck))
                {
                    response = "<h3>" + translator.GetTranslatedString("AvatarPasswordError") + "</h3>";
                    return(null);
                }
                if (UserEmail == "")
                {
                    response = "<h3>" + translator.GetTranslatedString("AvatarEmailError") + "</h3>";
                    return(null);
                }

                // Thish -  Only one space is allowed in the name to seperate First and Last of the avatar name
                if (AvatarName.Split(' ').Length != 2)
                {
                    response = "<h3>" + translator.GetTranslatedString("AvatarNameSpacingError") + "</h3>";
                    return(null);
                }

                // so far so good...
                if (ToSAccept)
                {
                    AvatarPassword = Util.Md5Hash(AvatarPassword);

                    IUserAccountService accountService =
                        webInterface.Registry.RequestModuleInterface <IUserAccountService>();
                    UUID   userID = UUID.Random();
                    string error  = accountService.CreateUser(userID, settings.DefaultScopeID, AvatarName, AvatarPassword,
                                                              UserEmail);
                    if (error == "")
                    {
                        // set the user account type
                        UserAccount account = accountService.GetUserAccount(null, userID);
                        account.UserFlags = UserFlags;
                        accountService.StoreUserAccount(account);

                        // create and save agent info
                        IAgentConnector con = Framework.Utilities.DataManager.RequestPlugin <IAgentConnector> ();
                        con.CreateNewAgent(userID);
                        IAgentInfo agent = con.GetAgent(userID);
                        agent.OtherAgentInformation ["RLFirstName"] = FirstName;
                        agent.OtherAgentInformation ["RLLastName"]  = LastName;
                        //agent.OtherAgentInformation ["RLAddress"] = UserAddress;
                        agent.OtherAgentInformation ["RLCity"] = UserCity;
                        //agent.OtherAgentInformation ["RLZip"] = UserZip;
                        agent.OtherAgentInformation ["UserDOBMonth"] = UserDOBMonth;
                        agent.OtherAgentInformation ["UserDOBDay"]   = UserDOBDay;
                        agent.OtherAgentInformation ["UserDOBYear"]  = UserDOBYear;
                        agent.OtherAgentInformation ["UserFlags"]    = UserFlags;

                        /*if (activationRequired)
                         * {
                         *  UUID activationToken = UUID.Random();
                         *  agent.OtherAgentInformation["WebUIActivationToken"] = Util.Md5Hash(activationToken.ToString() + ":" + PasswordHash);
                         *  resp["WebUIActivationToken"] = activationToken;
                         * }*/
                        con.UpdateAgent(agent);

                        // create user profile details
                        IProfileConnector profileData =
                            Framework.Utilities.DataManager.RequestPlugin <IProfileConnector> ();
                        if (profileData != null)
                        {
                            IUserProfileInfo profile = profileData.GetUserProfile(userID);
                            if (profile == null)
                            {
                                profileData.CreateNewProfile(userID);
                                profile = profileData.GetUserProfile(userID);
                            }

                            if (AvatarArchive != "")
                            {
                                profile.AArchiveName = AvatarArchive;

                                List <AvatarArchive> avarchives = webInterface.Registry.RequestModuleInterface <IAvatarAppearanceArchiver>().GetAvatarArchives();
                                UUID snapshotUUID = UUID.Zero;
                                foreach (var archive in avarchives)
                                {
                                    if (archive.FolderName == AvatarArchive)
                                    {
                                        snapshotUUID = archive.Snapshot;
                                    }
                                }

                                if (snapshotUUID != UUID.Zero)
                                {
                                    profile.Image = snapshotUUID;
                                }
                            }
                            profile.MembershipGroup = webInterface.UserFlagToType(UserFlags, webInterface.EnglishTranslator);     // membership is english
                            profile.IsNewUser       = true;
                            profileData.UpdateUserProfile(profile);
                        }

                        IAgentInfoService agentInfoService = webInterface.Registry.RequestModuleInterface <IAgentInfoService> ();
                        Vector3           position         = new Vector3(128, 128, 25);
                        Vector3           lookAt           = new Vector3(0, 0, 22);

                        if (agentInfoService != null)
                        {
                            agentInfoService.SetHomePosition(userID.ToString(), (UUID)UserHomeRegion, position, lookAt);
                        }

                        vars.Add("ErrorMessage", "Successfully created account, redirecting to main page");
                        response = "<h3>Successfully created account, redirecting to main page</h3>" +
                                   "<script language=\"javascript\">" +
                                   "setTimeout(function() {window.location.href = \"index.html\";}, 3000);" +
                                   "</script>";
                    }
                    else
                    {
                        vars.Add("ErrorMessage", "<h3>" + error + "</h3>");
                        response = "<h3>" + error + "</h3>";
                    }
                }
                else
                {
                    response = "<h3>You did not accept the Terms of Service agreement.</h3>";
                }
                return(null);
            }

            List <Dictionary <string, object> > daysArgs = new List <Dictionary <string, object> >();

            for (int i = 1; i <= 31; i++)
            {
                daysArgs.Add(new Dictionary <string, object> {
                    { "Value", i }
                });
            }

            List <Dictionary <string, object> > monthsArgs = new List <Dictionary <string, object> >();

            //for (int i = 1; i <= 12; i++)
            //    monthsArgs.Add(new Dictionary<string, object> {{"Value", i}});

            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Jan_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Feb_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Mar_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Apr_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("May_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Jun_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Jul_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Aug_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Sep_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Oct_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Nov_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Dec_Short") }
            });



            List <Dictionary <string, object> > yearsArgs = new List <Dictionary <string, object> >();

            for (int i = 1940; i <= 2013; i++)
            {
                yearsArgs.Add(new Dictionary <string, object> {
                    { "Value", i }
                });
            }

            vars.Add("Days", daysArgs);
            vars.Add("Months", monthsArgs);
            vars.Add("Years", yearsArgs);

            var sortBy = new Dictionary <string, bool>();

            sortBy.Add("RegionName", true);

            var RegionListVars = new List <Dictionary <string, object> >();
            var regions        = Framework.Utilities.DataManager.RequestPlugin <IRegionData>().Get((RegionFlags)0,
                                                                                                   RegionFlags.Hyperlink |
                                                                                                   RegionFlags.Foreign |
                                                                                                   RegionFlags.Hidden,
                                                                                                   null, null, sortBy);

            foreach (var region in regions)
            {
                RegionListVars.Add(new Dictionary <string, object> {
                    { "RegionName", region.RegionName },
                    { "RegionUUID", region.RegionID }
                });
            }

            vars.Add("RegionList", RegionListVars);
            vars.Add("UserHomeRegionText", translator.GetTranslatedString("UserHomeRegionText"));


            vars.Add("UserTypeText", translator.GetTranslatedString("UserTypeText"));
            vars.Add("UserType", webInterface.UserTypeArgs(translator));

            List <AvatarArchive> archives = webInterface.Registry.RequestModuleInterface <IAvatarAppearanceArchiver>().GetAvatarArchives();

            List <Dictionary <string, object> > avatarArchives = new List <Dictionary <string, object> >();
            IWebHttpTextureService webTextureService           = webInterface.Registry.
                                                                 RequestModuleInterface <IWebHttpTextureService>();

            foreach (var archive in archives)
            {
                avatarArchives.Add(new Dictionary <string, object>
                {
                    { "AvatarArchiveName", archive.FolderName },
                    { "AvatarArchiveSnapshotID", archive.Snapshot },
                    {
                        "AvatarArchiveSnapshotURL",
                        webTextureService.GetTextureURL(archive.Snapshot)
                    }
                });
            }

            vars.Add("AvatarArchive", avatarArchives);


            IConfig loginServerConfig =
                webInterface.Registry.RequestModuleInterface <ISimulationBase>().ConfigSource.Configs["LoginService"];
            string tosLocation = "";

            if (loginServerConfig != null && loginServerConfig.GetBoolean("UseTermsOfServiceOnFirstLogin", false))
            {
                tosLocation = loginServerConfig.GetString("FileNameOfTOS", "");
                tosLocation = PathHelpers.VerifyReadFile(tosLocation, ".txt", Constants.DEFAULT_DATA_DIR);
            }
            string ToS = "There are no Terms of Service currently. This may be changed at any point in the future.";

            if (tosLocation != "")
            {
                System.IO.StreamReader reader =
                    new System.IO.StreamReader(System.IO.Path.Combine(Environment.CurrentDirectory, tosLocation));
                ToS = reader.ReadToEnd();
                reader.Close();
            }

            // check for user name seed
            string[] m_userNameSeed = null;
            if (loginServerConfig != null)
            {
                string userNameSeed = loginServerConfig.GetString("UserNameSeed", "");
                if (userNameSeed != "")
                {
                    m_userNameSeed = userNameSeed.Split(',');
                }
            }

            Utilities.MarkovNameGenerator ufNames = new Utilities.MarkovNameGenerator();
            Utilities.MarkovNameGenerator ulNames = new Utilities.MarkovNameGenerator();
            string[] nameSeed = m_userNameSeed == null ? Utilities.UserNames : m_userNameSeed;

            string firstName   = ufNames.FirstName(nameSeed, 3, 4);
            string lastName    = ulNames.FirstName(nameSeed, 5, 6);
            string enteredName = firstName + " " + lastName;

            vars.Add("AvatarName", enteredName);
            vars.Add("ToSMessage", ToS);
            vars.Add("TermsOfServiceAccept", translator.GetTranslatedString("TermsOfServiceAccept"));
            vars.Add("TermsOfServiceText", translator.GetTranslatedString("TermsOfServiceText"));
            vars.Add("RegistrationsDisabled", "");
            //vars.Add("RegistrationsDisabled", translator.GetTranslatedString("RegistrationsDisabled"));
            vars.Add("RegistrationText", translator.GetTranslatedString("RegistrationText"));
            vars.Add("AvatarNameText", translator.GetTranslatedString("AvatarNameText"));
            vars.Add("AvatarPasswordText", translator.GetTranslatedString("Password"));
            vars.Add("AvatarPasswordConfirmationText", translator.GetTranslatedString("PasswordConfirmation"));
            vars.Add("AvatarScopeText", translator.GetTranslatedString("AvatarScopeText"));
            vars.Add("FirstNameText", translator.GetTranslatedString("FirstNameText"));
            vars.Add("LastNameText", translator.GetTranslatedString("LastNameText"));
            vars.Add("UserAddressText", translator.GetTranslatedString("UserAddressText"));
            vars.Add("UserZipText", translator.GetTranslatedString("UserZipText"));
            vars.Add("UserCityText", translator.GetTranslatedString("UserCityText"));
            vars.Add("UserCountryText", translator.GetTranslatedString("UserCountryText"));
            vars.Add("UserDOBText", translator.GetTranslatedString("UserDOBText"));
            vars.Add("UserEmailText", translator.GetTranslatedString("UserEmailText"));
            vars.Add("Accept", translator.GetTranslatedString("Accept"));
            vars.Add("Submit", translator.GetTranslatedString("Submit"));
            vars.Add("SubmitURL", "register.html");
            vars.Add("ErrorMessage", "");
            vars.Add("Registrations", true);
            vars.Add("NoRegistrations", false);

            return(vars);
        }
 public ProfileInfoHandler()
 {
     ProfileConnector = DataManager.RequestPlugin<IProfileConnector>("IProfileConnectorLocal");
     AgentConnector = DataManager.RequestPlugin<IAgentConnector>("IAgentConnectorLocal");
 }
        OSDMap GetProfile(OSDMap map)
        {
            OSDMap resp   = new OSDMap();
            string Name   = map ["Name"].AsString();
            UUID   userID = map ["UUID"].AsUUID();

            UserAccount account = Name != "" ?
                                  m_registry.RequestModuleInterface <IUserAccountService> ().GetUserAccount(null, Name) :
                                  m_registry.RequestModuleInterface <IUserAccountService> ().GetUserAccount(null, userID);

            if (account != null)
            {
                OSDMap accountMap = new OSDMap();

                accountMap ["Created"]     = account.Created;
                accountMap ["Name"]        = account.Name;
                accountMap ["PrincipalID"] = account.PrincipalID;
                accountMap ["Email"]       = account.Email;

                TimeSpan diff  = DateTime.Now - Util.ToDateTime(account.Created);
                int      years = (int)diff.TotalDays / 356;
                int      days  = years > 0 ? (int)diff.TotalDays / years : (int)diff.TotalDays;
                accountMap ["TimeSinceCreated"] = years + " years, " + days + " days"; // if we're sending account.Created do we really need to send this string ?

                IProfileConnector profileConnector = DataPlugins.RequestPlugin <IProfileConnector> ();
                IUserProfileInfo  profile          = profileConnector.GetUserProfile(account.PrincipalID);
                if (profile != null)
                {
                    resp ["profile"] = profile.ToOSD(false); //not trusted, use false

                    if (account.UserFlags == 0)
                    {
                        account.UserFlags = 2; //Set them to no info given
                    }
                    string flags = ((IUserProfileInfo.ProfileFlags)account.UserFlags).ToString();
                    IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile.ToString();

                    accountMap ["AccountInfo"] = (profile.CustomType != "" ? profile.CustomType :
                                                  account.UserFlags == 0 ? "Resident" : "Admin") + "\n" + flags;
                    UserAccount partnerAccount = m_registry.RequestModuleInterface <IUserAccountService> ().GetUserAccount(null, profile.Partner);
                    if (partnerAccount != null)
                    {
                        accountMap ["Partner"]     = partnerAccount.Name;
                        accountMap ["PartnerUUID"] = partnerAccount.PrincipalID;
                    }
                    else
                    {
                        accountMap ["Partner"]     = "";
                        accountMap ["PartnerUUID"] = UUID.Zero;
                    }
                }
                IAgentConnector agentConnector = DataPlugins.RequestPlugin <IAgentConnector> ();
                IAgentInfo      agent          = agentConnector.GetAgent(account.PrincipalID);
                if (agent != null)
                {
                    OSDMap agentMap = new OSDMap();
                    agentMap ["RLName"]    = agent.OtherAgentInformation ["RLName"].AsString();
                    agentMap ["RLGender"]  = agent.OtherAgentInformation ["RLGender"].AsString();
                    agentMap ["RLAddress"] = agent.OtherAgentInformation ["RLAddress"].AsString();
                    agentMap ["RLZip"]     = agent.OtherAgentInformation ["RLZip"].AsString();
                    agentMap ["RLCity"]    = agent.OtherAgentInformation ["RLCity"].AsString();
                    agentMap ["RLCountry"] = agent.OtherAgentInformation ["RLCountry"].AsString();
                    resp ["agent"]         = agentMap;
                }
                resp ["account"] = accountMap;
            }

            return(resp);
        }
 public AgentInfoHandler()
 {
     AgentConnector = DataManager.RequestPlugin<IAgentConnector>("IAgentConnectorLocal");
 }
        OSDMap CreateAccount(OSDMap map)
        {
            bool   Verified = false;
            string Name     = map ["Name"].AsString();

            string Password = "";

            if (map.ContainsKey("Password"))
            {
                Password = map ["Password"].AsString();
            }
            else
            {
                Password = map ["PasswordHash"].AsString();  //is really plaintext password, the system hashes it later. Not sure why it was called PasswordHash to start with. I guess the original design was to have the PHP code generate the salt and password hash, then just simply store it here
            }

            //string PasswordSalt = map["PasswordSalt"].AsString(); //not being used
            string HomeRegion    = map ["HomeRegion"].AsString();
            string Email         = map ["Email"].AsString();
            string AvatarArchive = map ["AvatarArchive"].AsString();
            int    userLevel     = map ["UserLevel"].AsInteger();
            string UserTitle     = map ["UserTitle"].AsString();

            //server expects: 0 is PG, 1 is Mature, 2 is Adult - use this when setting MaxMaturity and MaturityRating
            //viewer expects: 13 is PG, 21 is Mature, 42 is Adult

            int MaxMaturity = 2;                //set to adult by default

            if (map.ContainsKey("MaxMaturity")) //MaxMaturity is the highest level that they can change the maturity rating to in the viewer
            {
                MaxMaturity = map ["MaxMaturity"].AsInteger();
            }

            int MaturityRating = MaxMaturity;      //set the default to whatever MaxMaturity was set tom incase they didn't define MaturityRating

            if (map.ContainsKey("MaturityRating")) //MaturityRating is the rating the user wants to be able to see
            {
                MaturityRating = map ["MaturityRating"].AsInteger();
            }

            bool activationRequired = map.ContainsKey("ActivationRequired") ? map ["ActivationRequired"].AsBoolean() : false;

            IUserAccountService accountService = m_registry.RequestModuleInterface <IUserAccountService> ();

            if (accountService == null)
            {
                return(null);
            }

            if (!Password.StartsWith("$1$", System.StringComparison.Ordinal))
            {
                Password = "******" + Util.Md5Hash(Password);
            }
            Password = Password.Remove(0, 3);  //remove $1$

            accountService.CreateUser(Name, Password, Email);
            UserAccount       user             = accountService.GetUserAccount(null, Name);
            IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService> ();
            IGridService      gridService      = m_registry.RequestModuleInterface <IGridService> ();

            if (agentInfoService != null && gridService != null)
            {
                GridRegion r = gridService.GetRegionByName(null, HomeRegion);
                if (r != null)
                {
                    agentInfoService.SetHomePosition(user.PrincipalID.ToString(), r.RegionID, new Vector3(r.RegionSizeX / 2, r.RegionSizeY / 2, 20), Vector3.Zero);
                }
                else
                {
                    MainConsole.Instance.DebugFormat("[API]: Could not set home position for user {0}, region \"{1}\" did not produce a result from the grid service", Name, HomeRegion);
                }
            }

            Verified = user != null;
            UUID userID = UUID.Zero;

            OSDMap resp = new OSDMap();

            resp ["Verified"] = OSD.FromBoolean(Verified);

            if (Verified)
            {
                userID         = user.PrincipalID;
                user.UserLevel = userLevel;

                // could not find a way to save this data here.
                DateTime RLDOB     = map ["RLDOB"].AsDate();
                string   RLGender  = map ["RLGender"].AsString();
                string   RLName    = map ["RLName"].AsString();
                string   RLAddress = map ["RLAddress"].AsString();
                string   RLCity    = map ["RLCity"].AsString();
                string   RLZip     = map ["RLZip"].AsString();
                string   RLCountry = map ["RLCountry"].AsString();
                string   RLIP      = map ["RLIP"].AsString();



                IAgentConnector con = DataPlugins.RequestPlugin <IAgentConnector> ();
                con.CreateNewAgent(userID);

                IAgentInfo agent = con.GetAgent(userID);

                agent.MaxMaturity    = MaxMaturity;
                agent.MaturityRating = MaturityRating;

                agent.OtherAgentInformation ["RLDOB"]     = RLDOB;
                agent.OtherAgentInformation ["RLGender"]  = RLGender;
                agent.OtherAgentInformation ["RLName"]    = RLName;
                agent.OtherAgentInformation ["RLAddress"] = RLAddress;
                agent.OtherAgentInformation ["RLCity"]    = RLCity;
                agent.OtherAgentInformation ["RLZip"]     = RLZip;
                agent.OtherAgentInformation ["RLCountry"] = RLCountry;
                agent.OtherAgentInformation ["RLIP"]      = RLIP;
                if (activationRequired)
                {
                    UUID activationToken = UUID.Random();
                    agent.OtherAgentInformation ["WebUIActivationToken"] = Util.Md5Hash(activationToken.ToString() + ":" + Password);
                    resp ["WebUIActivationToken"] = activationToken;
                }
                con.UpdateAgent(agent);

                accountService.StoreUserAccount(user);

                IProfileConnector profileData = DataPlugins.RequestPlugin <IProfileConnector> ();
                IUserProfileInfo  profile     = profileData.GetUserProfile(user.PrincipalID);
                if (profile == null)
                {
                    profileData.CreateNewProfile(user.PrincipalID);
                    profile = profileData.GetUserProfile(user.PrincipalID);
                }
                if (AvatarArchive.Length > 0)
                {
                    profile.AArchiveName = AvatarArchive;
                }
                //    MainConsole.Instance.InfoFormat("[WebUI] Triggered Archive load of " + profile.AArchiveName);
                profile.IsNewUser = true;

                profile.MembershipGroup = UserTitle;
                profile.CustomType      = UserTitle;

                profileData.UpdateUserProfile(profile);
                //   MainConsole.Instance.RunCommand("load avatar archive " + user.FirstName + " " + user.LastName + " Devil");
            }

            resp ["UUID"] = OSD.FromUUID(userID);
            return(resp);
        }
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters, ITranslator translator, out string response)
        {
            response = null;
            var vars = new Dictionary <string, object>();

            if (requestParameters.ContainsKey("Submit"))
            {
                string AvatarName     = requestParameters["AvatarName"].ToString();
                string AvatarPassword = requestParameters["AvatarPassword"].ToString();
                string FirstName      = requestParameters["FirstName"].ToString();
                string LastName       = requestParameters["LastName"].ToString();
                string UserAddress    = requestParameters["UserAddress"].ToString();
                string UserZip        = requestParameters["UserZip"].ToString();
                string UserCity       = requestParameters["UserCity"].ToString();
                string UserEmail      = requestParameters["UserEmail"].ToString();
                string UserDOBMonth   = requestParameters["UserDOBMonth"].ToString();
                string UserDOBDay     = requestParameters["UserDOBDay"].ToString();
                string UserDOBYear    = requestParameters["UserDOBYear"].ToString();
                string AvatarArchive  = requestParameters.ContainsKey("AvatarArchive") ? requestParameters["AvatarArchive"].ToString() : "";
                bool   ToSAccept      = requestParameters.ContainsKey("ToSAccept") && requestParameters["ToSAccept"].ToString() == "Accepted";

                IGenericsConnector generics = Aurora.DataManager.DataManager.RequestPlugin <IGenericsConnector>();
                var settings = generics.GetGeneric <GridSettings>(UUID.Zero, "WebSettings", "Settings");

                if (ToSAccept)
                {
                    AvatarPassword = Util.Md5Hash(AvatarPassword);

                    IUserAccountService accountService = webInterface.Registry.RequestModuleInterface <IUserAccountService>();
                    UUID   userID = UUID.Random();
                    string error  = accountService.CreateUser(userID, settings.DefaultScopeID, AvatarName, AvatarPassword, UserEmail);
                    if (error == "")
                    {
                        IAgentConnector con = Aurora.DataManager.DataManager.RequestPlugin <IAgentConnector>();
                        con.CreateNewAgent(userID);
                        IAgentInfo agent = con.GetAgent(userID);
                        agent.OtherAgentInformation["RLFirstName"]  = FirstName;
                        agent.OtherAgentInformation["RLLastName"]   = LastName;
                        agent.OtherAgentInformation["RLAddress"]    = UserAddress;
                        agent.OtherAgentInformation["RLCity"]       = UserCity;
                        agent.OtherAgentInformation["RLZip"]        = UserZip;
                        agent.OtherAgentInformation["UserDOBMonth"] = UserDOBMonth;
                        agent.OtherAgentInformation["UserDOBDay"]   = UserDOBDay;
                        agent.OtherAgentInformation["UserDOBYear"]  = UserDOBYear;

                        /*if (activationRequired)
                         * {
                         *  UUID activationToken = UUID.Random();
                         *  agent.OtherAgentInformation["WebUIActivationToken"] = Util.Md5Hash(activationToken.ToString() + ":" + PasswordHash);
                         *  resp["WebUIActivationToken"] = activationToken;
                         * }*/
                        con.UpdateAgent(agent);

                        if (AvatarArchive != "")
                        {
                            IProfileConnector profileData = Aurora.DataManager.DataManager.RequestPlugin <IProfileConnector>();
                            profileData.CreateNewProfile(userID);

                            IUserProfileInfo profile = profileData.GetUserProfile(userID);
                            profile.AArchiveName = AvatarArchive + ".database";
                            profile.IsNewUser    = true;
                            profileData.UpdateUserProfile(profile);
                        }

                        response = "<h3>Successfully created account, redirecting to main page</h3>" +
                                   "<script language=\"javascript\">" +
                                   "setTimeout(function() {window.location.href = \"index.html\";}, 3000);" +
                                   "</script>";
                    }
                    else
                    {
                        response = "<h3>" + error + "</h3>";
                    }
                }
                else
                {
                    response = "<h3>You did not accept the Terms of Service agreement.</h3>";
                }
                return(null);
            }

            List <Dictionary <string, object> > daysArgs = new List <Dictionary <string, object> >();

            for (int i = 1; i <= 31; i++)
            {
                daysArgs.Add(new Dictionary <string, object> {
                    { "Value", i }
                });
            }

            List <Dictionary <string, object> > monthsArgs = new List <Dictionary <string, object> >();

            for (int i = 1; i <= 12; i++)
            {
                monthsArgs.Add(new Dictionary <string, object> {
                    { "Value", i }
                });
            }

            List <Dictionary <string, object> > yearsArgs = new List <Dictionary <string, object> >();

            for (int i = 1900; i <= 2013; i++)
            {
                yearsArgs.Add(new Dictionary <string, object> {
                    { "Value", i }
                });
            }

            vars.Add("Days", daysArgs);
            vars.Add("Months", monthsArgs);
            vars.Add("Years", yearsArgs);

            List <AvatarArchive> archives = Aurora.DataManager.DataManager.RequestPlugin <IAvatarArchiverConnector>().GetAvatarArchives(true);

            List <Dictionary <string, object> > avatarArchives = new List <Dictionary <string, object> >();
            IWebHttpTextureService webTextureService           = webInterface.Registry.
                                                                 RequestModuleInterface <IWebHttpTextureService>();

            foreach (var archive in archives)
            {
                avatarArchives.Add(new Dictionary <string, object> {
                    { "AvatarArchiveName", archive.Name },
                    { "AvatarArchiveSnapshotID", archive.Snapshot },
                    { "AvatarArchiveSnapshotURL", webTextureService.GetTextureURL(UUID.Parse(archive.Snapshot)) }
                });
            }

            vars.Add("AvatarArchive", avatarArchives);


            IConfig loginServerConfig = webInterface.Registry.RequestModuleInterface <ISimulationBase>().ConfigSource.Configs["LoginService"];
            string  tosLocation       = "";

            if (loginServerConfig != null && loginServerConfig.GetBoolean("UseTermsOfServiceOnFirstLogin", false))
            {
                tosLocation = loginServerConfig.GetString("FileNameOfTOS", "");
            }
            string ToS = "There are no Terms of Service currently. This may be changed at any point in the future.";

            if (tosLocation != "")
            {
                System.IO.StreamReader reader = new System.IO.StreamReader(System.IO.Path.Combine(Environment.CurrentDirectory, tosLocation));
                ToS = reader.ReadToEnd();
                reader.Close();
            }
            vars.Add("ToSMessage", ToS);
            vars.Add("TermsOfServiceAccept", translator.GetTranslatedString("TermsOfServiceAccept"));
            vars.Add("TermsOfServiceText", translator.GetTranslatedString("TermsOfServiceText"));
            vars.Add("RegistrationsDisabled", translator.GetTranslatedString("RegistrationsDisabled"));
            vars.Add("RegistrationText", translator.GetTranslatedString("RegistrationText"));
            vars.Add("AvatarNameText", translator.GetTranslatedString("AvatarNameText"));
            vars.Add("AvatarPasswordText", translator.GetTranslatedString("Password"));
            vars.Add("AvatarPasswordConfirmationText", translator.GetTranslatedString("PasswordConfirmation"));
            vars.Add("AvatarScopeText", translator.GetTranslatedString("AvatarScopeText"));
            vars.Add("FirstNameText", translator.GetTranslatedString("FirstNameText"));
            vars.Add("LastNameText", translator.GetTranslatedString("LastNameText"));
            vars.Add("UserAddressText", translator.GetTranslatedString("UserAddressText"));
            vars.Add("UserZipText", translator.GetTranslatedString("UserZipText"));
            vars.Add("UserCityText", translator.GetTranslatedString("UserCityText"));
            vars.Add("UserCountryText", translator.GetTranslatedString("UserCountryText"));
            vars.Add("UserDOBText", translator.GetTranslatedString("UserDOBText"));
            vars.Add("UserEmailText", translator.GetTranslatedString("UserEmailText"));
            vars.Add("Accept", translator.GetTranslatedString("Accept"));
            vars.Add("Submit", translator.GetTranslatedString("Submit"));
            vars.Add("SubmitURL", "register.html");

            return(vars);
        }
 public ProfileInfoHandler()
 {
     ProfileConnector = DataManager.RequestPlugin <IProfileConnector>("IProfileConnectorLocal");
     AgentConnector   = DataManager.RequestPlugin <IAgentConnector>("IAgentConnectorLocal");
 }
        byte[] ProcessUpdateAgentPreferences(Stream request, UUID agentID)
        {
            OSDMap rm = OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request)) as OSDMap;

            if (rm == null)
            {
                return(MainServer.BadRequest);
            }
            IAgentConnector data = Framework.Utilities.DataManager.RequestPlugin <IAgentConnector> ();

            if (data != null)
            {
                IAgentInfo agent = data.GetAgent(agentID);
                if (agent == null)
                {
                    return(MainServer.BadRequest);
                }
                // Access preferences ?
                if (rm.ContainsKey("access_prefs"))
                {
                    OSDMap accessPrefs = (OSDMap)rm ["access_prefs"];
                    string Level       = accessPrefs ["max"].AsString();
                    int    maxLevel    = 0;
                    if (Level == "PG")
                    {
                        maxLevel = 0;
                    }
                    if (Level == "M")
                    {
                        maxLevel = 1;
                    }
                    if (Level == "A")
                    {
                        maxLevel = 2;
                    }
                    agent.MaturityRating = maxLevel;
                }
                // Next permissions
                if (rm.ContainsKey("default_object_perm_masks"))
                {
                    OSDMap permsMap = (OSDMap)rm ["default_object_perm_masks"];
                    agent.PermEveryone  = permsMap ["Everyone"].AsInteger();
                    agent.PermGroup     = permsMap ["Group"].AsInteger();
                    agent.PermNextOwner = permsMap ["NextOwner"].AsInteger();
                }
                // Hoverheight
                if (rm.ContainsKey("hover_height"))
                {
                    agent.HoverHeight = rm ["hover_height"].AsReal();
                }
                // Language
                if (rm.ContainsKey("language"))
                {
                    agent.Language = rm ["language"].AsString();
                }
                // Show Language to others / objects
                if (rm.ContainsKey("language_is_public"))
                {
                    agent.LanguageIsPublic = rm ["language_is_public"].AsBoolean();
                }
                data.UpdateAgent(agent);
                // Build a response that can be send back to the viewer
                OSDMap resp            = new OSDMap();
                OSDMap respAccessPrefs = new OSDMap();
                respAccessPrefs ["max"] = Utilities.GetMaxMaturity(agent.MaxMaturity);
                resp ["access_prefs"]   = respAccessPrefs;
                OSDMap respDefaultPerms = new OSDMap();
                respDefaultPerms ["Everyone"]      = agent.PermEveryone;
                respDefaultPerms ["Group"]         = agent.PermGroup;
                respDefaultPerms ["NextOwner"]     = agent.PermNextOwner;
                resp ["default_object_perm_masks"] = respDefaultPerms;
                resp ["god_level"]          = 0; // *TODO: Add this
                resp ["hover_height"]       = agent.HoverHeight;
                resp ["language"]           = agent.Language;
                resp ["language_is_public"] = agent.LanguageIsPublic;

                return(OSDParser.SerializeLLSDXmlBytes(resp));
            }
            return(MainServer.BlankResponse);
        }
Example #20
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";
                if (m_TOSLocation.ToLower().StartsWith("http://"))
                {
                    return(new LLFailedLoginResponse(LoginResponseEnum.ToSNeedsSent, m_TOSLocation, false));
                }

                // text file
                var ToSText = File.ReadAllText(Path.Combine(Environment.CurrentDirectory, m_TOSLocation));
                return(new LLFailedLoginResponse(LoginResponseEnum.ToSNeedsSent, ToSText, 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);
        }
Example #21
0
        private bool OnAllowedIncomingTeleport(UUID userID, IScene scene, Vector3 Position, out Vector3 newPosition, out string reason)
        {
            newPosition = Position;
            UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, userID);

            IScenePresence Sp = scene.GetScenePresence(userID);

            if (account == null)
            {
                reason = "Failed authentication.";
                return(false); //NO!
            }

            //Make sure that this user is inside the region as well
            if (Position.X < -2f || Position.Y < -2f ||
                Position.X > scene.RegionInfo.RegionSizeX + 2 || Position.Y > scene.RegionInfo.RegionSizeY + 2)
            {
                m_log.DebugFormat(
                    "[EstateService]: AllowedIncomingTeleport was given an illegal position of {0} for avatar {1}, {2}. Clamping",
                    Position, Name, userID);
                bool changedX = false;
                bool changedY = false;
                while (Position.X < 0)
                {
                    Position.X += scene.RegionInfo.RegionSizeX;
                    changedX    = true;
                }
                while (Position.X > scene.RegionInfo.RegionSizeX)
                {
                    Position.X -= scene.RegionInfo.RegionSizeX;
                    changedX    = true;
                }

                while (Position.Y < 0)
                {
                    Position.Y += scene.RegionInfo.RegionSizeY;
                    changedY    = true;
                }
                while (Position.Y > scene.RegionInfo.RegionSizeY)
                {
                    Position.Y -= scene.RegionInfo.RegionSizeY;
                    changedY    = true;
                }

                if (changedX)
                {
                    Position.X = scene.RegionInfo.RegionSizeX - Position.X;
                }
                if (changedY)
                {
                    Position.Y = scene.RegionInfo.RegionSizeY - Position.Y;
                }
            }

            //Check that we are not underground as well
            float posZLimit = scene.RequestModuleInterface <ITerrainChannel>()[(int)Position.X, (int)Position.Y] + (float)1.25;

            if (posZLimit >= (Position.Z) && !(Single.IsInfinity(posZLimit) || Single.IsNaN(posZLimit)))
            {
                Position.Z = posZLimit;
            }

            IAgentConnector AgentConnector = DataManager.DataManager.RequestPlugin <IAgentConnector>();
            IAgentInfo      agentInfo      = null;

            if (AgentConnector != null)
            {
                agentInfo = AgentConnector.GetAgent(userID);
            }

            ILandObject             ILO = null;
            IParcelManagementModule parcelManagement = scene.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                ILO = parcelManagement.GetLandObject(Position.X, Position.Y);
            }

            if (ILO == null)
            {
                //Can't find land, give them the first parcel in the region and find a good position for them
                ILO      = parcelManagement.AllParcels()[0];
                Position = parcelManagement.GetParcelCenterAtGround(ILO);
            }

            //parcel permissions
            if (ILO.IsBannedFromLand(userID)) //Note: restricted is dealt with in the next block
            {
                if (Sp == null)
                {
                    reason = "Banned from this parcel.";
                    return(true);
                }

                if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
                {
                    //We found a place for them, but we don't need to check any further
                    return(true);
                }
            }
            //Move them out of banned parcels
            ParcelFlags parcelflags = (ParcelFlags)ILO.LandData.Flags;

            if ((parcelflags & ParcelFlags.UseAccessGroup) == ParcelFlags.UseAccessGroup &&
                (parcelflags & ParcelFlags.UseAccessList) == ParcelFlags.UseAccessList &&
                (parcelflags & ParcelFlags.UsePassList) == ParcelFlags.UsePassList)
            {
                //One of these is in play then
                if ((parcelflags & ParcelFlags.UseAccessGroup) == ParcelFlags.UseAccessGroup)
                {
                    if (Sp == null)
                    {
                        reason = "Banned from this parcel.";
                        return(true);
                    }
                    if (Sp.ControllingClient.ActiveGroupId != ILO.LandData.GroupID)
                    {
                        if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
                        {
                            //We found a place for them, but we don't need to check any further
                            return(true);
                        }
                    }
                }
                else if ((parcelflags & ParcelFlags.UseAccessList) == ParcelFlags.UseAccessList)
                {
                    if (Sp == null)
                    {
                        reason = "Banned from this parcel.";
                        return(true);
                    }
                    //All but the people on the access list are banned
                    if (ILO.IsRestrictedFromLand(userID))
                    {
                        if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
                        {
                            //We found a place for them, but we don't need to check any further
                            return(true);
                        }
                    }
                }
                else if ((parcelflags & ParcelFlags.UsePassList) == ParcelFlags.UsePassList)
                {
                    if (Sp == null)
                    {
                        reason = "Banned from this parcel.";
                        return(true);
                    }
                    //All but the people on the pass/access list are banned
                    if (ILO.IsRestrictedFromLand(Sp.UUID))
                    {
                        if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
                        {
                            //We found a place for them, but we don't need to check any further
                            return(true);
                        }
                    }
                }
            }

            EstateSettings ES = scene.RegionInfo.EstateSettings;

            //Move them to the nearest landing point
            if (!ES.AllowDirectTeleport)
            {
                if (!scene.Permissions.IsGod(userID))
                {
                    Telehub telehub = RegionConnector.FindTelehub(scene.RegionInfo.RegionID, scene.RegionInfo.RegionHandle);
                    if (telehub != null)
                    {
                        if (telehub.SpawnPos.Count == 0)
                        {
                            Position = new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ);
                        }
                        else
                        {
                            int LastTelehubNum = 0;
                            if (!LastTelehub.TryGetValue(scene.RegionInfo.RegionID, out LastTelehubNum))
                            {
                                LastTelehubNum = 0;
                            }
                            Position = telehub.SpawnPos[LastTelehubNum] + new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ);
                            LastTelehubNum++;
                            if (LastTelehubNum == telehub.SpawnPos.Count)
                            {
                                LastTelehubNum = 0;
                            }
                            LastTelehub[scene.RegionInfo.RegionID] = LastTelehubNum;
                        }
                    }
                }
            }
            if (!scene.Permissions.GenericParcelPermission(userID, ILO, (ulong)GroupPowers.None))
            {
                if (ILO.LandData.LandingType == 2) //Blocked, force this person off this land
                {
                    //Find a new parcel for them
                    List <ILandObject> Parcels = parcelManagement.ParcelsNearPoint(Position);
                    if (Parcels.Count == 0)
                    {
                        IScenePresence SP;
                        scene.TryGetScenePresence(userID, out SP);
                        newPosition = parcelManagement.GetNearestRegionEdgePosition(SP);
                    }
                    else
                    {
                        bool found = false;
                        //We need to check here as well for bans, can't toss someone into a parcel they are banned from
                        foreach (ILandObject Parcel in Parcels)
                        {
                            if (!Parcel.IsBannedFromLand(userID))
                            {
                                //Now we have to check their userloc
                                if (ILO.LandData.LandingType == 2)
                                {
                                    continue;                           //Blocked, check next one
                                }
                                else if (ILO.LandData.LandingType == 1) //Use their landing spot
                                {
                                    newPosition = Parcel.LandData.UserLocation;
                                }
                                else //They allow for anywhere, so dump them in the center at the ground
                                {
                                    newPosition = parcelManagement.GetParcelCenterAtGround(Parcel);
                                }
                                found = true;
                            }
                        }
                        if (!found) //Dump them at the edge
                        {
                            if (Sp != null)
                            {
                                newPosition = parcelManagement.GetNearestRegionEdgePosition(Sp);
                            }
                            else
                            {
                                reason = "Banned from this parcel.";
                                return(true);
                            }
                        }
                    }
                }
                else if (ILO.LandData.LandingType == 1) //Move to tp spot
                {
                    if (ILO.LandData.UserLocation != Vector3.Zero)
                    {
                        newPosition = ILO.LandData.UserLocation;
                    }
                    else // Dump them at the nearest region corner since they havn't set a landing point
                    {
                        newPosition = parcelManagement.GetNearestRegionEdgePosition(Sp);
                    }
                }
            }

            //We assume that our own region isn't null....
            if (agentInfo != null)
            {
                //Can only enter prelude regions once!
                int flags = scene.GridService.GetRegionFlags(scene.RegionInfo.ScopeID, scene.RegionInfo.RegionID);
                if (flags != -1 && ((flags & (int)Aurora.Framework.RegionFlags.Prelude) == (int)Aurora.Framework.RegionFlags.Prelude) && agentInfo != null)
                {
                    if (agentInfo.OtherAgentInformation.ContainsKey("Prelude" + scene.RegionInfo.RegionID))
                    {
                        reason = "You may not enter this region as you have already been to this prelude region.";
                        return(false);
                    }
                    else
                    {
                        agentInfo.OtherAgentInformation.Add("Prelude" + scene.RegionInfo.RegionID, OSD.FromInteger((int)IAgentFlags.PastPrelude));
                        AgentConnector.UpdateAgent(agentInfo); //This only works for standalones... and thats ok
                    }
                }
            }


            if ((ILO.LandData.Flags & (int)ParcelFlags.DenyAnonymous) != 0)
            {
                if ((account.UserFlags & (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile) == (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile)
                {
                    reason = "You may not enter this region.";
                    return(false);
                }
            }

            if ((ILO.LandData.Flags & (uint)ParcelFlags.DenyAgeUnverified) != 0 && agentInfo != null)
            {
                if ((agentInfo.Flags & IAgentFlags.Minor) == IAgentFlags.Minor)
                {
                    reason = "You may not enter this region.";
                    return(false);
                }
            }

            newPosition = Position;
            reason      = "";
            return(true);
        }
Example #22
0
        private bool OnAllowedIncomingAgent(IScene scene, AgentCircuitData agent, bool isRootAgent, out string reason)
        {
            #region Incoming Agent Checks

            UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, agent.AgentID);

            IScenePresence Sp = scene.GetScenePresence(agent.AgentID);
            if (account == null)
            {
                reason = "Failed authentication.";
                return(false); //NO!
            }

            if (LoginsDisabled)
            {
                reason = "Logins Disabled";
                return(false);
            }

            //Check how long its been since the last TP
            if (m_enabledBlockTeleportSeconds && Sp != null && !Sp.IsChildAgent)
            {
                if (TimeSinceLastTeleport.ContainsKey(Sp.Scene.RegionInfo.RegionID))
                {
                    if (TimeSinceLastTeleport[Sp.Scene.RegionInfo.RegionID] > Util.UnixTimeSinceEpoch())
                    {
                        reason = "Too many teleports. Please try again soon.";
                        return(false); // Too soon since the last TP
                    }
                }
                TimeSinceLastTeleport[Sp.Scene.RegionInfo.RegionID] = Util.UnixTimeSinceEpoch() + ((int)(SecondsBeforeNextTeleport));
            }

            //Gods tp freely
            if ((Sp != null && Sp.GodLevel != 0) || account.UserLevel != 0)
            {
                reason = "";
                return(true);
            }

            //Check whether they fit any ban criteria
            if (Sp != null)
            {
                foreach (string banstr in BanCriteria)
                {
                    if (Sp.Name.Contains(banstr))
                    {
                        reason = "You have been banned from this region.";
                        return(false);
                    }
                    else if (((System.Net.IPEndPoint)Sp.ControllingClient.GetClientEP()).Address.ToString().Contains(banstr))
                    {
                        reason = "You have been banned from this region.";
                        return(false);
                    }
                }
                //Make sure they exist in the grid right now
                OpenSim.Services.Interfaces.IAgentInfoService presence = scene.RequestModuleInterface <IAgentInfoService>();
                if (presence == null)
                {
                    reason = String.Format("Failed to verify user presence in the grid for {0} in region {1}. Presence service does not exist.", account.Name, scene.RegionInfo.RegionName);
                    return(false);
                }

                OpenSim.Services.Interfaces.UserInfo pinfo = presence.GetUserInfo(agent.AgentID.ToString());

                if (pinfo == null || (!pinfo.IsOnline && ((agent.teleportFlags & (uint)TeleportFlags.ViaLogin) == 0)))
                {
                    reason = String.Format("Failed to verify user presence in the grid for {0}, access denied to region {1}.", account.Name, scene.RegionInfo.RegionName);
                    return(false);
                }
            }

            EstateSettings ES = scene.RegionInfo.EstateSettings;

            IEntityCountModule entityCountModule = scene.RequestModuleInterface <IEntityCountModule>();
            if (entityCountModule != null && scene.RegionInfo.RegionSettings.AgentLimit
                < entityCountModule.RootAgents + 1)
            {
                reason = "Too many agents at this time. Please come back later.";
                return(false);
            }

            List <EstateBan> EstateBans = new List <EstateBan>(ES.EstateBans);
            int i = 0;
            //Check bans
            foreach (EstateBan ban in EstateBans)
            {
                if (ban.BannedUserID == agent.AgentID)
                {
                    if (Sp != null)
                    {
                        string banIP = ((System.Net.IPEndPoint)Sp.ControllingClient.GetClientEP()).Address.ToString();

                        if (ban.BannedHostIPMask != banIP) //If it changed, ban them again
                        {
                            //Add the ban with the new hostname
                            ES.AddBan(new EstateBan()
                            {
                                BannedHostIPMask   = banIP,
                                BannedUserID       = ban.BannedUserID,
                                EstateID           = ban.EstateID,
                                BannedHostAddress  = ban.BannedHostAddress,
                                BannedHostNameMask = ban.BannedHostNameMask
                            });
                            //Update the database
                            ES.Save();
                        }
                    }

                    reason = "Banned from this region.";
                    return(false);
                }
                if (Sp != null)
                {
                    IPAddress   end  = Sp.ControllingClient.EndPoint;
                    IPHostEntry rDNS = null;
                    try
                    {
                        rDNS = Dns.GetHostEntry(end);
                    }
                    catch (System.Net.Sockets.SocketException)
                    {
                        m_log.WarnFormat("[IPBAN] IP address \"{0}\" cannot be resolved via DNS", end);
                        rDNS = null;
                    }
                    if (ban.BannedHostIPMask == agent.IPAddress ||
                        (rDNS != null && rDNS.HostName.Contains(ban.BannedHostIPMask)) ||
                        end.ToString().StartsWith(ban.BannedHostIPMask))
                    {
                        //Ban the new user
                        ES.AddBan(new EstateBan()
                        {
                            EstateID           = ES.EstateID,
                            BannedHostIPMask   = agent.IPAddress,
                            BannedUserID       = agent.AgentID,
                            BannedHostAddress  = agent.IPAddress,
                            BannedHostNameMask = agent.IPAddress
                        });
                        ES.Save();

                        reason = "Banned from this region.";
                        return(false);
                    }
                }
                i++;
            }

            //Estate owners/managers/access list people/access groups tp freely as well
            if (ES.EstateOwner == agent.AgentID ||
                new List <UUID>(ES.EstateManagers).Contains(agent.AgentID) ||
                new List <UUID>(ES.EstateAccess).Contains(agent.AgentID) ||
                (Sp != null && new List <UUID>(ES.EstateGroups).Contains(Sp.ControllingClient.ActiveGroupId)))
            {
                reason = "";
                return(true);
            }

            if (ES.DenyAnonymous && ((account.UserFlags & (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile) == (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile))
            {
                reason = "You may not enter this region.";
                return(false);
            }

            if (ES.DenyIdentified && ((account.UserFlags & (int)IUserProfileInfo.ProfileFlags.PaymentInfoOnFile) == (int)IUserProfileInfo.ProfileFlags.PaymentInfoOnFile))
            {
                reason = "You may not enter this region.";
                return(false);
            }

            if (ES.DenyTransacted && ((account.UserFlags & (int)IUserProfileInfo.ProfileFlags.PaymentInfoInUse) == (int)IUserProfileInfo.ProfileFlags.PaymentInfoInUse))
            {
                reason = "You may not enter this region.";
                return(false);
            }

            long m_Day = 25 * 60 * 60; //Find out day length in seconds
            if (scene.RegionInfo.RegionSettings.MinimumAge != 0 && (account.Created - Util.UnixTimeSinceEpoch()) < (scene.RegionInfo.RegionSettings.MinimumAge * m_Day))
            {
                reason = "You may not enter this region.";
                return(false);
            }

            if (!ES.PublicAccess)
            {
                reason = "You may not enter this region.";
                return(false);
            }

            IAgentConnector AgentConnector = DataManager.DataManager.RequestPlugin <IAgentConnector>();
            IAgentInfo      agentInfo      = null;
            if (AgentConnector != null)
            {
                agentInfo = AgentConnector.GetAgent(agent.AgentID);
                if (agentInfo == null)
                {
                    AgentConnector.CreateNewAgent(agent.AgentID);
                    agentInfo = AgentConnector.GetAgent(agent.AgentID);
                }
            }


            if (agentInfo != null && scene.RegionInfo.AccessLevel > Util.ConvertMaturityToAccessLevel((uint)agentInfo.MaturityRating))
            {
                reason = "The region has too high of a maturity level. Blocking teleport.";
                return(false);
            }

            if (agentInfo != null && ES.DenyMinors && (agentInfo.Flags & IAgentFlags.Minor) == IAgentFlags.Minor)
            {
                reason = "The region has too high of a maturity level. Blocking teleport.";
                return(false);
            }

            #endregion

            reason = "";
            return(true);
        }
        /// <summary>
        /// Creates a user
        /// TODO: Does not implement the restrict to estate option
        /// </summary>
        /// <param name="map"></param>
        /// <returns></returns>
        private OSD CreateUser(OSDMap map)
        {
            //Required params
            string username     = map["username"];
            int    last_name_id = map["last_name_id"];
            string email        = map["email"];
            string password     = map["password"];
            string dob          = map["dob"];

            //Optional params
            int    limited_to_estate = map["limited_to_estate"];
            string start_region_name = map["start_region_name"];
            float  start_local_x     = map["start_local_x"];
            float  start_local_y     = map["start_local_y"];
            float  start_local_z     = map["start_local_z"];
            float  start_look_at_x   = map["start_look_at_x"];
            float  start_look_at_y   = map["start_look_at_y"];
            float  start_look_at_z   = map["start_look_at_z"];
            OSD    resp = null;

            if (username != "" && last_name_id != 0 && email != "" &&
                password != "" && dob != "")
            {
                IUserAccountService accountService = m_registry.RequestModuleInterface <IUserAccountService>();
                if (m_lastNameRegistry.ContainsKey(last_name_id))
                {
                    string      lastName = m_lastNameRegistry[last_name_id];
                    UserAccount user     = accountService.GetUserAccount(null, username, lastName);
                    if (user == null)
                    {
                        //The pass is in plain text... so put it in and create the account
                        accountService.CreateUser(username + " " + lastName, password, email);
                        DateTime time = DateTime.ParseExact(dob, "YYYY-MM-DD", System.Globalization.CultureInfo.InvariantCulture);
                        user = accountService.GetUserAccount(null, username, lastName);
                        //Update the dob
                        user.Created = Util.ToUnixTime(time);
                        accountService.StoreUserAccount(user);

                        IAgentConnector agentConnector = Aurora.Framework.Utilities.DataManager.RequestPlugin <IAgentConnector>();
                        if (agentConnector != null)
                        {
                            agentConnector.CreateNewAgent(user.PrincipalID);
                            if (map.ContainsKey("limited_to_estate"))
                            {
                                IAgentInfo agentInfo = agentConnector.GetAgent(user.PrincipalID);
                                agentInfo.OtherAgentInformation["LimitedToEstate"] = limited_to_estate;
                                agentConnector.UpdateAgent(agentInfo);
                            }
                        }

                        MainConsole.Instance.Info("[RegApi]: Created new user " + user.Name);
                        try
                        {
                            if (start_region_name != "")
                            {
                                IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService>();
                                if (agentInfoService != null)
                                {
                                    agentInfoService.SetHomePosition(user.PrincipalID.ToString(),
                                                                     m_registry.RequestModuleInterface <IGridService>().GetRegionByName
                                                                         (null, start_region_name).RegionID,
                                                                     new Vector3(start_local_x,
                                                                                 start_local_y,
                                                                                 start_local_z),
                                                                     new Vector3(start_look_at_x,
                                                                                 start_look_at_y,
                                                                                 start_look_at_z));
                                }
                            }
                        }
                        catch
                        {
                            MainConsole.Instance.Warn("[RegApi]: Encountered an error when setting the home position of a new user");
                        }
                        OSDMap r = new OSDMap();
                        r["agent_id"] = user.PrincipalID;
                        resp          = r;
                    }
                    else //Already exists
                    {
                        resp = false;
                    }
                }
                else //Could not find last name
                {
                    resp = false;
                }
            }
            else //Not enough params
            {
                resp = false;
            }

            return(resp);
        }