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