• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AuthenticationException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.auth0.android.authentication.AuthenticationException的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationException类的具体用法?Java AuthenticationException怎么用?Java AuthenticationException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AuthenticationException类属于com.auth0.android.authentication包,在下文中一共展示了AuthenticationException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: renewAuthentication

import com.auth0.android.authentication.AuthenticationException; //导入依赖的package包/类
private void renewAuthentication() {
    String refreshToken = CredentialsManager.getCredentials(this).getRefreshToken();
    authenticationClient.renewAuth(refreshToken).start(new BaseCallback<Credentials, AuthenticationException>() {
        @Override
        public void onSuccess(final Credentials payload) {
            runOnUiThread(new Runnable() {
                public void run() {
                    Toast.makeText(MainActivity.this, "New access_token: " + payload.getAccessToken(), Toast.LENGTH_SHORT).show();
                }
            });
        }

        @Override
        public void onFailure(AuthenticationException error) {
            runOnUiThread(new Runnable() {
                public void run() {
                    Toast.makeText(MainActivity.this, "Failed to get the new access_token", Toast.LENGTH_SHORT).show();
                }
            });
        }
    });
}
 
开发者ID:auth0-samples,项目名称:auth0-android-sample,代码行数:23,代码来源:MainActivity.java


示例2: getToken

import com.auth0.android.authentication.AuthenticationException; //导入依赖的package包/类
/**
 * Performs a request to the Auth0 API to get the OAuth Token and end the PKCE flow.
 * The instance of this class must be disposed after this method is called.
 *
 * @param authorizationCode received in the call to /authorize with a "grant_type=code"
 * @param callback          to notify the result of this call to.
 */
public void getToken(String authorizationCode, @NonNull final AuthCallback callback) {
    apiClient.token(authorizationCode, redirectUri)
            .setCodeVerifier(codeVerifier)
            .start(new BaseCallback<Credentials, AuthenticationException>() {
                @Override
                public void onSuccess(Credentials payload) {
                    callback.onSuccess(payload);
                }

                @Override
                public void onFailure(AuthenticationException error) {
                    if ("Unauthorized".equals(error.getDescription())) {
                        Log.e(TAG, "Please go to 'https://manage.auth0.com/#/applications/" + apiClient.getClientId() + "/settings' and set 'Client Type' to 'Native' to enable PKCE.");
                    }
                    callback.onFailure(error);
                }
            });
}
 
开发者ID:auth0,项目名称:Auth0.Android,代码行数:26,代码来源:PKCE.java


示例3: start

import com.auth0.android.authentication.AuthenticationException; //导入依赖的package包/类
/**
 * Request user Authentication. The result will be received in the callback.
 *
 * @param activity    context to run the authentication
 * @param callback    to receive the parsed results
 * @param requestCode to use in the authentication request
 * @deprecated This method has been deprecated since it only applied to WebView authentication and Google is no longer supporting it. Please use {@link WebAuthProvider.Builder#start(Activity, AuthCallback)}
 */
@Deprecated
public void start(@NonNull Activity activity, @NonNull AuthCallback callback, int requestCode) {
    managerInstance = null;
    if (account.getAuthorizeUrl() == null) {
        final AuthenticationException ex = new AuthenticationException("a0.invalid_authorize_url", "Auth0 authorize URL not properly set. This can be related to an invalid domain.");
        callback.onFailure(ex);
        return;
    }

    OAuthManager manager = new OAuthManager(account, callback, values);
    manager.useFullScreen(useFullscreen);
    manager.useBrowser(useBrowser);
    manager.setCustomTabsOptions(ctOptions);
    manager.setPKCE(pkce);

    managerInstance = manager;

    String redirectUri = CallbackHelper.getCallbackUri(scheme, activity.getApplicationContext().getPackageName(), account.getDomainUrl());
    manager.startAuthorization(activity, redirectUri, requestCode);
}
 
开发者ID:auth0,项目名称:Auth0.Android,代码行数:29,代码来源:WebAuthProvider.java


示例4: shouldReturnErrorAfterStartingTheRequestIfAuthenticationRequestFails

import com.auth0.android.authentication.AuthenticationException; //导入依赖的package包/类
@Test
public void shouldReturnErrorAfterStartingTheRequestIfAuthenticationRequestFails() throws Exception {
    final UserProfile userProfile = mock(UserProfile.class);
    final AuthenticationException error = mock(AuthenticationException.class);

    final AuthenticationRequestMock authenticationRequestMock = new AuthenticationRequestMock(null, error);
    final ParameterizableRequestMock tokenInfoRequestMock = new ParameterizableRequestMock(userProfile, null);
    final BaseCallback callback = mock(BaseCallback.class);

    profileRequest = new ProfileRequest(authenticationRequestMock, tokenInfoRequestMock);
    profileRequest.start(callback);

    assertTrue(authenticationRequestMock.isStarted());
    assertFalse(tokenInfoRequestMock.isStarted());

    verify(callback).onFailure(error);
}
 
开发者ID:auth0,项目名称:Auth0.Android,代码行数:18,代码来源:ProfileRequestTest.java


示例5: shouldReturnErrorAfterStartingTheRequestIfTokenInfoRequestFails

import com.auth0.android.authentication.AuthenticationException; //导入依赖的package包/类
@Test
public void shouldReturnErrorAfterStartingTheRequestIfTokenInfoRequestFails() throws Exception {
    final Credentials credentials = mock(Credentials.class);
    final AuthenticationException error = mock(AuthenticationException.class);

    final AuthenticationRequestMock authenticationRequestMock = new AuthenticationRequestMock(credentials, null);
    final ParameterizableRequestMock tokenInfoRequestMock = new ParameterizableRequestMock(null, error);
    final BaseCallback callback = mock(BaseCallback.class);

    profileRequest = new ProfileRequest(authenticationRequestMock, tokenInfoRequestMock);
    profileRequest.start(callback);

    assertTrue(authenticationRequestMock.isStarted());
    assertTrue(tokenInfoRequestMock.isStarted());

    verify(callback).onFailure(error);
}
 
开发者ID:auth0,项目名称:Auth0.Android,代码行数:18,代码来源:ProfileRequestTest.java


示例6: shouldReThrowAnyFailedCodeExchangeException

import com.auth0.android.authentication.AuthenticationException; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Test
public void shouldReThrowAnyFailedCodeExchangeException() throws Exception {
    final AuthenticationException exception = Mockito.mock(AuthenticationException.class);
    PKCE pkce = Mockito.mock(PKCE.class);
    Mockito.doAnswer(new Answer() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            callbackCaptor.getValue().onFailure(exception);
            return null;
        }
    }).when(pkce).getToken(any(String.class), callbackCaptor.capture());
    WebAuthProvider.init(account)
            .withState("1234567890")
            .useCodeGrant(true)
            .withPKCE(pkce)
            .start(activity, callback);
    Intent intent = createAuthIntent(createHash("urlId", "urlAccess", "urlRefresh", "urlType", 1111L, "1234567890", null, null));
    assertTrue(WebAuthProvider.resume(intent));

    verify(callback).onFailure(exception);
}
 
开发者ID:auth0,项目名称:Auth0.Android,代码行数:23,代码来源:WebAuthProviderTest.java


示例7: validateToken

import com.auth0.android.authentication.AuthenticationException; //导入依赖的package包/类
private void validateToken() {
    AuthenticationAPIClient client = new AuthenticationAPIClient(mAuth0);
    client.tokenInfo(mIdToken)
            .start(new BaseCallback<UserProfile, AuthenticationException>() {
                @Override
                public void onSuccess(final UserProfile payload) {
                    Log.d(TAG, payload.getExtraInfo().toString());
                    MainActivity.this.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            // update ui
                            updateUI(payload);
                        }
                    });
                }

                @Override
                public void onFailure(AuthenticationException error) {
                    // this means that the id token has expired.
                    // We need to request for a new one, using the refresh token
                    requestNewIdToken();
                }
            });
}
 
开发者ID:segunfamisa,项目名称:auth0-demo-android,代码行数:25,代码来源:MainActivity.java


示例8: createFacebookCallback

import com.auth0.android.authentication.AuthenticationException; //导入依赖的package包/类
private FacebookApi.Callback createFacebookCallback() {
    final AuthCallback callback = getSafeCallback();
    return new FacebookApi.Callback() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            if (loginResult.getRecentlyDeniedPermissions().isEmpty()) {
                requestAuth0Token(loginResult.getAccessToken().getToken());
            } else {
                Log.w(TAG, "Some permissions were not granted: " + loginResult.getRecentlyDeniedPermissions().toString());
                callback.onFailure(new AuthenticationException("Some of the requested permissions were not granted by the user."));
            }
        }

        @Override
        public void onCancel() {
            Log.w(TAG, "User cancelled the log in dialog");
            callback.onFailure(new AuthenticationException("User cancelled the authentication consent dialog."));
        }

        @Override
        public void onError(FacebookException error) {
            Log.e(TAG, "Error on log in: " + error.getMessage());
            callback.onFailure(new AuthenticationException(error.getMessage()));
        }
    };
}
 
开发者ID:auth0,项目名称:Lock-Facebook.Android,代码行数:27,代码来源:FacebookAuthProvider.java


示例9: requestAuth0Token

import com.auth0.android.authentication.AuthenticationException; //导入依赖的package包/类
private void requestAuth0Token(String token) {
    final AuthCallback callback = getSafeCallback();
    auth0.loginWithOAuthAccessToken(token, connectionName)
            .addAuthenticationParameters(getParameters())
            .start(new AuthenticationCallback<Credentials>() {
                @Override
                public void onSuccess(Credentials credentials) {
                    callback.onSuccess(credentials);
                }

                @Override
                public void onFailure(AuthenticationException error) {
                    callback.onFailure(error);
                }
            });
}
 
开发者ID:auth0,项目名称:Lock-Facebook.Android,代码行数:17,代码来源:FacebookAuthProvider.java


示例10: getSafeCallback

import com.auth0.android.authentication.AuthenticationException; //导入依赖的package包/类
private AuthCallback getSafeCallback() {
    final AuthCallback callback = getCallback();
    return callback != null ? callback : new AuthCallback() {
        @Override
        public void onFailure(@NonNull Dialog dialog) {
            Log.w(TAG, "Called authorize with no callback defined");
        }

        @Override
        public void onFailure(AuthenticationException exception) {
            Log.w(TAG, "Called authorize with no callback defined");
        }

        @Override
        public void onSuccess(@NonNull Credentials credentials) {
            Log.w(TAG, "Called authorize with no callback defined");
        }
    };
}
 
开发者ID:auth0,项目名称:Lock-Facebook.Android,代码行数:20,代码来源:FacebookAuthProvider.java


示例11: shouldFailWithTextWhenSomePermissionsWereRejected

import com.auth0.android.authentication.AuthenticationException; //导入依赖的package包/类
@Test
public void shouldFailWithTextWhenSomePermissionsWereRejected() throws Exception {
    when(client.loginWithOAuthAccessToken(TOKEN, CONNECTION_NAME)).thenReturn(request);
    doAnswer(new Answer() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            final FacebookApi.Callback callback = (FacebookApi.Callback) invocation.getArguments()[3];
            callback.onSuccess(createLoginResultFromToken(TOKEN, false));
            return null;
        }
    }).when(apiHelper).login(eq(activity), eq(AUTH_REQ_CODE), anyCollectionOf(String.class), any(FacebookApi.Callback.class));
    provider.start(activity, callback, PERMISSION_REQ_CODE, AUTH_REQ_CODE);

    ArgumentCaptor<AuthenticationException> throwableCaptor = ArgumentCaptor.forClass(AuthenticationException.class);
    verify(callback).onFailure(throwableCaptor.capture());
    final AuthenticationException exception = throwableCaptor.getValue();
    assertThat(exception, is(notNullValue()));
    assertThat(exception.getMessage(), is("Some of the requested permissions were not granted by the user."));
}
 
开发者ID:auth0,项目名称:Lock-Facebook.Android,代码行数:20,代码来源:FacebookAuthProviderTest.java


示例12: shouldFailWithTextWhenFacebookRequestFailed

import com.auth0.android.authentication.AuthenticationException; //导入依赖的package包/类
@Test
public void shouldFailWithTextWhenFacebookRequestFailed() throws Exception {
    doAnswer(new Answer() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            final FacebookApi.Callback callback = (FacebookApi.Callback) invocation.getArguments()[3];
            callback.onError(new FacebookException("facebook error"));
            return null;
        }
    }).when(apiHelper).login(eq(activity), eq(AUTH_REQ_CODE), anyCollectionOf(String.class), any(FacebookApi.Callback.class));
    provider.start(activity, callback, PERMISSION_REQ_CODE, AUTH_REQ_CODE);

    ArgumentCaptor<AuthenticationException> throwableCaptor = ArgumentCaptor.forClass(AuthenticationException.class);
    verify(callback).onFailure(throwableCaptor.capture());
    final AuthenticationException exception = throwableCaptor.getValue();
    assertThat(exception, is(notNullValue()));
    assertThat(exception.getMessage(), is("facebook error"));
}
 
开发者ID:auth0,项目名称:Lock-Facebook.Android,代码行数:19,代码来源:FacebookAuthProviderTest.java


示例13: shouldFailWithTextWhenFacebookRequestIsCancelled

import com.auth0.android.authentication.AuthenticationException; //导入依赖的package包/类
@Test
public void shouldFailWithTextWhenFacebookRequestIsCancelled() throws Exception {
    doAnswer(new Answer() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            final FacebookApi.Callback callback = (FacebookApi.Callback) invocation.getArguments()[3];
            callback.onCancel();
            return null;
        }
    }).when(apiHelper).login(eq(activity), eq(AUTH_REQ_CODE), anyCollectionOf(String.class), any(FacebookApi.Callback.class));
    provider.start(activity, callback, PERMISSION_REQ_CODE, AUTH_REQ_CODE);

    ArgumentCaptor<AuthenticationException> throwableCaptor = ArgumentCaptor.forClass(AuthenticationException.class);
    verify(callback).onFailure(throwableCaptor.capture());
    final AuthenticationException exception = throwableCaptor.getValue();
    assertThat(exception, is(notNullValue()));
    assertThat(exception.getMessage(), is("User cancelled the authentication consent dialog."));
}
 
开发者ID:auth0,项目名称:Lock-Facebook.Android,代码行数:19,代码来源:FacebookAuthProviderTest.java


示例14: shouldFailWithTextWhenCredentialsRequestFailed

import com.auth0.android.authentication.AuthenticationException; //导入依赖的package包/类
@Test
public void shouldFailWithTextWhenCredentialsRequestFailed() throws Exception {
    doAnswer(new Answer() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            final FacebookApi.Callback callback = (FacebookApi.Callback) invocation.getArguments()[3];
            callback.onSuccess(createLoginResultFromToken(TOKEN, true));
            return null;
        }
    }).when(apiHelper).login(eq(activity), eq(AUTH_REQ_CODE), anyCollectionOf(String.class), any(FacebookApi.Callback.class));
    shouldFailRequest(request);
    when(client.loginWithOAuthAccessToken(TOKEN, CONNECTION_NAME))
            .thenReturn(request);

    provider.start(activity, callback, PERMISSION_REQ_CODE, AUTH_REQ_CODE);

    ArgumentCaptor<AuthenticationException> throwableCaptor = ArgumentCaptor.forClass(AuthenticationException.class);
    verify(callback).onFailure(throwableCaptor.capture());
    final AuthenticationException exception = throwableCaptor.getValue();
    assertThat(exception, is(notNullValue()));
}
 
开发者ID:auth0,项目名称:Lock-Facebook.Android,代码行数:22,代码来源:FacebookAuthProviderTest.java


示例15: onAuthentication

import com.auth0.android.authentication.AuthenticationException; //导入依赖的package包/类
@Override
public void onAuthentication(Credentials credentials) {
    Log.i(TAG, "Auth ok! User has given us all google requested permissions.");
    AuthenticationAPIClient client = new AuthenticationAPIClient(getAccount());
    client.tokenInfo(credentials.getIdToken())
            .start(new BaseCallback<UserProfile, AuthenticationException>() {
                @Override
                public void onSuccess(UserProfile payload) {
                    final GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(FilesActivity.this, Collections.singletonList(DriveScopes.DRIVE_METADATA_READONLY));
                    credential.setSelectedAccountName(payload.getEmail());
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            new FetchFilesTask().execute(credential);
                        }
                    });
                }

                @Override
                public void onFailure(AuthenticationException error) {
                }
            });

}
 
开发者ID:auth0,项目名称:Lock-Google.Android,代码行数:25,代码来源:FilesActivity.java


示例16: requestAuth0Token

import com.auth0.android.authentication.AuthenticationException; //导入依赖的package包/类
private void requestAuth0Token(String token) {
    this.auth0
            .loginWithOAuthAccessToken(token, connectionName)
            .addAuthenticationParameters(getParameters())
            .start(new AuthenticationCallback<Credentials>() {
                @Override
                public void onSuccess(Credentials credentials) {
                    getSafeCallback().onSuccess(credentials);
                }

                @Override
                public void onFailure(AuthenticationException error) {
                    getSafeCallback().onFailure(error);
                }
            });
}
 
开发者ID:auth0,项目名称:Lock-Google.Android,代码行数:17,代码来源:GoogleAuthProvider.java


示例17: getSafeCallback

import com.auth0.android.authentication.AuthenticationException; //导入依赖的package包/类
private AuthCallback getSafeCallback() {
    final AuthCallback callback = getCallback();
    return callback != null ? callback : new AuthCallback() {
        @Override
        public void onFailure(@NonNull Dialog dialog) {
            Log.w(TAG, "Using callback when no auth session was running");
        }

        @Override
        public void onFailure(AuthenticationException exception) {
            Log.w(TAG, "Using callback when no auth session was running");
        }

        @Override
        public void onSuccess(@NonNull Credentials credentials) {
            Log.w(TAG, "Using callback when no auth session was running");
        }
    };
}
 
开发者ID:auth0,项目名称:Lock-Google.Android,代码行数:20,代码来源:GoogleAuthProvider.java


示例18: onFailure

import com.auth0.android.authentication.AuthenticationException; //导入依赖的package包/类
@Override
public void onFailure(final AuthenticationException error) {
    Log.e(TAG, "Failed to authenticate the user: " + error.getMessage(), error);
    handler.post(new Runnable() {
        @Override
        public void run() {
            lockView.showProgress(false);

            final AuthenticationError authError = loginErrorBuilder.buildFrom(error);
            if (error.isMultifactorRequired() || error.isMultifactorEnrollRequired()) {
                lockView.showMFACodeForm(lastDatabaseLogin);
                return;
            }
            String message = authError.getMessage(LockActivity.this);
            showErrorMessage(message);
        }
    });
}
 
开发者ID:auth0,项目名称:Lock.Android,代码行数:19,代码来源:LockActivity.java


示例19: buildFrom

import com.auth0.android.authentication.AuthenticationException; //导入依赖的package包/类
@Override
public AuthenticationError buildFrom(AuthenticationException exception) {
    int messageRes;
    String description = null;

    if (exception.isInvalidCredentials()) {
        messageRes = invalidCredentialsResource;
    } else if (exception.isMultifactorCodeInvalid()) {
        messageRes = invalidMFACodeResource;
    } else if (USER_EXISTS_ERROR.equals(exception.getCode()) || USERNAME_EXISTS_ERROR.equals(exception.getCode())) {
        messageRes = userExistsResource;
    } else if (exception.isRuleError()) {
        messageRes = unauthorizedResource;
        if (!USER_IS_BLOCKED_DESCRIPTION.equals(exception.getDescription())) {
            description = exception.getDescription();
        }
    } else if (WRONG_CLIENT_TYPE_ERROR.equals(exception.getDescription())) {
        Log.w("Lock", "The Client Type must be set to 'native' in order to authenticate using Code Grant (PKCE). Please change the type in your Auth0 client's dashboard: https://manage.auth0.com/#/clients");
        messageRes = defaultMessage;
    } else if (TOO_MANY_ATTEMPTS_ERROR.equals(exception.getCode())) {
        messageRes = tooManyAttemptsResource;
    } else {
        messageRes = defaultMessage;
    }
    return new AuthenticationError(messageRes, description);
}
 
开发者ID:auth0,项目名称:Lock.Android,代码行数:27,代码来源:LoginErrorMessageBuilder.java


示例20: buildFrom

import com.auth0.android.authentication.AuthenticationException; //导入依赖的package包/类
@Override
public AuthenticationError buildFrom(AuthenticationException exception) {
    int messageRes;
    String description = null;

    if (USER_EXISTS_ERROR.equals(exception.getCode()) || USERNAME_EXISTS_ERROR.equals(exception.getCode())) {
        messageRes = userExistsResource;
    } else if (exception.isPasswordAlreadyUsed()) {
        messageRes = passwordAlreadyUsedResource;
    } else if (exception.isPasswordNotStrongEnough()) {
        messageRes = passwordNotStrongResource;
    } else if (exception.isRuleError()) {
        messageRes = defaultMessage;
        description = exception.getDescription();
    } else if (TOO_MANY_ATTEMPTS_ERROR.equals(exception.getCode())) {
        messageRes = tooManyAttemptsResource;
    } else {
        messageRes = defaultMessage;
    }
    return new AuthenticationError(messageRes, description);
}
 
开发者ID:auth0,项目名称:Lock.Android,代码行数:22,代码来源:SignUpErrorMessageBuilder.java



注:本文中的com.auth0.android.authentication.AuthenticationException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DynamicMetricsRegistry类代码示例发布时间:2022-05-22
下一篇:
Java DataRead类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap