예제 #1
0
        public async Task FindAuthFactorAsync()
        {
            // Arrange
            var userId = new UserId();

            var authFactor = new GameAuthentication <LeagueOfLegendsGameAuthenticationFactor>(
                new PlayerId(),
                new LeagueOfLegendsGameAuthenticationFactor(
                    1,
                    string.Empty,
                    2,
                    string.Empty));

            TestMock.GameAuthenticationRepository
            .Setup(repository => repository.GetAuthenticationAsync <LeagueOfLegendsGameAuthenticationFactor>(It.IsAny <UserId>(), It.IsAny <Game>()))
            .ReturnsAsync(authFactor)
            .Verifiable();

            var authFactorService = new GameAuthenticationService(
                TestMock.GameAuthenticationGeneratorFactory.Object,
                TestMock.GameAuthenticationValidatorFactory.Object,
                TestMock.GameAuthenticationRepository.Object);

            // Act
            await authFactorService.FindAuthenticationAsync <LeagueOfLegendsGameAuthenticationFactor>(userId, Game.LeagueOfLegends);

            // Assert
            TestMock.GameAuthenticationRepository.Verify(
                repository => repository.GetAuthenticationAsync <LeagueOfLegendsGameAuthenticationFactor>(It.IsAny <UserId>(), It.IsAny <Game>()),
                Times.Once);
        }
예제 #2
0
    public void SecureCall(string token, string securePayload, Action <string> callback)
    {
        List <WebModels.ItemsInfo> listOfItems = new List <WebModels.ItemsInfo>();

        WebModels.ItemsInfo item = new WebModels.ItemsInfo();
        item.amount   = 1;
        item.ItemID   = 106465;
        item.location = 0;
        listOfItems.Add(item);

        GiveOwnerItemWebserviceRequest request = new GiveOwnerItemWebserviceRequest();

        request.listOfItems = listOfItems;
        request.ownerID     = "ef595214-369f-4313-9ac7-b0036e5ac25c";
        request.appID       = GameAuthentication.GetAppID();
        request.OwnerType   = WebModels.OwnerTypes.User;

        string newStringRequest = JsonConvert.SerializeObject(request);

        SecurePayload payload = new SecurePayload();

        payload.token = token;
        payload.data  = newStringRequest;

        string securePayloadString = JsonConvert.SerializeObject(payload);

        Debug.Log(securePayloadString);

        string url = cloudGoodsURL + "SecureAction?appID=" + GameAuthentication.GetAppID() + "&payload=" + WWW.EscapeURL(EncryptStringUnity(securePayloadString));

        WWW www = new WWW(url);

        StartCoroutine(ServiceGetString(www, callback));
    }
예제 #3
0
    void Start()
    {
        ContainerKeybinding.DisableKeybinding("Login");

        loginTab.SetActive(true);
        registerErrorLabel.text = "";
        registerTab.SetActive(false);
        confirmationTab.SetActive(false);

        loginUserEmailValidator    = loginUserEmail.GetComponent <UIInputVisualValidation>();
        loginUserPasswordValidator = loginUserPassword.GetComponent <UIInputVisualValidation>();

        registerUserNameValidator            = registerUserName.GetComponent <UIInputLengthValidation>();
        registerUserEmailValidator           = registerUserEmail.GetComponent <UIInputVisualValidation>();
        registerUserPasswordValidator        = registerUserPassword.GetComponent <UIInputVisualValidation>();;
        registerUserPasswordConfirmValidator = registerUserPasswordConfirm.GetComponent <UIInputVisualValidation>();
        resendVerificationTextObject.SetActive(false);
        if (!string.IsNullOrEmpty(PlayerPrefs.GetString("SocialPlay_Login_UserEmail")))
        {
            loginUserEmail.value = PlayerPrefs.GetString("SocialPlay_Login_UserEmail");
        }

        if (!string.IsNullOrEmpty(PlayerPrefs.GetString("SocialPlay_UserGuid")))
        {
            SPLogin.UserInfo userInfo = new SPLogin.UserInfo(new Guid(PlayerPrefs.GetString("SocialPlay_UserGuid")), PlayerPrefs.GetString("SocialPlay_UserName"), PlayerPrefs.GetString("SocialPlay_UserEmail"));

            GameAuthentication.OnUserAuthorized(new WebserviceCalls.UserInfo(userInfo.ID.ToString(), userInfo.name, userInfo.email));

            RecivedUserGuid(userInfo);
        }
    }
예제 #4
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     Systems.AppId = new Guid(AppID);
 }
예제 #5
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     Systems.AppId = new Guid(AppID);
 }
    // Use this for initialization
    void Start()
    {
        Debug.Log("In Editor, Logging in as Test User with access token: " + GameAuthentication.GetAppID());
        var socialPlayUserObj = new PlatformUser();

        socialPlayUserObj.appID          = new Guid(GameAuthentication.GetAppID());
        socialPlayUserObj.platformID     = 1;
        socialPlayUserObj.platformUserID = "2";
        socialPlayUserObj.userName       = "******";
        Systems.UserGetter.GetSocialPlayUser(socialPlayUserObj, GameAuthentication.OnUserAuthorized);
    }
    void RecieveFromJava(string message)
    {
        if (message != "Fail")
        {
            BundlePurchaseRequest bundlePurchaseRequest = new BundlePurchaseRequest();
            bundlePurchaseRequest.BundleID     = currentBundleID;
            bundlePurchaseRequest.UserID       = ItemSystemGameData.UserID;
            bundlePurchaseRequest.ReceiptToken = message;

            //TODO implement platform check for platform credit bundle purchase
            bundlePurchaseRequest.PaymentPlatform = 3;

            string bundleJsonString = JsonConvert.SerializeObject(bundlePurchaseRequest);

            WebserviceCalls.webservice.PurchaseCreditBundles(new Guid(GameAuthentication.GetAppID()), bundleJsonString, OnReceivedPurchaseResponse);
        }
    }
예제 #8
0
    void UserNameCallBack(FBResult response)
    {
        Dictionary <string, object> FBInfo = Facebook.MiniJSON.Json.Deserialize(response.Text) as Dictionary <string, object>;

        if (string.IsNullOrEmpty(response.Error))
        {
            var socialPlayUserObj = new PlatformUser();
            socialPlayUserObj.appID          = new Guid(GameAuthentication.GetAppID());
            socialPlayUserObj.platformID     = 1;
            socialPlayUserObj.platformUserID = FB.UserId;
            socialPlayUserObj.userName       = FBInfo["first_name"].ToString();
            Systems.UserGetter.GetSocialPlayUser(socialPlayUserObj, GameAuthentication.OnUserAuthorized);

            if (OnRecivedUserInfo != null)
            {
                OnRecivedUserInfo();
            }
        }
    }
예제 #9
0
        public void Contructor_Tests()
        {
            // Arrange
            var authenticationFactor = new LeagueOfLegendsGameAuthenticationFactor(
                1,
                string.Empty,
                2,
                string.Empty);

            var playerId = new PlayerId();

            // Act
            var authFactor = new GameAuthentication <LeagueOfLegendsGameAuthenticationFactor>(playerId, authenticationFactor);

            // Assert
            authFactor.PlayerId.Should().Be(playerId);
            authFactor.PlayerId.Should().NotBeNull();

            authFactor.Factor.Should().Be(authenticationFactor);
            authFactor.Factor.Should().NotBeNull();
        }
예제 #10
0
 void RecivedLoginCode(SPLogin_Responce loginResponse)
 {
     if (loginResponse.code == 7)
     {
         loginResponse.message = "Server Related Error";
     }
     if (loginResponse.code == 0)
     {
         if (recivedUserInfo != null)
         {
             UserInfo userInfo = loginResponse.userInfo;
             GameAuthentication.OnUserAuthorized(new WebserviceCalls.UserInfo(userInfo.ID.ToString(), userInfo.name, userInfo.email));
             recivedUserInfo(userInfo);
         }
     }
     else
     {
         if (loginMessageResponce != null)
         {
             loginMessageResponce(loginResponse);
         }
     }
 }
예제 #11
0
        public async Task ValidateAuthFactorAsync()
        {
            // Arrange
            var authFactor = new GameAuthentication <LeagueOfLegendsGameAuthenticationFactor>(
                new PlayerId(),
                new LeagueOfLegendsGameAuthenticationFactor(
                    1,
                    string.Empty,
                    2,
                    string.Empty));

            var summoner = new Summoner
            {
                ProfileIconId = 1
            };

            TestMock.LeagueOfLegendsService.Setup(x => x.Summoner.GetSummonerByAccountIdAsync(It.IsAny <Region>(), It.IsAny <string>()))
            .ReturnsAsync(summoner)
            .Verifiable();

            var leagueAdapter = new LeagueOfLegendsAuthenticationValidatorAdapter(
                TestMock.LeagueOfLegendsService.Object,
                TestMock.GameAuthenticationRepository.Object);

            TestMock.GameAuthenticationValidatorFactory.Setup(validator => validator.CreateInstance(It.IsAny <Game>())).Returns(leagueAdapter).Verifiable();

            var authFactorService = new GameAuthenticationService(
                TestMock.GameAuthenticationGeneratorFactory.Object,
                TestMock.GameAuthenticationValidatorFactory.Object,
                TestMock.GameAuthenticationRepository.Object);

            // Act
            await authFactorService.ValidateAuthenticationAsync(new UserId(), Game.LeagueOfLegends, authFactor);

            // Assert
            TestMock.GameAuthenticationValidatorFactory.Verify(validator => validator.CreateInstance(It.IsAny <Game>()), Times.Once);
        }
예제 #12
0
 public static void Login(string email, string pass)
 {
     ItemSystemGameData.AppID = new Guid(GameAuthentication.GetAppID());
     WebserviceCalls.webservice.SPLogin_UserLogin(ItemSystemGameData.AppID, email, pass, instance.RecivedLoginCode);
 }
예제 #13
0
        public async Task <DomainValidationResult <GameAuthentication> > ValidateAuthenticationAsync(UserId userId, Game game, GameAuthentication gameAuthentication)
        {
            var adapter = _gameAuthenticationValidatorFactory.CreateInstance(game);

            return(await adapter.ValidateAuthenticationAsync(userId, gameAuthentication));
        }
예제 #14
0
        public async Task LinkCredentialAsync()
        {
            // Arrange
            var userId = new UserId();

            var userAuthFactor = new GameAuthentication <LeagueOfLegendsGameAuthenticationFactor>(
                new PlayerId(),
                new LeagueOfLegendsGameAuthenticationFactor(
                    1,
                    string.Empty,
                    2,
                    string.Empty));

            TestMock.GameCredentialRepository.Setup(repository => repository.CredentialExistsAsync(It.IsAny <UserId>(), It.IsAny <Game>()))
            .ReturnsAsync(false)
            .Verifiable();

            TestMock.GameAuthenticationService.Setup(authFactor => authFactor.AuthenticationExistsAsync(It.IsAny <UserId>(), It.IsAny <Game>()))
            .ReturnsAsync(true)
            .Verifiable();

            TestMock.GameAuthenticationService.Setup(authFactor => authFactor.FindAuthenticationAsync(It.IsAny <UserId>(), It.IsAny <Game>()))
            .ReturnsAsync(userAuthFactor)
            .Verifiable();

            TestMock.GameAuthenticationService
            .Setup(
                authFactor => authFactor.ValidateAuthenticationAsync(
                    It.IsAny <UserId>(),
                    It.IsAny <Game>(),
                    It.IsAny <GameAuthentication <LeagueOfLegendsGameAuthenticationFactor> >()))
            .ReturnsAsync(new DomainValidationResult <GameAuthentication>())
            .Verifiable();

            TestMock.GameCredentialRepository.Setup(repository => repository.CreateCredential(It.IsAny <Credential>())).Verifiable();

            TestMock.GameCredentialRepository.Setup(repository => repository.UnitOfWork.CommitAsync(It.IsAny <bool>(), It.IsAny <CancellationToken>()))
            .Returns(Task.CompletedTask)
            .Verifiable();

            var authFactorService = new GameCredentialService(TestMock.GameCredentialRepository.Object, TestMock.GameAuthenticationService.Object);

            // Act
            await authFactorService.LinkCredentialAsync(userId, Game.LeagueOfLegends);

            // Assert
            TestMock.GameCredentialRepository.Verify(repository => repository.CredentialExistsAsync(It.IsAny <UserId>(), It.IsAny <Game>()), Times.Once);

            TestMock.GameAuthenticationService.Verify(authFactor => authFactor.AuthenticationExistsAsync(It.IsAny <UserId>(), It.IsAny <Game>()), Times.Once);

            TestMock.GameAuthenticationService.Verify(authFactor => authFactor.FindAuthenticationAsync(It.IsAny <UserId>(), It.IsAny <Game>()), Times.Once);

            TestMock.GameAuthenticationService.Verify(
                authFactor => authFactor.ValidateAuthenticationAsync(
                    It.IsAny <UserId>(),
                    It.IsAny <Game>(),
                    It.IsAny <GameAuthentication <LeagueOfLegendsGameAuthenticationFactor> >()),
                Times.Once);

            TestMock.GameCredentialRepository.Verify(repository => repository.CreateCredential(It.IsAny <Credential>()), Times.Once);

            TestMock.GameCredentialRepository.Verify(
                repository => repository.UnitOfWork.CommitAsync(It.IsAny <bool>(), It.IsAny <CancellationToken>()),
                Times.Once);
        }
예제 #15
0
 public void GetBundle()
 {
     //TODO change hard coded platformID
     WebserviceCalls.webservice.GetCreditBundles(GameAuthentication.GetAppID(), 3, OnPurchaseBundlesRecieved);
 }
예제 #16
0
 // Use this for initialization
 void Start()
 {
     webservicecalls.GetToken(GameAuthentication.GetAppID(), "1", OnReceivedToken);
 }
예제 #17
0
 public async Task AddAuthenticationAsync <TAuthenticationFactor>(UserId userId, Game game, GameAuthentication <TAuthenticationFactor> gameAuthentication)
     where TAuthenticationFactor : class, IGameAuthenticationFactor
 {
     await _redisCacheClient.Db5.AddAsync(GenerateKey(userId, game), gameAuthentication, TimeSpan.FromMinutes(15));
 }
예제 #18
0
 public static void RegisterUser(string email, string pass, string userName)
 {
     ItemSystemGameData.AppID = new Guid(GameAuthentication.GetAppID());
     WebserviceCalls.webservice.SPLogin_UserRegister(ItemSystemGameData.AppID, email, pass, userName, instance.RecivedRegisterUser);
 }
예제 #19
0
 public static void ForgotPassword(string Email)
 {
     ItemSystemGameData.AppID = new Guid(GameAuthentication.GetAppID());
     WebserviceCalls.webservice.SPLoginForgotPassword(ItemSystemGameData.AppID, Email, instance.RecivedForgotPassword);
 }
예제 #20
0
 public static void ResendVerificationEmail(string email)
 {
     ItemSystemGameData.AppID = new Guid(GameAuthentication.GetAppID());
     WebserviceCalls.webservice.SPLoginResendVerificationEmail(ItemSystemGameData.AppID, email, instance.RecivedVerificationEmailResponce);
 }
예제 #21
0
 void OnReceivedUserInfo(WebserviceCalls.UserInfo userInfo)
 {
     GameAuthentication.OnUserAuthorized(userInfo);
 }
예제 #22
0
 public async Task <DomainValidationResult <GameAuthentication> > ValidateAuthenticationAsync(UserId userId, GameAuthentication gameAuthentication)
 {
     return(await this.ValidateAuthenticationAsync(userId, JsonConvert.DeserializeObject <TAuthentication>(JsonConvert.SerializeObject(gameAuthentication))));
 }