Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;

import java.util.stream.Collectors;
import java.util.stream.IntStream;

import javax.inject.Inject;
import javax.inject.Singleton;

Expand Down Expand Up @@ -65,10 +69,11 @@ public class DocumentCategoryApi implements DocumentCategoryPigeon.DocumentCateg

ClientCryptoManagerService clientCryptoManagerService;



@Inject
public DocumentCategoryApi(RegistrationService registrationService,FileSignatureDao fileSignatureRepository,GlobalParamRepository globalParamRepository,MasterDataService masterDataService,CertificateManagerService certificateManagerService,CryptoManagerService cryptoManagerServiceImpl,ClientCryptoManagerService clientCryptoManagerService,Context context) {
public DocumentCategoryApi(RegistrationService registrationService, FileSignatureDao fileSignatureRepository,
GlobalParamRepository globalParamRepository, MasterDataService masterDataService,
CertificateManagerService certificateManagerService, CryptoManagerService cryptoManagerServiceImpl,
ClientCryptoManagerService clientCryptoManagerService, Context context) {
this.registrationService = registrationService;
this.context = context;
this.fileSignatureRepository = fileSignatureRepository;
Expand All @@ -79,14 +84,33 @@ public DocumentCategoryApi(RegistrationService registrationService,FileSignature
this.cryptoManagerServiceImpl = cryptoManagerServiceImpl;
this.clientCryptoManagerService = clientCryptoManagerService;
}

@Override
public void getDocumentCategories(@NonNull String categoryCode, @NonNull String langCode, @NonNull DocumentCategoryPigeon.Result<List<String>> result) {
public void getDocumentCategories(@NonNull String categoryCode, @NonNull String langCode,
@NonNull List<String> languages, @NonNull DocumentCategoryPigeon.Result<List<String>> result) {
List<String> documentCategory = new ArrayList<>();
try {
Map<String, Object> dataContext = this.registrationService.getRegistrationDto().getMVELDataContext();
String applicantTypeCode = this.evaluateMvelScript((String) this.globalParamRepository.getCachedStringMAVELScript(), dataContext);
String applicantTypeCode = this
.evaluateMvelScript((String) this.globalParamRepository.getCachedStringMAVELScript(), dataContext);
Log.i(getClass().getSimpleName(), "applicantType: " + applicantTypeCode);
documentCategory = this.masterDataService.getDocumentTypes(categoryCode, applicantTypeCode, langCode);
if (languages.size() <= 1) {
List<String> docs = this.masterDataService.getDocumentTypes(categoryCode, applicantTypeCode, langCode);
documentCategory = docs != null ? docs : Collections.emptyList();
} else {
List<List<String>> docsPerLang = languages.stream()
.map(l -> this.masterDataService.getDocumentTypes(categoryCode, applicantTypeCode, l))
.map(d -> d != null ? d : Collections.<String>emptyList())
.collect(Collectors.toList());

documentCategory = IntStream.range(0, docsPerLang.stream().mapToInt(List::size).max().orElse(0))
.mapToObj(i -> docsPerLang.stream()
.filter(l -> i < l.size())
.map(l -> l.get(i))
.collect(Collectors.joining(" / ")))
.filter(s -> !s.isEmpty())
.collect(Collectors.toList());
}
} catch (Exception e) {
Log.e(getClass().getSimpleName(), "Fetch document values: " + Arrays.toString(e.getStackTrace()));
}
Expand All @@ -106,9 +130,9 @@ public void getDocumentSize(@NonNull DocumentCategoryPigeon.Result<String> resul

public String evaluateMvelScript(String scriptName, Map<String, Object> dataContext) {
try {
Map<String, String> ageGroups = new HashMap<String, String>();
Map<String, String> ageGroups = new HashMap<String, String>();
JSONObject ageGroupConfig = new JSONObject((String) this.globalParamRepository.getCachedStringAgeGroup());
for (Iterator<String> it = ageGroupConfig.keys(); it.hasNext(); ) {
for (Iterator<String> it = ageGroupConfig.keys(); it.hasNext();) {
String key = it.next();
ageGroups.put(key, ageGroupConfig.getString(key));
}
Expand All @@ -119,25 +143,25 @@ public String evaluateMvelScript(String scriptName, Map<String, Object> dataCont
context.put("ageGroups", ageGroups);
return MVEL.eval("return getApplicantType();", context, String.class);
} catch (Exception e) {
Log.e(getClass().getSimpleName(),"Failed to evaluate mvel script", e);
Log.e(getClass().getSimpleName(), "Failed to evaluate mvel script", e);
}
return null;
}

private String getScript(String scriptName) {
if(SCRIPT_CACHE.containsKey(scriptName) && SCRIPT_CACHE.get(scriptName) != null)
if (SCRIPT_CACHE.containsKey(scriptName) && SCRIPT_CACHE.get(scriptName) != null)
return SCRIPT_CACHE.get(scriptName);

try {
Optional<FileSignature> fileSignature = this.fileSignatureRepository.findByFileName(scriptName);
if(!fileSignature.isPresent()) {
if (!fileSignature.isPresent()) {
Log.e("File signature not found : {}", scriptName);
return null;
}

Path path = Paths.get(context.getFilesDir().getAbsolutePath(), scriptName);
byte[] bytes;
if(fileSignature.get().getEncrypted()) {
if (fileSignature.get().getEncrypted()) {
CryptoRequestDto cryptoRequestDto = new CryptoRequestDto();
cryptoRequestDto.setValue(FileUtils.readFileToString(path.toFile(), StandardCharsets.UTF_8));
CryptoResponseDto cryptoResponseDto = clientCryptoFacade.decrypt(cryptoRequestDto);
Expand All @@ -146,29 +170,30 @@ private String getScript(String scriptName) {
bytes = FileUtils.readFileToByteArray(path.toFile());
}
String actualData = String.format("{\"hash\":\"%s\"}", HMACUtils2.digestAsPlainText(bytes));
if(!validateScriptSignature(fileSignature.get().getSignature(), actualData)) {
if (!validateScriptSignature(fileSignature.get().getSignature(), actualData)) {
Log.e("File signature validation failed : {}", scriptName);
return null;
}
SCRIPT_CACHE.put(scriptName, new String(bytes));

} catch (Exception e) {
Log.e(getClass().getSimpleName(),"Failed to get mvel script", e);
Log.e(getClass().getSimpleName(), "Failed to get mvel script", e);
}
return SCRIPT_CACHE.get(scriptName);
}


private boolean validateScriptSignature(String signature, String actualData) throws Exception {

String certificateData = this.certificateManagerService.getCertificate("SERVER-RESPONSE", "SIGN-VERIFY");

JWTSignatureVerifyRequestDto jwtSignatureVerifyRequestDto = new JWTSignatureVerifyRequestDto();
jwtSignatureVerifyRequestDto.setJwtSignatureData(signature);
jwtSignatureVerifyRequestDto.setActualData(CryptoUtil.encodeToURLSafeBase64(actualData.getBytes(StandardCharsets.UTF_8)));
jwtSignatureVerifyRequestDto
.setActualData(CryptoUtil.encodeToURLSafeBase64(actualData.getBytes(StandardCharsets.UTF_8)));
jwtSignatureVerifyRequestDto.setCertificateData(certificateData);

JWTSignatureVerifyResponseDto verifyResponseDto = this.clientCryptoManagerService.jwtVerify(jwtSignatureVerifyRequestDto);
JWTSignatureVerifyResponseDto verifyResponseDto = this.clientCryptoManagerService
.jwtVerify(jwtSignatureVerifyRequestDto);

return verifyResponseDto.isSignatureValid();
}
Expand Down
File renamed without changes
7 changes: 6 additions & 1 deletion assets/l10n/app_ar.arb
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,11 @@
"connect_devices_and_scan": "يرجى توصيل أجهزتك والضغط على 'مسح' لاكتشافها",
"search_for_key": "ابحث عن المفتاح",
"sync_restart_dialog_message": "سيتم إعادة تشغيل التطبيق بمجرد النقر على إعادة التشغيل، وسيتم توجيهك إلى صفحة تسجيل الدخول.",
"sync_restart_button": "إعادة التشغيل"
"sync_restart_button": "إعادة التشغيل",
"app_restart_message": "تم حفظ التكوين بنجاح. جارٍ إعادة تشغيل التطبيق...",
"select_option": "اختر خياراً",
"cron_expression": "تعبير كرون",
"id": "بطاقة تعريف",
"name": "اسم"
}

7 changes: 6 additions & 1 deletion assets/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -363,5 +363,10 @@
"connect_devices_and_scan": "Please connect your devices and tap 'Scan' to detect them",
"search_for_key": "Search for Key",
"sync_restart_dialog_message": "The app will restart once you click Restart, and you will be redirected to the login page.",
"sync_restart_button": "Restart"
"sync_restart_button": "Restart",
"app_restart_message": "Configuration saved successfully. Restarting app...",
"select_option": "Select Option",
"cron_expression": "Cron Expression",
"id": "ID",
"name": "Name"
}
7 changes: 6 additions & 1 deletion assets/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,11 @@
"connect_devices_and_scan": "Veuillez connecter vos appareils et appuyer sur 'ANALYSE' pour les détecter",
"search_for_key": "Rechercher une clé",
"sync_restart_dialog_message": "L'application redémarrera une fois que vous aurez cliqué sur Redémarrer, et vous serez redirigé vers la page de connexion.",
"sync_restart_button": "Redémarrer"
"sync_restart_button": "Redémarrer",
"app_restart_message": "Configuration enregistrée avec succès. Redémarrage de l'application...",
"select_option": "Sélectionner une option",
"cron_expression": "Expression Cron",
"id": "IDENTIFIANT",
"name": "Nom"
}

7 changes: 6 additions & 1 deletion assets/l10n/app_hi.arb
Original file line number Diff line number Diff line change
Expand Up @@ -363,5 +363,10 @@
"connect_devices_and_scan": "कृपया अपने डिवाइस कनेक्ट करें और उन्हें खोजने के लिए 'स्कैन' पर टैप करें",
"search_for_key": "कुंजी खोजें",
"sync_restart_dialog_message": "जैसे ही आप पुनः आरंभ करें पर क्लिक करेंगे ऐप पुनः आरंभ हो जाएगा, और आपको लॉगिन पृष्ठ पर पुनः निर्देशित किया जाएगा।",
"sync_restart_button": "पुनः आरंभ करें"
"sync_restart_button": "पुनः आरंभ करें",
"app_restart_message": "कॉन्फ़िगरेशन सफलतापूर्वक सहेजा गया. ऐप पुनः प्रारंभ हो रहा है...",
"select_option": "विकल्प चुनें",
"cron_expression": "क्रोन एक्सप्रेशन",
"id": "आईडी",
"name": "नाम"
}
7 changes: 6 additions & 1 deletion assets/l10n/app_kn.arb
Original file line number Diff line number Diff line change
Expand Up @@ -363,5 +363,10 @@
"connect_devices_and_scan": "ದಯವಿಟ್ಟು ನಿಮ್ಮ ಸಾಧನಗಳನ್ನು ಸಂಪರ್ಕಿಸಿ ಮತ್ತು ಅವುಗಳನ್ನು ಪತ್ತೆಹಚ್ಚಲು 'ಸ್ಕ್ಯಾನ್' ಅನ್ನು ಟ್ಯಾಪ್ ಮಾಡಿ",
"search_for_key": "ಕೀಗಾಗಿ ಹುಡುಕಿ",
"sync_restart_dialog_message": "ನೀವು ಮರುಪ್ರಾರಂಭ ಕ್ಲಿಕ್ ಮಾಡಿದ ನಂತರ ಅಪ್ಲಿಕೇಶನ್ ಮರುಪ್ರಾರಂಭವಾಗುತ್ತದೆ ಮತ್ತು ನಿಮ್ಮನ್ನು ಲಾಗಿನ್ ಪುಟಕ್ಕೆ ಮರುನಿರ್ದೇಶಿಸಲಾಗುತ್ತದೆ.",
"sync_restart_button": "ಮರುಪ್ರಾರಂಭ"
"sync_restart_button": "ಮರುಪ್ರಾರಂಭ",
"app_restart_message": "ಕಾನ್ಫಿಗರೇಶನ್ ಯಶಸ್ವಿಯಾಗಿ ಉಳಿಸಲಾಗಿದೆ. ಅಪ್ಲಿಕೇಶನ್ ಅನ್ನು ಮರುಪ್ರಾರಂಭಿಸಲಾಗುತ್ತಿದೆ...",
"select_option": "ಆಯ್ಕೆಯನ್ನು ಆರಿಸಿ",
"cron_expression": "ಕ್ರಾನ್ ಎಕ್ಸ್‌ಪ್ರೆಶನ್",
"id": "ID",
"name": "ಹೆಸರು"
}
7 changes: 6 additions & 1 deletion assets/l10n/app_ta.arb
Original file line number Diff line number Diff line change
Expand Up @@ -372,5 +372,10 @@
"connect_devices_and_scan": "தயவுசெய்து உங்கள் சாதனங்களை இணைத்து, அவற்றைக் கண்டறிய 'ஊடுகதிர்' என்பதைத் தட்டவும்",
"search_for_key": "விசையைத் தேடவும்",
"sync_restart_dialog_message": "மறுதொடக்கம் என்பதைக் கிளிக் செய்தவுடன் பயன்பாடு மறுதொடங்கும், மற்றும் நீங்கள் உள்நுழைவு பக்கத்திற்கு திருப்பிவிடப்படுவீர்கள்.",
"sync_restart_button": "மறுதொடக்கம்"
"sync_restart_button": "மறுதொடக்கம்",
"app_restart_message": "உள்ளமைவு வெற்றிகரமாக சேமிக்கப்பட்டது. பயன்பாட்டை மறுதொடக்கம் செய்கிறது...",
"select_option": "விருப்பத்தைத் தேர்ந்தெடுக்கவும்",
"cron_expression": "கிரான் வெளிப்பாடு",
"id": "ஐடி",
"name": "பெயர்"
}
4 changes: 2 additions & 2 deletions lib/platform_android/document_category_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import 'package:registration_client/platform_spi/document_category_service.dart'

class DocumentCategoryImpl implements DocumentCategory {
@override
Future<List<String?>> getDocumentCategories(String categoryCode, String langCode) async{
Future<List<String?>> getDocumentCategories(String categoryCode, String langCode, List<String> languages) async{

List<String?> documentValuesList = [];
try {
documentValuesList = await DocumentCategoryApi()
.getDocumentCategories(categoryCode,langCode);
.getDocumentCategories(categoryCode, langCode, languages);
} on PlatformException {
debugPrint('DynamicServiceResponseApi call failed!');
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion lib/platform_spi/document_category_service.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:registration_client/platform_android/document_category_impl.dart';

abstract class DocumentCategory {
Future<List<String?>> getDocumentCategories(String categoryCode,String langCode);
Future<List<String?>> getDocumentCategories(String categoryCode, String langCode, List<String> languages);

Future<String> getDocumentSize();

Expand Down
8 changes: 2 additions & 6 deletions lib/provider/approve_packets_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import 'dart:convert';
import 'dart:developer';

import 'package:flutter/material.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:registration_client/model/registration.dart';
import 'package:registration_client/utils/secure_storage.dart';
import 'package:registration_client/platform_android/packet_service_impl.dart';
import 'package:registration_client/utils/constants.dart';
import 'package:webview_flutter_plus/webview_flutter_plus.dart';
Expand All @@ -12,11 +12,7 @@ import '../platform_android/sync_response_service_impl.dart';
import '../platform_spi/packet_service.dart';

class ApprovePacketsProvider with ChangeNotifier {
final storage = const FlutterSecureStorage(
aOptions: AndroidOptions(
encryptedSharedPreferences: true,
),
);
final storage = appSecureStorage;

List<Map<String, Object>> packetsList = [];
List<Map<String, Object>> matchingPackets = [];
Expand Down
12 changes: 4 additions & 8 deletions lib/provider/registration_task_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import 'dart:developer';
import 'dart:typed_data';

import 'package:flutter/material.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:flutter/services.dart';
import 'package:registration_client/utils/secure_storage.dart';
import 'package:registration_client/pigeon/dash_board_pigeon.dart';
import 'package:registration_client/pigeon/dynamic_response_pigeon.dart';
import 'package:registration_client/pigeon/registration_data_pigeon.dart';
Expand All @@ -32,11 +32,7 @@ class RegistrationTaskProvider with ChangeNotifier {
final DashBoard dashBoard = DashBoard();
DynamicResponseService dynamicResponseService = DynamicResponseService();
final DocumentCategory documentCategory = DocumentCategory();
static const storage = FlutterSecureStorage(
aOptions: AndroidOptions(
encryptedSharedPreferences: true,
),
);
static const storage = appSecureStorage;

List<Object?> _listOfProcesses = List.empty(growable: true);
List<String?> _listOfSettings = List.empty(growable: true);
Expand Down Expand Up @@ -274,8 +270,8 @@ class RegistrationTaskProvider with ChangeNotifier {
}

Future<List<String?>> getDocumentType(
String categoryCode, String langCode) async {
return await documentCategory.getDocumentCategories(categoryCode, langCode);
String categoryCode, String langCode, List<String> languages) async {
return await documentCategory.getDocumentCategories(categoryCode, langCode, languages);
}

removeDocumentField(String fieldId) async {
Expand Down
36 changes: 20 additions & 16 deletions lib/ui/approve_packet/approve_packet_ui.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,27 @@ class _ApprovePacketsPageState extends State<ApprovePacketsPage> {
elevation: 0,
toolbarHeight: 75,
leadingWidth: 80,
leading: Container(
margin: const EdgeInsets.all(14),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.white.withOpacity(0.2),
padding: const EdgeInsets.all(4)),
child: const Icon(
Icons.arrow_back,
size: 32,
leading: Semantics(
label: 'pending_approval_back_button',
excludeSemantics: true,
child: Container(
margin: const EdgeInsets.all(14),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.white.withOpacity(0.2),
padding: const EdgeInsets.all(4)),
child: const Icon(
Icons.arrow_back,
size: 32,
),
onPressed: () {
context
.read<RegistrationTaskProvider>()
.getApplicationUploadNumber();
context.read<ApprovePacketsProvider>().getTotalCreatedPackets();
Navigator.of(context).pop();
},
),
onPressed: () {
context
.read<RegistrationTaskProvider>()
.getApplicationUploadNumber();
context.read<ApprovePacketsProvider>().getTotalCreatedPackets();
Navigator.of(context).pop();
},
),
),
title: Text(AppLocalizations.of(context)!.pending_approval),
Expand Down
Loading