/// <summary> /// Sets the remote client associated with the socket /// </summary> /// <param name="socket">socket</param> /// <param name="client">remote clien</param> public static void SetRemoteClient(this AsyncSocket socket, RemoteClient client) { remoteClient = client; }
public AutoLoginToken(string key, RemoteClient client) { Key = key; Issued = DateTime.Now; Client = client; }
private bool CheckAuthenticationRequest(RemoteClient client, JToken msg) { if (msg == null || !msg.HasValues) { WifiRemote.LogMessage("Client sent empty authentication String", WifiRemote.LogType.Warn); return false; } AuthMethod auth = AllowedAuth; if (auth == AuthMethod.None) { // Every auth request is valid for AuthMethod.None return true; } JObject message = (JObject)msg; // For AuthMethod.Both we have to check which method was choosen. if (AllowedAuth == AuthMethod.Both) { if (message["AuthMethod"] == null) { WifiRemote.LogMessage("User " + client.ToString() + " authentification failed, no authMethod submitted", WifiRemote.LogType.Info); return false; } else { String authString = (string)message["AuthMethod"]; if (authString != null) { if (authString.Equals("userpass")) { auth = AuthMethod.UserPassword; } else if (authString.Equals("passcode")) { auth = AuthMethod.Passcode; } else { WifiRemote.LogMessage("User " + client.ToString() + " authentification failed, invalid authMethod '" + authString + "'", WifiRemote.LogType.Info); return false; } } } } // Check user credentials if (auth == AuthMethod.UserPassword) { if (message["User"] != null && message["Password"] != null) { String user = (string)message["User"]; String pass = (string)message["Password"]; if (user.Equals(this.UserName) && pass.Equals(this.Password)) { client.AuthenticatedBy = auth; client.User = user; client.Password = pass; client.IsAuthenticated = true; WifiRemote.LogMessage("User " + client.ToString() + " successfully authentificated by username and password", WifiRemote.LogType.Debug); return true; } } } else if (auth == AuthMethod.Passcode) { if (message["PassCode"] != null) { String pass = (string)message["PassCode"]; if (pass.Equals(this.PassCode)) { client.AuthenticatedBy = auth; client.PassCode = pass; client.IsAuthenticated = true; WifiRemote.LogMessage("User " + client.ToString() + " successfully authentificated by passcode", WifiRemote.LogType.Debug); return true; } } } WifiRemote.LogMessage("User " + client.ToString() + " authentification failed", WifiRemote.LogType.Info); return false; }