示例#1
0
        private async void AuthenticatCredentials(string name, string passphrase)
        {
            AuthenticateHandler auth = new AuthenticateHandler();

            auth.Name     = name;
            auth.Password = passphrase;

            string response = auth.Validate();

            if (response.Contains("The user"))
            {
                await main.ShowMessageAsync("Non-existant User", response);
            }
            else if (response.Contains("Incorrect"))
            {
                await main.ShowMessageAsync("Incorrect Password", response);
            }
            else
            {
                await main.ShowMessageAsync("Successful login", response);

                string token = auth.RetrieveAccessToken();
                SuccessfulLoginAsync(token);
            }
        }
示例#2
0
        /// <summary>
        ///     Tell a single agent to disconnect from the region.
        ///     Does not send the DisableSimulator EQM or close child agents
        /// </summary>
        /// <param name="?"></param>
        /// <param name="presence"></param>
        /// <param name="forceClose"></param>
        /// <returns></returns>
        public bool RemoveAgent(IScenePresence presence, bool forceClose)
        {
            AddAsyncEvent(delegate
            {
                presence.ControllingClient.Close(forceClose);
                foreach (IClientNetworkServer cns in m_clientServers)
                {
                    cns.RemoveClient(presence.ControllingClient);
                }

                if (presence.ParentID != UUID.Zero)
                {
                    presence.StandUp();
                }

                EventManager.TriggerOnClosingClient(presence.ControllingClient);
                EventManager.TriggerOnRemovePresence(presence);

                ForEachClient(
                    delegate(IClientAPI client)
                {
                    if (client.AgentId != presence.UUID)
                    {
                        //We can safely ignore null reference exceptions.  It means the avatar is dead and cleaned up anyway
                        try
                        {
                            client.SendKillObject(presence.Scene.RegionInfo.RegionHandle,
                                                  new IEntity[] { presence });
                        }
                        catch (NullReferenceException)
                        {
                        }
                    }
                });

                // Remove the avatar from the scene
                m_sceneGraph.RemoveScenePresence(presence);
                m_clientManager.Remove(presence.UUID);

                try
                {
                    presence.Close();
                }
                catch (Exception e)
                {
                    MainConsole.Instance.Error(
                        "[SCENE] Scene.cs:RemoveClient:Presence.Close exception: " + e);
                }

                //Remove any interfaces it might have stored
                presence.RemoveAllInterfaces();

                AuthenticateHandler.RemoveCircuit(presence.UUID);
                //MainConsole.Instance.InfoFormat("[SCENE] Memory pre  GC {0}", System.GC.GetTotalMemory(false));
                //MainConsole.Instance.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
            });
            return(true);
        }
示例#3
0
        /// <summary>
        /// Adding a New Client and Create a Presence for it.
        /// Called by the LLClientView when the UseCircuitCode packet comes in
        /// Used by NPCs to add themselves to the Scene
        /// </summary>
        /// <param name="client"></param>
        public void AddNewClient(IClientAPI client)
        {
            try
            {
                System.Net.IPEndPoint ep       = (System.Net.IPEndPoint)client.GetClientEP();
                AgentCircuitData      aCircuit = AuthenticateHandler.AuthenticateSession(client.SessionId, client.AgentId, client.CircuitCode, ep);

                if (aCircuit == null) // no good, didn't pass NewUserConnection successfully
                {
                    return;
                }

                m_clientManager.Add(client);

                //Create the scenepresence
                IScenePresence sp = m_sceneGraph.CreateAndAddChildScenePresence(client);
                sp.IsChildAgent = aCircuit.child;


                //Trigger events
                m_eventManager.TriggerOnNewPresence(sp);

                //Make sure the appearanace is updated
                if (aCircuit != null)
                {
                    IAvatarAppearanceModule appearance = sp.RequestModuleInterface <IAvatarAppearanceModule> ();
                    if (appearance != null)
                    {
                        appearance.Appearance = aCircuit.Appearance;
                    }
                }

                if (GetScenePresence(client.AgentId) != null)
                {
                    EventManager.TriggerOnNewClient(client);
                    if ((aCircuit.teleportFlags & (uint)TeleportFlags.ViaLogin) != 0)
                    {
                        EventManager.TriggerOnClientLogin(client);
                    }
                }

                //Add the client to login stats
                ILoginMonitor monitor = (ILoginMonitor)RequestModuleInterface <IMonitorModule>().GetMonitor("", "LoginMonitor");
                if ((aCircuit.teleportFlags & (uint)TeleportFlags.ViaLogin) != 0 && monitor != null)
                {
                    monitor.AddSuccessfulLogin();
                }
            }
            catch (Exception ex)
            {
                m_log.Warn("[Scene]: Error in AddNewClient: " + ex.ToString());
            }
        }
示例#4
0
        /// <summary>
        ///     Adding a New Client and Create a Presence for it.
        ///     Called by the LLClientView when the UseCircuitCode packet comes in
        ///     Used by NPCs to add themselves to the Scene
        /// </summary>
        /// <param name="client"></param>
        /// <param name="completed"></param>
        public void AddNewClient(IClientAPI client, BlankHandler completed)
        {
            AddAsyncEvent(delegate
            {
                try
                {
                    AgentCircuitData aCircuit = AuthenticateHandler.GetAgentCircuitData(client.AgentId);

                    m_clientManager.Add(client);

                    //Create the scenepresence
                    IScenePresence sp = CreateAndAddChildScenePresence(client);
                    sp.IsChildAgent   = aCircuit.IsChildAgent;

                    //Trigger events
                    m_eventManager.TriggerOnNewPresence(sp);

                    if (GetScenePresence(client.AgentId) != null)
                    {
                        EventManager.TriggerOnNewClient(client);
                        if ((aCircuit.TeleportFlags & (uint)TeleportFlags.ViaLogin) != 0)
                        {
                            EventManager.TriggerOnClientLogin(client);
                        }
                    }

                    //Add the client to login stats
                    ILoginMonitor monitor3 = RequestModuleInterface <IMonitorModule>().GetMonitor <ILoginMonitor>(null);
                    if ((aCircuit.TeleportFlags & (uint)TeleportFlags.ViaLogin) != 0 &&
                        monitor3 != null)
                    {
                        monitor3.AddSuccessfulLogin();
                    }

                    if (sp.IsChildAgent)
                    {
                        //If we're a child, trigger this so that we get updated in the modules
                        sp.TriggerSignificantClientMovement();
                    }
                    if (completed != null)
                    {
                        completed();
                    }
                }
                catch (Exception ex)
                {
                    MainConsole.Instance.Warn("[Scene]: Error in AddNewClient: " + ex);
                }
            });
        }
		public void SignOut(AuthenticateHandler callback)
		{
			Contract.ArgumentNotNull("callback", callback);
			
			try
			{
				// TODO Release token
				Token = null;

				callback(true, null);
			}
			catch (Exception e)
			{
				if (callback != null)
				{
					callback(false, e.Message);
				}
			}
		}
示例#6
0
        public void SignOut(AuthenticateHandler callback)
        {
            Contract.ArgumentNotNull("callback", callback);

            try
            {
                // TODO Release token
                Token = null;

                callback(true, null);
            }
            catch (Exception e)
            {
                if (callback != null)
                {
                    callback(false, e.Message);
                }
            }
        }
示例#7
0
        /// <summary>
        /// Tell a single agent to disconnect from the region.
        /// Does not send the DisableSimulator EQM or close child agents
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        public bool RemoveAgent(IScenePresence presence)
        {
            presence.ControllingClient.Close();
            if (presence.ParentID != UUID.Zero)
            {
                presence.StandUp();
            }

            EventManager.TriggerClientClosed(presence.UUID, this);
            EventManager.TriggerOnClosingClient(presence.ControllingClient);
            EventManager.TriggerOnRemovePresence(presence);

            ForEachClient(
                delegate(IClientAPI client)
            {
                //We can safely ignore null reference exceptions.  It means the avatar is dead and cleaned up anyway
                try { client.SendKillObject(presence.Scene.RegionInfo.RegionHandle, new IEntity[] { presence }); }
                catch (NullReferenceException) { }
            });

            try
            {
                presence.Close();
            }
            catch (Exception e)
            {
                m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
            }

            //Remove any interfaces it might have stored
            presence.RemoveAllInterfaces();

            // Remove the avatar from the scene
            m_sceneGraph.RemoveScenePresence(presence);
            m_clientManager.Remove(presence.UUID);

            AuthenticateHandler.RemoveCircuit(presence.ControllingClient.CircuitCode);
            //m_log.InfoFormat("[SCENE] Memory pre  GC {0}", System.GC.GetTotalMemory(false));
            //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
            return(true);
        }
示例#8
0
        /// <summary>
        /// Adding a New Client and Create a Presence for it.
        /// Called by the LLClientView when the UseCircuitCode packet comes in
        /// Used by NPCs to add themselves to the Scene
        /// </summary>
        /// <param name="client"></param>
        /// <param name="completed"></param>
        public void AddNewClient(IClientAPI client, BlankHandler completed)
        {
            lock (m_events)
                m_events.Add(delegate
                {
                    try
                    {
                        System.Net.IPEndPoint ep  = (System.Net.IPEndPoint)client.GetClientEP();
                        AgentCircuitData aCircuit = AuthenticateHandler.AuthenticateSession(client.SessionId, client.AgentId, client.CircuitCode, ep);

                        if (aCircuit == null) // no good, didn't pass NewUserConnection successfully
                        {
                            completed();
                            return;
                        }

                        m_clientManager.Add(client);

                        //Create the scenepresence
                        IScenePresence sp = CreateAndAddChildScenePresence(client);
                        sp.IsChildAgent   = aCircuit.child;
                        sp.DrawDistance   = aCircuit.DrawDistance;

                        //Trigger events
                        m_eventManager.TriggerOnNewPresence(sp);

                        //Make sure the appearanace is updated
                        IAvatarAppearanceModule appearance = sp.RequestModuleInterface <IAvatarAppearanceModule>();
                        if (appearance != null)
                        {
                            appearance.Appearance = aCircuit.Appearance ?? sp.Scene.AvatarService.GetAppearance(sp.UUID);
                            if (appearance.Appearance == null)
                            {
                                MainConsole.Instance.Error("[AsyncScene]: NO AVATAR APPEARANCE FOUND FOR " + sp.Name);
                                appearance.Appearance = new AvatarAppearance(sp.UUID);
                            }
                        }

                        if (GetScenePresence(client.AgentId) != null)
                        {
                            EventManager.TriggerOnNewClient(client);
                            if ((aCircuit.teleportFlags & (uint)TeleportFlags.ViaLogin) != 0)
                            {
                                EventManager.TriggerOnClientLogin(client);
                            }
                        }

                        //Add the client to login stats
                        ILoginMonitor monitor3 = (ILoginMonitor)RequestModuleInterface <IMonitorModule>().GetMonitor("", MonitorModuleHelper.LoginMonitor);
                        if ((aCircuit.teleportFlags & (uint)TeleportFlags.ViaLogin) != 0 && monitor3 != null)
                        {
                            monitor3.AddSuccessfulLogin();
                        }

                        if (sp.IsChildAgent)//If we're a child, trigger this so that we get updated in the modules
                        {
                            sp.TriggerSignificantClientMovement();
                        }
                        completed();
                    }
                    catch (Exception ex)
                    {
                        MainConsole.Instance.Warn("[Scene]: Error in AddNewClient: " + ex);
                    }
                });
        }
示例#9
0
        public static void Authenticate(string apiUrl, string username, string password, AuthenticateHandler authenticateHandler)
        {
            var requestObject = new { Username = username, Password = password };

            PostAsync <AuthenticateResult>(ValidateUrl(apiUrl), requestObject, (authenticateResult, statusCode) =>
            {
                if (statusCode != HttpStatusCode.OK)
                {
                    return;
                }

                if (authenticateResult.AuthenticateStatusCode == AuthenticateStatusCode.OK)
                {
                    BearerToken     = authenticateResult.token;
                    IsAuthenticated = true;
                }

                authenticateHandler.Invoke(authenticateResult);
            });
        }
 public BasicAuthentication(AuthenticateHandler handler)
 {
     _handler = handler;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DigestAuthentication"/> class.
 /// </summary>
 /// <param name="authenticator">The authenticator.</param>
 public DigestAuthentication(AuthenticateHandler authenticator)
 {
     _authenticator = authenticator;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DigestAuthentication"/> class.
 /// </summary>
 /// <param name="authenticator">The authenticator.</param>
 public DigestAuthentication(AuthenticateHandler authenticator)
 {
     _authenticator = authenticator;
 }
 public BasicAuthentication(AuthenticateHandler handler)
 {
     _handler = handler;
 }