@@ -47,9 +47,6 @@ public class HelperService {
4747 @ Value ("${mosip.esignet.compass.authenticator.otp-value:111111}" )
4848 private String otpValue ;
4949
50- @ Value ("#{${mosip.esignet.authenticator.compass.identity-openid-claims-mapping}}" )
51- private Map <String ,String > oidcClaimsMapping ;
52-
5350 @ Autowired
5451 private CacheService cacheService ;
5552
@@ -140,18 +137,62 @@ private String generateB64EncodedHash(String algorithm, String value) throws Kyc
140137 public Map <String , Object > buildKycDataBasedOnPolicy (List <String > claims , UserInfo userInfo ) throws KycExchangeException {
141138 Map <String , Object > kyc = new HashMap <>();
142139 for (String claim : claims ) {
143- String methodName = oidcClaimsMapping .get (claim );
144-
145- if (methodName != null ) {
146- try {
147- Method method = UserInfo .class .getMethod (methodName );
148- Object value = method .invoke (userInfo );
149- if (value != null ) {
150- kyc .put (claim , value );
140+ switch (claim ) {
141+ case "name" :
142+ if (userInfo .getFirstNamePrimary () != null ) {
143+ kyc .put ("name" , userInfo .getFirstNamePrimary ());
151144 }
152- } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e ) {
153- throw new KycExchangeException ("Error invoking method for claim: " +claim ,e .getMessage ());
154- }
145+ break ;
146+ case "birthdate" :
147+ if (userInfo .getDateOfBirth () != null ) {
148+ kyc .put ("birthdate" , userInfo .getDateOfBirth ());
149+ }
150+ break ;
151+ case "birthCountry" :
152+ if (userInfo .getBirthCountry () != null ) {
153+ kyc .put ("birthCountry" , userInfo .getBirthCountry ());
154+ }
155+ break ;
156+ case "cardAccessNumber" :
157+ if (userInfo .getCardAccessNumber () != null ) {
158+ kyc .put ("cardAccessNumber" , userInfo .getCardAccessNumber ());
159+ }
160+ break ;
161+ case "email" :
162+ if (userInfo .getEmail () != null ) {
163+ kyc .put ("email" , userInfo .getEmail ());
164+ }
165+ break ;
166+ case "faceImageColor" :
167+ if (userInfo .getFaceImageColor () != null ) {
168+ kyc .put ("faceImageColor" , userInfo .getFaceImageColor ());
169+ }
170+ break ;
171+ case "gender" :
172+ if (userInfo .getGender () != null ) {
173+ kyc .put ("gender" , userInfo .getGender ());
174+ }
175+ break ;
176+ case "lastNameSecondary" :
177+ if (userInfo .getLastNameSecondary () != null ) {
178+ kyc .put ("lastNameSecondary" , userInfo .getLastNameSecondary ());
179+ }
180+ break ;
181+ case "nationalUid" :
182+ if (userInfo .getNationalUid () != null ) {
183+ kyc .put ("nationalUid" , userInfo .getNationalUid ());
184+ }
185+ break ;
186+ case "nationality" :
187+ if (userInfo .getNationality () != null ) {
188+ kyc .put ("nationality" , userInfo .getNationality ());
189+ }
190+ break ;
191+ case "compassId" :
192+ if (userInfo .getCompassId () != null ) {
193+ kyc .put ("compassId" , userInfo .getCompassId ());
194+ }
195+ break ;
155196 }
156197 }
157198 return kyc ;
0 commit comments