Skip to content

Commit

Permalink
MOSIP-30687 On demand template extraction changes
Browse files Browse the repository at this point in the history
Signed-off-by: Neha Farheen <[email protected]>
  • Loading branch information
Neha Farheen committed Jan 29, 2024
1 parent 1169fb1 commit eb48b87
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ public Tuple3<String, String, String> encryptData(byte[] data, String partnerCer
return Tuples.of(CryptoUtil.encodeBase64Url(encryptedData.getT1()), CryptoUtil.encodeBase64Url(encryptedData.getT2()), digestAsPlainText(certificateThumbprint));
}

public byte[] encryptIdData(byte[] dataToEncrypt, String partnerCertificate)
public byte[] asymmetricEncryption(byte[] dataToEncrypt, String partnerCertificate)
throws IdAuthenticationBusinessException {
X509Certificate x509Certificate = getX509Certificate(partnerCertificate);
PublicKey publicKey = x509Certificate.getPublicKey();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,27 +100,27 @@ public void publishEvent(EventModel eventModel) {
webSubHelper.publishEvent(onDemadTemplateExtractionTopic, eventModel);
}

public void notify(Object authrequestdto, String headerSignature, Optional<PartnerDTO> partner,
public void notify(BaseRequestDTO baserequestdto, String headerSignature, Optional<PartnerDTO> partner,
IdAuthenticationBusinessException e, Map<String, Object> metadata) {
try {
sendEvents(authrequestdto, headerSignature, partner, e, metadata);
sendEvents(baserequestdto, headerSignature, partner, e, metadata);
} catch (Exception exception) {
logger.error(IdRepoSecurityManager.getUser(), "On demand template extraction", "notify",
exception.getMessage());
}
}

private void sendEvents(Object authrequestdto, String headerSignature, Optional<PartnerDTO> partner,
private void sendEvents(BaseRequestDTO baserequestdto, String headerSignature, Optional<PartnerDTO> partner,
IdAuthenticationBusinessException e, Map<String, Object> metadata) {
logger.info("Inside sendEvents ondemand extraction");
Map<String, Object> eventData = new HashMap<>();
eventData.put(ERROR_CODE, e.getErrorCode());
eventData.put(ERROR_MESSAGE, e.getErrorText());
eventData.put(REQUESTDATETIME, DateUtils.formatToISOString(DateUtils.getUTCCurrentDateTime()));
eventData.put(INDIVIDUAL_ID, encryptIndividualId(((BaseRequestDTO) authrequestdto).getIndividualId(),
eventData.put(INDIVIDUAL_ID, encryptIndividualId(baserequestdto.getIndividualId(),
metadata.get(IdAuthCommonConstants.PARTNER_CERTIFICATE).toString()));
eventData.put(AUTH_PARTNER_ID, partner.get().getPartnerId());
eventData.put(INDIVIDUAL_ID_TYPE, ((BaseRequestDTO) authrequestdto).getIndividualIdType());
eventData.put(INDIVIDUAL_ID_TYPE, baserequestdto.getIndividualIdType());
eventData.put(ENTITY_NAME, partner.get().getPartnerName());
eventData.put(REQUEST_SIGNATURE, headerSignature);
EventModel eventModel = createEventModel(onDemadTemplateExtractionTopic, eventData);
Expand All @@ -144,7 +144,7 @@ private EventModel createEventModel(String topic, Map<String, Object> eventData)

private byte[] encryptIndividualId(String id, String partnerCertificate) {
try {
return securityManager.encryptIdData(id.getBytes(), partnerCertificate);
return securityManager.asymmetricEncryption(id.getBytes(), partnerCertificate);
} catch (IdAuthenticationBusinessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Expand Down

0 comments on commit eb48b87

Please sign in to comment.