Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/mosip/inji-verify into i…
Browse files Browse the repository at this point in the history
…njiver-846-ovp-pending-tasks

Signed-off-by: srikanth716 <[email protected]>
  • Loading branch information
srikanth716 committed Jan 7, 2025
2 parents 0722960 + 089381e commit 988707d
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 41 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand All @@ -10,10 +12,12 @@
<version>3.2.3</version>
</parent>

<groupId>io.inji.verify</groupId>
<groupId>io.inji.verify</groupId>
<artifactId>verify-service-parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
<description>Parent project of MOSIP Inji verify backend service</description>
<description>Parent project of MOSIP Inji verify backend service</description>
<url>https://github.com/mosip/inji-verify</url>
<packaging>pom</packaging>
<licenses>
Expand Down Expand Up @@ -145,6 +149,8 @@
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties
</generateGitPropertiesFilename>
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties
</generateGitPropertiesFilename>
<includeOnlyProperties>
<includeOnlyProperty>^git.build.(time|version)$</includeOnlyProperty>
<includeOnlyProperty>^git.commit.id.(abbrev|full)$</includeOnlyProperty>
Expand Down
4 changes: 4 additions & 0 deletions verify-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.inji.verify</groupId>
<groupId>io.inji.verify</groupId>
<artifactId>verify-service-parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
Expand All @@ -14,6 +17,7 @@
<version>0.1.0-SNAPSHOT</version>
<name>verify-service</name>
<description>Inji verify backend server implementing the OpenId4VP flow and online verification of VC</description>
<description>Inji verify backend server implementing the OpenId4VP flow and online verification of VC</description>
<packaging>jar</packaging>
<dependencyManagement>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
package io.inji.verify.dto.authorizationrequest;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.inji.verify.dto.presentation.VPDefinitionResponseDto;
import io.inji.verify.models.PresentationDefinition;
import io.inji.verify.shared.Constants;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.cache.annotation.Cacheable;

import java.time.Instant;

@Getter
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
@Cacheable
public class AuthorizationRequestResponseDto {

private final String responseType = Constants.RESPONSE_TYPE;
private final String responseUri = Constants.RESPONSE_SUBMISSION_URI_ROOT+Constants.RESPONSE_SUBMISSION_URI;
private final long issuedAt = Instant.now().toEpochMilli();
private final String clientId;
private final String presentationDefinitionUri;
private final VPDefinitionResponseDto presentationDefinition;
private final String nonce;
}
@Getter
public class VPRequestResponseDto {
String transactionId;
String requestId;
AuthorizationRequestResponseDto authorizationDetails;
long expiresAt;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ public class VPRequestResponseDto {
String requestId;
AuthorizationRequestResponseDto authorizationDetails;
long expiresAt;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package io.inji.verify.dto.authorizationrequest;

import org.json.JSONObject;

import com.fasterxml.jackson.annotation.JsonInclude;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.json.JSONObject;

@AllArgsConstructor
@Getter
Expand All @@ -12,4 +14,4 @@ public class VPResultDto {
String transactionId;
boolean verified;
JSONObject claims;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package io.inji.verify.dto.presentation;

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

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;


@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package io.inji.verify.dto.presentation;

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

import com.fasterxml.jackson.annotation.JsonInclude;

import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.List;
import java.util.Map;

@AllArgsConstructor
@Getter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package io.inji.verify.dto.presentation;

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

import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import com.nimbusds.jose.shaded.gson.annotations.SerializedName;

import lombok.AllArgsConstructor;
import lombok.Getter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
@AllArgsConstructor
@NoArgsConstructor(force = true)
public class PresentationDefinition {

@Id
private final String id;

Expand All @@ -34,9 +35,8 @@ public class PresentationDefinition {
@JdbcTypeCode(SqlTypes.JSON)
private final List<SubmissionRequirementDto> submissionRequirements;


@JsonIgnore
public String getURL(){
return Constants.VP_DEFINITION_URI +this.id;
public String getURL() {
return Constants.VP_DEFINITION_URI + this.id;
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package io.inji.verify.repository;

import io.inji.verify.models.AuthorizationRequestCreateResponse;
import java.util.List;

import org.jetbrains.annotations.NotNull;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;
import io.inji.verify.models.AuthorizationRequestCreateResponse;

public interface AuthorizationRequestCreateResponseRepository extends JpaRepository<AuthorizationRequestCreateResponse, String> {
List<AuthorizationRequestCreateResponse> findAllByTransactionIdOrderByExpiresAtDesc(@NotNull String transactionId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@Service
@Slf4j
public class VCVerificationServiceImpl implements VCVerificationService {

@Autowired
CredentialsVerifier credentialsVerifier;

Expand All @@ -22,8 +23,9 @@ public VCVerificationStatusDto verify(String vc) {
VerificationResult verificationResult = credentialsVerifier.verify(vc, CredentialFormat.LDP_VC);
log.info("VC verification result:: " + verificationResult);
if (verificationResult.getVerificationStatus()) {
if (verificationResult.getVerificationErrorCode().equals(CredentialValidatorConstants.ERROR_CODE_VC_EXPIRED))
if (verificationResult.getVerificationErrorCode().equals(CredentialValidatorConstants.ERROR_CODE_VC_EXPIRED)) {
return new VCVerificationStatusDto(VerificationStatus.EXPIRED);
}
return new VCVerificationStatusDto(VerificationStatus.SUCCESS);
}
return new VCVerificationStatusDto(VerificationStatus.INVALID);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package io.inji.verify.services;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import io.inji.verify.dto.presentation.VPDefinitionResponseDto;
import io.inji.verify.models.PresentationDefinition;
import io.inji.verify.spi.VPDefinitionService;
import io.inji.verify.repository.PresentationDefinitionRepository;
import io.inji.verify.spi.VPDefinitionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ public void shouldCreateNewAuthorizationRequest() {
when(mockPresentationDefinitionRepository.save(any(PresentationDefinition.class))).thenReturn(null);
when(mockAuthorizationRequestCreateResponseRepository.save(any(AuthorizationRequestCreateResponse.class))).thenReturn(null);

VPRequestCreateDto vpRequestCreateDto = new VPRequestCreateDto();
vpRequestCreateDto.setTransactionId("test_transaction_id");
vpRequestCreateDto.setClientId("test_client_id");
List<InputDescriptorDto> mockInputDescriptorDtos = mock();
List<SubmissionRequirementDto> mockSubmissionRequirementDtos = mock();
VPDefinitionResponseDto mockPresentationDefinitionDto = new VPDefinitionResponseDto("test_id", mockInputDescriptorDtos, mockSubmissionRequirementDtos);
VPRequestCreateDto vpRequestCreateDto = new VPRequestCreateDto("test_client_id","test_transaction_id",null,"",mockPresentationDefinitionDto);
vpRequestCreateDto.setPresentationDefinition(new VPDefinitionResponseDto("test_id", mockInputDescriptorDtos, mockSubmissionRequirementDtos));


VPRequestResponseDto responseDto = service.createAuthorizationRequest(vpRequestCreateDto);
Expand All @@ -62,11 +64,11 @@ public void shouldCreateNewAuthorizationRequest() {
}
@Test
public void shouldCreateAuthorizationRequestWithMissingTransactionId() {

VPRequestCreateDto vpRequestCreateDto = new VPRequestCreateDto();
vpRequestCreateDto.setClientId("test_client_id");
List<InputDescriptorDto> mockInputDescriptorDtos = mock();
List<SubmissionRequirementDto> mockSubmissionRequirementDtos = mock();
VPDefinitionResponseDto mockPresentationDefinitionDto = new VPDefinitionResponseDto("test_id", mockInputDescriptorDtos, mockSubmissionRequirementDtos);
VPRequestCreateDto vpRequestCreateDto = new VPRequestCreateDto("test_client_id",null,null,"",mockPresentationDefinitionDto);
vpRequestCreateDto.setPresentationDefinition(new VPDefinitionResponseDto("test_id", mockInputDescriptorDtos, mockSubmissionRequirementDtos));

VPRequestResponseDto responseDto = service.createAuthorizationRequest(vpRequestCreateDto);

Expand Down

0 comments on commit 988707d

Please sign in to comment.