TF-1115 Implement catch exception for AuthenticationOIDCDataSource
This commit is contained in:
@@ -95,10 +95,11 @@ class EmailBindings extends BaseBindings {
|
||||
Get.find<RemoteExceptionThrower>()));
|
||||
Get.lazyPut(() => StateDataSourceImpl(Get.find<StateCacheClient>(), Get.find<CacheExceptionThrower>()));
|
||||
Get.lazyPut(() => AuthenticationOIDCDataSourceImpl(
|
||||
Get.find<OIDCHttpClient>(),
|
||||
Get.find<AuthenticationClientBase>(),
|
||||
Get.find<TokenOidcCacheManager>(),
|
||||
Get.find<OidcConfigurationCacheManager>()
|
||||
Get.find<OIDCHttpClient>(),
|
||||
Get.find<AuthenticationClientBase>(),
|
||||
Get.find<TokenOidcCacheManager>(),
|
||||
Get.find<OidcConfigurationCacheManager>(),
|
||||
Get.find<RemoteExceptionThrower>(),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import 'package:tmail_ui_user/features/login/domain/usecases/get_stored_token_oi
|
||||
import 'package:tmail_ui_user/features/thread/data/local/email_cache_manager.dart';
|
||||
import 'package:tmail_ui_user/main/bindings/network/binding_tag.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/cache_exception_thrower.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/remote_exception_thrower.dart';
|
||||
import 'package:tmail_ui_user/main/utils/email_receive_manager.dart';
|
||||
|
||||
class HomeBindings extends BaseBindings {
|
||||
@@ -81,10 +82,11 @@ class HomeBindings extends BaseBindings {
|
||||
Get.find<AccountCacheManager>()
|
||||
));
|
||||
Get.lazyPut(() => AuthenticationOIDCDataSourceImpl(
|
||||
Get.find<OIDCHttpClient>(),
|
||||
Get.find<AuthenticationClientBase>(),
|
||||
Get.find<TokenOidcCacheManager>(),
|
||||
Get.find<OidcConfigurationCacheManager>()
|
||||
Get.find<OIDCHttpClient>(),
|
||||
Get.find<AuthenticationClientBase>(),
|
||||
Get.find<TokenOidcCacheManager>(),
|
||||
Get.find<OidcConfigurationCacheManager>(),
|
||||
Get.find<RemoteExceptionThrower>(),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:tmail_ui_user/features/login/data/local/oidc_configuration_cache
|
||||
import 'package:tmail_ui_user/features/login/data/local/token_oidc_cache_manager.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/network/authentication_client/authentication_client_base.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/network/oidc_http_client.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
|
||||
|
||||
class AuthenticationOIDCDataSourceImpl extends AuthenticationOIDCDataSource {
|
||||
|
||||
@@ -11,12 +12,15 @@ class AuthenticationOIDCDataSourceImpl extends AuthenticationOIDCDataSource {
|
||||
final AuthenticationClientBase _authenticationClient;
|
||||
final TokenOidcCacheManager _tokenOidcCacheManager;
|
||||
final OidcConfigurationCacheManager _oidcConfigurationCacheManager;
|
||||
final ExceptionThrower _exceptionThrower;
|
||||
|
||||
AuthenticationOIDCDataSourceImpl(
|
||||
this._oidcHttpClient,
|
||||
this._authenticationClient,
|
||||
this._tokenOidcCacheManager,
|
||||
this._oidcConfigurationCacheManager);
|
||||
this._oidcConfigurationCacheManager,
|
||||
this._exceptionThrower
|
||||
);
|
||||
|
||||
@override
|
||||
Future<OIDCResponse> checkOIDCIsAvailable(OIDCRequest oidcRequest) {
|
||||
@@ -24,7 +28,7 @@ class AuthenticationOIDCDataSourceImpl extends AuthenticationOIDCDataSource {
|
||||
final oidcResponse = await _oidcHttpClient.checkOIDCIsAvailable(oidcRequest);
|
||||
return oidcResponse!;
|
||||
}).catchError((error) {
|
||||
throw error;
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -33,7 +37,7 @@ class AuthenticationOIDCDataSourceImpl extends AuthenticationOIDCDataSource {
|
||||
return Future.sync(() async {
|
||||
return await _oidcHttpClient.getOIDCConfiguration(oidcResponse);
|
||||
}).catchError((error) {
|
||||
throw error;
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -42,35 +46,64 @@ class AuthenticationOIDCDataSourceImpl extends AuthenticationOIDCDataSource {
|
||||
return Future.sync(() async {
|
||||
return await _authenticationClient.getTokenOIDC(clientId, redirectUrl, discoveryUrl, scopes);
|
||||
}).catchError((error) {
|
||||
throw error;
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<TokenOIDC> getStoredTokenOIDC(String tokenIdHash) {
|
||||
return _tokenOidcCacheManager.getTokenOidc(tokenIdHash);
|
||||
return Future.sync(() async {
|
||||
return await _tokenOidcCacheManager.getTokenOidc(tokenIdHash);
|
||||
}).catchError((error) {
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> persistTokenOIDC(TokenOIDC tokenOidc) {
|
||||
return _tokenOidcCacheManager.persistOneTokenOidc(tokenOidc);
|
||||
return Future.sync(() async {
|
||||
return await _tokenOidcCacheManager.persistOneTokenOidc(tokenOidc);
|
||||
}).catchError((error) {
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<OIDCConfiguration> getStoredOidcConfiguration() {
|
||||
return _oidcConfigurationCacheManager.getOidcConfiguration();
|
||||
return Future.sync(() async {
|
||||
return await _oidcConfigurationCacheManager.getOidcConfiguration();
|
||||
}).catchError((error) {
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> persistAuthorityOidc(String authority) {
|
||||
return _oidcConfigurationCacheManager.persistAuthorityOidc(authority);
|
||||
return Future.sync(() async {
|
||||
return await _oidcConfigurationCacheManager.persistAuthorityOidc(authority);
|
||||
}).catchError((error) {
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<TokenOIDC> refreshingTokensOIDC(String clientId, String redirectUrl,
|
||||
String discoveryUrl, List<String> scopes, String refreshToken) {
|
||||
return _authenticationClient.refreshingTokensOIDC(
|
||||
clientId, redirectUrl, discoveryUrl, scopes, refreshToken);
|
||||
Future<TokenOIDC> refreshingTokensOIDC(
|
||||
String clientId,
|
||||
String redirectUrl,
|
||||
String discoveryUrl,
|
||||
List<String> scopes,
|
||||
String refreshToken
|
||||
) {
|
||||
return Future.sync(() async {
|
||||
return await _authenticationClient.refreshingTokensOIDC(
|
||||
clientId,
|
||||
redirectUrl,
|
||||
discoveryUrl,
|
||||
scopes,
|
||||
refreshToken);
|
||||
}).catchError((error) {
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -78,32 +111,52 @@ class AuthenticationOIDCDataSourceImpl extends AuthenticationOIDCDataSource {
|
||||
return Future.sync(() async {
|
||||
return await _authenticationClient.logoutOidc(tokenId, config);
|
||||
}).catchError((error) {
|
||||
throw error;
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteAuthorityOidc() {
|
||||
return _oidcConfigurationCacheManager.deleteAuthorityOidc();
|
||||
return Future.sync(() async {
|
||||
return await _oidcConfigurationCacheManager.deleteAuthorityOidc();
|
||||
}).catchError((error) {
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> authenticateOidcOnBrowser(String clientId, String redirectUrl,
|
||||
String discoveryUrl, List<String> scopes) {
|
||||
return _authenticationClient.authenticateOidcOnBrowser(
|
||||
Future<void> authenticateOidcOnBrowser(
|
||||
String clientId,
|
||||
String redirectUrl,
|
||||
String discoveryUrl,
|
||||
List<String> scopes
|
||||
) {
|
||||
return Future.sync(() async {
|
||||
return await _authenticationClient.authenticateOidcOnBrowser(
|
||||
clientId,
|
||||
redirectUrl,
|
||||
discoveryUrl,
|
||||
scopes);
|
||||
}).catchError((error) {
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String?> getAuthenticationInfo() {
|
||||
return _authenticationClient.getAuthenticationInfo();
|
||||
return Future.sync(() async {
|
||||
return await _authenticationClient.getAuthenticationInfo();
|
||||
}).catchError((error) {
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteTokenOIDC() {
|
||||
return _tokenOidcCacheManager.deleteTokenOidc();
|
||||
return Future.sync(() async {
|
||||
return await _tokenOidcCacheManager.deleteTokenOidc();
|
||||
}).catchError((error) {
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -49,6 +49,7 @@ import 'package:tmail_ui_user/features/login/domain/usecases/save_login_username
|
||||
import 'package:tmail_ui_user/features/login/presentation/login_controller.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/usecases/log_out_oidc_interactor.dart';
|
||||
import 'package:tmail_ui_user/main/bindings/network/binding_tag.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/remote_exception_thrower.dart';
|
||||
|
||||
class LoginBindings extends BaseBindings {
|
||||
|
||||
@@ -90,10 +91,11 @@ class LoginBindings extends BaseBindings {
|
||||
void bindingsDataSourceImpl() {
|
||||
Get.lazyPut(() => AuthenticationDataSourceImpl());
|
||||
Get.lazyPut(() => AuthenticationOIDCDataSourceImpl(
|
||||
Get.find<OIDCHttpClient>(),
|
||||
Get.find<AuthenticationClientBase>(),
|
||||
Get.find<TokenOidcCacheManager>(),
|
||||
Get.find<OidcConfigurationCacheManager>()
|
||||
Get.find<OIDCHttpClient>(),
|
||||
Get.find<AuthenticationClientBase>(),
|
||||
Get.find<TokenOidcCacheManager>(),
|
||||
Get.find<OidcConfigurationCacheManager>(),
|
||||
Get.find<RemoteExceptionThrower>()
|
||||
));
|
||||
Get.lazyPut(() => HiveAccountDatasourceImpl(
|
||||
Get.find<AccountCacheManager>()
|
||||
|
||||
+5
-4
@@ -170,10 +170,11 @@ class MailboxDashBoardBindings extends BaseBindings {
|
||||
Get.find<CacheExceptionThrower>()));
|
||||
Get.lazyPut(() => HiveAccountDatasourceImpl(Get.find<AccountCacheManager>()));
|
||||
Get.lazyPut(() => AuthenticationOIDCDataSourceImpl(
|
||||
Get.find<OIDCHttpClient>(),
|
||||
Get.find<AuthenticationClientBase>(),
|
||||
Get.find<TokenOidcCacheManager>(),
|
||||
Get.find<OidcConfigurationCacheManager>()
|
||||
Get.find<OIDCHttpClient>(),
|
||||
Get.find<AuthenticationClientBase>(),
|
||||
Get.find<TokenOidcCacheManager>(),
|
||||
Get.find<OidcConfigurationCacheManager>(),
|
||||
Get.find<RemoteExceptionThrower>(),
|
||||
));
|
||||
Get.lazyPut(() => SessionStorageComposerDatasourceImpl());
|
||||
}
|
||||
|
||||
@@ -63,10 +63,11 @@ class ManageAccountDashBoardBindings extends BaseBindings {
|
||||
void bindingsDataSourceImpl() {
|
||||
Get.lazyPut(() => HiveAccountDatasourceImpl(Get.find<AccountCacheManager>()));
|
||||
Get.lazyPut(() => AuthenticationOIDCDataSourceImpl(
|
||||
Get.find<OIDCHttpClient>(),
|
||||
Get.find<AuthenticationClientBase>(),
|
||||
Get.find<TokenOidcCacheManager>(),
|
||||
Get.find<OidcConfigurationCacheManager>()
|
||||
Get.find<OIDCHttpClient>(),
|
||||
Get.find<AuthenticationClientBase>(),
|
||||
Get.find<TokenOidcCacheManager>(),
|
||||
Get.find<OidcConfigurationCacheManager>(),
|
||||
Get.find<RemoteExceptionThrower>()
|
||||
));
|
||||
Get.lazyPut(() => ManageAccountDataSourceImpl(
|
||||
Get.find<ManageAccountAPI>(),
|
||||
|
||||
@@ -26,6 +26,7 @@ import 'package:tmail_ui_user/features/login/domain/usecases/get_stored_token_oi
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/usecases/log_out_oidc_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/session/domain/usecases/get_session_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/session/presentation/session_controller.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/remote_exception_thrower.dart';
|
||||
|
||||
class SessionPageBindings extends BaseBindings {
|
||||
|
||||
@@ -54,10 +55,11 @@ class SessionPageBindings extends BaseBindings {
|
||||
@override
|
||||
void bindingsDataSourceImpl() {
|
||||
Get.lazyPut(() => AuthenticationOIDCDataSourceImpl(
|
||||
Get.find<OIDCHttpClient>(),
|
||||
Get.find<AuthenticationClientBase>(),
|
||||
Get.find<TokenOidcCacheManager>(),
|
||||
Get.find<OidcConfigurationCacheManager>()
|
||||
Get.find<OIDCHttpClient>(),
|
||||
Get.find<AuthenticationClientBase>(),
|
||||
Get.find<TokenOidcCacheManager>(),
|
||||
Get.find<OidcConfigurationCacheManager>(),
|
||||
Get.find<RemoteExceptionThrower>(),
|
||||
));
|
||||
Get.lazyPut(() => HiveAccountDatasourceImpl(
|
||||
Get.find<AccountCacheManager>()
|
||||
|
||||
Reference in New Issue
Block a user