Skip to content

Commit

Permalink
Added kyc-auth new API for IdP service, fixed couple of bugs. (#916)
Browse files Browse the repository at this point in the history
  • Loading branch information
mahammedtaheer authored Nov 8, 2022
1 parent 8b90b5a commit 5d21928
Show file tree
Hide file tree
Showing 72 changed files with 12,166 additions and 10,770 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ test.txt
/.recommenders/
**/*.iml
.vscode
.sts4-cache*
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package io.mosip.authentication.common.service.entity;

import java.time.LocalDateTime;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import lombok.Data;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@Data
@Table(name = "kyc_token_store", schema = "ida")
@Entity
public class KycTokenData {

@Id
@NotNull
@Column(name = "id")
private String kycTokenId;

@NotNull
@Column(name = "id_vid_hash")
private String idVidHash;

@NotNull
@Column(name = "kyc_token")
private String kycToken;

@NotNull
@Column(name = "psu_token")
private String psuToken;

@NotNull
@Column(name = "oidc_client_id")
private String oidcClientId;

@NotNull
@Column(name = "token_issued_dtimes")
private LocalDateTime tokenIssuedDateTime;

@NotNull
@Column(name = "auth_req_dtimes")
private LocalDateTime authReqDateTime;

@NotNull
@Column(name = "kyc_token_status")
private String kycTokenStatus;

@NotNull
@Column(name = "cr_by")
private String createdBy;

@NotNull
@Column(name = "cr_dtimes")
private LocalDateTime crDTimes;

@Column(name = "upd_by")
private String updatedBy;

@Column(name = "upd_dtimes")
private LocalDateTime updDTimes;

@Column(name = "is_deleted")
private boolean isDeleted;

@Column(name = "del_dtimes")
private LocalDateTime delDTimes;
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public class MispLicenseData {
@NotNull
@Column(name = "misp_status")
private String mispStatus;

@Column(name = "policy_id")
private String policyId;

@NotNull
@Column(name = "cr_by")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package io.mosip.authentication.common.service.entity;

import java.time.LocalDateTime;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import lombok.Data;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@Data
@Table(name = "oidc_client_data", schema = "ida")
@Entity
public class OIDCClientData {

@Id
@NotNull
@Column(name = "oidc_client_id")
private String clientId;

@NotNull
@Column(name = "oidc_client_name")
private String clientName;

@NotNull
@Column(name = "oidc_client_status")
private String clientStatus;

@NotNull
@Column(name = "user_claims")
private String userClaims;

@NotNull
@Column(name = "auth_context_refs")
private String authContextRefs;

@NotNull
@Column(name = "client_auth_methods")
private String clientAuthMethods;

@NotNull
@Column(name = "partner_id")
private String partnerId;

@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "partner_id", referencedColumnName = "partner_id", insertable = false, updatable = false)
private PartnerData partnerData;

@NotNull
@Column(name = "cr_by")
private String createdBy;

@NotNull
@Column(name = "cr_dtimes")
private LocalDateTime crDTimes;

@Column(name = "upd_by")
private String updatedBy;

@Column(name = "upd_dtimes")
private LocalDateTime updDTimes;

@Column(name = "is_deleted")
private boolean isDeleted;

@Column(name = "del_dtimes")
private LocalDateTime delDTimes;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import lombok.Data;
import lombok.NoArgsConstructor;

Expand Down Expand Up @@ -68,6 +71,7 @@ public class PartnerMapping {

@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "api_key_id", referencedColumnName = "api_key_id", insertable = false, updatable = false)
@NotFound(action = NotFoundAction.IGNORE)
private ApiKeyData apiKeyData;

@Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
import io.mosip.authentication.core.indauth.dto.ActionableAuthError;
import io.mosip.authentication.core.indauth.dto.AuthError;
import io.mosip.authentication.core.indauth.dto.AuthResponseDTO;
import io.mosip.authentication.core.indauth.dto.KycAuthResponseDTO;
import io.mosip.authentication.core.indauth.dto.KycResponseDTO;
import io.mosip.authentication.core.indauth.dto.EKycAuthResponseDTO;
import io.mosip.authentication.core.indauth.dto.EKycResponseDTO;
import io.mosip.authentication.core.indauth.dto.ResponseDTO;
import io.mosip.authentication.core.logger.IdaLogger;
import io.mosip.authentication.core.otp.dto.OtpResponseDTO;
Expand Down Expand Up @@ -361,8 +361,8 @@ private static Object frameErrorResponse(String requestReceived, String type, Li
String responseTime = DateUtils.formatToISOString(DateUtils.getUTCCurrentDateTime());
switch (requestReceived) {
case "kyc":
KycAuthResponseDTO kycAuthResponseDTO = new KycAuthResponseDTO();
KycResponseDTO kycResponse = new KycResponseDTO();
EKycAuthResponseDTO kycAuthResponseDTO = new EKycAuthResponseDTO();
EKycResponseDTO kycResponse = new EKycResponseDTO();
kycResponse.setKycStatus(false);
kycAuthResponseDTO.setResponse(kycResponse);
kycAuthResponseDTO.setErrors(errors);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import io.mosip.authentication.core.indauth.dto.AuthStatusInfo;
import io.mosip.authentication.core.indauth.dto.IdType;
import io.mosip.authentication.core.indauth.dto.IdentityInfoDTO;
import io.mosip.authentication.core.indauth.dto.KycAuthRequestDTO;
import io.mosip.authentication.core.indauth.dto.EkycAuthRequestDTO;
import io.mosip.authentication.core.logger.IdaLogger;
import io.mosip.authentication.core.partner.dto.PartnerPolicyResponseDTO;
import io.mosip.authentication.core.partner.dto.PolicyDTO;
Expand Down Expand Up @@ -138,16 +138,17 @@ public AuthResponseDTO authenticateIndividual(AuthRequestDTO authRequestDTO, boo
String partnerApiKey, boolean markVidConsumed, ObjectWithMetadata requestWrapperMetadata) throws IdAuthenticationBusinessException {

String idvid = authRequestDTO.getIndividualId();
String idvidHash = securityManager.hash(idvid);
String idvIdType = IdType.getIDTypeStrOrDefault(authRequestDTO.getIndividualIdType());
logger.debug(IdAuthCommonConstants.SESSION_ID, "AuthFacedImpl", "authenticateIndividual: ",
idvIdType + "-" + idvid);
idvIdType + "-" + idvidHash);

Set<String> filterAttributes = new HashSet<>();
filterAttributes.addAll(idInfoHelper.buildDemoAttributeFilters(authRequestDTO));
filterAttributes.addAll(idInfoHelper.buildBioFilters(authRequestDTO));

if(authRequestDTO instanceof KycAuthRequestDTO) {
KycAuthRequestDTO kycAuthRequestDTO = (KycAuthRequestDTO) authRequestDTO;
if(authRequestDTO instanceof EkycAuthRequestDTO) {
EkycAuthRequestDTO kycAuthRequestDTO = (EkycAuthRequestDTO) authRequestDTO;
// In case of ekyc request and photo also needed we need to add face to get it
// filtered
if(IdInfoHelper.isKycAttributeHasPhoto(kycAuthRequestDTO)) {
Expand Down Expand Up @@ -226,7 +227,7 @@ public AuthResponseDTO authenticateIndividual(AuthRequestDTO authRequestDTO, boo

}

private void addKycPolicyAttributes(Set<String> filterAttributes, KycAuthRequestDTO kycAuthRequestDTO)
private void addKycPolicyAttributes(Set<String> filterAttributes, EkycAuthRequestDTO kycAuthRequestDTO)
throws IdAuthenticationBusinessException {
List<String> allowedKycAttributes = kycAuthRequestDTO.getAllowedKycAttributes();
if(allowedKycAttributes != null && !allowedKycAttributes.isEmpty()) {
Expand Down
Loading

0 comments on commit 5d21928

Please sign in to comment.