Skip to content

Commit

Permalink
Merge pull request #169 from Infosys/feature-flutter
Browse files Browse the repository at this point in the history
Critical Bug Fixes
  • Loading branch information
jainhitesh9998 authored Oct 9, 2023
2 parents d524132 + e976c58 commit 40d3451
Show file tree
Hide file tree
Showing 104 changed files with 1,043 additions and 496 deletions.
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<application
android:label="registration_client"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:icon="@mipmap/launcher_icon"
android:usesCleartextTraffic="true">
<service android:name=".SyncBackgroundService" />
<service android:name=".UploadBackgroundService" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import io.mosip.registration.clientmanager.spi.JobManagerService;
import io.mosip.registration.keymanager.spi.CertificateManagerService;
import io.mosip.registration.keymanager.spi.ClientCryptoManagerService;
import io.mosip.registration_client.api_services.AuditDetailsApi;
import io.mosip.registration_client.api_services.AuthenticationApi;
import io.mosip.registration_client.api_services.BiometricsDetailsApi;
import io.mosip.registration_client.api_services.CommonDetailsApi;
Expand Down Expand Up @@ -79,15 +80,17 @@ public Context provideApplicationContext() {
@Singleton
UserDetailsApi getLoginActivityApi(LoginService loginService,
RegistrationCenterRepository registrationCenterRepository,
MasterDataService masterDataService) {
return new UserDetailsApi(loginService, registrationCenterRepository, masterDataService);
MasterDataService masterDataService,
AuditManagerService auditManagerService) {
return new UserDetailsApi(loginService, registrationCenterRepository, masterDataService, auditManagerService);
}

@Provides
@Singleton
MachineDetailsApi getMachineDetailsApi(ClientCryptoManagerService clientCryptoManagerService,
RegistrationCenterRepository registrationCenterRepository) {
return new MachineDetailsApi(clientCryptoManagerService, registrationCenterRepository);
RegistrationCenterRepository registrationCenterRepository,
AuditManagerService auditManagerService) {
return new MachineDetailsApi(clientCryptoManagerService, registrationCenterRepository, auditManagerService);
}


Expand All @@ -103,17 +106,18 @@ AuthenticationApi getAuthenticationApi(SyncRestService syncRestService,

@Provides
@Singleton
CommonDetailsApi getCommonApiImpl(MasterDataService masterDataService){
return new CommonDetailsApi(masterDataService);
CommonDetailsApi getCommonApiImpl(MasterDataService masterDataService, AuditManagerService auditManagerService){
return new CommonDetailsApi(masterDataService, auditManagerService);
}


@Provides
@Singleton
ProcessSpecDetailsApi getProcessSpecDetailsApi(IdentitySchemaRepository identitySchemaRepository,
GlobalParamRepository globalParamRepository,RegistrationService registrationService) {
GlobalParamRepository globalParamRepository,RegistrationService registrationService,
AuditManagerService auditManagerService) {
return new ProcessSpecDetailsApi(appContext, identitySchemaRepository,
globalParamRepository,registrationService);
globalParamRepository,registrationService, auditManagerService);

}

Expand All @@ -126,34 +130,36 @@ BiometricsDetailsApi getBiometricsDetailsApi(AuditManagerService auditManagerSer

@Provides
@Singleton
RegistrationApi getRegistrationDataApi(RegistrationService registrationService, TemplateService templateService) {
return new RegistrationApi(registrationService, templateService);
RegistrationApi getRegistrationDataApi(RegistrationService registrationService, TemplateService templateService,
AuditManagerService auditManagerService) {
return new RegistrationApi(registrationService, templateService, auditManagerService);

}

@Provides
@Singleton
PacketAuthenticationApi getPacketAuthenticationApi(SyncRestService syncRestService, SyncRestUtil syncRestFactory,
LoginService loginService, PacketService packetService) {
return new PacketAuthenticationApi(syncRestService, syncRestFactory, loginService, packetService);
LoginService loginService, PacketService packetService,
AuditManagerService auditManagerService) {
return new PacketAuthenticationApi(syncRestService, syncRestFactory, loginService, packetService, auditManagerService);
}

@Provides
@Singleton
DemographicsDetailsApi getDemographicsDetailsApi(RegistrationService registrationService) {
return new DemographicsDetailsApi(registrationService);
DemographicsDetailsApi getDemographicsDetailsApi(RegistrationService registrationService, AuditManagerService auditManagerService) {
return new DemographicsDetailsApi(registrationService, auditManagerService);
}

@Provides
@Singleton
DynamicDetailsApi getDynamicDetailsApi(MasterDataService masterDataService) {
return new DynamicDetailsApi(masterDataService);
DynamicDetailsApi getDynamicDetailsApi(MasterDataService masterDataService, AuditManagerService auditManagerService) {
return new DynamicDetailsApi(masterDataService, auditManagerService);
}

@Provides
@Singleton
DocumentDetailsApi getDocumentDetailsApi(RegistrationService registrationService) {
return new DocumentDetailsApi(registrationService);
DocumentDetailsApi getDocumentDetailsApi(RegistrationService registrationService, AuditManagerService auditManagerService) {
return new DocumentDetailsApi(registrationService, auditManagerService);
}
@Provides
@Singleton
Expand All @@ -168,7 +174,8 @@ MasterDataSyncApi getSyncResponseApi(
BlocklistedWordRepository blocklistedWordRepository,
SyncJobDefRepository syncJobDefRepository,
LanguageRepository languageRepository,
JobManagerService jobManagerService) {
JobManagerService jobManagerService,
AuditManagerService auditManagerService) {
return new MasterDataSyncApi( clientCryptoManagerService,
machineRepository, registrationCenterRepository,
syncRestService, certificateManagerService,
Expand All @@ -177,8 +184,15 @@ MasterDataSyncApi getSyncResponseApi(
documentTypeRepository, applicantValidDocRepository,
templateRepository, dynamicFieldRepository,
locationRepository, blocklistedWordRepository,
syncJobDefRepository, languageRepository,jobManagerService
syncJobDefRepository, languageRepository,jobManagerService,
auditManagerService
);
}

@Provides
@Singleton
AuditDetailsApi getAuditDetailsApi(AuditManagerService auditManagerService) {
return new AuditDetailsApi(auditManagerService);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import io.mosip.registration.clientmanager.spi.SyncRestService;
import io.mosip.registration.clientmanager.util.SyncRestUtil;
import io.mosip.registration.keymanager.spi.ClientCryptoManagerService;
import io.mosip.registration_client.api_services.AuditDetailsApi;
import io.mosip.registration_client.api_services.AuthenticationApi;
import io.mosip.registration_client.api_services.BiometricsDetailsApi;
import io.mosip.registration_client.api_services.CommonDetailsApi;
Expand All @@ -68,6 +69,7 @@
import io.mosip.registration_client.api_services.ProcessSpecDetailsApi;
import io.mosip.registration_client.api_services.RegistrationApi;
import io.mosip.registration_client.api_services.UserDetailsApi;
import io.mosip.registration_client.model.AuditResponsePigeon;
import io.mosip.registration_client.model.AuthResponsePigeon;
import io.mosip.registration_client.model.BiometricsPigeon;
import io.mosip.registration_client.model.CommonDetailsPigeon;
Expand Down Expand Up @@ -152,6 +154,8 @@ public class MainActivity extends FlutterActivity {

@Inject
MasterDataSyncApi masterDataSyncApi;
@Inject
AuditDetailsApi auditDetailsApi;

@Inject
SyncJobDefRepository syncJobDefRepository;
Expand Down Expand Up @@ -311,6 +315,7 @@ public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {

DynamicResponsePigeon.DynamicResponseApi.setup(flutterEngine.getDartExecutor().getBinaryMessenger(), dynamicDetailsApi);
MasterDataSyncPigeon.SyncApi.setup(flutterEngine.getDartExecutor().getBinaryMessenger(), masterDataSyncApi);
AuditResponsePigeon.AuditResponseApi.setup(flutterEngine.getDartExecutor().getBinaryMessenger(), auditDetailsApi);

new MethodChannel(flutterEngine.getDartExecutor().getBinaryMessenger(), REG_CLIENT_CHANNEL)
.setMethodCallHandler(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package io.mosip.registration_client.api_services;

import android.util.Log;

import androidx.annotation.NonNull;

import java.util.Arrays;
import java.util.Objects;

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

import io.mosip.registration.clientmanager.constant.AuditEvent;
import io.mosip.registration.clientmanager.constant.Components;
import io.mosip.registration.clientmanager.spi.AuditManagerService;
import io.mosip.registration_client.model.AuditResponsePigeon;

@Singleton
public class AuditDetailsApi implements AuditResponsePigeon.AuditResponseApi {
AuditManagerService auditManagerService;

@Inject
public AuditDetailsApi(AuditManagerService auditManagerService) {
this.auditManagerService = auditManagerService;
}

@Override
public void audit(@NonNull String id, @NonNull String componentId, @NonNull AuditResponsePigeon.Result<Void> result) {
try {
Arrays.stream(AuditEvent.values()).forEach((event) -> {
if(Objects.equals(event.getId(), id)) {
auditEvent(event, componentId);
}
});
} catch (Exception e) {
Log.e(getClass().getSimpleName(), "Exception in system audit event!", e);
}
}

private void auditEvent(AuditEvent auditEvent, String componentId) {
Arrays.stream(Components.values()).forEach((component) -> {
if(Objects.equals(component.getId(), componentId)) {
auditManagerService.audit(auditEvent, component);
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import javax.inject.Inject;
import javax.inject.Singleton;

import io.mosip.registration.clientmanager.constant.AuditEvent;
import io.mosip.registration.clientmanager.constant.Components;
import io.mosip.registration.clientmanager.dto.http.ResponseWrapper;
import io.mosip.registration.clientmanager.dto.http.ServiceError;
import io.mosip.registration.clientmanager.exception.InvalidMachineSpecIDException;
Expand Down Expand Up @@ -154,6 +156,7 @@ private void offlineLogin(final String username, final String password, AuthResp

@Override
public void login(@NonNull String username, @NonNull String password, @NonNull Boolean isConnected, @NonNull AuthResponsePigeon.Result<AuthResponsePigeon.AuthResponse> result) {
auditManagerService.audit(AuditEvent.LOGIN_WITH_PASSWORD, Components.LOGIN);
if(!isConnected) {
offlineLogin(username, password, result);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,15 @@

@Singleton
public class BiometricsDetailsApi implements BiometricsPigeon.BiometricsApi {

private Activity activity;

private final AuditManagerService auditManagerService;

private final ObjectMapper objectMapper;

private final Biometrics095Service biometricsService;

private final RegistrationService registrationService;

private final GlobalParamRepository globalParamRepository;



private Modality currentModality;

private static final String TAG="BiometricsDetailApi";

private String callbackId;

private String fieldId;
private String purpose;
private int capturedAttempts;
Expand All @@ -97,7 +85,6 @@ public BiometricsDetailsApi(AuditManagerService auditManagerService, ObjectMappe
this.biometricsService=biometrics095Service;
this.registrationService=registrationService;
this.globalParamRepository=globalParamRepository;

}

public void setCallbackActivity(MainActivity mainActivity){
Expand All @@ -107,6 +94,7 @@ public void setCallbackActivity(MainActivity mainActivity){

@Override
public void invokeDiscoverSbi(@NonNull String fieldId, @NonNull String modality, @NonNull BiometricsPigeon.Result<String> result) {
auditManagerService.audit(AuditEvent.BIOMETRIC_CAPTURE, Components.REGISTRATION);
currentModality = getModality(modality);
this.fieldId=fieldId;
discoverSBI();
Expand All @@ -116,22 +104,16 @@ public void invokeDiscoverSbi(@NonNull String fieldId, @NonNull String modality,
@Override
public void getBestBiometrics(@NonNull String fieldId, @NonNull String modality, @NonNull BiometricsPigeon.Result<List<String>> result) {
try{

RegistrationDto registrationDto=registrationService.getRegistrationDto();

ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
String json;
List<String> jsonList=new ArrayList<>();
biometricsDtoList=registrationDto.getBestBiometrics(fieldId,getModality(modality));
for(int i=0;i<biometricsDtoList.size();i++){
json=ow.writeValueAsString(biometricsDtoList.get(i));
jsonList.add(json);

}

result.success(jsonList);


}catch (Exception e){
Log.e(TAG,e.getMessage());
}
Expand All @@ -145,13 +127,10 @@ public void getBiometrics(@NonNull String fieldId, @NonNull String modality, @No
String json;
List<String> jsonList=new ArrayList<>();
biometricsDtoList=registrationDto.getBiometrics(fieldId,getModality(modality),attempt.intValue()-1);

for(int i=0;i<biometricsDtoList.size();i++){
json=ow.writeValueAsString(biometricsDtoList.get(i));
jsonList.add(json);

}

result.success(jsonList);
}catch(Exception e){
Log.e(TAG,e.getMessage());
Expand All @@ -164,7 +143,6 @@ public void extractImageValues(@NonNull String fieldId, @NonNull String modality
List<byte[]> listByteArrayTester=new ArrayList<>();
try{
RegistrationDto registrationDto=registrationService.getRegistrationDto();

ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
String json;
List<String> jsonList=new ArrayList<>();
Expand Down Expand Up @@ -393,25 +371,24 @@ public void conditionalBioAttributeValidation(@NonNull String fieldId, @NonNull
Map<String,Boolean> dataContext=new HashMap<String,Boolean>();
Pattern REGEX_PATTERN =
Pattern.compile("[a-zA-Z]+");

Matcher matcher=REGEX_PATTERN.matcher(expression);

while (matcher.find()) {
dataContext.put(matcher.group(),false);
for (BiometricsDto dto:biometricsDtoList
) {
for (BiometricsDto dto:biometricsDtoList) {
if(dto.getBioSubType()!=null){
if(customMatcher(dto.getBioSubType(),matcher.group())){
dataContext.put(matcher.group(),true);
break;
}
}
else{
if(dto.getModality().matches(matcher.group().toUpperCase())){
if(dto.getModality().toUpperCase().matches(matcher.group().toUpperCase())){
dataContext.put(matcher.group(),true);
break;
}
}

}
}
Log.i(TAG, "Printing Map: " + dataContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@
import javax.inject.Singleton;

import io.mosip.registration.clientmanager.dto.registration.GenericValueDto;
import io.mosip.registration.clientmanager.spi.AuditManagerService;
import io.mosip.registration.clientmanager.spi.MasterDataService;
import io.mosip.registration_client.model.CommonDetailsPigeon;

@Singleton
public class CommonDetailsApi implements CommonDetailsPigeon.CommonDetailsApi {

MasterDataService masterDataService;
AuditManagerService auditManagerService;

@Inject
public CommonDetailsApi(MasterDataService masterDataService){
public CommonDetailsApi(MasterDataService masterDataService, AuditManagerService auditManagerService){
this.masterDataService=masterDataService;
this.auditManagerService = auditManagerService;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import javax.inject.Singleton;

import io.mosip.registration.clientmanager.dto.registration.RegistrationDto;
import io.mosip.registration.clientmanager.spi.AuditManagerService;
import io.mosip.registration.clientmanager.spi.RegistrationService;
import io.mosip.registration.keymanager.util.CryptoUtil;
import io.mosip.registration.packetmanager.dto.SimpleType;
Expand All @@ -19,12 +20,12 @@
@Singleton
public class DemographicsDetailsApi implements DemographicsDataPigeon.DemographicsApi {
private final RegistrationService registrationService;


AuditManagerService auditManagerService;

@Inject
public DemographicsDetailsApi(RegistrationService registrationService) {
public DemographicsDetailsApi(RegistrationService registrationService, AuditManagerService auditManagerService) {
this.registrationService = registrationService;
this.auditManagerService = auditManagerService;

}

Expand Down
Loading

0 comments on commit 40d3451

Please sign in to comment.