本文整理汇总了Java中android.accounts.AuthenticatorException类的典型用法代码示例。如果您正苦于以下问题:Java AuthenticatorException类的具体用法?Java AuthenticatorException怎么用?Java AuthenticatorException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AuthenticatorException类属于android.accounts包,在下文中一共展示了AuthenticatorException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: syncLogon4LetvPhone
import android.accounts.AuthenticatorException; //导入依赖的package包/类
private void syncLogon4LetvPhone() {
new Thread() {
public void run() {
try {
String blockingGetAuthToken = LogonManager.this.accountManager.blockingGetAuthToken(LogonManager.this.accounts[0], LogonManager.this.AUTH_TOKEN_TYPE_LETV, true);
LemallPlatform.getInstance().setSsoToken(blockingGetAuthToken);
LogonManager.this.syncToken4Logon(blockingGetAuthToken, (IWebviewListener) LogonManager.this.context);
} catch (OperationCanceledException e) {
e.printStackTrace();
} catch (AuthenticatorException e2) {
e2.printStackTrace();
} catch (IOException e3) {
e3.printStackTrace();
}
}
}.start();
}
示例2: doInBackground
import android.accounts.AuthenticatorException; //导入依赖的package包/类
protected Bundle doInBackground(Void... params) {
try {
return this.this$0.tryAddXiaomiAccount(this.val$activity);
} catch (SecurityException e) {
e.printStackTrace();
this.retryWebViewWay = true;
return null;
} catch (OperationCanceledException e2) {
e2.printStackTrace();
return null;
} catch (AuthenticatorException e3) {
e3.printStackTrace();
this.retryWebViewWay = true;
return null;
} catch (IOException e4) {
e4.printStackTrace();
return null;
}
}
示例3: convertErrorToException
import android.accounts.AuthenticatorException; //导入依赖的package包/类
private Exception convertErrorToException(int code, String message) {
if (code == ERROR_CODE_NETWORK_ERROR) {
return new IOException(message);
}
if (code == ERROR_CODE_UNSUPPORTED_OPERATION) {
return new UnsupportedOperationException(message);
}
if (code == ERROR_CODE_INVALID_RESPONSE) {
return new AuthenticatorException(message);
}
if (code == ERROR_CODE_BAD_ARGUMENTS) {
return new IllegalArgumentException(message);
}
return new AuthenticatorException(message);
}
示例4: onPerformSync
import android.accounts.AuthenticatorException; //导入依赖的package包/类
@Override
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) {
try {
String username = mAccountManager.blockingGetAuthToken(account, AccountGeneral.AUTHTOKEN_TYPE_FULL_ACCESS, true);
SyncServerInterface serverInterface = new SyncServerInterface(getContext());
User user = serverInterface.getUserInfo(username);
UserContentHelper.clearUsers(getContext());
if (user != null) {
UserContentHelper.addUser(getContext(), user);
}
} catch (OperationCanceledException | IOException | AuthenticatorException e) {
e.printStackTrace();
syncResult.stats.numParseExceptions++;
}
}
示例5: a
import android.accounts.AuthenticatorException; //导入依赖的package包/类
public final void a(Context paramContext, String paramString)
{
try
{
ebf.a(paramContext, paramString);
return;
}
catch (ebg localebg)
{
throw new AuthenticatorException("Cannot invalidate token", localebg);
}
catch (ebe localebe)
{
throw new AuthenticatorException("Cannot invalidate token", localebe);
}
}
示例6: a
import android.accounts.AuthenticatorException; //导入依赖的package包/类
public String a(Context paramContext, String paramString1, String paramString2, boolean paramBoolean)
{
fpw localfpw = (fpw)mbb.a(paramContext, fpw.class);
if (paramBoolean) {
return this.b.a(paramContext, paramString1, paramString2);
}
try
{
String str = localfpw.a(paramString1, paramString2);
return str;
}
catch (fpv localfpv)
{
throw new AuthenticatorException("Recoverable error", localfpv);
}
}
示例7: a
import android.accounts.AuthenticatorException; //导入依赖的package包/类
public Account[] a(String paramString, String[] paramArrayOfString)
{
try
{
Account[] arrayOfAccount = (Account[])AccountManager.get(this.a).getAccountsByTypeAndFeatures(paramString, paramArrayOfString, null, null).getResult(b, TimeUnit.MILLISECONDS);
return arrayOfAccount;
}
catch (AuthenticatorException localAuthenticatorException)
{
throw new fpv(localAuthenticatorException);
}
catch (OperationCanceledException localOperationCanceledException)
{
throw new IOException(localOperationCanceledException);
}
}
示例8: run
import android.accounts.AuthenticatorException; //导入依赖的package包/类
public void run(AccountManagerFuture<Bundle> result) {
Bundle bundle;
try {
bundle = result.getResult();
Intent intent = (Intent)bundle.get(AccountManager.KEY_INTENT);
if(intent != null) {
// User input required
context.startActivity(intent);
} else {
AccountManager.get(context).invalidateAuthToken(bundle.getString(AccountManager.KEY_ACCOUNT_TYPE), bundle.getString(AccountManager.KEY_AUTHTOKEN));
AccountManager.get(context).invalidateAuthToken("ah", bundle.getString(AccountManager.KEY_AUTHTOKEN));
onGetAuthToken(bundle);
}
} catch (OperationCanceledException | AuthenticatorException | IOException e) {
//notifyUser(context.getString(R.string.flowzr_sync_error_no_network), 100);
//showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network);
//context.setReady();
e.printStackTrace();
}
}
示例9: getToken
import android.accounts.AuthenticatorException; //导入依赖的package包/类
@Override
public AndroidToken getToken(Account account, AndroidTokenType type) throws AuthenticationCanceledException {
try {
AndroidToken token;
Activity activity = activityManager.getActivity();
if (account == null) {
token = createAccountAndGetToken(activity, type);
} else {
token = getToken(activity, account, type);
}
if (token == null) {
throw new AuthenticationCanceledException("user canceled the login!");
}
return token;
} catch (AuthenticatorException | OperationCanceledException | IOException e) {
throw new AuthenticationCanceledException(e);
}
}
示例10: createAccountAndGetToken
import android.accounts.AuthenticatorException; //导入依赖的package包/类
private AndroidToken createAccountAndGetToken(@Nullable Activity activity, @NonNull AndroidTokenType type)
throws AuthenticatorException, OperationCanceledException, IOException {
AccountManagerFuture<Bundle> future = accountManager
.addAccount(type.accountType, type.tokenType, null, null, activity, null, null);
Bundle result = future.getResult();
String accountName = result.getString(AccountManager.KEY_ACCOUNT_NAME);
if (accountName != null) {
Account account = new Account(result.getString(AccountManager.KEY_ACCOUNT_NAME),
result.getString(AccountManager.KEY_ACCOUNT_TYPE));
String token = accountManager.peekAuthToken(account, type.tokenType);
String refreshToken = accountManager.peekAuthToken(account, getRefreshTokenType(type));
if (token != null) return new AndroidToken(token, refreshToken);
}
return null;
}
示例11: getToken
import android.accounts.AuthenticatorException; //导入依赖的package包/类
@Override
protected Token getToken() throws AuthFailureError {
String tokenStr;
try {
// NOTE: We pass true for notifyAuthFailure for clarity, but our authenticator always
// assumes it is true, because AccountManager#KEY_NOTIFY_ON_FAILURE is a hidden API.
tokenStr = mAccountManager.blockingGetAuthToken(
mAccount, AccountAuthenticator.TOKEN_TYPE_OAUTH, true /* notifyAuthFailure */);
} catch (AuthenticatorException | OperationCanceledException | IOException e) {
throw new AuthFailureError("Unable to obtain auth token", e);
}
mToken = WireUtil.decodeFromString(tokenStr, Token.class);
if (mToken == null) {
throw new AuthFailureError("Error decoding token string");
}
return mToken;
}
示例12: getClientFor
import android.accounts.AuthenticatorException; //导入依赖的package包/类
@Override
public OwnCloudClient getClientFor(OwnCloudAccount account, Context context)
throws AccountNotFoundException, OperationCanceledException, AuthenticatorException,
IOException {
Log_OC.d(TAG, "getClientFor(OwnCloudAccount ... : ");
OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(
account.getBaseUri(),
context.getApplicationContext(),
true);
Log_OC.v(TAG, " new client {" +
(account.getName() != null ?
account.getName() :
AccountUtils.buildAccountName(account.getBaseUri(), "")
) + ", " + client.hashCode() + "}");
if (account.getCredentials() == null) {
account.loadCredentials(context);
}
client.setCredentials(account.getCredentials());
return client;
}
示例13: saveAllClients
import android.accounts.AuthenticatorException; //导入依赖的package包/类
@Override
public void saveAllClients(Context context, String accountType)
throws AccountNotFoundException, AuthenticatorException, IOException,
OperationCanceledException {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log_OC.d(TAG, "Saving sessions... ");
}
Iterator<String> accountNames = mClientsWithKnownUsername.keySet().iterator();
String accountName = null;
Account account = null;
while (accountNames.hasNext()) {
accountName = accountNames.next();
account = new Account(accountName, accountType);
AccountUtils.saveClient(
mClientsWithKnownUsername.get(accountName),
account,
context);
}
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log_OC.d(TAG, "All sessions saved");
}
}
示例14: getQuestions
import android.accounts.AuthenticatorException; //导入依赖的package包/类
public JSONObject getQuestions(QuestionsGetRequest request) throws IOException, JSONException, InvalidAccessTokenException, AuthenticatorException, OperationCanceledException, ServerErrorException {
UrlParams params = new UrlParams();
params.add("first_question_id", request.getFirstQuestionId());
params.add("limit", request.getLimit());
params.add("offset", request.getOffset());
params.add("tab", request.getContentSection().toString().toLowerCase());
for (int category : request.getCategories()) {
params.add("categories[]", category);
}
HttpResponse response = makeProtectedGetCall(resolveApiUrl(request.getPath()), params);
if (response == null || response.getBody() == null) {
return null;
}
return new JSONObject(response.getBody());
}
示例15: uploadImage
import android.accounts.AuthenticatorException; //导入依赖的package包/类
public JSONObject uploadImage(ImageUploadRequest request) throws JSONException, IOException, InvalidAccessTokenException, AuthenticatorException, OperationCanceledException, ServerErrorException {
UrlParams params = new UrlParams();
ImageData image = request.getImage();
ImageParamFacade imageParamFacade = new ImageParamFacade(image);
try {
imageParamFacade.write(params, "image", "preview");
HttpResponse response = makeProtectedMultipartPostCall(resolveApiUrl(request.getPath()), params);
if (response == null || response.getBody() == null) {
return null;
}
return new JSONObject(response.getBody());
} finally {
imageParamFacade.close();
}
}