Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES-187 #1092

Merged
merged 1 commit into from
Sep 14, 2023
Merged

ES-187 #1092

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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