/// <summary> /// Authenticates using the specified email. /// </summary> /// <param name="gameId">The game id.</param> /// <param name="userName">The username.</param> /// <param name="password">The password.</param> /// <returns>A valid PlayerIOClient instance.</returns> /// <exception cref="System.NotSupportedException">Mousebreaker login is not supported for the specified game.</exception> /// <exception cref="AuthenticationException">Invalid credentials for Mousebreaker authentication.</exception> public static Client Authenticate(string gameId, string userName, string password, string[] playerInsightSegments = null) { if (gameId != EERabbitAuth.GameId) { throw new NotSupportedException(); } var c = Simple.Authenticate(gameId, "guest", "guest"); var userId = c.BigDB.Load("usernames", userName)["owner"].ToString(); if (userId.StartsWith("mouse", StringComparison.CurrentCulture)) { return(Simple.Authenticate(gameId, userId.Substring(5), password)); } else { if (userId != null) { // It's possible that a user chose a password that happened to be a base64 string // that's 88 characters long and they do not use mousebreaker. // Reset authentication type and try again var rabbit = new RabbitAuth(); rabbit.AuthenticationType = AuthenticationType.Unknown; return(rabbit.LogOn(gameId, userId, password)); } } throw new AuthenticationException(); }
public void MousebreakerAuthenticationTest() { var authResult = RabbitAuth.GetAuthType("*****@*****.**", "cHJvY2Vzc29yX3dpbGxfbmV2ZXJfZmluZF90aGlzX211YWhhaGFfd2VsbF9tYXliZV9oZV93aWxsX2J1dF9pXw=="); Assert.AreEqual(AuthenticationType.Mousebreaker, authResult); var invalidEmail = RabbitAuth.GetAuthType("testinvalidemailexample.com", "cHJvY2Vzc29yX3dpbGxfbmV2ZXJfZmluZF90aGlzX211YWhhaGFfd2VsbF9tYXliZV9oZV93aWxsX2J1dF9pXw=="); Assert.AreNotEqual(AuthenticationType.Mousebreaker, invalidEmail); }
public void RegularAuthenticationTest() { var authResult = RabbitAuth.GetAuthType("*****@*****.**", "testpassword"); Assert.AreEqual(AuthenticationType.Regular, authResult); var authResultLongEmail = RabbitAuth.GetAuthType("*****@*****.**", "testpass"); Assert.AreEqual(AuthenticationType.Regular, authResultLongEmail); }
public void NullAuthenticationTest() { AuthenticationException expectedException = null; try { RabbitAuth.GetAuthType(null, null); } catch (AuthenticationException ex) { expectedException = ex; } Assert.IsNotNull(expectedException); }
public void InvalidAuthenticationTest() { InvalidOperationException expectedException = null; try { RabbitAuth.GetAuthType("47823", "notahexadecimalstringohno"); } catch (InvalidOperationException ex) { expectedException = ex; } Assert.IsNull(expectedException); }
public void FacebookAuthenticationTest() { var authResult = RabbitAuth.GetAuthType(null, "TcsL8qdSwvzDqudWGfYEGF5RrBLBSanHW78t5Z87ngKzUDdhCE4Jbtq6Vrwk2vuVS8WW2RYT54hwFxchWywLLvQaUyA2k2fanfAs"); Assert.AreEqual(AuthenticationType.Facebook, authResult); }
public void ArmorGamesAuthenticationTest() { var authResult = RabbitAuth.GetAuthType("ee6ab941d09050400c4f916dbb47aad8", "23b9a5088c3c940f82945b6f3df80abc"); Assert.AreEqual(AuthenticationType.ArmorGames, authResult); }
public void KongregateAuthenticationTest() { var authResult = RabbitAuth.GetAuthType("123456", "969ad76abf19b5c3e5917321e659abe6d8d6f3aba73e5158863c3b4159c00366"); Assert.AreEqual(AuthenticationType.Kongregate, authResult); }
public void Start(string email, string password, string roomId, string[] directories, IStorageProvider storage) { this._storage = storage; this.LogMessage(String.Format("Welcome to CupCake! (API version: {0})", this.GetVersion())); // Create the client this._client = new CupCakeClient(new AssemblyCatalog(Assembly.GetExecutingAssembly())); this._client.PlatformLoader.EnableComplete += this.PlatformLoader_EnableComplete; this._client.ServiceLoader.EnableComplete += this.ServiceLoader_EnableComplete; // Load plugins this.LogMessage("Loading plugin dlls..."); foreach (string dir in directories) { if (Directory.Exists(dir)) this._client.AggregateCatalog.Catalogs.Add(new DirectoryCatalog(dir)); else this.LogMessage("Invalid folder: " + dir); } // Get room version this.LogMessage("Joining room..."); // Connect to playerIO and join room Connection connection = new RabbitAuth().LogIn(email, roomId, password); // Start this.LogMessage("Starting plugins..."); this._client.Start(connection); // Handle disconnect, if we are already too late, disconnect connection.OnDisconnect += this.connection_OnDisconnect; if (!connection.Connected) this.Disconnected(); this.LogMessage("Done."); }