
one.credify.sdk.model.EncryptedUserInfo Maven / Gradle / Ivy
//package one.credify.sdk.model;
//
//import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
//import lombok.*;
//import lombok.experimental.FieldDefaults;
//import one.credify.crypto.Encryption;
//import one.credify.sdk.dto.*;
//import one.credify.sdk.enumeration.ContentType;
//import one.credify.sdk.enumeration.EkycDocumentType;
//
//import java.util.Map;
//
//import static one.credify.sdk.utils.ServicexUtils.*;
//
//@NoArgsConstructor
//@AllArgsConstructor
//@Builder
//@Getter
//@Setter
//@FieldDefaults(level = AccessLevel.PRIVATE)
//public class EncryptedUserInfo {
// private static final String EKYC_KEY = "ekyc";
// private static final String DRIVING_PERMIT_KEY = "driving_permit";
// private static final String IDCARD_KEY = "idcard";
// private static final String JWT_KEY = "JWT";
// private static final String JWT_PAYLOAD_KEY = "payload";
// private static final String EKYC_IMAGE_FACE_KEY = "img_face";
// private static final String EKYC_IMAGE_BACK_KEY = "img_back";
// private static final String EKYC_IMAGE_FRONT_KEY = "img_front";
//
// Map claimNames;
//
// Map> claimSources;
//
// String credifyId;
//
// // standard claims
// Address address;
//
// // non basic standard claims
// Address permanentAddress;
// Employment employment;
// BankAccount bankAccount;
// ReferencePerson primaryReferencePerson;
// ReferencePerson secondaryReferencePerson;
// Spouse spouse;
//
//
// Commitment commitment;
//
// @NoArgsConstructor
// @Getter
// @Setter
// @FieldDefaults(level = AccessLevel.PRIVATE)
// public static class OpenId {
// UserOidcInfo.Ext extraData;
//
// String sid;
// String transactionId;
// String signingPublicKey;
//
// }
//
// @NoArgsConstructor
// @Getter
// @Setter
// @FieldDefaults(level = AccessLevel.PRIVATE)
// public static class Profile {
// String birthdate;
// String familyName;
// String gender;
// String givenName;
// String middleName;
// String name;
// String phoneNumber;
// String phoneNumberVerified;
// String email;
// String emailVerified;
// String profileCommitment;
// }
//
// @NoArgsConstructor
// @Getter
// @Setter
// @FieldDefaults(level = AccessLevel.PRIVATE)
// public static class Address {
// String country;
// String locality;
// String region;
// String streetAddress;
// String postalCode;
//
// String formatted;
// String streetNumber;
// String street;
// String sublocalityLevel3;
// String sublocalityLevel2;
// String sublocality;
// String countryCode;
//
// public UserOidcInfo.Address decryptData(Encryption encryption) throws Exception {
// return UserOidcInfo.Address.builder()
// .formatted(decryptString(encryption, formatted))
// .streetNumber(decryptString(encryption, streetNumber))
// .street(decryptString(encryption, street))
// .streetAddress(decryptString(encryption, streetAddress))
// .sublocalityLevel3(decryptString(encryption, sublocalityLevel3))
// .sublocalityLevel2(decryptString(encryption, sublocalityLevel2))
// .sublocality(decryptString(encryption, sublocality))
// .locality(decryptString(encryption, locality))
// .region(decryptString(encryption, region))
// .postalCode(decryptString(encryption, postalCode))
// .country(decryptString(encryption, country))
// .countryCode(decryptString(encryption, countryCode))
// .build();
// }
// }
//
// @NoArgsConstructor
// @Getter
// @Setter
// @FieldDefaults(level = AccessLevel.PRIVATE)
// public static class AdvancedProfile {
// String currentHousingType;
// String educationLevel;
// String maritalStatus;
// String numberOfDependents;
// String currentHousingTypeOther;
// }
//
// @NoArgsConstructor
// @Getter
// @Setter
// @FieldDefaults(level = AccessLevel.PRIVATE)
// public static class Income {
// String mainIncomeType;
// String monthlyWageIncome;
// String payrollDate;
// String receivingSalaryMethod;
// String monthlyFamilyIncome;
// String monthlyExpenses;
// String otherIncomes;
// }
//
// @NoArgsConstructor
// @AllArgsConstructor
// @Builder
// @Getter
// @Setter
// @FieldDefaults(level = AccessLevel.PRIVATE)
// public static class Employment {
// String occupation;
// String otherOccupation;
// String laborContractType;
// String department;
// String workingTime;
// String position;
// String companyName;
// String companyPhoneNumber;
// String companyTaxNumber;
// String companyRegistrationType;
// String companyIndustry;
// Address workAddress;
// Address companyAddress;
// String companyIndustryOther;
// String companyRegistrationTypeOther;
//
// public UserOidcInfo.Employment decryptData(Encryption encryption) throws Exception {
// UserOidcInfo.Employment.EmploymentBuilder builder = UserOidcInfo.Employment.builder()
// .occupation(decryptString(encryption, occupation))
// .otherOccupation(decryptString(encryption, otherOccupation))
// .laborContractType(decryptString(encryption, laborContractType))
// .department(decryptString(encryption, department))
// .workingTime(decryptInt(encryption, workingTime))
// .position(decryptString(encryption, position))
// .companyName(decryptString(encryption, companyName))
// .companyPhoneNumber(decryptString(encryption, companyPhoneNumber))
// .companyTaxNumber(decryptString(encryption, companyTaxNumber))
// .companyRegistrationType(decryptString(encryption, companyRegistrationType))
// .companyIndustry(decryptString(encryption, companyIndustry))
// .companyIndustryOther(decryptString(encryption, companyIndustryOther))
// .companyRegistrationTypeOther(decryptString(encryption, companyRegistrationTypeOther));
//
// if (workAddress != null) {
// builder = builder.workAddress(workAddress.decryptData(encryption));
// }
//
// if (companyAddress != null) {
// builder = builder.companyAddress(companyAddress.decryptData(encryption));
// }
// return builder.build();
// }
// }
//
// @NoArgsConstructor
// @AllArgsConstructor
// @Builder
// @Getter
// @Setter
// @FieldDefaults(level = AccessLevel.PRIVATE)
// public static class BankAccount {
// String accountOwner;
// String accountNumber;
// String bank;
// String branch;
//
// public UserOidcInfo.BankAccount decryptData(Encryption encryption) throws Exception {
// return UserOidcInfo.BankAccount.builder()
// .accountOwner(decryptString(encryption, accountOwner))
// .accountNumber(decryptString(encryption, accountNumber))
// .bank(decryptString(encryption, bank))
// .branch(decryptString(encryption, branch))
// .build();
// }
// }
//
// @NoArgsConstructor
// @AllArgsConstructor
// @Builder
// @Getter
// @Setter
// @FieldDefaults(level = AccessLevel.PRIVATE)
// public static class ReferencePerson {
// String name;
// String phoneNumber;
// String relationship;
//
// public UserOidcInfo.ReferencePerson decryptData(Encryption encryption) throws Exception {
// return UserOidcInfo.ReferencePerson.builder()
// .name(decryptString(encryption, name))
// .phoneNumber(decryptString(encryption, phoneNumber))
// .relationship(decryptString(encryption, relationship))
// .build();
// }
// }
//
// @NoArgsConstructor
// @Getter
// @Setter
// @FieldDefaults(level = AccessLevel.PRIVATE)
// @JsonIgnoreProperties(ignoreUnknown = true)
// public static class Spouse {
// String name;
// String phoneNumber;
// String idCardNumber;
//
// public UserOidcInfo.Spouse decryptData(Encryption encryption) throws Exception {
// return UserOidcInfo.Spouse.builder()
// .name(decryptString(encryption, name))
// .phoneNumber(decryptString(encryption, phoneNumber))
// .idCardNumber(decryptString(encryption, idCardNumber))
// .build();
// }
// }
//
// @NoArgsConstructor
// @AllArgsConstructor
// @Builder
// @Getter
// @Setter
// @FieldDefaults(level = AccessLevel.PRIVATE)
// public static class Commitment {
// String phoneCommitment;
// String emailCommitment;
// String profileCommitment;
// String addressCommitment;
// String ekycCommitment;
// String permanentAddressCommitment;
// String advancedProfileCommitment;
// String employmentCommitment;
// String incomeCommitment;
// String bankAccountCommitment;
// String primaryReferencePersonCommitment;
// String secondaryReferencePersonCommitment;
//
// public UserOidcInfo.Commitment decryptData(Encryption encryption) throws Exception {
// return UserOidcInfo.Commitment.builder()
// .phoneCommitment(decryptString(encryption, phoneCommitment))
// .ekycCommitment(decryptString(encryption, emailCommitment))
// .profileCommitment(decryptString(encryption, profileCommitment))
// .addressCommitment(decryptString(encryption, addressCommitment))
// .ekycCommitment(decryptString(encryption, ekycCommitment))
// .permanentAddressCommitment(decryptString(encryption, permanentAddressCommitment))
// .advancedProfileCommitment(decryptString(encryption, advancedProfileCommitment))
// .employmentCommitment(decryptString(encryption, employmentCommitment))
// .incomeCommitment(decryptString(encryption, incomeCommitment))
// .bankAccountCommitment(decryptString(encryption, bankAccountCommitment))
// .primaryReferencePersonCommitment(decryptString(encryption, primaryReferencePersonCommitment))
// .secondaryReferencePersonCommitment(decryptString(encryption, secondaryReferencePersonCommitment))
// .build();
// }
// }
//
// public UserOidcInfo decryptData(Encryption encryption) throws Exception {
// UserOidcInfo.UserOidcInfoBuilder builder = UserOidcInfo.builder()
// .extraData(extraData)
// .sid(sid)
// .credifyId(credifyId)
// .transactionId(transactionId)
// .signingPublicKey(signingPublicKey)
// .birthdate(decryptString(encryption, birthdate))
// .familyName(decryptString(encryption, familyName))
// .gender(decryptString(encryption, gender))
// .givenName(decryptString(encryption, givenName))
// .middleName(decryptString(encryption, middleName))
// .name(decryptString(encryption, name))
// .phoneNumber(decryptString(encryption, phoneNumber))
// .email(decryptString(encryption, email))
// .numberOfDependents(decryptInt(encryption, numberOfDependents))
// .currentHousingTypeOther(decryptString(encryption, currentHousingTypeOther))
// .commitment(commitment.decryptData(encryption));
//
// if (phoneNumberVerified != null) {
// builder.phoneNumberVerified(decryptBoolean(encryption, phoneNumberVerified));
// }
//
// if (emailVerified != null) {
// builder.emailVerified(decryptBoolean(encryption, emailVerified));
// }
//
// if (address != null) {
// builder.address(address.decryptData(encryption));
// }
//
// if (permanentAddress != null) {
// builder.permanentAddress(permanentAddress.decryptData(encryption));
// }
//
// if (employment != null) {
// builder.employment(employment.decryptData(encryption));
// }
//
// if (bankAccount != null) {
// builder.bankAccount(bankAccount.decryptData(encryption));
// }
//
// if (primaryReferencePerson != null) {
// builder.primaryReferencePerson(primaryReferencePerson.decryptData(encryption));
// }
//
// if (secondaryReferencePerson != null) {
// builder.secondaryReferencePerson(secondaryReferencePerson.decryptData(encryption));
// }
//
// if (spouse != null) {
// builder.spouse(spouse.decryptData(encryption));
// }
//
// // decrypt advanced_profile info
// builder = builder.currentHousingType(decryptString(encryption, currentHousingType))
// .educationLevel(decryptString(encryption, educationLevel))
// .maritalStatus(decryptString(encryption, maritalStatus));
//
// // decrypt income info
// builder = builder.mainIncomeType(decryptString(encryption, mainIncomeType))
// .payrollDate(decryptString(encryption, payrollDate))
// .receivingSalaryMethod(decryptString(encryption, receivingSalaryMethod));
// if (monthlyWageIncome != null) {
// builder = builder.monthlyWageIncome(decryptLong(encryption, monthlyWageIncome));
// }
// if (monthlyFamilyIncome != null) {
// builder = builder.monthlyFamilyIncome(decryptLong(encryption, monthlyFamilyIncome));
// }
// if (monthlyExpenses != null) {
// builder = builder.monthlyExpenses(decryptLong(encryption, monthlyExpenses));
// }
// if (otherIncomes != null) {
// builder = builder.otherIncomes(decryptString(encryption, otherIncomes));
// }
//
// if (claimSources != null) {
// // decrypt ekyc jwt token from claim sources
// if (claimSources.containsKey(EKYC_KEY)) {
// Map ekycClaimSource = claimSources.get(EKYC_KEY);
// if (ekycClaimSource.containsKey(JWT_KEY)) {
// Jwt jwt = Jwt.parseJwe(encryption, ekycClaimSource.get(JWT_KEY));
// EkycDto ekycDto = Constants.MAPPER.readValue(jwt.getRawPayload(), EkycDto.class);
// builder.ekyc(decryptEkyc(encryption, ekycDto));
// }
// }
// // decrypt idcard jwt token from claim sources
// if (claimSources.containsKey(IDCARD_KEY)) {
// Map ekycClaimSource = claimSources.get(IDCARD_KEY);
// if (ekycClaimSource.containsKey(JWT_KEY)) {
// Jwt jwt = Jwt.parseJwe(encryption, ekycClaimSource.get(JWT_KEY));
// IdcardDto ekycDto = Constants.MAPPER.readValue(jwt.getRawPayload(), IdcardDto.class);
// builder.idcardOldNumber(ekycDto.getIdcardOldNumber());
//
// UserOidcInfo.Ekyc decryptedEkyc = decryptEkyc(encryption, ekycDto);
// if (StringUtils.isNotEmpty(ekycDto.getIdcardNumber())) {
// decryptedEkyc.setDocumentNumber(ekycDto.getIdcardNumber());
// }
// if (StringUtils.isNotEmpty(ekycDto.getIdcardIssuer())) {
// decryptedEkyc.setIssuer(ekycDto.getIdcardIssuer());
// }
// if (StringUtils.isNotEmpty(ekycDto.getIdcardDateOfIssuance())) {
// decryptedEkyc.setDateOfIssuance(ekycDto.getIdcardDateOfIssuance());
// }
// if (StringUtils.isNotEmpty(ekycDto.getIdcardDateOfExpiry())) {
// decryptedEkyc.setDateOfExpiry(ekycDto.getIdcardDateOfExpiry());
// }
// builder.idcard(decryptedEkyc);
// }
// }
// // decrypt driving permit jwt token from claim sources
// if (claimSources.containsKey(DRIVING_PERMIT_KEY)) {
// Map ekycClaimSource = claimSources.get(DRIVING_PERMIT_KEY);
// if (ekycClaimSource.containsKey(JWT_KEY)) {
// Jwt jwt = Jwt.parseJwe(encryption, ekycClaimSource.get(JWT_KEY));
// DrivingPermitDto ekycDto = Constants.MAPPER.readValue(jwt.getRawPayload(), DrivingPermitDto.class);
// UserOidcInfo.Ekyc decryptedEkyc = decryptEkyc(encryption, ekycDto);
// if (StringUtils.isNotEmpty(ekycDto.getDrivingPermitNumber())) {
// decryptedEkyc.setDocumentNumber(ekycDto.getDrivingPermitNumber());
// }
// if (StringUtils.isNotEmpty(ekycDto.getDrivingPermitIssuer())) {
// decryptedEkyc.setIssuer(ekycDto.getDrivingPermitIssuer());
// }
// if (StringUtils.isNotEmpty(ekycDto.getDrivingPermitDateOfIssuance())) {
// decryptedEkyc.setDateOfIssuance(ekycDto.getDrivingPermitDateOfIssuance());
// }
// if (StringUtils.isNotEmpty(ekycDto.getDrivingPermitDateOfExpiry())) {
// decryptedEkyc.setDateOfExpiry(ekycDto.getDrivingPermitDateOfExpiry());
// }
// builder.drivingPermit(decryptedEkyc);
// }
// }
// }
//
// return builder.build();
// return null;
// }
//
// private UserOidcInfo.Ekyc decryptEkyc(Encryption encryption, UserInfoRes.EkycInterface ekycDto) throws Exception {
// UserOidcInfo.Ekyc ekyc = new UserOidcInfo.Ekyc();
//
//
// VerifiedClaimsDto.Evidence evidence = ekycDto.getEvidence();
// VerifiedClaimsDto.Claims ekycClaims = ekycDto.getClaims();
// if (evidence != null) {
// if (evidence.getAttachments() != null) {
// evidence.getAttachments().forEach(attachment -> {
// switch (attachment.getDesc()) {
// case EKYC_IMAGE_FACE_KEY:
// ekyc.setImageFace(UserOidcInfo.EkycAttachment.builder()
// .type(ContentType.getType(attachment.getContentType()))
// .content(attachment.getContent())
// .build());
// break;
// case EKYC_IMAGE_BACK_KEY:
// ekyc.setImageBack(UserOidcInfo.EkycAttachment.builder()
// .type(ContentType.getType(attachment.getContentType()))
// .content(attachment.getContent())
// .build());
// break;
// case EKYC_IMAGE_FRONT_KEY:
// ekyc.setImageFront(UserOidcInfo.EkycAttachment.builder()
// .type(ContentType.getType(attachment.getContentType()))
// .content(attachment.getContent())
// .build());
// break;
// }
// });
//
// VerifiedClaimsDto.DocumentDetail documentDetail = evidence.getDocumentDetails();
// if (documentDetail != null) {
// ekyc.setDateOfExpiry(documentDetail.getDateOfExpiry());
// ekyc.setDocumentNumber(documentDetail.getDocumentNumber());
// ekyc.setDateOfIssuance(documentDetail.getDateOfIssuance());
// ekyc.setType(EkycDocumentType.getType(documentDetail.getType()));
// if (documentDetail.getIssuer() != null) {
// ekyc.setIssuer(documentDetail.getIssuer().getName());
// }
//
// }
// }
//
// }
// if (ekycClaims != null) {
// ekyc.setName(ekycClaims.getName());
// ekyc.setBirthdate(ekycClaims.getBirthdate());
// if (ekycClaims.getAddress() != null) {
// ekyc.setFormatted(ekycClaims.getAddress().getFormatted());
// ekyc.setLocality(ekycClaims.getAddress().getLocality());
// ekyc.setRegion(ekycClaims.getAddress().getRegion());
// }
// if (ekycClaims.getNationalities() != null && ekycClaims.getNationalities().size() > 0) {
// ekyc.setNationality(ekycClaims.getNationalities().get(0));
// }
// }
// return ekyc;
// }
//
//
//
//}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy