Skip to content
Merged
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
10 changes: 5 additions & 5 deletions mock-certify-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<groupId>io.inji.certify</groupId>
<artifactId>mock-certify-plugin</artifactId>
<version>0.5.0-SNAPSHOT</version>
<version>0.6.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>mock-certify-integration-impl</name>
Expand Down Expand Up @@ -63,15 +63,15 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.mosip.certify</groupId>
<groupId>io.inji.certify</groupId>
<artifactId>certify-core</artifactId>
<version>0.12.0-SNAPSHOT</version>
<version>0.14.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.mosip.esignet</groupId>
<artifactId>esignet-core</artifactId>
<version>1.5.1</version>
<version>1.6.2</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
Expand All @@ -82,7 +82,7 @@
<dependency>
<groupId>io.mosip.esignet</groupId>
<artifactId>esignet-integration-api</artifactId>
<version>1.5.1</version>
<version>1.6.2</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
Expand Down
19 changes: 12 additions & 7 deletions mosip-identity-certify-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.inji.certify</groupId>
<artifactId>mosip-identity-certify-plugin</artifactId>
<version>0.5.0-SNAPSHOT</version>
<version>0.6.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>mosipid-certify-integration-impl</name>
Expand Down Expand Up @@ -96,15 +96,15 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.mosip.certify</groupId>
<groupId>io.inji.certify</groupId>
<artifactId>certify-core</artifactId>
<version>0.12.0-SNAPSHOT</version>
<version>0.14.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.mosip.certify</groupId>
<groupId>io.inji.certify</groupId>
<artifactId>certify-integration-api</artifactId>
<version>0.12.0-SNAPSHOT</version>
<version>0.14.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -146,7 +146,7 @@
<groupId>io.mosip.esignet</groupId>
<artifactId>esignet-core</artifactId>

<version>1.5.1</version>
<version>1.6.2</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
Expand All @@ -157,14 +157,19 @@
<dependency>
<groupId>io.mosip.esignet</groupId>
<artifactId>esignet-integration-api</artifactId>
<version>1.5.1</version>
<version>1.6.2</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.15.4</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package io.mosip.certify.mosipid.integration.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import java.util.List;
import java.util.Map;

@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class IdaKycExchangeRequest {

private String id;
private String version;
private String requestTime;
private String transactionID;
private String kycToken;
private List<String> consentObtained;
private List<String> locales;
private String respType;
private String individualId;

/**
* claims metadata - Not set/un used for now from IDA
*/
private Map<String, Object> metadata;
/**
* User consented verified claims list.
*/
List<Map<String, Object>> verifiedConsentedClaims;
/**
* User consented unverified claims list.
*/
Map<String, Object> unVerifiedConsentedClaims;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package io.mosip.certify.mosipid.integration.dto;

import lombok.Data;

@Data
public class IdaKycExchangeResponse {

private String encryptedKyc;
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

@Component
@Slf4j
@ConditionalOnProperty(value = "mosip.certify.integration.vci-plugin", havingValue = "IdaVCIssuancePluginImpl")
@ConditionalOnProperty(value = "mosip.certify.integration.data-provider-plugin", havingValue = "IdaDataProviderPluginImpl")
public class AuthTransactionHelper {

private static final String AUTH_TOKEN_CACHE = "authtokens";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package io.mosip.certify.mosipid.integration.helper;

import io.mosip.esignet.core.dto.OIDCTransaction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cache.CacheManager;
import org.springframework.stereotype.Component;

@Component
@ConditionalOnProperty(value = "mosip.certify.integration.data-provider-plugin", havingValue = "IdaDataProviderPluginImpl")
public class TransactionHelper {

@Autowired
CacheManager cacheManager;

@Value("${mosip.certify.ida.vci-user-info-cache}")
private String userinfoCache;

@SuppressWarnings("unchecked")
public OIDCTransaction getOAuthTransaction(String accessTokenHash) throws Exception {
if (cacheManager.getCache(userinfoCache) != null) {
return cacheManager.getCache(userinfoCache).get(accessTokenHash, OIDCTransaction.class); //NOSONAR getCache() will not be returning null here.
}
throw new Exception("cache_missing");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package io.mosip.certify.mosipid.integration.helper;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.mosip.certify.mosipid.integration.dto.ClientIdSecretKeyRequest;
import io.mosip.kernel.core.http.RequestWrapper;
import io.mosip.kernel.core.http.ResponseWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.MediaType;
import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;

import java.time.LocalDateTime;

@Component
@Slf4j
@ConditionalOnProperty(value = "mosip.certify.integration.vci-plugin", havingValue = "IdaVCIssuancePluginImpl")
@Deprecated
public class VCIAuthTransactionHelper {

private static final String AUTH_TOKEN_CACHE = "authtokens";

@Autowired
private ObjectMapper objectMapper;

@Autowired
private RestTemplate restTemplate;

@Value("${mosip.certify.authenticator.ida.auth-token-url}")
private String authTokenUrl;

@Value("${mosip.certify.authenticator.ida.client-id}")
private String clientId;

@Value("${mosip.certify.authenticator.ida.secret-key}")
private String secretKey;

@Value("${mosip.certify.authenticator.ida.app-id}")
private String appId;

@Cacheable(value = AUTH_TOKEN_CACHE, key = "#root.target.AUTH_TOKEN_CACHE_KEY")
public String getAuthToken() throws Exception {
log.info("Started to get auth-token with appId : {} && clientId : {}",
appId, clientId);

RequestWrapper<ClientIdSecretKeyRequest> authRequest = new RequestWrapper<>();
authRequest.setRequesttime(LocalDateTime.now());
ClientIdSecretKeyRequest clientIdSecretKeyRequest = new ClientIdSecretKeyRequest(clientId, secretKey, appId);
authRequest.setRequest(clientIdSecretKeyRequest);

String requestBody = objectMapper.writeValueAsString(authRequest);
RequestEntity requestEntity = RequestEntity
.post(UriComponentsBuilder.fromUriString(authTokenUrl).build().toUri())
.contentType(MediaType.APPLICATION_JSON)
.body(requestBody);
ResponseEntity<ResponseWrapper> responseEntity = restTemplate.exchange(requestEntity,
new ParameterizedTypeReference<ResponseWrapper>() {});

String authToken = responseEntity.getHeaders().getFirst("authorization");
return authToken;
}

@CacheEvict(value = AUTH_TOKEN_CACHE, allEntries = true)
public void purgeAuthTokenCache() {
log.info("Evicting entry from AUTH_TOKEN_CACHE");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

@Component
@ConditionalOnProperty(value = "mosip.certify.integration.vci-plugin", havingValue = "IdaVCIssuancePluginImpl")
@Deprecated
public class VCITransactionHelper {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,20 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.nio.charset.StandardCharsets;

import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Base64;
import java.util.*;
import java.util.stream.Collectors;


@Service
@Slf4j
@ConditionalOnProperty(value = "mosip.certify.integration.vci-plugin", havingValue = "IdaVCIssuancePluginImpl")
@ConditionalOnProperty(value = "mosip.certify.integration.data-provider-plugin", havingValue = "IdaDataProviderPluginImpl")
public class HelperService {

public static final String UTC_DATETIME_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
Expand All @@ -42,7 +45,7 @@ protected String getRequestSignature(String request) {
JWTSignatureRequestDto jwtSignatureRequestDto = new JWTSignatureRequestDto();
jwtSignatureRequestDto.setApplicationId(OIDC_PARTNER_APP_ID);
jwtSignatureRequestDto.setReferenceId("");
jwtSignatureRequestDto.setIncludePayload(false);
jwtSignatureRequestDto.setIncludePayload(true);
jwtSignatureRequestDto.setIncludeCertificate(true);
jwtSignatureRequestDto.setDataToSign(HelperService.b64Encode(request));
JWTSignatureResponseDto responseDto = signatureService.jwtSign(jwtSignatureRequestDto);
Expand All @@ -60,4 +63,18 @@ protected static String b64Encode(String value) {
return urlSafeEncoder.encodeToString(value.getBytes(StandardCharsets.UTF_8));
}

//Converts an array of two-letter language codes to their corresponding ISO 639-2/T language codes.
protected List<String> convertLangCodesToISO3LanguageCodes(String[] langCodes) {
if(langCodes == null || langCodes.length == 0)
return List.of();
return Arrays.stream(langCodes)
.map(langCode -> {
try {
return StringUtils.isEmpty(langCode) ? null : new Locale(langCode).getISO3Language();
} catch (MissingResourceException ex) {}
return null;
})
.filter(Objects::nonNull)
.collect(Collectors.toList());
}
}
Loading