Skip to content

Commit

Permalink
ES-187
Browse files Browse the repository at this point in the history
  • Loading branch information
ase-101 committed Sep 14, 2023
1 parent 02d0c0b commit a5188a6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 38 deletions.
4 changes: 2 additions & 2 deletions authentication/esignet-integration-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
<dependency>
<groupId>io.mosip.esignet</groupId>
<artifactId>esignet-integration-api</artifactId>
<version>1.2.0-SNAPSHOT</version>
<version>1.2.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>io.mosip.esignet</groupId>
<artifactId>esignet-core</artifactId>
<version>1.2.0-SNAPSHOT</version>
<version>1.2.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
import javax.crypto.Cipher;

import io.mosip.authentication.esignet.integration.dto.IdaVcExchangeResponse;
import io.mosip.esignet.api.exception.VCIExchangeException;
import io.mosip.esignet.api.util.ErrorConstants;
import io.mosip.esignet.core.dto.OIDCTransaction;
import org.apache.commons.lang3.NotImplementedException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
Expand All @@ -18,6 +19,7 @@
import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;

Expand All @@ -42,11 +44,7 @@
@ConditionalOnProperty(value = "mosip.esignet.integration.vci-plugin", havingValue = "IdaVCIssuancePluginImpl")
public class IdaVCIssuancePluginImpl implements VCIssuancePlugin {
private static final String CLIENT_ID = "client_id";
private static final String RELYING_PARTY_ID = "relyingPartyId";
private static final String ACCESS_TOKEN_HASH = "accessTokenHash";
private static final String INDIVIDUAL_ID = "individualId";
private static final String KYC_TOKEN = "kycToken";
private static final String AUTH_TRANSACTION_ID = "authTransactionId";
public static final String SIGNATURE_HEADER_NAME = "signature";
public static final String AUTHORIZATION_HEADER_NAME = "Authorization";
public static final String OIDC_SERVICE_APP_ID = "OIDC_SERVICE";
Expand Down Expand Up @@ -95,10 +93,9 @@ public class IdaVCIssuancePluginImpl implements VCIssuancePlugin {
private Base64.Decoder urlSafeDecoder = Base64.getUrlDecoder();


@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public VCResult getVerifiableCredentialWithLinkedDataProof(VCRequestDto vcRequestDto, String holderId,
Map<String, Object> identityDetails) {
public VCResult<JsonLDObject> getVerifiableCredentialWithLinkedDataProof(VCRequestDto vcRequestDto, String holderId,
Map<String, Object> identityDetails) throws VCIExchangeException {
log.info("Started to created the VCIssuance");
try {
OIDCTransaction transaction = vciTransactionHelper
Expand Down Expand Up @@ -131,42 +128,31 @@ public VCResult getVerifiableCredentialWithLinkedDataProof(VCRequestDto vcReques
.header(SIGNATURE_HEADER_NAME, helperService.getRequestSignature(requestBody))
.header(AUTHORIZATION_HEADER_NAME, AUTHORIZATION_HEADER_NAME).body(requestBody);

switch (vcRequestDto.getFormat()) {
case "ldp_vc":
ResponseEntity<IdaResponseWrapper<IdaVcExchangeResponse<JsonLDObject>>> responseEntity = restTemplate.exchange(requestEntity,
new ParameterizedTypeReference<IdaResponseWrapper<IdaVcExchangeResponse<JsonLDObject>>>() {
});
return getLinkedDataProofCredential(responseEntity);
default:
log.error("Errors in response received from IDA VCI Exchange: {}");
break;
ResponseEntity<IdaResponseWrapper<IdaVcExchangeResponse<JsonLDObject>>> responseEntity = restTemplate.exchange(
requestEntity, new ParameterizedTypeReference<IdaResponseWrapper<IdaVcExchangeResponse<JsonLDObject>>>() {});
if (responseEntity.getStatusCode().is2xxSuccessful() && responseEntity.getBody() != null) {
IdaResponseWrapper<IdaVcExchangeResponse<JsonLDObject>> responseWrapper = responseEntity.getBody();
if (responseWrapper.getResponse() != null) {
VCResult vCResult = new VCResult();
vCResult.setCredential(responseWrapper.getResponse().getVerifiableCredentials());
vCResult.setFormat(vcRequestDto.getFormat());
return vCResult;
}
log.error("Errors in response received from IDA VCI Exchange: {}", responseWrapper.getErrors());
throw new VCIExchangeException(CollectionUtils.isEmpty(responseWrapper.getErrors()) ?
ErrorConstants.DATA_EXCHANGE_FAILED : responseWrapper.getErrors().get(0).getErrorCode());
}
log.error("Error response received from IDA (VCI-exchange) with status : {}", responseEntity.getStatusCode());
} catch (Exception e) {
log.error("IDA Vci-exchange failed ", e);
}
return null;

}

@SuppressWarnings({ "rawtypes", "unchecked" })
public VCResult getLinkedDataProofCredential(ResponseEntity<IdaResponseWrapper<IdaVcExchangeResponse<JsonLDObject>>> responseEntity) {
if (responseEntity.getStatusCode().is2xxSuccessful() && responseEntity.getBody() != null) {
IdaResponseWrapper<IdaVcExchangeResponse<JsonLDObject>> responseWrapper = responseEntity.getBody();
if (responseWrapper.getResponse() != null) {
VCResult vCResult = new VCResult();
vCResult.setCredential(responseWrapper.getResponse().getVerifiableCredentials());
vCResult.setFormat("ldp_vc");
return vCResult;
}
log.error("Errors in response received from IDA VC Exchange: {}", responseWrapper.getErrors());
}
return null;
throw new VCIExchangeException();
}

@Override
public VCResult<String> getVerifiableCredential(VCRequestDto vcRequestDto, String holderId,
Map<String, Object> identityDetails) {
throw new NotImplementedException("This method is not implemented");
Map<String, Object> identityDetails) throws VCIExchangeException {
throw new VCIExchangeException(ErrorConstants.NOT_IMPLEMENTED);
}

protected String getIndividualId(String encryptedIndividualId) throws Exception {
Expand Down

0 comments on commit a5188a6

Please sign in to comment.