protected Bundle getExtrasForAccount() {
   final Bundle extras = new Bundle();
   final ExtendedJSONObject o = new ExtendedJSONObject();
   o.put(FxAccountAbstractSetupActivity.JSON_KEY_AUTH, fxAccount.getAccountServerURI());
   final ExtendedJSONObject services = new ExtendedJSONObject();
   services.put(FxAccountAbstractSetupActivity.JSON_KEY_SYNC, fxAccount.getTokenServerURI());
   services.put(FxAccountAbstractSetupActivity.JSON_KEY_PROFILE, fxAccount.getProfileServerURI());
   o.put(FxAccountAbstractSetupActivity.JSON_KEY_SERVICES, services);
   extras.putString(FxAccountAbstractSetupActivity.EXTRA_EXTRAS, o.toJSONString());
   return extras;
 }
 public void updateCredentials(String email, String password) {
   String serverURI = fxAccount.getAccountServerURI();
   Executor executor = Executors.newSingleThreadExecutor();
   FxAccountClient client = new FxAccountClient20(serverURI, executor);
   PasswordStretcher passwordStretcher = makePasswordStretcher(password);
   try {
     hideRemoteError();
     RequestDelegate<LoginResponse> delegate =
         new UpdateCredentialsDelegate(email, passwordStretcher, serverURI);
     new FxAccountSignInTask(
             this, this, email, passwordStretcher, client, getQueryParameters(), delegate)
         .execute();
   } catch (Exception e) {
     Logger.warn(LOG_TAG, "Got exception updating credentials for account.", e);
     showRemoteError(e, R.string.fxaccount_update_credentials_unknown_error);
   }
 }
 protected void updateAuthServerPreference() {
   final String authServer = fxAccount.getAccountServerURI();
   final boolean shouldBeShown =
       ALWAYS_SHOW_AUTH_SERVER
           || !FxAccountConstants.DEFAULT_AUTH_SERVER_ENDPOINT.equals(authServer);
   final boolean currentlyShown = null != findPreference(authServerPreference.getKey());
   if (currentlyShown != shouldBeShown) {
     if (shouldBeShown) {
       accountCategory.addPreference(authServerPreference);
     } else {
       accountCategory.removePreference(authServerPreference);
     }
   }
   // Always set the summary, because on first run, the preference is visible,
   // and the above block will be skipped if there is a custom value.
   authServerPreference.setSummary(authServer);
 }
Пример #4
0
  /**
   * Persist Firefox account to disk as a JSON object.
   *
   * @param AndroidFxAccount the account to persist to disk
   * @param filename name of file to persist to; must not contain path separators.
   */
  public static void pickle(final AndroidFxAccount account, final String filename) {
    final ExtendedJSONObject o = new ExtendedJSONObject();
    o.put(KEY_PICKLE_VERSION, Long.valueOf(PICKLE_VERSION));
    o.put(KEY_PICKLE_TIMESTAMP, Long.valueOf(System.currentTimeMillis()));

    o.put(KEY_ACCOUNT_VERSION, AndroidFxAccount.CURRENT_ACCOUNT_VERSION);
    o.put(KEY_ACCOUNT_TYPE, FxAccountConstants.ACCOUNT_TYPE);
    o.put(KEY_EMAIL, account.getEmail());
    o.put(KEY_PROFILE, account.getProfile());
    o.put(KEY_IDP_SERVER_URI, account.getAccountServerURI());
    o.put(KEY_TOKEN_SERVER_URI, account.getTokenServerURI());
    o.put(KEY_IS_SYNCING_ENABLED, account.isSyncing());

    // TODO: If prefs version changes under us, SyncPrefsPath will change, "clearing" prefs.

    final ExtendedJSONObject bundle = account.unbundle();
    if (bundle == null) {
      Logger.warn(LOG_TAG, "Unable to obtain account bundle; aborting.");
      return;
    }
    o.put(KEY_BUNDLE, bundle);

    writeToDisk(account.context, filename, o);
  }