diff --git a/lib/l10n/app_cs.arb b/lib/l10n/app_cs.arb index 86ef658e7..113f82d50 100644 --- a/lib/l10n/app_cs.arb +++ b/lib/l10n/app_cs.arb @@ -476,5 +476,18 @@ "hidePushTokensDescription": "Skrýt push tokeny ze seznamu tokenů. Tím se tokeny neodstraní a budou stále viditelné na samostatné obrazovce.", "settingsGroupGeneral": "Obecné informace", "licensesAndVersion": "Licence a verze", - "privacyPolicy": "Zásady ochrany osobních údajů" + "privacyPolicy": "Zásady ochrany osobních údajů", + "legacySigningErrorTitle": "Při použití zastaralého tokenu došlo k chybě: {tokenLabel}", + "@legacySigningErrorTitle": { + "description": "Title of the error dialog that is shown when an error occurs while using a legacy token.", + "placeholders": { + "tokenLabel": { + "example": "PUSH1234A" + } + } + }, + "legacySigningErrorMessage": "Token byl vytvořen v zastaralé verzi aplikace, což může vést k problémům při jeho používání.\nPokud problém přetrvává, doporučujeme vytvořit nový push token!", + "@legacySigningErrorMessage": { + "description": "Message of the error dialog that is shown when an error occurs while using a legacy token." + } } \ No newline at end of file diff --git a/lib/l10n/app_de.arb b/lib/l10n/app_de.arb index af6b8c0b4..ab4a3b9d5 100644 --- a/lib/l10n/app_de.arb +++ b/lib/l10n/app_de.arb @@ -455,5 +455,18 @@ "hidePushTokensDescription": "Push-Token aus der Token-Liste ausblenden. Dadurch werden die Token nicht gelöscht und sind weiterhin auf einem separaten Bildschirm sichtbar.", "settingsGroupGeneral": "Allgemeines", "licensesAndVersion": "Lizenzen und Version", - "privacyPolicy": "Datenschutzerklärung" + "privacyPolicy": "Datenschutzerklärung", + "legacySigningErrorTitle": "Bei der Verwendung des veralteten Tokens ist ein Fehler aufgetreten: {tokenLabel}", + "@legacySigningErrorTitle": { + "description": "Title of the error dialog that is shown when an error occurs while using a legacy token.", + "placeholders": { + "tokenLabel": { + "example": "PUSH1234A" + } + } + }, + "legacySigningErrorMessage": "Der Token wurde in einer veralteten Version der App erstellt, was zu Problemen bei der Verwendung führen kann. Es wird empfohlen, einen neuen Push-Token zu erstellen, wenn das Problem weiterhin besteht!", + "@legacySigningErrorMessage": { + "description": "Message of the error dialog that is shown when an error occurs while using a legacy token." + } } \ No newline at end of file diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 4d06cf173..687c6eee1 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -467,5 +467,18 @@ "hidePushTokensDescription": "Hide push tokens from the token list. This will not delete the tokens and they will still be visible on a separate screen.", "settingsGroupGeneral": "General", "licensesAndVersion": "Licenses and version", - "privacyPolicy": "Privacy policy" + "privacyPolicy": "Privacy policy", + "legacySigningErrorTitle": "An error occured while using the legacy token: {tokenLabel}", + "@legacySigningErrorTitle": { + "description": "Title of the error dialog that is shown when an error occurs while using a legacy token.", + "placeholders": { + "tokenLabel": { + "example": "PUSH1234A" + } + } + }, + "legacySigningErrorMessage": "The token was enrolled in a old version of this app, which may cause trouble using it.\nIt is suggested to enroll a new push token if the problem persist!", + "@legacySigningErrorMessage": { + "description": "Message of the error dialog that is shown when an error occurs while using a legacy token." + } } \ No newline at end of file diff --git a/lib/l10n/app_es.arb b/lib/l10n/app_es.arb index e2d10073f..8b51f7607 100644 --- a/lib/l10n/app_es.arb +++ b/lib/l10n/app_es.arb @@ -472,5 +472,18 @@ "hidePushTokensDescription": "Ocultar tokens push de la lista de tokens. Esto no borrará los tokens y seguirán siendo visibles en una pantalla aparte", "settingsGroupGeneral": "Información general", "licensesAndVersion": "Licencias y versión", - "privacyPolicy": "Política de privacidad" + "privacyPolicy": "Política de privacidad", + "legacySigningErrorTitle": "Se ha producido un error al utilizar el token obsoleto: {tokenLabel}", + "@legacySigningErrorTitle": { + "description": "Title of the error dialog that is shown when an error occurs while using a legacy token.", + "placeholders": { + "tokenLabel": { + "example": "PUSH1234A" + } + } + }, + "legacySigningErrorMessage": "El token se creó en una versión obsoleta de la aplicación, lo que puede provocar problemas al utilizarlo.\nSe recomienda crear un nuevo token push si el problema persiste.", + "@legacySigningErrorMessage": { + "description": "Message of the error dialog that is shown when an error occurs while using a legacy token." + } } \ No newline at end of file diff --git a/lib/l10n/app_fr.arb b/lib/l10n/app_fr.arb index 2fb8fac7b..3307299bf 100644 --- a/lib/l10n/app_fr.arb +++ b/lib/l10n/app_fr.arb @@ -477,5 +477,18 @@ "hidePushTokensDescription": "Masquer les jetons de poussée de la liste des jetons. Cela ne supprimera pas les jetons et ils seront toujours visibles sur un écran séparé", "settingsGroupGeneral": "Généralités", "licensesAndVersion": "Licences et version", - "privacyPolicy": "Politique de confidentialité" + "privacyPolicy": "Politique de confidentialité", + "legacySigningErrorTitle": "Une erreur s'est produite lors de l'utilisation du jeton obsolète : {tokenLabel}", + "@legacySigningErrorTitle": { + "description": "Title of the error dialog that is shown when an error occurs while using a legacy token.", + "placeholders": { + "tokenLabel": { + "example": "PUSH1234A" + } + } + }, + "legacySigningErrorMessage": "Le token a été créé dans une version obsolète de l'application, ce qui peut entraîner des problèmes d'utilisation.\nIl est recommandé de créer un nouveau token push si le problème persiste !", + "@legacySigningErrorMessage": { + "description": "Message of the error dialog that is shown when an error occurs while using a legacy token." + } } \ No newline at end of file diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index bd9a26c08..0a0515bef 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -990,6 +990,18 @@ abstract class AppLocalizations { /// In en, this message translates to: /// **'Privacy policy'** String get privacyPolicy; + + /// Title of the error dialog that is shown when an error occurs while using a legacy token. + /// + /// In en, this message translates to: + /// **'An error occured while using the legacy token: {tokenLabel}'** + String legacySigningErrorTitle(Object tokenLabel); + + /// Message of the error dialog that is shown when an error occurs while using a legacy token. + /// + /// In en, this message translates to: + /// **'The token was enrolled in a old version of this app, which may cause trouble using it.\nIt is suggested to enroll a new push token if the problem persist!'** + String get legacySigningErrorMessage; } class _AppLocalizationsDelegate extends LocalizationsDelegate { diff --git a/lib/l10n/app_localizations_cs.dart b/lib/l10n/app_localizations_cs.dart index 828244447..42555bcd6 100644 --- a/lib/l10n/app_localizations_cs.dart +++ b/lib/l10n/app_localizations_cs.dart @@ -467,4 +467,12 @@ class AppLocalizationsCs extends AppLocalizations { @override String get privacyPolicy => 'Zásady ochrany osobních údajů'; + + @override + String legacySigningErrorTitle(Object tokenLabel) { + return 'Při použití zastaralého tokenu došlo k chybě: $tokenLabel'; + } + + @override + String get legacySigningErrorMessage => 'Token byl vytvořen v zastaralé verzi aplikace, což může vést k problémům při jeho používání.\nPokud problém přetrvává, doporučujeme vytvořit nový push token!'; } diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dart index f6ab86544..8bb2e2c50 100644 --- a/lib/l10n/app_localizations_de.dart +++ b/lib/l10n/app_localizations_de.dart @@ -467,4 +467,12 @@ class AppLocalizationsDe extends AppLocalizations { @override String get privacyPolicy => 'Datenschutzerklärung'; + + @override + String legacySigningErrorTitle(Object tokenLabel) { + return 'Bei der Verwendung des veralteten Tokens ist ein Fehler aufgetreten: $tokenLabel'; + } + + @override + String get legacySigningErrorMessage => 'Der Token wurde in einer veralteten Version der App erstellt, was zu Problemen bei der Verwendung führen kann. Es wird empfohlen, einen neuen Push-Token zu erstellen, wenn das Problem weiterhin besteht!'; } diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index b67450712..ecb07b7c7 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -467,4 +467,12 @@ class AppLocalizationsEn extends AppLocalizations { @override String get privacyPolicy => 'Privacy policy'; + + @override + String legacySigningErrorTitle(Object tokenLabel) { + return 'An error occured while using the legacy token: $tokenLabel'; + } + + @override + String get legacySigningErrorMessage => 'The token was enrolled in a old version of this app, which may cause trouble using it.\nIt is suggested to enroll a new push token if the problem persist!'; } diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dart index b1d40f6ad..35ee0472a 100644 --- a/lib/l10n/app_localizations_es.dart +++ b/lib/l10n/app_localizations_es.dart @@ -467,4 +467,12 @@ class AppLocalizationsEs extends AppLocalizations { @override String get privacyPolicy => 'Política de privacidad'; + + @override + String legacySigningErrorTitle(Object tokenLabel) { + return 'Se ha producido un error al utilizar el token obsoleto: $tokenLabel'; + } + + @override + String get legacySigningErrorMessage => 'El token se creó en una versión obsoleta de la aplicación, lo que puede provocar problemas al utilizarlo.\nSe recomienda crear un nuevo token push si el problema persiste.'; } diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dart index d8eb95e45..b3a0edf8e 100644 --- a/lib/l10n/app_localizations_fr.dart +++ b/lib/l10n/app_localizations_fr.dart @@ -467,4 +467,12 @@ class AppLocalizationsFr extends AppLocalizations { @override String get privacyPolicy => 'Politique de confidentialité'; + + @override + String legacySigningErrorTitle(Object tokenLabel) { + return 'Une erreur s\'est produite lors de l\'utilisation du jeton obsolète : $tokenLabel'; + } + + @override + String get legacySigningErrorMessage => 'Le token a été créé dans une version obsolète de l\'application, ce qui peut entraîner des problèmes d\'utilisation.\nIl est recommandé de créer un nouveau token push si le problème persiste !'; } diff --git a/lib/l10n/app_localizations_nl.dart b/lib/l10n/app_localizations_nl.dart index ca9085218..040a99b46 100644 --- a/lib/l10n/app_localizations_nl.dart +++ b/lib/l10n/app_localizations_nl.dart @@ -467,4 +467,12 @@ class AppLocalizationsNl extends AppLocalizations { @override String get privacyPolicy => 'Privacybeleid'; + + @override + String legacySigningErrorTitle(Object tokenLabel) { + return 'Er is een fout opgetreden bij het gebruik van het verouderde token: $tokenLabel'; + } + + @override + String get legacySigningErrorMessage => 'Het token is aangemaakt in een verouderde versie van de app, wat kan leiden tot problemen bij het gebruik ervan.\nHet wordt aanbevolen om een nieuw push token aan te maken als het probleem zich blijft voordoen!'; } diff --git a/lib/l10n/app_localizations_pl.dart b/lib/l10n/app_localizations_pl.dart index fd8588ff3..70be5ddb3 100644 --- a/lib/l10n/app_localizations_pl.dart +++ b/lib/l10n/app_localizations_pl.dart @@ -467,4 +467,12 @@ class AppLocalizationsPl extends AppLocalizations { @override String get privacyPolicy => 'Polityka prywatności'; + + @override + String legacySigningErrorTitle(Object tokenLabel) { + return 'Wystąpił błąd podczas korzystania z przestarzałego tokena: $tokenLabel'; + } + + @override + String get legacySigningErrorMessage => 'Token został utworzony w nieaktualnej wersji aplikacji, co może prowadzić do problemów podczas korzystania z niego.\nZaleca się utworzenie nowego tokena push, jeśli problem nadal występuje!'; } diff --git a/lib/l10n/app_nl.arb b/lib/l10n/app_nl.arb index 05af7e593..5d95b74c7 100644 --- a/lib/l10n/app_nl.arb +++ b/lib/l10n/app_nl.arb @@ -466,5 +466,18 @@ "hidePushTokensDescription": "Verberg push tokens uit de token lijst. Hierdoor worden de tokens niet verwijderd en blijven ze zichtbaar op een apart scherm.", "settingsGroupGeneral": "Algemene informatie", "licensesAndVersion": "Licenties en versie", - "privacyPolicy": "Privacybeleid" + "privacyPolicy": "Privacybeleid", + "legacySigningErrorTitle": "Er is een fout opgetreden bij het gebruik van het verouderde token: {tokenLabel}", + "@legacySigningErrorTitle": { + "description": "Title of the error dialog that is shown when an error occurs while using a legacy token.", + "placeholders": { + "tokenLabel": { + "example": "PUSH1234A" + } + } + }, + "legacySigningErrorMessage": "Het token is aangemaakt in een verouderde versie van de app, wat kan leiden tot problemen bij het gebruik ervan.\nHet wordt aanbevolen om een nieuw push token aan te maken als het probleem zich blijft voordoen!", + "@legacySigningErrorMessage": { + "description": "Message of the error dialog that is shown when an error occurs while using a legacy token." + } } \ No newline at end of file diff --git a/lib/l10n/app_pl.arb b/lib/l10n/app_pl.arb index ba86eba40..878aa24f9 100644 --- a/lib/l10n/app_pl.arb +++ b/lib/l10n/app_pl.arb @@ -470,5 +470,18 @@ "hidePushTokensDescription": "Ukryj tokeny push z listy tokenów. Nie spowoduje to usunięcia tokenów i będą one nadal widoczne na osobnym ekranie", "settingsGroupGeneral": "Informacje ogólne", "licensesAndVersion": "Licencje i wersja", - "privacyPolicy": "Polityka prywatności" + "privacyPolicy": "Polityka prywatności", + "legacySigningErrorTitle": "Wystąpił błąd podczas korzystania z przestarzałego tokena: {tokenLabel}", + "@legacySigningErrorTitle": { + "description": "Title of the error dialog that is shown when an error occurs while using a legacy token.", + "placeholders": { + "tokenLabel": { + "example": "PUSH1234A" + } + } + }, + "legacySigningErrorMessage": "Token został utworzony w nieaktualnej wersji aplikacji, co może prowadzić do problemów podczas korzystania z niego.\nZaleca się utworzenie nowego tokena push, jeśli problem nadal występuje!", + "@legacySigningErrorMessage": { + "description": "Message of the error dialog that is shown when an error occurs while using a legacy token." + } } \ No newline at end of file diff --git a/lib/repo/secure_token_repository.dart b/lib/repo/secure_token_repository.dart index b3b9a42e8..cb9eb0246 100644 --- a/lib/repo/secure_token_repository.dart +++ b/lib/repo/secure_token_repository.dart @@ -26,6 +26,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:mutex/mutex.dart'; +import 'package:pi_authenticator_legacy/identifiers.dart'; import 'package:privacyidea_authenticator/interfaces/repo/token_repository.dart'; import 'package:privacyidea_authenticator/l10n/app_localizations.dart'; import 'package:privacyidea_authenticator/model/tokens/token.dart'; @@ -111,6 +112,7 @@ class SecureTokenRepository implements TokenRepository { if (key == _CURRENT_APP_TOKEN_KEY || key == _NEW_APP_TOKEN_KEY) { continue; } + _storage.delete(key: key); Logger.warning( 'Could not deserialize token from secure storage. Value: $value, key: $key', name: 'storage_utils.dart#loadAllTokens', diff --git a/lib/utils/push_provider.dart b/lib/utils/push_provider.dart index a051e87b9..e4a82008f 100644 --- a/lib/utils/push_provider.dart +++ b/lib/utils/push_provider.dart @@ -57,6 +57,7 @@ class PushProvider { Future initialize({required PushRequestNotifier pushSubscriber, required FirebaseUtils firebaseUtils}) async { if (_initialized) return; + Logger.warning('PushProvider is already initialized', name: 'push_provider.dart#initializePushProvider'); _initialized = true; this.firebaseUtils = firebaseUtils; this.pushSubscriber = pushSubscriber; diff --git a/lib/utils/rsa_utils.dart b/lib/utils/rsa_utils.dart index 35e5ba3c0..c94464465 100644 --- a/lib/utils/rsa_utils.dart +++ b/lib/utils/rsa_utils.dart @@ -25,10 +25,13 @@ import 'package:base32/base32.dart'; import 'package:flutter/foundation.dart'; import 'package:pi_authenticator_legacy/pi_authenticator_legacy.dart'; import 'package:pointycastle/export.dart'; +import 'package:privacyidea_authenticator/l10n/app_localizations.dart'; import 'package:privacyidea_authenticator/model/tokens/push_token.dart'; import 'package:privacyidea_authenticator/utils/crypto_utils.dart'; +import 'package:privacyidea_authenticator/utils/customizations.dart'; import 'package:privacyidea_authenticator/utils/identifiers.dart'; import 'package:privacyidea_authenticator/utils/logger.dart'; +import 'package:privacyidea_authenticator/utils/riverpod_providers.dart'; class RsaUtils { const RsaUtils(); @@ -213,25 +216,19 @@ class RsaUtils { /// push token so that the app can directly access the private key. /// Returns the signature on success and null on failure. Future trySignWithToken(PushToken token, String message) async { - String? signature; - if (token.privateTokenKey == null) { - // It is a legacy token so the operation could cause an exception - try { - signature = await const LegacyUtils().sign(token.serial, message); - } catch (error, stackTrace) { - Logger.error("Error", - error: "An error occured while using the legacy token ${token.label}. " - "The token was enrolled in a old version of this app, which may cause trouble" - " using it. It is suggested to enroll a new push token if the problems persist!", - name: 'crypto_utils.dart#trySignWithToken', - stackTrace: stackTrace); - return null; - } - } else { - signature = createBase32Signature(token.rsaPrivateTokenKey!, utf8.encode(message) as Uint8List); + if (token.privateTokenKey != null) { + return createBase32Signature(token.rsaPrivateTokenKey!, utf8.encode(message) as Uint8List); } + // It is a legacy token so the operation could cause an exception + try { + return await const LegacyUtils().sign(token.serial, message); + } catch (error) { + final legacySigningErrorTitle = AppLocalizations.of(globalNavigatorKey.currentContext!)!.legacySigningErrorTitle(token.label); + final legacySigningErrorMessage = AppLocalizations.of(globalNavigatorKey.currentContext!)!.legacySigningErrorMessage; + globalRef?.read(statusMessageProvider.notifier).state = (legacySigningErrorTitle, legacySigningErrorMessage); - return signature; + return null; + } } Future> generateRSAKeyPair() async {