Skip to content

Commit

Permalink
Renamed plugin to peru-identity-dataprovider-plugin
Browse files Browse the repository at this point in the history
Signed-off-by: Piyush7034 <[email protected]>
  • Loading branch information
Piyush7034 committed Jan 30, 2025
1 parent 5f161bf commit 94cf309
Show file tree
Hide file tree
Showing 15 changed files with 70 additions and 207 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/push-trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,24 +228,24 @@ jobs:
GPG_SECRET: ${{ secrets.GPG_SECRET }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

build-maven-soap-client-dataprovider-plugin:
build-maven-peru-identity-dataprovider-plugin:
uses: mosip/kattu/.github/workflows/maven-build.yml@master-java21
with:
SERVICE_LOCATION: soap-client-dataprovider-plugin
BUILD_ARTIFACT: soap-client-dataprovider-plugin
SERVICE_LOCATION: peru-identity-dataprovider-plugin
BUILD_ARTIFACT: peru-identity-dataprovider-plugin
secrets:
OSSRH_USER: ${{ secrets.OSSRH_USER }}
OSSRH_SECRET: ${{ secrets.OSSRH_SECRET }}
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
GPG_SECRET: ${{ secrets.GPG_SECRET }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

publish_to_nexus_soap-client-dataprovider-plugin:
publish_to_nexus_peru-identity-dataprovider-plugin:
if: "${{ !contains(github.ref, 'master') && github.event_name != 'pull_request' && github.event_name != 'release' && github.event_name != 'prerelease' && github.event_name != 'publish' }}"
needs: build-maven-soap-client-dataprovider-plugin
needs: build-maven-peru-identity-dataprovider-plugin
uses: mosip/kattu/.github/workflows/maven-publish-to-nexus.yml@master-java21
with:
SERVICE_LOCATION: ./soap-client-dataprovider-plugin
SERVICE_LOCATION: ./peru-identity-dataprovider-plugin
secrets:
OSSRH_USER: ${{ secrets.OSSRH_USER }}
OSSRH_SECRET: ${{ secrets.OSSRH_SECRET }}
Expand All @@ -254,12 +254,12 @@ jobs:
GPG_SECRET: ${{ secrets.GPG_SECRET }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

sonar_analysis_soap-client-dataprovider-plugin:
needs: build-maven-soap-client-dataprovider-plugin
sonar_analysis_peru-identity-dataprovider-plugin:
needs: build-maven-peru-identity-dataprovider-plugin
if: "${{ github.event_name != 'pull_request' }}"
uses: mosip/kattu/.github/workflows/maven-sonar-analysis.yml@master-java21
with:
SERVICE_LOCATION: ./soap-client-dataprovider-plugin
SERVICE_LOCATION: ./peru-identity-dataprovider-plugin
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
ORG_KEY: ${{ secrets.ORG_KEY }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<modelVersion>4.0.0</modelVersion>

<groupId>io.mosip.certify</groupId>
<artifactId>soap-client-dataprovider-plugin</artifactId>
<version>0.3.1-SNAPSHOT</version>
<artifactId>peru-identity-dataprovider-plugin</artifactId>
<version>0.3.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>soap-client-dataprovider-plugin</name>
<name>peru-identity-dataprovider-plugin</name>
<url>https://github.com/mosip/digital-credential-plugins</url>

<licenses>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.mosip.certify.soapclientdataprovider.integration.dto.request;
package io.mosip.certify.peruiddataprovider.integration.dto.request;

import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.mosip.certify.soapclientdataprovider.integration.dto.request;
package io.mosip.certify.peruiddataprovider.integration.dto.request;

import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.mosip.certify.soapclientdataprovider.integration.dto.request;
package io.mosip.certify.peruiddataprovider.integration.dto.request;

import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.mosip.certify.soapclientdataprovider.integration.dto.request;
package io.mosip.certify.peruiddataprovider.integration.dto.request;

import jakarta.xml.bind.annotation.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.mosip.certify.soapclientdataprovider.integration.dto.response;
package io.mosip.certify.peruiddataprovider.integration.dto.response;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

package io.mosip.certify.soapclientdataprovider.integration.dto.response;
package io.mosip.certify.peruiddataprovider.integration.dto.response;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
Expand Down Expand Up @@ -54,6 +54,16 @@ public class DatosPersona {
protected String estadoCivil;
@JacksonXmlProperty
protected String restriccion;
@JacksonXmlProperty
protected String foto;

public String getFoto() {
return foto;
}

public void setFoto(String foto) {
this.foto = foto;
}

/**
* Gets the value of the dni property.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package io.mosip.certify.soapclientdataprovider.integration.dto.response;
package io.mosip.certify.peruiddataprovider.integration.dto.response;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;

@JacksonXmlRootElement(localName = "Body")
@JsonIgnoreProperties(ignoreUnknown = true)
public class Body {
public class ResponseBody {
@JacksonXmlProperty(localName = "consultarResponse", namespace = "http://localhost:80/")
private ConsultarResponse consultarResponse;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package io.mosip.certify.soapclientdataprovider.integration.dto.response;
package io.mosip.certify.peruiddataprovider.integration.dto.response;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import io.mosip.certify.soapclientdataprovider.integration.dto.response.Body;
import io.mosip.certify.peruiddataprovider.integration.dto.response.ResponseBody;

@JacksonXmlRootElement(localName = "Envelope", namespace = "http://schemas.xmlsoap.org/soap/envelope/")
@JsonIgnoreProperties(ignoreUnknown = true)
public class Envelope {
public class ResponseEnvelope {

@JacksonXmlProperty(localName = "Body")
private Body body;
private ResponseBody body;

public Body getBody() { return body; }
public void setBody(Body body) { this.body = body; }
public ResponseBody getBody() { return body; }
public void setBody(ResponseBody body) { this.body = body; }
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package io.mosip.certify.soapclientdataprovider.integration.dto.response;
package io.mosip.certify.peruiddataprovider.integration.dto.response;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import io.mosip.certify.soapclientdataprovider.integration.dto.response.DatosPersona;
import io.mosip.certify.peruiddataprovider.integration.dto.response.DatosPersona;

@JacksonXmlRootElement(localName = "return")
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,43 +1,38 @@
package io.mosip.certify.soapclientdataprovider.integration.service;
package io.mosip.certify.peruiddataprovider.integration.service;

import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import io.mosip.certify.soapclientdataprovider.integration.dto.request.ConsultaArg;
import io.mosip.certify.soapclientdataprovider.integration.dto.request.Consultar;
import io.mosip.certify.soapclientdataprovider.integration.dto.request.RequestBody;
import io.mosip.certify.soapclientdataprovider.integration.dto.request.RequestEnvelope;
import io.mosip.certify.soapclientdataprovider.integration.dto.response.Envelope;
import io.mosip.certify.soapclientdataprovider.integration.dto.response.ResponseReturn;
import io.mosip.certify.peruiddataprovider.integration.dto.request.ConsultaArg;
import io.mosip.certify.peruiddataprovider.integration.dto.response.ResponseEnvelope;
import io.mosip.certify.peruiddataprovider.integration.dto.response.ResponseReturn;
import io.mosip.certify.util.SoapUtil;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.Marshaller;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.io.OutputStream;
import java.io.StringWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;

@Service
@Slf4j
public class ConsultaDniService {
final String ENDPOINT_URI = "http://65.1.93.129/consultadnie/ConsultaDniService";

public ResponseReturn getConsultarResponse(ConsultaArg consultaArg) throws Exception {
try {


// SOAP Endpoint and Request Body
String endpointUrl = "http://65.1.93.129/consultadnie/ConsultaDniService";
// SOAP Request Body
String soapRequest = SoapUtil.buildSoapRequest(consultaArg);
// Send SOAP request and get response
String soapResponse = sendSOAPRequest(endpointUrl, soapRequest);
String soapResponse = sendSOAPRequest(ENDPOINT_URI, soapRequest);

try {
XmlMapper xmlMapper = new XmlMapper();
Envelope resp = xmlMapper.readValue(soapResponse, Envelope.class);
ResponseEnvelope responseEnvelope = xmlMapper.readValue(soapResponse, ResponseEnvelope.class);

if(responseEnvelope != null && responseEnvelope.getBody() != null && responseEnvelope.getBody().getConsultarResponse() != null) {
return responseEnvelope.getBody().getConsultarResponse().getResponseReturn();
}

return resp.getBody().getConsultarResponse().getResponseReturn();
} catch (Exception e) {
log.info("Error during deserialization", e);
throw new Exception("ERROR_DURING_DESERIALIZATION");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package io.mosip.certify.soapclientdataprovider.integration.service;
package io.mosip.certify.peruiddataprovider.integration.service;

import io.mosip.certify.api.exception.DataProviderExchangeException;
import io.mosip.certify.api.spi.DataProviderPlugin;
import io.mosip.certify.soapclientdataprovider.integration.dto.request.ConsultaArg;
import io.mosip.certify.soapclientdataprovider.integration.dto.response.DatosPersona;
import io.mosip.certify.soapclientdataprovider.integration.dto.response.ResponseReturn;
import io.mosip.certify.peruiddataprovider.integration.dto.request.ConsultaArg;
import io.mosip.certify.peruiddataprovider.integration.dto.response.DatosPersona;
import io.mosip.certify.peruiddataprovider.integration.dto.response.ResponseReturn;
import lombok.extern.slf4j.Slf4j;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -17,7 +17,7 @@
@ConditionalOnProperty(value = "mosip.certify.integration.data-provider-plugin", havingValue = "SoapClientDataProviderPlugin")
@Component
@Slf4j
public class SoapClientDataProviderPlugin implements DataProviderPlugin {
public class PeruDataProviderCertifyPlugin implements DataProviderPlugin {
@Autowired
private ConsultaDniService consultaDniService;

Expand All @@ -36,7 +36,7 @@ public JSONObject fetchData(Map<String, Object> identityDetails) throws DataProv
try {
String nuConsultaDni = (String) identityDetails.get("sub");
ConsultaArg arg = new ConsultaArg();
arg.setNuDniConsulta("06794000");
arg.setNuDniConsulta(nuConsultaDni);
arg.setNuDniUsuario(nuDniUsuario);
arg.setNuRucUsuario(nuRucUsuario);
arg.setPassword(password);
Expand All @@ -45,26 +45,25 @@ public JSONObject fetchData(Map<String, Object> identityDetails) throws DataProv
log.info("co result: " + responseReturn.getCoResultado());
log.info("de result: " + responseReturn.getDeResultado());
if(!responseReturn.getCoResultado().equals("0000")) {
throw new Exception("INVALID_DNI");
throw new Exception(responseReturn.getDeResultado());
}

if(responseReturn.getDatosPersona() != null) {
DatosPersona datosPersona = responseReturn.getDatosPersona();
jsonObject.put("dni", datosPersona.getDni());
jsonObject.put("prenombres", datosPersona.getPrenombres());
jsonObject.put("primerApellido", datosPersona.getPrimerApellido());
jsonObject.put("apellidoCasada", datosPersona.getApellidoCasada());
jsonObject.put("segundoApellido", datosPersona.getSegundoApellido());
jsonObject.put("fechaNacimiento", datosPersona.getFechaNacimiento());
jsonObject.put("genero", datosPersona.getGenero());
jsonObject.put("estadoCivil", datosPersona.getEstadoCivil());
jsonObject.put("restriccion", datosPersona.getRestriccion());

jsonObject.put("firstName", datosPersona.getPrenombres());
jsonObject.put("firstLastName", datosPersona.getPrimerApellido());
jsonObject.put("secondLastName", datosPersona.getSegundoApellido());
jsonObject.put("dateOfBirth", datosPersona.getFechaNacimiento());
jsonObject.put("gender", datosPersona.getGenero());
jsonObject.put("maritalStatus", datosPersona.getEstadoCivil());
jsonObject.put("restriction", datosPersona.getRestriccion());
jsonObject.put("face", datosPersona.getFoto());
return jsonObject;
}
} catch (Exception e) {
log.error("Failed to fetch response from soap resource.");
throw new DataProviderExchangeException("INVALID_CONSULTA_DNI");
throw new DataProviderExchangeException(e.getMessage());
}
throw new DataProviderExchangeException("FAILED_TO_FETCH_DATA");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package io.mosip.certify.util;

import io.mosip.certify.soapclientdataprovider.integration.dto.request.ConsultaArg;
import io.mosip.certify.soapclientdataprovider.integration.dto.request.Consultar;
import io.mosip.certify.soapclientdataprovider.integration.dto.request.RequestBody;
import io.mosip.certify.soapclientdataprovider.integration.dto.request.RequestEnvelope;
import io.mosip.certify.peruiddataprovider.integration.dto.request.ConsultaArg;
import io.mosip.certify.peruiddataprovider.integration.dto.request.Consultar;
import io.mosip.certify.peruiddataprovider.integration.dto.request.RequestBody;
import io.mosip.certify.peruiddataprovider.integration.dto.request.RequestEnvelope;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.Marshaller;

Expand Down
Loading

0 comments on commit 94cf309

Please sign in to comment.