public void Send(string lookupValue, string languageCode, Action <ISendNonRegisteredTransactorUpgradeResult> callback)
 {
     try
     {
         guestControllerClient.UpgradeNrt(new RecoverRequest
         {
             lookupValue = lookupValue
         }, languageCode, delegate(GuestControllerResult <NotificationResponse> r)
         {
             if (!r.Success)
             {
                 callback(new SendNonRegisteredTransactorUpgradeResult(success: false));
             }
             else
             {
                 ISendNonRegisteredTransactorUpgradeResult upgradeNrtResult = GuestControllerErrorParser.GetUpgradeNrtResult(r.Response.error);
                 if (upgradeNrtResult != null)
                 {
                     callback(upgradeNrtResult);
                 }
                 else
                 {
                     callback(new SendNonRegisteredTransactorUpgradeResult(r.Response.data != null));
                 }
             }
         });
     }
     catch (Exception ex)
     {
         logger.Critical("Unhandled exception: " + ex);
         callback(new SendNonRegisteredTransactorUpgradeResult(success: false));
     }
 }
 public void Send(string lookupValue, string languageCode, Action <ISendUsernameRecoveryResult> callback)
 {
     try
     {
         RecoverRequest recoverRequest = new RecoverRequest();
         recoverRequest.lookupValue = lookupValue;
         RecoverRequest request = recoverRequest;
         guestControllerClient.RecoverUsername(request, languageCode, delegate(GuestControllerResult <NotificationResponse> r)
         {
             if (!r.Success)
             {
                 callback(new SendUsernameRecoveryResult(success: false));
             }
             else
             {
                 ISendUsernameRecoveryResult recoverUsernameResult = GuestControllerErrorParser.GetRecoverUsernameResult(r.Response.error);
                 if (recoverUsernameResult != null)
                 {
                     callback(recoverUsernameResult);
                 }
                 else
                 {
                     callback(new SendUsernameRecoveryResult(r.Response.data != null));
                 }
             }
         });
     }
     catch (Exception ex)
     {
         logger.Critical("Unhandled exception: " + ex);
         callback(new SendUsernameRecoveryResult(success: false));
     }
 }
Example #3
0
 public void Send(string lookupValue, string languageCode, Action <ISendMultipleAccountsResolutionResult> callback)
 {
     try
     {
         guestControllerClient.ResolveMase(new RecoverRequest
         {
             lookupValue = lookupValue
         }, languageCode, delegate(GuestControllerResult <NotificationResponse> r)
         {
             if (!r.Success)
             {
                 callback(new SendMultipleAccountsResolutionResult(success: false));
             }
             else
             {
                 ISendMultipleAccountsResolutionResult resolveMaseResult = GuestControllerErrorParser.GetResolveMaseResult(r.Response.error);
                 if (resolveMaseResult != null)
                 {
                     callback(resolveMaseResult);
                 }
                 else
                 {
                     callback(new SendMultipleAccountsResolutionResult(r.Response.data != null));
                 }
             }
         });
     }
     catch (Exception ex)
     {
         logger.Critical("Unhandled exception: " + ex);
         callback(new SendMultipleAccountsResolutionResult(success: false));
     }
 }
Example #4
0
        private static void HandleResult(string activityCode, Action <IPermissionResult> callback, GuestControllerResult <PermissionResponse> result)
        {
            if (!result.Success)
            {
                callback(MakeGenericFailure());
                return;
            }
            PermissionResponse response = result.Response;

            if (response.error != null || response.data == null)
            {
                callback(GuestControllerErrorParser.GetPermissionResult(response.error) ?? MakeGenericFailure());
                return;
            }
            ActivityApprovalStatus activityApprovalStatus = ActivityApprovalStatusConverter.Convert(response.data.approvalStatus);

            if (response.data.activityCode != activityCode || activityApprovalStatus == ActivityApprovalStatus.Unknown)
            {
                callback(MakeGenericFailure());
            }
            else
            {
                callback(new PermissionResult(success: true, activityApprovalStatus));
            }
        }
        private void HandleResult(GuestControllerResult <SiteConfigurationResponse> gcResult, Action <IInternalGetRegistrationConfigurationResult> callback)
        {
            SiteConfigurationResponse response = gcResult.Response;

            if (!gcResult.Success)
            {
                callback(new GetRegistrationConfigurationResult(success: false, null));
                return;
            }
            IInternalGetRegistrationConfigurationResult regConfigResult = GuestControllerErrorParser.GetRegConfigResult(response.error);

            if (regConfigResult != null)
            {
                callback(regConfigResult);
                return;
            }
            if (!ValidateResponse(response))
            {
                callback(new GetRegistrationConfigurationResult(success: false, null));
                return;
            }
            RegistrationConfiguration configuration = new RegistrationConfiguration(response.data, ageBandBuilder);

            callback(new GetRegistrationConfigurationResult(success: true, configuration));
        }
Example #6
0
        private void HandleRegisterSuccess(GuestControllerResult <LogInResponse> result, IEnumerable <Disney.Mix.SDK.Internal.GuestControllerDomain.MarketingItem> marketing, Action <IRegisterResult> callback)
        {
            IList <IInvalidProfileItemError> profileItemErrors = null;

            try
            {
                if (!result.Success)
                {
                    callback(new RegisterResult(success: false, null, null));
                    return;
                }
                IRegisterResult registerResult = GuestControllerErrorParser.GetRegisterResult(result.Response.error);
                if (registerResult != null)
                {
                    callback(registerResult);
                    return;
                }
                profileItemErrors = GuestControllerErrorParser.GetRegisterProfileItemErrors(result.Response.error);
                if (result.Response.data == null)
                {
                    if (result.Response.error != null && profileItemErrors == null)
                    {
                        logger.Critical("Received unhandled error exception" + JsonParser.ToJson(result.Response.error));
                    }
                    callback(new RegisterResult(success: false, null, profileItemErrors));
                    return;
                }
                LogInData loginData = result.Response.data;
                if (loginData.displayName == null || loginData.etag == null || loginData.profile == null || loginData.token == null || loginData.token.access_token == null)
                {
                    logger.Critical("Invalid login data:" + JsonParser.ToJson(loginData));
                    callback(new RegisterResult(success: false, null, profileItemErrors));
                    return;
                }
                loginData.profile.status = GuestControllerErrorParser.GetAccountStatusCode(result.Response.error, loginData.profile.status);
                string countryCode = GuestControllerUtils.GetCountryCode(loginData.profile);
                database.StoreSession(loginData.token.swid, loginData.token.access_token, loginData.token.refresh_token, loginData.displayName.displayName, loginData.profile.firstName, loginData.etag, loginData.profile.ageBand, loginData.displayName.proposedDisplayName, loginData.displayName.proposedStatus, loginData.profile.status, updateLastProfileRefreshTime: true, countryCode);
                mixSessionStarter.Start(loginData.token.swid, loginData.token.access_token, delegate
                {
                    HandleMixSessionStartSuccess(profileItemErrors, loginData.token.swid, loginData.profile, loginData.displayName, marketing, callback);
                }, delegate
                {
                    callback(new RegisterResult(success: false, null, profileItemErrors));
                });
            }
            catch (CorruptionException ex)
            {
                logger.Fatal("Corruption detected during registration: " + ex);
                callback(new RegisterCorruptionDetectedResult());
            }
            catch (Exception ex2)
            {
                logger.Critical("Unhandled exception: " + ex2);
                callback(new RegisterResult(success: false, null, profileItemErrors));
            }
        }
        private static IVerifyAdultResult ParseError(AdultVerificationResponse response)
        {
            IVerifyAdultResult verifyAdultResult = GuestControllerErrorParser.GetVerifyAdultResult(response.error);

            if (verifyAdultResult == null)
            {
                return(MakeGenericFailure());
            }
            if (verifyAdultResult is IVerifyAdultFailedQuestionsResult && response.data != null && response.data.questions != null)
            {
                VerifyAdultQuestion[] questions = response.data.questions.Select((AdultVerificationQuestion q) => new VerifyAdultQuestion(q.questionId, q.questionText, q.choices)).ToArray();
                VerifyAdultQuiz       quiz      = new VerifyAdultQuiz(questions, response.data.applicationId);
                verifyAdultResult = new VerifyAdultFailedQuestionsResult(quiz);
            }
            return(verifyAdultResult);
        }
 private static void Send(AbstractLogger logger, IGuestControllerClient guestControllerClient, ValidateRequest request, Action <IValidateNewAccountResult> callback)
 {
     try
     {
         guestControllerClient.Validate(request, delegate(GuestControllerResult <ValidateResponse> r)
         {
             if (!r.Success)
             {
                 callback(new ValidateNewAccountResult(success: false, null));
             }
             else
             {
                 ValidateResponse response = r.Response;
                 if (response.error == null)
                 {
                     callback(new ValidateNewAccountResult(success: true, null));
                 }
                 else
                 {
                     IValidateNewAccountResult validateResult = GuestControllerErrorParser.GetValidateResult(response.error);
                     if (validateResult != null)
                     {
                         callback(validateResult);
                     }
                     else
                     {
                         IEnumerable <IValidateNewAccountError> validationErrors = GuestControllerErrorParser.GetValidationErrors(response.error);
                         callback(new ValidateNewAccountResult(success: false, validationErrors));
                     }
                 }
             }
         });
     }
     catch (Exception ex)
     {
         logger.Critical("Unhandled exception: " + ex);
         callback(new ValidateNewAccountResult(success: false, null));
     }
 }
Example #9
0
 private static void HandleUpdateProfileResult(AbstractLogger logger, IDatabase database, string swid, IEpochTime epochTime, GuestControllerResult <ProfileResponse> result, IInternalRegistrationProfile profile, Action <IUpdateProfileResult> callback)
 {
     try
     {
         if (!result.Success)
         {
             callback(new UpdateProfileResult(success: false, null));
             return;
         }
         IList <IInvalidProfileItemError> registerProfileItemErrors = GuestControllerErrorParser.GetRegisterProfileItemErrors(result.Response.error);
         if (result.Response.data == null)
         {
             callback(new UpdateProfileResult(success: false, registerProfileItemErrors));
             return;
         }
         ProfileData profileData = result.Response.data;
         if (profileData.displayName != null)
         {
             database.UpdateSessionDocument(swid, delegate(SessionDocument doc)
             {
                 doc.DisplayNameText           = profileData.displayName.displayName;
                 doc.ProposedDisplayName       = profileData.displayName.proposedDisplayName;
                 doc.ProposedDisplayNameStatus = profileData.displayName.proposedStatus;
                 doc.FirstName              = profileData.profile.firstName;
                 doc.AccountStatus          = profileData.profile.status;
                 doc.LastProfileRefreshTime = epochTime.Seconds;
             });
         }
         profile.Update(profileData.profile, profileData.displayName, profileData.marketing);
         callback(new UpdateProfileResult(success: true, registerProfileItemErrors));
     }
     catch (Exception ex)
     {
         logger.Critical("Unhandled exception: " + ex);
         callback(new UpdateProfileResult(success: false, null));
     }
 }
        private static IPermissionResult ParseError(GuestControllerWebCallResponse response)
        {
            IPermissionResult permissionResult = GuestControllerErrorParser.GetPermissionResult(response.error);

            return(permissionResult ?? MakeGenericFailure());
        }
        private static IVerifyAdultResult ParseError(GuestControllerWebCallResponse response)
        {
            IVerifyAdultResult verifyAdultResult = GuestControllerErrorParser.GetVerifyAdultResult(response.error);

            return(verifyAdultResult ?? MakeGenericFailure());
        }
Example #12
0
 private void HandleRefreshSuccess(Action <IRestoreLastSessionResult> callback, GuestControllerResult <RefreshResponse> result, SessionDocument lastSessionDoc)
 {
     try
     {
         GuestApiErrorCollection   error2 = result.Response.error;
         RefreshData               data   = result.Response.data;
         IRestoreLastSessionResult error  = GuestControllerErrorParser.GetRestoreLastSessionResult(error2);
         if (data == null && error != null)
         {
             if (error is IRestoreLastSessionFailedInvalidOrExpiredTokenResult && lastSessionDoc.AccountStatus == "AWAIT_PARENT_CONSENT")
             {
                 callback(new RestoreLastSessionFailedParentalConsentResult());
             }
             else
             {
                 callback(error);
             }
             return;
         }
         if (data == null)
         {
             if (error2 != null)
             {
                 logger.Critical("Received unhandled error exception:\n" + JsonParser.ToJson(error2) + "\nResponse headers:\n" + string.Join("\n", result.ResponseHeaders.Select((KeyValuePair <string, string> h) => h.Key + ": " + h.Value).ToArray()));
             }
             callback(new RestoreLastSessionResult(success: false, null));
             return;
         }
         if (!ValidateRefreshData(data))
         {
             logger.Critical("Error parsing the refresh data: " + JsonParser.ToJson(data));
             callback(new RestoreLastSessionResult(success: false, null));
             return;
         }
         Token token = data.token;
         lastSessionDoc.GuestControllerAccessToken = token.access_token;
         lastSessionDoc.GuestControllerEtag        = data.etag;
         database.UpdateGuestControllerToken(token, data.etag);
         try
         {
             IInternalSession session = sessionFactory.Create(lastSessionDoc.Swid);
             session.Resume(delegate(IResumeSessionResult r)
             {
                 HandleOfflineSessionResumed(r, session, error, callback);
             });
         }
         catch (Exception ex)
         {
             logger.Critical("Error creating session: " + ex);
             callback(new RestoreLastSessionResult(success: false, null));
         }
     }
     catch (CorruptionException ex2)
     {
         logger.Fatal("Corruption detected during session restoration: " + ex2);
         callback(new RestoreLastSessionCorruptionDetectedResult());
     }
     catch (Exception ex)
     {
         logger.Critical("Unhandled exception: " + ex);
         callback(new RestoreLastSessionResult(success: false, null));
     }
 }
Example #13
0
        private static ILinkChildResult ParseError(GuestControllerWebCallResponse response)
        {
            ILinkChildResult linkChildResult = GuestControllerErrorParser.GetLinkChildResult(response.error);

            return(linkChildResult ?? MakeGenericFailure());
        }
        private QueueItem CreateRefreshQueueItem(Action <GuestControllerResult <RefreshResponse> > callback)
        {
            Action <GuestControllerResult <RefreshResponse> > failureCallback = delegate(GuestControllerResult <RefreshResponse> r)
            {
                callback(new GuestControllerResult <RefreshResponse>(success: false, r.Response, r.ResponseHeaders));
            };
            QueueItem queueItem = CreateQueueItem("/client/{client-id}/guest/refresh-auth/{refresh-token}", HttpMethod.POST, new EmptyRequest(), GuestControllerAuthenticationType.None, delegate(GuestControllerResult <RefreshResponse> r)
            {
                if (!r.Success)
                {
                    AuthenticationUnavailableEventArgs e = new AuthenticationUnavailableEventArgs();
                    this.OnAuthenticationLost(this, e);
                    failureCallback(r);
                }
                else
                {
                    GuestApiErrorCollection guestApiErrorCollection = r.Response.error;
                    RefreshData data = r.Response.data;
                    IRefreshGuestControllerTokenError refreshGuestControllerTokenError = GuestControllerErrorParser.GetGuestControllerTokenRefreshError(guestApiErrorCollection);
                    if (refreshGuestControllerTokenError is IRefreshRequiresLegalMarketingUpdateError)
                    {
                        refreshGuestControllerTokenError = null;
                        guestApiErrorCollection          = null;
                        this.OnLegalMarketingUpdateRequired(this, new LegalMarketingUpdateRequiredEventArgs());
                    }
                    if (refreshGuestControllerTokenError is IRefreshTokenGatedLocationError)
                    {
                        logger.Critical("Location gated during Guest Controller token refresh");
                        AuthenticationLostGatedCountryEventArgs e2 = new AuthenticationLostGatedCountryEventArgs();
                        this.OnAuthenticationLost(this, e2);
                        failureCallback(r);
                    }
                    else if (refreshGuestControllerTokenError is IRefreshProfileDisabledError || refreshGuestControllerTokenError is IRefreshTemporaryBanError)
                    {
                        logger.Critical("Banned during Guest Controller token refresh");
                        AccountBannedEventArgs e3 = new AccountBannedEventArgs(logger, null);
                        this.OnAuthenticationLost(this, e3);
                        failureCallback(r);
                    }
                    else if (refreshGuestControllerTokenError != null)
                    {
                        logger.Critical("Guest Controller token refresh error: " + refreshGuestControllerTokenError);
                        AuthenticationRevokedEventArgs e4 = new AuthenticationRevokedEventArgs();
                        this.OnAuthenticationLost(this, e4);
                        failureCallback(r);
                    }
                    else if (guestApiErrorCollection != null)
                    {
                        logger.Critical("Unhandled error during Guest Controller token refresh: " + JsonParser.ToJson(guestApiErrorCollection));
                        AuthenticationUnavailableEventArgs e = new AuthenticationUnavailableEventArgs();
                        this.OnAuthenticationLost(this, e);
                        failureCallback(r);
                    }
                    else if (data == null || data.token == null || data.token.access_token == null || data.token.refresh_token == null)
                    {
                        logger.Critical("Refreshing Guest Controller token returned invalid refresh data: " + JsonParser.ToJson(data));
                        AuthenticationUnavailableEventArgs e = new AuthenticationUnavailableEventArgs();
                        this.OnAuthenticationLost(this, e);
                        failureCallback(r);
                    }
                    else
                    {
                        Token token = data.token;
                        database.UpdateGuestControllerToken(token, data.etag);
                        this.OnAccessTokenChanged(this, new GuestControllerAccessTokenChangedEventArgs(token.access_token));
                        callback(r);
                    }
                }
            });

            queueItem.RefreshedAccessToken = true;
            return(queueItem);
        }
Example #15
0
        private void HandleLoginSuccess(GuestControllerResult <LogInResponse> result, Action <ILoginResult> callback)
        {
            try
            {
                LogInResponse           response          = result.Response;
                LogInData               data              = response.data;
                GuestApiErrorCollection gcErrorCollection = response.error;
                ILoginResult            loginResult       = GuestControllerErrorParser.GetLoginResult(gcErrorCollection);
                bool   flag          = false;
                string hallPassToken = string.Empty;
                string swid          = string.Empty;
                if (data != null || loginResult == null)
                {
                    goto IL_015d;
                }
                if (loginResult is ILoginFailedParentalConsentResult)
                {
                    foreach (GuestApiError error in gcErrorCollection.errors)
                    {
                        TemporaryToken data2 = error.data;
                        if (data2 != null)
                        {
                            flag          = true;
                            hallPassToken = data2.accessToken;
                            swid          = data2.swid;
                            break;
                        }
                    }
                    if (flag)
                    {
                        goto IL_015d;
                    }
                    callback(loginResult);
                }
                else
                {
                    callback(loginResult);
                }
                goto end_IL_0018;
IL_015d:
                if (data == null && !flag)
                {
                    if (gcErrorCollection != null)
                    {
                        logger.Critical("Received unhandled error exception: " + JsonParser.ToJson(gcErrorCollection));
                    }
                    callback(new LoginResult(success: false, null));
                }
                else if (flag)
                {
                    database.StoreSession(swid, hallPassToken, null, null, null, null, null, null, null, null, updateLastProfileRefreshTime: false, null);
                    IGuestControllerClient guestControllerClient = guestControllerClientFactory.Create(swid);
                    ProfileGetter.GetProfile(logger, guestControllerClient, delegate(ProfileData profileData)
                    {
                        if (profileData == null)
                        {
                            database.DeleteSession(swid);
                            callback(new LoginFailedParentalConsentResult());
                        }
                        else
                        {
                            StoreSession(swid, hallPassToken, null, profileData.etag, profileData.displayName, profileData.profile);
                            HandleRefreshProfileSuccess(callback, loginResult, gcErrorCollection, profileData.profile, profileData.displayName, profileData.marketing, swid, hallPassToken);
                        }
                    });
                }
                else if (!ValidateLogInData(data))
                {
                    logger.Critical("Error parsing the login data:" + JsonParser.ToJson(data));
                    callback(new LoginResult(success: false, null));
                }
                else
                {
                    Token token = data.token;
                    StoreSession(token.swid, token.access_token, token.refresh_token, data.etag, data.displayName, data.profile);
                    HandleRefreshProfileSuccess(callback, loginResult, gcErrorCollection, data.profile, data.displayName, data.marketing, token.swid, token.access_token);
                }
                end_IL_0018 :;
            }
            catch (CorruptionException ex)
            {
                logger.Fatal("Corruption detected during login: "******"Unhandled exception: " + ex2);
                callback(new LoginResult(success: false, null));
            }
        }