Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ES-313] fixes merged from develop to release branch #1106

Merged
merged 54 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
6c978f4
MOSIP-26891 added condition in caching (#1045)
Neha2365 Jul 3, 2023
cfb3eeb
Mosip 26891 caches in ida module should avoid caching null values (#1…
Neha2365 Jul 3, 2023
e08ecb2
Mosip 26891 caches in ida module should avoid caching null values (#1…
Neha2365 Jul 3, 2023
2eeb04d
Mosip 26891 caches in ida module should avoid caching null values (#1…
Neha2365 Jul 3, 2023
2663a46
Mosip 26891 caches in ida module should avoid caching null values (#1…
Neha2365 Jul 3, 2023
385dd45
[BUGFIX] [ES-176]
jainhitesh9998 Jul 19, 2023
0d8d7cc
Merge pull request #1054 from jainhitesh9998/bugfix-ES-176
vishwa-vyom Jul 19, 2023
82fee8f
iat validation corrected
anshulv1401 Jul 19, 2023
ede9bfc
Merge pull request #1055 from anshulv1401/develop
mahammedtaheer Jul 20, 2023
2f555fa
[MOSIP-28622] fixed firstname, lastname not populating in e-signet is…
mahammedtaheer Jul 27, 2023
a450107
Merge pull request #1056 from mahammedtaheer/develop
mahammedtaheer Jul 27, 2023
94794fb
[MOSIP-28484] Added error handling for deploy.sh script (#1061)
akilalakshmanan Aug 21, 2023
208b9c0
Implemented the VCI plugin in IDA
Aug 29, 2023
de7b9b5
Format the code
Aug 29, 2023
3fce833
Changes done
Aug 30, 2023
395eff4
Changes done
Aug 30, 2023
bed3ab2
Changes done
Aug 30, 2023
b14a44f
Decrypted the individualId
Aug 31, 2023
611400a
[ES-186] Added new Vci Exchange API to add support for VCI.
mahammedtaheer Sep 1, 2023
b3b29fb
Merge pull request #1074 from mahammedtaheer/develop
mahammedtaheer Sep 1, 2023
dcb7f68
Added new repo for LD signature library. (#1075)
mahammedtaheer Sep 5, 2023
b6ee915
updated push trigger to include settings.xml for sonar analysis and f…
mahammedtaheer Sep 5, 2023
773bdd5
Merge pull request #1076 from mahammedtaheer/develop
mahammedtaheer Sep 5, 2023
c6ad7df
removed show progress argument for wget command to display download p…
mahammedtaheer Sep 5, 2023
04122c6
Merge pull request #1077 from mahammedtaheer/develop
mahammedtaheer Sep 5, 2023
fd5f3be
Merge pull request #1073 from Neha2365/ES-187-mosip-ida-vc-provider-p…
mahammedtaheer Sep 5, 2023
d23f4a4
ES-107
Sep 5, 2023
4ce7470
Merge pull request #1078 from ase-101/binding
mahammedtaheer Sep 5, 2023
29f0e07
Fixed the cache read issue
Sep 5, 2023
8364700
Merge pull request #1080 from ase-101/binding
mahammedtaheer Sep 5, 2023
3440616
ES-187
Sep 6, 2023
1a72a3f
Merge pull request #1081 from ase-101/binding
mahammedtaheer Sep 6, 2023
726b86e
ES-187
Sep 6, 2023
3369075
Merge pull request #1082 from ase-101/binding
mahammedtaheer Sep 6, 2023
20b8efc
[ES-186] Fixed integration issues.
mahammedtaheer Sep 6, 2023
d5f908e
Merge pull request #1083 from mahammedtaheer/develop
mahammedtaheer Sep 6, 2023
975616d
ES-187
Sep 6, 2023
1fbdf68
Merge pull request #1084 from ase-101/binding
mahammedtaheer Sep 6, 2023
e2f67cf
[ES-186] changed the VC ID to UUID instead of PSUT and added locales.
mahammedtaheer Sep 8, 2023
6640467
Merge pull request #1085 from mahammedtaheer/develop
mahammedtaheer Sep 8, 2023
75abafc
[MOSIP-29163] updated reusable workflows (#1088)
bhumi46 Sep 8, 2023
02d0c0b
merge from release-1.2.0.1 to develop (#1089)
mahammedtaheer Sep 11, 2023
e7b2053
ES-187 (#1092)
ase-101 Sep 14, 2023
181e784
[ES-280], [ES-281] (#1094)
mahammedtaheer Sep 15, 2023
384b193
Fixed test cases error. (#1095)
mahammedtaheer Sep 15, 2023
c60fa2b
Fixed Test cases error. (#1096)
mahammedtaheer Sep 15, 2023
8046ca9
Fixed test case error. (#1097)
mahammedtaheer Sep 15, 2023
fa35a3c
Fixed Test cases error. (#1098)
mahammedtaheer Sep 15, 2023
b60338b
[ES-261] test cases for idaVCIssuancePluginImpl (#1093)
kaifk468 Sep 21, 2023
d5386bc
[ES-261] changes in testCases for IdaVCIssuancePluginImpl (#1100)
kaifk468 Sep 25, 2023
1d42341
[MOSIP-29163] updated reusable workflows (#1103)
bhumi46 Sep 25, 2023
e8281e3
[ES-313] Fixed blank attribute issue & language not available issue. …
mahammedtaheer Oct 3, 2023
dc9a981
[ES-313] merge from develop to release branch.
mahammedtaheer Oct 3, 2023
c1f9fc6
Resolved Merge issues.
mahammedtaheer Oct 3, 2023
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
@@ -1,26 +1,17 @@
package io.mosip.authentication.common.service.helper;

import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import io.mosip.authentication.common.service.entity.KycTokenData;
import io.mosip.authentication.common.service.entity.OIDCClientData;
import io.mosip.authentication.common.service.repository.KycTokenDataRepository;
import io.mosip.authentication.common.service.repository.OIDCClientDataRepository;
import io.mosip.authentication.common.service.util.EnvUtil;
import io.mosip.authentication.common.service.util.IdaRequestResponsConsumerUtil;
import io.mosip.authentication.core.constant.IdAuthCommonConstants;
import io.mosip.authentication.core.constant.IdAuthenticationErrorConstants;
import io.mosip.authentication.core.constant.KycTokenStatusType;
import io.mosip.authentication.core.exception.IdAuthenticationBusinessException;
import io.mosip.authentication.core.indauth.dto.BaseRequestDTO;
import io.mosip.authentication.core.logger.IdaLogger;
import io.mosip.authentication.core.spi.indauth.service.KycService;
import io.mosip.kernel.core.logger.spi.Logger;
Expand All @@ -31,29 +22,19 @@
* @author Mahammed Taheer
*/

@Component
public class TokenValidationHelper {

/** The mosip logger. */
private static Logger mosipLogger = IdaLogger.getLogger(TokenValidationHelper.class);

@Value("${ida.idp.consented.individual_id.attribute.name:individual_id}")
private String consentedIndividualIdAttributeName;


/** The Kyc Service */
@Autowired
private KycService kycService;

@Autowired
private KycTokenDataRepository kycTokenDataRepo;

@Autowired
private IdInfoHelper idInfoHelper;

@Autowired
private OIDCClientDataRepository oidcClientDataRepo;


public KycTokenData findAndValidateIssuedToken(String tokenData, String oidcClientId, String reqTransactionId,
String idvidHash) throws IdAuthenticationBusinessException {

Expand Down Expand Up @@ -131,49 +112,4 @@ private void validateToken(KycTokenData kycTokenData, String oidcClientId, Strin
IdAuthenticationErrorConstants.KYC_TOKEN_EXPIRED.getErrorMessage());
}
}

public void mapConsentedAttributesToIdSchemaAttributes(List<String> consentAttributes, Set<String> filterAttributes,
List<String> policyAllowedKycAttribs) throws IdAuthenticationBusinessException {

if(consentAttributes != null && !consentAttributes.isEmpty()) {
for (String attrib : consentAttributes) {
Collection<? extends String> idSchemaAttribute = idInfoHelper.getIdentityAttributesForIdName(attrib);
filterAttributes.addAll(idSchemaAttribute);
}
// removing individual id from consent if the claim is not allowed in policy.
if (!policyAllowedKycAttribs.contains(consentedIndividualIdAttributeName)) {
consentAttributes.remove(consentedIndividualIdAttributeName);
}
}
}

public Set<String> filterByPolicyAllowedAttributes(Set<String> filterAttributes, List<String> policyAllowedKycAttribs) {
return policyAllowedKycAttribs.stream()
.filter(attribute -> filterAttributes.contains(attribute))
.collect(Collectors.toSet());
}

public String getKycExchangeResponseTime(BaseRequestDTO authRequestDTO) {
String dateTimePattern = EnvUtil.getDateTimePattern();
return IdaRequestResponsConsumerUtil.getResponseTime(authRequestDTO.getRequestTime(), dateTimePattern);
}

public List<String> filterAllowedUserClaims(String oidcClientId, List<String> consentAttributes) {
mosipLogger.info(IdAuthCommonConstants.IDA, this.getClass().getSimpleName(), "filterAllowedUserClaims",
"Checking for OIDC client allowed userclaims");
Optional<OIDCClientData> oidcClientData = oidcClientDataRepo.findByClientId(oidcClientId);

List<String> oidcClientAllowedUserClaims = List.of(oidcClientData.get().getUserClaims())
.stream()
.map(String::toLowerCase)
.collect(Collectors.toList());
if (consentAttributes.isEmpty()) {
return oidcClientAllowedUserClaims;
}

return consentAttributes.stream()
.filter(claim -> oidcClientAllowedUserClaims.contains(claim.toLowerCase()))
.collect(Collectors.toList());

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
package io.mosip.authentication.service.kyc.facade;

import java.time.LocalDateTime;
import java.util.AbstractMap.SimpleEntry;
import java.util.Collection;
import java.util.HashSet;
Expand All @@ -26,11 +27,13 @@
import io.mosip.authentication.common.service.builder.AuthTransactionBuilder;
import io.mosip.authentication.common.service.entity.AutnTxn;
import io.mosip.authentication.common.service.entity.KycTokenData;
import io.mosip.authentication.common.service.entity.OIDCClientData;
import io.mosip.authentication.common.service.helper.AuditHelper;
import io.mosip.authentication.common.service.helper.TokenValidationHelper;
import io.mosip.authentication.common.service.integration.TokenIdManager;
import io.mosip.authentication.common.service.repository.IdaUinHashSaltRepo;
import io.mosip.authentication.common.service.repository.KycTokenDataRepository;
import io.mosip.authentication.common.service.repository.OIDCClientDataRepository;
import io.mosip.authentication.common.service.transaction.manager.IdAuthSecurityManager;
import io.mosip.authentication.common.service.util.EnvUtil;
import io.mosip.authentication.common.service.util.IdaRequestResponsConsumerUtil;
Expand Down Expand Up @@ -70,6 +73,7 @@
import io.mosip.authentication.core.spi.indauth.match.IdInfoFetcher;
import io.mosip.authentication.core.spi.indauth.service.KycService;
import io.mosip.authentication.core.spi.partner.service.PartnerService;
import io.mosip.authentication.service.kyc.util.ExchangeDataAttributesUtil;
import io.mosip.kernel.core.logger.spi.Logger;
import reactor.util.function.Tuple3;

Expand Down Expand Up @@ -133,6 +137,9 @@ public class KycFacadeImpl implements KycFacade {
@Autowired
private TokenValidationHelper tokenValidationHelper;

@Autowired
private ExchangeDataAttributesUtil exchangeDataAttributesUtil;

/*
* (non-Javadoc)
*
Expand Down Expand Up @@ -399,15 +406,15 @@ public KycExchangeResponseDTO processKycExchange(KycExchangeRequestDTO kycExchan
}

List<String> consentAttributes = kycExchangeRequestDTO.getConsentObtained();
List<String> allowedConsentAttributes = tokenValidationHelper.filterAllowedUserClaims(oidcClientId, consentAttributes);
List<String> allowedConsentAttributes = exchangeDataAttributesUtil.filterAllowedUserClaims(oidcClientId, consentAttributes);

PolicyDTO policyDto = policyDtoOpt.get();
List<String> policyAllowedKycAttribs = Optional.ofNullable(policyDto.getAllowedKycAttributes()).stream()
.flatMap(Collection::stream).map(KYCAttributes::getAttributeName).collect(Collectors.toList());

Set<String> filterAttributes = new HashSet<>();
tokenValidationHelper.mapConsentedAttributesToIdSchemaAttributes(allowedConsentAttributes, filterAttributes, policyAllowedKycAttribs);
Set<String> policyAllowedAttributes = tokenValidationHelper.filterByPolicyAllowedAttributes(filterAttributes, policyAllowedKycAttribs);
exchangeDataAttributesUtil.mapConsentedAttributesToIdSchemaAttributes(allowedConsentAttributes, filterAttributes, policyAllowedKycAttribs);
Set<String> policyAllowedAttributes = exchangeDataAttributesUtil.filterByPolicyAllowedAttributes(filterAttributes, policyAllowedKycAttribs);

boolean isBioRequired = false;
if (filterAttributes.contains(CbeffDocType.FACE.getType().value().toLowerCase()) ||
Expand Down Expand Up @@ -438,7 +445,7 @@ public KycExchangeResponseDTO processKycExchange(KycExchangeRequestDTO kycExchan
kycExchangeResponseDTO.setId(kycExchangeRequestDTO.getId());
kycExchangeResponseDTO.setTransactionID(kycExchangeRequestDTO.getTransactionID());
kycExchangeResponseDTO.setVersion(kycExchangeRequestDTO.getVersion());
kycExchangeResponseDTO.setResponseTime(tokenValidationHelper.getKycExchangeResponseTime(kycExchangeRequestDTO));
kycExchangeResponseDTO.setResponseTime(exchangeDataAttributesUtil.getKycExchangeResponseTime(kycExchangeRequestDTO));

EncryptedKycRespDTO encryptedKycRespDTO = new EncryptedKycRespDTO();
encryptedKycRespDTO.setEncryptedKyc(respJson);
Expand All @@ -455,7 +462,6 @@ public KycExchangeResponseDTO processKycExchange(KycExchangeRequestDTO kycExchan
}
}


// Need to move below duplicate code to common to be used by OTPService and KycExchange.
private void saveToTxnTable(KycExchangeRequestDTO kycExchangeRequestDTO, boolean isInternal, boolean status, String partnerId, String token,
KycExchangeResponseDTO kycExchangeResponseDTO, ObjectWithMetadata requestWithMetadata)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
*
*/
package io.mosip.authentication.service.kyc.facade;

import java.util.ArrayList;
Expand Down Expand Up @@ -52,6 +49,7 @@
import io.mosip.authentication.core.spi.indauth.match.IdInfoFetcher;
import io.mosip.authentication.core.spi.partner.service.PartnerService;
import io.mosip.authentication.service.kyc.impl.VciServiceImpl;
import io.mosip.authentication.service.kyc.util.ExchangeDataAttributesUtil;
import io.mosip.kernel.core.logger.spi.Logger;

/**
Expand Down Expand Up @@ -104,6 +102,9 @@ public class VciFacadeImpl implements VciFacade {
@Autowired
private KycTokenDataRepository kycTokenDataRepo;

@Autowired
private ExchangeDataAttributesUtil exchangeDataAttributesUtil;

@Override
public VciExchangeResponseDTO processVciExchange(VciExchangeRequestDTO vciExchangeRequestDTO, String partnerId,
String oidcClientId, Map<String, Object> metadata, ObjectWithMetadata requestWithMetadata) throws IdAuthenticationBusinessException {
Expand Down Expand Up @@ -133,15 +134,15 @@ public VciExchangeResponseDTO processVciExchange(VciExchangeRequestDTO vciExchan

// Will implement later the consent claims based on credential definition input
List<String> consentAttributes = Collections.emptyList();
List<String> allowedConsentAttributes = tokenValidationHelper.filterAllowedUserClaims(oidcClientId, consentAttributes);
List<String> allowedConsentAttributes = exchangeDataAttributesUtil.filterAllowedUserClaims(oidcClientId, consentAttributes);

PolicyDTO policyDto = policyDtoOpt.get();
List<String> policyAllowedKycAttribs = Optional.ofNullable(policyDto.getAllowedKycAttributes()).stream()
.flatMap(Collection::stream).map(KYCAttributes::getAttributeName).collect(Collectors.toList());

Set<String> filterAttributes = new HashSet<>();
tokenValidationHelper.mapConsentedAttributesToIdSchemaAttributes(allowedConsentAttributes, filterAttributes, policyAllowedKycAttribs);
Set<String> policyAllowedAttributes = tokenValidationHelper.filterByPolicyAllowedAttributes(filterAttributes, policyAllowedKycAttribs);
exchangeDataAttributesUtil.mapConsentedAttributesToIdSchemaAttributes(allowedConsentAttributes, filterAttributes, policyAllowedKycAttribs);
Set<String> policyAllowedAttributes = exchangeDataAttributesUtil.filterByPolicyAllowedAttributes(filterAttributes, policyAllowedKycAttribs);

boolean isBioRequired = false;
if (filterAttributes.contains(CbeffDocType.FACE.getType().value().toLowerCase()) ||
Expand Down Expand Up @@ -178,7 +179,7 @@ public VciExchangeResponseDTO processVciExchange(VciExchangeRequestDTO vciExchan
vciExchangeResponseDTO.setId(vciExchangeRequestDTO.getId());
vciExchangeResponseDTO.setTransactionID(vciExchangeRequestDTO.getTransactionID());
vciExchangeResponseDTO.setVersion(vciExchangeRequestDTO.getVersion());
vciExchangeResponseDTO.setResponseTime(tokenValidationHelper.getKycExchangeResponseTime(vciExchangeRequestDTO));
vciExchangeResponseDTO.setResponseTime(exchangeDataAttributesUtil.getKycExchangeResponseTime(vciExchangeRequestDTO));
vciExchangeResponseDTO.setResponse(vcResponseDTO);
saveToTxnTable(vciExchangeRequestDTO, false, true, partnerId, token, vciExchangeResponseDTO, requestWithMetadata);
auditHelper.audit(AuditModules.VCI_EXCHANGE, AuditEvents.VCI_EXCHANGE_REQUEST_RESPONSE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.nio.ByteBuffer;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.time.temporal.ValueRange;
import java.util.AbstractMap.SimpleEntry;
import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -441,9 +442,11 @@ public boolean isKycTokenExpire(LocalDateTime tokenIssuedDateTime, String kycTok
LocalDateTime currentTime = LocalDateTime.now();

long diffSeconds = ChronoUnit.SECONDS.between(tokenIssuedDateTime, currentTime);

long adjustmentSeconds = EnvUtil.getKycTokenExpireTimeAdjustmentSeconds();
ValueRange valueRange = ValueRange.of(0, adjustmentSeconds);

if (tokenIssuedDateTime != null && adjustmentSeconds < diffSeconds) {
if (tokenIssuedDateTime != null && !valueRange.isValidIntValue(diffSeconds)) {
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,15 +399,21 @@ private Map<String, Object> getCredSubjectMap(String credSubjectId, Map<String,
continue;
if (idInfoList.size() == 1) {
IdentityInfoDTO identityInfo = idInfoList.get(0);
if (Objects.isNull(identityInfo.getLanguage()))
credSubjectMap.put(idSchemaAttribute, idInfoList.get(0).getValue());
if (Objects.isNull(identityInfo.getLanguage())) {
String value = identityInfo.getValue();
if (Objects.nonNull(value) && (value.trim().length() > 0))
credSubjectMap.put(idSchemaAttribute, value);
}
else {
Map<String, String> valueMap = new HashMap<>();
String lang = identityInfo.getLanguage();
if (locales.contains(lang)) {
valueMap.put(IdAuthCommonConstants.LANGUAGE_STRING, lang);
valueMap.put(IdAuthCommonConstants.VALUE_STRING, identityInfo.getValue());
credSubjectMap.put(idSchemaAttribute, valueMap);
String value = identityInfo.getValue();
if (Objects.nonNull(value) && (value.trim().length() > 0)) {
valueMap.put(IdAuthCommonConstants.LANGUAGE_STRING, lang);
valueMap.put(IdAuthCommonConstants.VALUE_STRING, value);
credSubjectMap.put(idSchemaAttribute, valueMap);
}
}
}
continue;
Expand All @@ -417,12 +423,16 @@ private Map<String, Object> getCredSubjectMap(String credSubjectId, Map<String,
Map<String, String> valueMap = new HashMap<>();
String lang = identityInfo.getLanguage();
if (locales.contains(lang)) {
valueMap.put(IdAuthCommonConstants.LANGUAGE_STRING, identityInfo.getLanguage());
valueMap.put(IdAuthCommonConstants.VALUE_STRING, identityInfo.getValue());
valueList.add(valueMap);
String value = identityInfo.getValue();
if (Objects.nonNull(value) && (value.trim().length() > 0)) {
valueMap.put(IdAuthCommonConstants.LANGUAGE_STRING, identityInfo.getLanguage());
valueMap.put(IdAuthCommonConstants.VALUE_STRING, identityInfo.getValue());
valueList.add(valueMap);
}
}
}
credSubjectMap.put(idSchemaAttribute, valueList);
if (valueList.size() > 0)
credSubjectMap.put(idSchemaAttribute, valueList);
}
}
return credSubjectMap;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package io.mosip.authentication.service.kyc.util;

import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import io.mosip.authentication.common.service.entity.OIDCClientData;
import io.mosip.authentication.common.service.helper.IdInfoHelper;
import io.mosip.authentication.common.service.repository.OIDCClientDataRepository;
import io.mosip.authentication.common.service.util.EnvUtil;
import io.mosip.authentication.common.service.util.IdaRequestResponsConsumerUtil;
import io.mosip.authentication.core.constant.IdAuthCommonConstants;
import io.mosip.authentication.core.exception.IdAuthenticationBusinessException;
import io.mosip.authentication.core.indauth.dto.BaseRequestDTO;
import io.mosip.authentication.core.logger.IdaLogger;
import io.mosip.kernel.core.logger.spi.Logger;

/**
* Utility class to filter the consented attribute and policy allowed attributes.
*
* @author Mahammed Taheer
*/

@Component
public class ExchangeDataAttributesUtil {

/** The mosip logger. */
private static Logger mosipLogger = IdaLogger.getLogger(ExchangeDataAttributesUtil.class);

@Value("${ida.idp.consented.individual_id.attribute.name:individual_id}")
private String consentedIndividualIdAttributeName;

@Autowired
private IdInfoHelper idInfoHelper;

@Autowired
private OIDCClientDataRepository oidcClientDataRepo;

public void mapConsentedAttributesToIdSchemaAttributes(List<String> consentAttributes, Set<String> filterAttributes,
List<String> policyAllowedKycAttribs) throws IdAuthenticationBusinessException {

if(consentAttributes != null && !consentAttributes.isEmpty()) {
for (String attrib : consentAttributes) {
Collection<? extends String> idSchemaAttribute = idInfoHelper.getIdentityAttributesForIdName(attrib);
filterAttributes.addAll(idSchemaAttribute);
}
// removing individual id from consent if the claim is not allowed in policy.
if (!policyAllowedKycAttribs.contains(consentedIndividualIdAttributeName)) {
consentAttributes.remove(consentedIndividualIdAttributeName);
}
}
}

public Set<String> filterByPolicyAllowedAttributes(Set<String> filterAttributes, List<String> policyAllowedKycAttribs) {
return policyAllowedKycAttribs.stream()
.filter(attribute -> filterAttributes.contains(attribute))
.collect(Collectors.toSet());
}

public String getKycExchangeResponseTime(BaseRequestDTO authRequestDTO) {
String dateTimePattern = EnvUtil.getDateTimePattern();
return IdaRequestResponsConsumerUtil.getResponseTime(authRequestDTO.getRequestTime(), dateTimePattern);
}

public List<String> filterAllowedUserClaims(String oidcClientId, List<String> consentAttributes) {
mosipLogger.info(IdAuthCommonConstants.IDA, this.getClass().getSimpleName(), "filterAllowedUserClaims",
"Checking for OIDC client allowed userclaims");
Optional<OIDCClientData> oidcClientData = oidcClientDataRepo.findByClientId(oidcClientId);

List<String> oidcClientAllowedUserClaims = List.of(oidcClientData.get().getUserClaims())
.stream()
.map(String::toLowerCase)
.collect(Collectors.toList());
if (consentAttributes.isEmpty()) {
return oidcClientAllowedUserClaims;
}

return consentAttributes.stream()
.filter(claim -> oidcClientAllowedUserClaims.contains(claim.toLowerCase()))
.collect(Collectors.toList());

}

}
Loading