use of com.okta.oidc.AuthenticationResultHandler.AuthResultListener in project okta-oidc-android by okta.
the class SyncWebAuthClientImpl method registerCallbackIfInterrupt.
@Override
public void registerCallbackIfInterrupt(Activity activity, ResultListener resultListener, ExecutorService executorService) {
AuthResultListener authResultListener = (result, type) -> {
if (!executorService.isShutdown()) {
executorService.execute(() -> {
switch(type) {
case SIGN_IN:
Result authorizationResult = processSignInResult(result);
resetCurrentState();
if (resultListener != null) {
resultListener.postResult(authorizationResult, type);
}
break;
case SIGN_OUT:
Result signOutResult = processSignOutResult(result);
resetCurrentState();
if (resultListener != null) {
resultListener.postResult(signOutResult, type);
}
break;
default:
break;
}
});
}
};
mHandler.setAuthenticationListener(authResultListener);
}
use of com.okta.oidc.AuthenticationResultHandler.AuthResultListener in project okta-oidc-android by okta.
the class AuthenticationResultHandlerTest method setAuthenticationListener.
@Test
public void setAuthenticationListener() throws InterruptedException {
AuthenticationResultHandler.handler().mCachedResult = StateResult.canceled();
AuthenticationResultHandler.handler().mCachedResultType = ResultType.SIGN_IN;
final StateResult[] resultFromListener = new StateResult[1];
final ResultType[] typeFromListener = new ResultType[1];
CountDownLatch latch = new CountDownLatch(1);
AuthResultListener listener = (result, type) -> {
resultFromListener[0] = result;
typeFromListener[0] = type;
latch.countDown();
};
AuthenticationResultHandler.handler().setAuthenticationListener(listener);
latch.await();
assertEquals(resultFromListener[0].getStatus(), CANCELED);
assertEquals(typeFromListener[0], ResultType.SIGN_IN);
assertNull(AuthenticationResultHandler.handler().mCachedResult);
assertNull(AuthenticationResultHandler.handler().mCachedResultType);
}
Aggregations