@Override public void handleSuccess(LoginResponse result) { Logger.info(LOG_TAG, "Got success signing in."); if (fxAccount == null) { this.handleError(new IllegalStateException("fxAccount must not be null")); return; } byte[] unwrapkB; try { // It is crucial that we use the email address provided by the server // (rather than whatever the user entered), because the user's keys are // wrapped and salted with the initial email they provided to // /create/account. Of course, we want to pass through what the user // entered locally as much as possible. byte[] quickStretchedPW = passwordStretcher.getQuickStretchedPW(result.remoteEmail.getBytes("UTF-8")); unwrapkB = FxAccountUtils.generateUnwrapBKey(quickStretchedPW); } catch (Exception e) { this.handleError(e); return; } fxAccount.setState( new Engaged( email, result.uid, result.verified, unwrapkB, result.sessionToken, result.keyFetchToken)); fxAccount.requestSync(FirefoxAccounts.FORCE); // For great debugging. if (FxAccountUtils.LOG_PERSONAL_INFORMATION) { fxAccount.dump(); } setResult(RESULT_OK); // Maybe show success activity. final Intent successIntent = makeSuccessIntent(email, result); if (successIntent != null) { startActivity(successIntent); } finish(); TelemetryWrapper.addToHistogram(TelemetryContract.SYNC11_MIGRATIONS_COMPLETED, 1); }
@Override public void handleSuccess(LoginResponse result) { Logger.info(LOG_TAG, "Got success response; adding Android account."); // We're on the UI thread, but it's okay to create the account here. AndroidFxAccount fxAccount; try { final String profile = Constants.DEFAULT_PROFILE; final String tokenServerURI = getTokenServerEndpoint(); // It is crucial that we use the email address provided by the server // (rather than whatever the user entered), because the user's keys are // wrapped and salted with the initial email they provided to // /create/account. Of course, we want to pass through what the user // entered locally as much as possible, so we create the Android account // with their entered email address, etc. // The passwordStretcher should have seen this email address before, so // we shouldn't be calculating the expensive stretch twice. byte[] quickStretchedPW = passwordStretcher.getQuickStretchedPW(result.remoteEmail.getBytes("UTF-8")); byte[] unwrapkB = FxAccountUtils.generateUnwrapBKey(quickStretchedPW); State state = new Engaged( email, result.uid, result.verified, unwrapkB, result.sessionToken, result.keyFetchToken); fxAccount = AndroidFxAccount.addAndroidAccount( getApplicationContext(), email, profile, serverURI, tokenServerURI, state); if (fxAccount == null) { throw new RuntimeException("Could not add Android account."); } if (selectedEngines != null) { Logger.info(LOG_TAG, "User has selected engines; storing to prefs."); SyncConfiguration.storeSelectedEnginesToPrefs(fxAccount.getSyncPrefs(), selectedEngines); } } catch (Exception e) { handleError(e); return; } // For great debugging. if (FxAccountUtils.LOG_PERSONAL_INFORMATION) { fxAccount.dump(); } // The GetStarted activity has called us and needs to return a result to the authenticator. final Intent intent = new Intent(); intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, email); intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, FxAccountConstants.ACCOUNT_TYPE); // intent.putExtra(AccountManager.KEY_AUTHTOKEN, accountType); setResult(RESULT_OK, intent); // Show success activity depending on verification status. Intent successIntent = makeSuccessIntent(email, result); startActivity(successIntent); finish(); }