0

このコードは、AndroidSampleSyncAdapterサンプルプロジェクトからのAuthenticatorActivityものです。それは言う、

サーバーから返されたauthTokenをこのアカウントの「パスワード」として保存するため、ユーザーの実際のパスワードをローカルに保存することはありません。

しかし、私はまったくauthToken使用されていないようです。なんで?これは間違いですか、それとも意図的なものですか?

/**
 * Called when response is received from the server for authentication
 * request. See onAuthenticationResult(). Sets the
 * AccountAuthenticatorResult which is sent back to the caller. We store the
 * authToken that's returned from the server as the 'password' for this
 * account - so we're never storing the user's actual password locally.
 *
 * @param result the confirmCredentials result.
 */
private void finishLogin(String authToken) {

    Log.i(TAG, "finishLogin()");
    final Account account = new Account(mUsername, Constants.ACCOUNT_TYPE);
    if (mRequestNewAccount) {
        mAccountManager.addAccountExplicitly(account, mPassword, null);
        // Set contacts sync for this account.
        ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, true);
    } else {
        mAccountManager.setPassword(account, mPassword);
    }
    final Intent intent = new Intent();
    intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, mUsername);
    intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, Constants.ACCOUNT_TYPE);
    setAccountAuthenticatorResult(intent.getExtras());
    setResult(RESULT_OK, intent);
    finish();
}
4

1 に答える 1

2

同意しました。特にSampleSyncAdapterはこれらのクラスに関する唯一のドキュメントの一部を表しているため、これは混乱を招きます。そうは言っても、AbstractAccountAuthenticatorとサービスの両方がパスワードに依存しているため、ここでのコメントは間違いだと思います。明確にするためにバグを提出しました:

http://code.google.com/p/android/issues/detail?id=40878&thanks=40878&ts=1354582803

于 2012-12-04T01:04:48.297 に答える