Skip to content

Commit

Permalink
Merge develop into 1.2.0 rc2 (#698)
Browse files Browse the repository at this point in the history
* Added default filter attributes to configuration (#596)

* Added default filter attributes to configuration

* Code updated

* Mosip 18119 auto allow new dynamic attributes for authentication (#598)

* Fixes in demo auth dynamic attributes

* Fixed error message for decoding failure

* Fix in fetching postal code for auth anonym profile

* WIP for dynamic attribute auto match

* Allow new dynamic attrib for auth without mapping

* Removed unwanted comment

* Fix age not match err msg (#599)

* Fixes in demo auth dynamic attributes

* Fixed error message for decoding failure

* Fix in fetching postal code for auth anonym profile

* WIP for dynamic attribute auto match

* Allow new dynamic attrib for auth without mapping

* Removed unwanted comment

* Fix in age not match error msg

* Fix bio auth type check issue due to case sensitive check (#600)

* Fix bio auth type check issue due to case sensitive check

* Minor fix

* junit test cases for AuthAnonymousProfileServiceImpl.java (#604)

* Mosip 18252 dsl bio auth fix (#609)

* Fix bio auth type check issue due to case sensitive check

* Minor fix

* Added missing Face for ekyc request in filter

* Fixed otp kyc filter NPE issue due to null bio (#615)

* Fixed multi modal auth cbeff load issue (#617)

* Fixed ekyc face retrival issue (#619)

* MOSIP-18366,MOSIP-18370 bio type subtype error message correction (#621)

* Fixed biotype,biosubtype related error messages

* Fix NPE for null idtype

* Test fixes

* Revert debug code for idserviceimpl

* test cases updated (#620)

* IdInfoHelper Test cases updated (#623)

* Fix dynamic attribute language code issue (#624)

* KycController updated with test cases (#625)

* Fixed test case failure (#626)

* updated test cases (#627)

* Revert "updated test cases" (#628)

This reverts commit 5cb0b79758ede70509ff7e0cbe864e9589434cff.

* Mosip 18411,MOSIP-17587 fix filter attrip for ekyc (#632)

* Fixed keymanager bean loading issue

* MOSIP-18411 fixed kyc attribute filtered out issue

* MOSIP-17587-Fix status for ekyc auth in anonym profile

* Mosip 18191 fix bio auth segment timestamp validation issue (#633)

* Fix duplicate type code in kyc auth txn entry

* MOSIP-18191 fix segment timestamp validation not working

* Added null check for auth type code duplicate condition

* MOSIP-18265 Added column to key alias table (#638)

* CredentialServiceImplTest (#636)

Co-authored-by: Vipul Dhurve <[email protected]>

* MOSIP-18053-fixed duplicate match inputs for multiple dynamic attrib in auth req (#640)

* MOSIP-18053-fixed duplicate match inputs for multiple dynamic attrib in req

* added jdoc

* [MOSIP-18119] Updated Notification timestamp based on timezone in prop (#641)

* [MOSIP-18119] Updated Notification timestamp based on timezone in prop (#643)

* [MOSIP-18119] Updated Notification timestamp based on timezone in prop

* [MOSIP-18119] Fixed test case failures

* Removed unnecessary db call (#645)

* MOSIP-18377 Column addition to indices (#649)

* MOSIP-16182 Add unique constraint to cert thumbprint column (#651)

* CredentialStoreServiceImplTest (#654)

* CredentialStoreServiceImplTest update

* CredentialStoreServiceImplTest update

Co-authored-by: Vipul Dhurve <[email protected]>

* MatchInputBuilderTest test cases (#655)

* [MOSIP-17776] added temp logging for debugging

* [MOSIP-17776] added temp logging for debugging (#658)

* [MOSIP-17776] reverted debugging code

* [MOSIP-17776] reverted debugging code

* [MOSIP-17776] reverted debugging code (#659)

* [MOSIP-17776] added temp logging for debugging

* [MOSIP-17776] reverted debugging code

* [MOSIP-17776] reverted debugging code

* AuthTransactionHelperTest updated with test cases (#657)

* [MOSIP-17776] added temp logging for debugging

* [MOSIP-9803] Updated swagger to accept Authorization header (#661)

* [MOSIP-17776] added temp logging for debugging

* [MOSIP-17776] reverted debugging code

* [MOSIP-17776] reverted debugging code

* [MOSIP-9803] Updated swagger to accept Authorization header

* [MOSIP-17776] added temp logging for debugging

* [MOSIP-9803] Updated swagger to accept Authorization header

* Created test class for HotlistServiceImpl (#660)

* CredentialStoreServiceImplTest update

* CredentialStoreServiceImplTest update

* Created Test class for HotlistServiceImpl: HotlistServiceImplTest

* Created Test class for HotlistServiceImpl: HotlistServiceImplTest

* Created Test class for HotlistServiceImpl: HotlistServiceImplTest

* Created Test class for HotlistServiceImpl: HotlistServiceImplTest

* Created Test class for HotlistServiceImpl: HotlistServiceImplTest

* Created Test class for HotlistServiceImpl: HotlistServiceImplTest

Co-authored-by: Vipul Dhurve <[email protected]>

* Mosip 18419 integrate with auth adapter for offline token validation (#656)

* Using RestHelper from ID Repo Core

* Fixes in rest helper config

* Added auth adapter download in docker cmd

* Fix compilation issue

* Mosip 18419 integrate with auth adapter for offline token validation 2 (#662)

* Using RestHelper from ID Repo Core

* Fixes in rest helper config

* Added auth adapter download in docker cmd

* Fix compilation issue

* Fixed missing env declaration in dockerfile

* Mosip 18419 integrate with auth adapter for offline token validation 3 (#663)

* Using RestHelper from ID Repo Core

* Fixes in rest helper config

* Added auth adapter download in docker cmd

* Fix compilation issue

* Fixed missing env declaration in dockerfile

* Added jar to classpath

* [MOSIP-9803] Updated swagger to accept Authorization header (#661)

* [MOSIP-17776] added temp logging for debugging

* [MOSIP-17776] reverted debugging code

* [MOSIP-17776] reverted debugging code

* [MOSIP-9803] Updated swagger to accept Authorization header

* [MOSIP-17776] added temp logging for debugging

* [MOSIP-9803] Updated swagger to accept Authorization header

* Mosip 18523 perf fixes (#665)

* Add cacheable to uin hash salt repo

* Minor refactor

* Fix to cache key

* MOSIP-16182 Composite unique key for ca cert store (#667)

* Created test class for WebSubHelper (#669)

* CredentialStoreServiceImplTest update

* CredentialStoreServiceImplTest update

* Created Test class for HotlistServiceImpl: HotlistServiceImplTest

* Created Test class for HotlistServiceImpl: HotlistServiceImplTest

* Created Test class for HotlistServiceImpl: HotlistServiceImplTest

* Created Test class for HotlistServiceImpl: HotlistServiceImplTest

* Created Test class for HotlistServiceImpl: HotlistServiceImplTest

* Created Test class for HotlistServiceImpl: HotlistServiceImplTest

* Created Test class for WebSubHelper: WebSubHelperTest

* Created Test class for WebSubHelper: WebSubHelperTest

* Created Test class for WebSubHelper: WebSubHelperTest

Co-authored-by: Vipul Dhurve <[email protected]>

* Integrate with resthelper-issue-fix (#671)

* Fix perf issue to use substring based logic for salt key calculation instead of modulo (#670)

* Added @transactional to handle duplicate requests (#678)

* Merge sonar coverage (#680)

* updated test cases

* updated test cases

* KycFacadeImplTest class test cases updated

* Test fix

Co-authored-by: Neosoft_MamtaA <[email protected]>

* Merge sonar coverage 2 (#681)

* updated test cases

* updated test cases

* KycFacadeImplTest class test cases updated

* Test fix

* Added json to classpath

Co-authored-by: Neosoft_MamtaA <[email protected]>

* Merge sonar coverage 2 (#682)

* updated test cases

* updated test cases

* KycFacadeImplTest class test cases updated

* Test fix

* Added json to classpath

* Test fix

Co-authored-by: Neosoft_MamtaA <[email protected]>

* Created Test class for MissingCredentialsItemReader => MissingCredentialsItemReaderTest (#683)

Co-authored-by: Vipul Dhurve <[email protected]>

* Created Test Class for IdAuthFraudAnalysisEventManager (#684)

* Created Test class for MissingCredentialsItemReader => MissingCredentialsItemReaderTest

* Created Test Class for IdAuthFraudAnalysisEventManager =>IdAuthFraudAnalysisEventManagerTest

Co-authored-by: Vipul Dhurve <[email protected]>

* Created Test class for PartnerServiceCallbackController (#685)

* Created Test class for MissingCredentialsItemReader => MissingCredentialsItemReaderTest

* Created Test Class for IdAuthFraudAnalysisEventManager =>IdAuthFraudAnalysisEventManagerTest

* Created Test Class for PartnerServiceCallbackController =>PartnerServiceCallbackControllerTest

* Created Test Class for PartnerServiceCallbackController =>PartnerServiceCallbackControllerTest

Co-authored-by: Vipul Dhurve <[email protected]>

* Created test class for PartnerServiceEventsInitializer (#686)

* Created Test class for MissingCredentialsItemReader => MissingCredentialsItemReaderTest

* Created Test Class for IdAuthFraudAnalysisEventManager =>IdAuthFraudAnalysisEventManagerTest

* Created Test Class for PartnerServiceCallbackController =>PartnerServiceCallbackControllerTest

* Created Test Class for PartnerServiceCallbackController =>PartnerServiceCallbackControllerTest

* Created test class for PartnerServiceEventsInitializer => PartnerServiceEventsInitializerTest

Co-authored-by: Vipul Dhurve <[email protected]>

* Fix in setting the policy metadata for authToken issue (#687)

* Mosip 18612 perf fix resp to map conversion 3 (#690)

* Fixed repeated request body parsing

* WIP - updated controller side

* Added missing class

* setting id version on respnse obj creation

* Fixed respTime, transaction ID Store, send Error

* Store auth txn and anonym profile

* Test fixes

* Fix to load missing bean

* WIP - Fixes in id version and anonym prof

* Fix in errors in anonym prof

* Reverted debug idserviceimpl

* Fix for error code in anonym prof for match failure

* Fixes to store auth txn and anonym prof on err

* Revert debug idserviceimpl

* Fix test failure

* reated test class for IdChangeEventsInitializer  (#692)

* Created Test class for MissingCredentialsItemReader => MissingCredentialsItemReaderTest

* Created Test Class for IdAuthFraudAnalysisEventManager =>IdAuthFraudAnalysisEventManagerTest

* Created Test Class for PartnerServiceCallbackController =>PartnerServiceCallbackControllerTest

* Created Test Class for PartnerServiceCallbackController =>PartnerServiceCallbackControllerTest

* Created test class for PartnerServiceEventsInitializer => PartnerServiceEventsInitializerTest

* Created test class for IdChangeEventsInitializer => IdChangeEventsInitializerTest

Co-authored-by: Vipul Dhurve <[email protected]>

* Moved test classes to test src (#693)

* Mosip 17586 sonar fix (#694)

* Moved test classes to test src

* fix package

* Fix unique ID creation logic (#696)

* [MOSIP-17776] added temp logging for debugging

* [MOSIP-17776] reverted debugging code

* [MOSIP-17776] added temp logging for debugging

* [MOSIP-17776] reverted debugging code

* [MOSIP-18119] Fixed send otp timestamp mismatch (#695)

* [MOSIP-18119] Updated Notification timestamp based on timezone in prop

* [MOSIP-18119] Fixed test case failures

* [MOSIP-18119] Fixed send otp timestamp mismatch

* [MOSIP-18119] Fixed send otp timestamp mismatch

* [MOSIP-1819] Updated test cases

* [MOSIP-18119] Fixed send otp timestamp mismatch

* [MOSIP-17776] added temp logging for debugging

* [MOSIP-17776] reverted debugging code

* [MOSIP-17776] added temp logging for debugging

* [MOSIP-17776] reverted debugging code

* [MOSIP-17776] added temp logging for debugging

* [MOSIP-17776] reverted debugging code

* [MOSIP-17776] added temp logging for debugging

* [MOSIP-17776] reverted debugging code

* [MOSIP-18119] removed debug code

Co-authored-by: Nagarjuna K <[email protected]>
Co-authored-by: Loganathan Sekar <[email protected]>
Co-authored-by: mamta-344 <[email protected]>
Co-authored-by: rambhatt1591 <[email protected]>
Co-authored-by: vipuldhurve02 <[email protected]>
Co-authored-by: Vipul Dhurve <[email protected]>
Co-authored-by: Neosoft_MamtaA <[email protected]>
  • Loading branch information
8 people authored Dec 7, 2021
1 parent 6bfdabd commit cb071e1
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 160 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
package io.mosip.authentication.common.service.builder;

import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.TimeZone;
import java.util.stream.Stream;

import io.mosip.authentication.common.service.util.IdaRequestResponsConsumerUtil;
import io.mosip.authentication.core.constant.IdAuthCommonConstants;
import io.mosip.authentication.core.indauth.dto.AuthError;
import io.mosip.authentication.core.indauth.dto.AuthResponseDTO;
import io.mosip.authentication.core.indauth.dto.AuthStatusInfo;
Expand All @@ -24,7 +19,7 @@
* @author Loganathan Sekar
*/
public class AuthResponseBuilder {

/** The built flag. */
private boolean built;

Expand All @@ -34,15 +29,12 @@ public class AuthResponseBuilder {
/** The auth status infos. */
private List<AuthStatusInfo> authStatusInfos;

private String dateTimePattern;

/**
* Instantiates a new auth response builder.
*
* @param dateTimePattern the date time pattern
*/
private AuthResponseBuilder(String dateTimePattern) {
this.dateTimePattern = dateTimePattern;
private AuthResponseBuilder() {
responseDTO = new AuthResponseDTO();
authStatusInfos = new ArrayList<>();
}
Expand Down Expand Up @@ -87,7 +79,7 @@ public AuthResponseBuilder addAuthStatusInfo(AuthStatusInfo authStatusInfo) {
return this;
}

public AuthResponseBuilder setId(String idType) {
public AuthResponseBuilder setId() {
responseDTO.setId("mosip.identity.auth");
return this;
}
Expand Down Expand Up @@ -122,16 +114,14 @@ public AuthResponseBuilder setVersion(String ver) {
* @param tokenID the auth token ID
* @return the auth response DTO
*/
public AuthResponseDTO build(String tokenID, String requestTime) {
public AuthResponseDTO build(String tokenID) {
assertNotBuilt();
boolean status = !authStatusInfos.isEmpty() && authStatusInfos.stream().allMatch(AuthStatusInfo::isStatus);
ResponseDTO res = new ResponseDTO();
res.setAuthStatus(status);
res.setAuthToken(tokenID);
responseDTO.setResponse(res);

String resTime = IdaRequestResponsConsumerUtil.getResponseTime(requestTime, dateTimePattern);
responseDTO.setResponseTime(resTime);
responseDTO.setResponseTime(DateUtils.getUTCCurrentDateTimeString(IdAuthCommonConstants.UTC_DATETIME_PATTERN));
AuthError[] authErrors = authStatusInfos.stream().flatMap(statusInfo -> Optional.ofNullable(statusInfo.getErr())
.map(List<AuthError>::stream).orElseGet(Stream::empty)).toArray(size -> new AuthError[size]);
if(authErrors.length > 0) {
Expand Down Expand Up @@ -161,8 +151,8 @@ private void assertNotBuilt() {
* @param dateTimePattern the date time pattern
* @return the auth response builder
*/
public static AuthResponseBuilder newInstance(String dateTimePattern) {
return new AuthResponseBuilder(dateTimePattern);
public static AuthResponseBuilder newInstance() {
return new AuthResponseBuilder();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ public AuthResponseDTO authenticateIndividual(AuthRequestDTO authRequestDTO, boo
String token = idService.getToken(idResDTO);

AuthResponseDTO authResponseDTO;
AuthResponseBuilder authResponseBuilder = AuthResponseBuilder
.newInstance(env.getProperty(IdAuthConfigKeyConstants.DATE_TIME_PATTERN));
AuthResponseBuilder authResponseBuilder = AuthResponseBuilder.newInstance();
Map<String, List<IdentityInfoDTO>> idInfo = null;
String authTokenId = null;
Boolean authTokenRequired = env.getProperty(IdAuthConfigKeyConstants.RESPONSE_TOKEN_ENABLE, Boolean.class);
Expand Down Expand Up @@ -193,9 +192,9 @@ public AuthResponseDTO authenticateIndividual(AuthRequestDTO authRequestDTO, boo
} finally {
// Set response token
if (authTokenRequired) {
authResponseDTO = authResponseBuilder.build(authTokenId, authRequestDTO.getRequestTime());
authResponseDTO = authResponseBuilder.build(authTokenId);
} else {
authResponseDTO = authResponseBuilder.build(null, authRequestDTO.getRequestTime());
authResponseDTO = authResponseBuilder.build(null);
}

IdaRequestResponsConsumerUtil.setIdVersionToResponse(requestWrapperMetadata, authResponseDTO);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package io.mosip.authentication.common.service.impl;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -314,17 +312,6 @@ private String getPhoneNumber(Map<String, List<IdentityInfoDTO>> idInfo) throws
return idInfoHelper.getEntityInfoAsString(DemoMatchType.PHONE, idInfo);
}

/**
* Formate date.
*
* @param date the date
* @param format the formate
* @return the date
*/
private String formatDate(Date date, String format) {
return new SimpleDateFormat(format).format(date);
}

/**
* This method gets the template languages in following order.
* 1. Gets user preferred languages if not
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.mosip.authentication.common.service.impl.notification;

import java.io.IOException;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
Expand Down Expand Up @@ -41,6 +42,9 @@
import io.mosip.authentication.core.spi.notification.service.NotificationService;
import io.mosip.authentication.core.util.LanguageComparator;
import io.mosip.authentication.core.util.MaskUtil;
import io.mosip.kernel.core.util.DateUtils;
import reactor.util.function.Tuple2;
import reactor.util.function.Tuples;

/***
*
Expand Down Expand Up @@ -90,20 +94,9 @@ public void sendAuthNotification(AuthRequestDTO authRequestDTO, String idvid, Au
for (String lang : templateLanguages) {
values.put(NAME + "_" + lang, infoHelper.getEntityInfoAsString(DemoMatchType.NAME, lang, idInfo));
}

String resTime = authResponseDTO.getResponseTime();

ZoneId zone = ZoneId.of(env.getProperty(IdAuthConfigKeyConstants.NOTIFICATION_TIME_ZONE));

ZonedDateTime dateTimeReq = ZonedDateTime.parse(resTime);
ZonedDateTime dateTimeConvertedToReqZone = dateTimeReq.withZoneSameInstant(zone);
String changedDate = dateTimeConvertedToReqZone.format(
DateTimeFormatter.ofPattern(env.getProperty(IdAuthConfigKeyConstants.NOTIFICATION_DATE_FORMAT)));
String changedTime = dateTimeConvertedToReqZone.format(
DateTimeFormatter.ofPattern(env.getProperty(IdAuthConfigKeyConstants.NOTIFICATION_TIME_FORMAT)));

values.put(DATE, changedDate);
values.put(TIME, changedTime);
Tuple2<String, String> dateAndTime = getDateAndTime(DateUtils.parseToLocalDateTime(authResponseDTO.getResponseTime()));
values.put(DATE, dateAndTime.getT1());
values.put(TIME, dateAndTime.getT2());
String maskedUin = "";
String charCount = env.getProperty(IdAuthConfigKeyConstants.UIN_MASKING_CHARCOUNT);
if (charCount != null && !charCount.isEmpty()) {
Expand Down Expand Up @@ -143,6 +136,64 @@ public void sendAuthNotification(AuthRequestDTO authRequestDTO, String idvid, Au
sendNotification(values, email, phoneNumber, SenderType.AUTH, notificationType, templateLanguages);
}

public void sendOTPNotification(String idvid, String idvidType, Map<String, String> valueMap,
List<String> templateLanguages, String otp, String notificationProperty, LocalDateTime otpGenerationTime)
throws IdAuthenticationBusinessException {
Map<String, Object> otpTemplateValues = getOtpTemplateValues(idvid, idvidType, valueMap, otpGenerationTime);
otpTemplateValues.put("otp", otp);
this.sendNotification(otpTemplateValues, valueMap.get(IdAuthCommonConstants.EMAIL),
valueMap.get(IdAuthCommonConstants.PHONE_NUMBER), SenderType.OTP, notificationProperty,
templateLanguages);
}

/*
* Send Otp Notification
*
*/
private Map<String, Object> getOtpTemplateValues(String idvid, String idvidType, Map<String, String> valueMap,
LocalDateTime otpGenerationTime) {

Tuple2<String, String> dateAndTime = getDateAndTime(otpGenerationTime);
String date = dateAndTime.getT1();
String time = dateAndTime.getT2();

String maskedUin = null;
Map<String, Object> values = new HashMap<>();
String charCount = env.getProperty(IdAuthConfigKeyConstants.UIN_MASKING_CHARCOUNT);
if (charCount != null) {
maskedUin = MaskUtil.generateMaskValue(idvid, Integer.parseInt(charCount));
}
values.put("idvid", maskedUin);
values.put("idvidType", idvidType);
Integer timeInSeconds = env.getProperty(IdAuthConfigKeyConstants.MOSIP_KERNEL_OTP_EXPIRY_TIME, Integer.class);
int timeInMinutes = (timeInSeconds % 3600) / 60;
values.put("validTime", String.valueOf(timeInMinutes));
values.put(DATE, date);
values.put(TIME, time);
values.putAll(valueMap);
values.remove(IdAuthCommonConstants.PHONE_NUMBER);
values.remove(IdAuthCommonConstants.EMAIL);
return values;
}

/**
* Gets the date and time.
*
* @param requestTime the request time
* @param pattern the pattern
* @return the date and time
*/
private Tuple2<String, String> getDateAndTime(LocalDateTime timestamp) {
ZonedDateTime dateTime = ZonedDateTime.of(timestamp, ZoneId.of("UTC")).withZoneSameInstant(getZone());
String date = dateTime.format(DateTimeFormatter.ofPattern(env.getProperty(IdAuthConfigKeyConstants.NOTIFICATION_DATE_FORMAT)));
String time = dateTime.format(DateTimeFormatter.ofPattern(env.getProperty(IdAuthConfigKeyConstants.NOTIFICATION_TIME_FORMAT)));
return Tuples.of(date, time);
}

private ZoneId getZone() {
return ZoneId.of(env.getProperty(IdAuthConfigKeyConstants.NOTIFICATION_TIME_ZONE));
}

/**
* Method to Send Notification to the Individual via SMS / E-Mail
*
Expand Down
Loading

0 comments on commit cb071e1

Please sign in to comment.