Skip to content

Commit

Permalink
[INJICERT-13] VCI Segregation from eSignet (#10)
Browse files Browse the repository at this point in the history
* [INJICERT-13] VCI Segregation from eSignet
Signed-off-by: Challarao <[email protected]>

* [INJICERT-13] kernel core dependency version upgrade to java 21
Signed-off-by: Challarao <[email protected]>

* [INJICERT-13] removed unused methods and classes
Signed-off-by: Challarao <[email protected]>

* [INJICERT-13] changed esignet reference for jwt uri to certify
Signed-off-by: Challarao <[email protected]>

* [INJICERT-13] removed vci service impl module and refactored code
Signed-off-by: Challarao <[email protected]>

* [INJICERT-13] moved dependencies to parent and added license to all files
Signed-off-by: Challarao <[email protected]>
  • Loading branch information
challabeehyv authored May 30, 2024
1 parent 8e79f5e commit 492cebf
Show file tree
Hide file tree
Showing 73 changed files with 3,566 additions and 17 deletions.
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# other directories
target/
.idea/
*.p12
*.iml
.settings/
.setting/
.mvn/
.project/
helm/*/Chart.lock
helm/*/charts/
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ Execute installation script
* Set the hostname of the endpoints correctly as per your docker setup
* Now generate a DID, create a credential schema and create an issuance registry
* take note of `$.schema[0].author` and `$.schema[0].id` from the create credential schema request
6. Add the jar file of Digital Credential Stack(DCS) plugin implementation in [loader_path](docker-compose-esignet/loader_path). The JAR can be built [from source](https://github.com/mosip/digital-credential-plugins/) or [downloaded directly](https://mvnrepository.com/artifact/io.mosip.esignet.sunbirdrc/sunbird-rc-esignet-integration-impl).
7. Modify the properties of the Esignet service located in the [esignet-default.properties](docker-compose-esignet/config/esignet-default.properties) file:
6. Add the jar file of Digital Credential Stack(DCS) plugin implementation in [loader_path](docker-compose/docker-compose-esignet/loader_path). The JAR can be built [from source](https://github.com/mosip/digital-credential-plugins/) or [downloaded directly](https://mvnrepository.com/artifact/io.mosip.esignet.sunbirdrc/sunbird-rc-esignet-integration-impl).
7. Modify the properties of the Esignet service located in the [esignet-default.properties](docker-compose/docker-compose-esignet/config/esignet-default.properties) file:
- Include Issuer ID and credential schema ID for the following properties: `mosip.esignet.vciplugin.sunbird-rc.credential-type.{credential type}.static-value-map.issuerId`, `mosip.esignet.vciplugin.sunbird-rc.credential-type.{credential-type}.cred-schema-id`.
- The `$.schema[0].author` DID goes to the config ending in issuerId and `$.schema[0].id` DID goes to the config ending in `cred-schema-id`.
8. Once the Esignet properties are configured, proceed to select Esignet from the options provided for eSignet.
Expand All @@ -60,11 +60,11 @@ Execute installation script

## Properties for custom use case

- Sample schemas for Insurance registry are provided [here](docker-compose-sunbird/schemas), change it according to use case.
- Sample schemas for Insurance registry are provided [here](docker-compose/docker-compose-sunbird/schemas), change it according to use case.
- Change these properties for different use case `mosip.esignet.authenticator.sunbird-rc.auth-factor.kba.field-details`,`mosip.esignet.authenticator.sunbird-rc.auth-factor.kba.individual-id-field`
- Add the Sunbird registry URL for these properties: `mosip.esignet.vciplugin.sunbird-rc.issue-credential-url`,`mosip.esignet.authenticator.sunbird-rc.auth-factor.kba.registry-search-url`.
- Specify the list of supported credential types using the property: `mosip.esignet.vciplugin.sunbird-rc.supported-credential-types`.
- For each supported credential type change the below properties. Sample properties are provided in the [default properties](docker-compose-esignet/config/esignet-default.properties) file.
- For each supported credential type change the below properties. Sample properties are provided in the [default properties](docker-compose/docker-compose-esignet/config/esignet-default.properties) file.
* Issuer id `mosip.esignet.vciplugin.sunbird-rc.credential-type.{credential type}.static-value-map.issuerId`
* Credential schema id `mosip.esignet.vciplugin.sunbird-rc.credential-type.{credential type}.cred-schema-id`
* Registry Url `mosip.esignet.vciplugin.sunbird-rc.credential-type.{credential type}.registry-get-url`
Expand Down
39 changes: 39 additions & 0 deletions certify-core/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- 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/. -->
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.mosip.certify</groupId>
<artifactId>certify-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>

<groupId>io.mosip.certify</groupId>
<artifactId>certify-core</artifactId>
<name>certify-core</name>
<version>${project.parent.version}</version>
<description>Certify Core Library</description>

<dependencies>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>${springdoc-openapi-webmvc-ui-version}</version>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>${commons.validator.version}</version>
</dependency>
<dependency>
<groupId>io.mosip.certify</groupId>
<artifactId>certify-integration-api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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.core.config;

import java.io.IOException;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerExceptionResolver;

@Component
public class LocalAuthenticationEntryPoint implements AuthenticationEntryPoint {
@Autowired
private HandlerExceptionResolver handlerExceptionResolver;

public LocalAuthenticationEntryPoint() {
}

public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {
this.handlerExceptionResolver.resolveException(request, response, (Object)null, authException);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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.core.constants;

public class Constants {

public static final String UTC_DATETIME_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
public static final String SPACE = " ";

public static final String C_NONCE = "c_nonce";
public static final String C_NONCE_EXPIRES_IN = "c_nonce_expires_in";
public static final String CLIENT_ID = "client_id";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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.core.constants;

public class ErrorConstants {

public static final String INVALID_REQUEST="invalid_request";
public static final String INVALID_SCOPE="invalid_scope";
public static final String INVALID_AUTH_TOKEN="invalid_token";
public static final String INVALID_ALGORITHM = "invalid_algorithm";
public static final String UNKNOWN_ERROR = "unknown_error";
public static final String UNSUPPORTED_VC_FORMAT = "unsupported_credential_format";
public static final String INVALID_VC_FORMAT = "invalid_vc_format";
public static final String INVALID_PROOF = "invalid_proof";
public static final String UNSUPPORTED_PROOF_TYPE = "unsupported_proof_type";
public static final String UNSUPPORTED_VC_TYPE = "unsupported_credential_type";
public static final String VC_ISSUANCE_FAILED = "vc_issuance_failed";
public static final String PROOF_HEADER_INVALID_TYP = "proof_header_invalid_typ";
public static final String PROOF_HEADER_INVALID_ALG = "proof_header_invalid_alg";
public static final String PROOF_HEADER_INVALID_KEY = "proof_header_invalid_key";
public static final String PROOF_HEADER_AMBIGUOUS_KEY = "proof_header_ambiguous_key";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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.core.dto;


import com.fasterxml.jackson.annotation.JsonProperty;
import io.mosip.certify.core.constants.ErrorConstants;
import lombok.Data;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import java.util.List;
import java.util.Map;

@Data
public class CredentialDefinition {

@JsonProperty("@context")
private List<@NotBlank(message = ErrorConstants.INVALID_REQUEST) String> context;

@NotEmpty(message = ErrorConstants.INVALID_REQUEST)
private List<@NotBlank(message = ErrorConstants.INVALID_REQUEST) String> type;

private Map<String, Object> credentialSubject;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* 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.core.dto;

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

import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
@Data
public class CredentialMetadata {

private String id;
private String format;
private String scope;
private List<String> proof_types_supported;
private List<String> types;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.core.dto;

import io.mosip.certify.core.constants.ErrorConstants;
import lombok.Data;

import jakarta.validation.constraints.NotBlank;

@Data
public class CredentialProof {

/**
* The proof object MUST contain a proof_type claim of type JSON string denoting the concrete proof type.
*/
@NotBlank(message = ErrorConstants.UNSUPPORTED_PROOF_TYPE)
private String proof_type;

/**
* When proof_type is jwt, a proof object MUST include a jwt claim
*/
private String jwt;

/**
* When proof_type is cwt, a proof object MUST include a cwt claim
*/
private String cwt;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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.core.dto;

import io.mosip.certify.core.constants.ErrorConstants;
import jakarta.validation.Valid;
import lombok.Data;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;

@Data
public class CredentialRequest {

/**
* REQUIRED. Format of the Credential to be issued.
*/
@NotBlank(message = ErrorConstants.INVALID_VC_FORMAT)
private String format;

/**
* OPTIONAL.
* JSON object containing proof of possession of the key material the issued Credential shall be bound to.
*/
@Valid
@NotNull(message = ErrorConstants.INVALID_PROOF)
private CredentialProof proof;

/**
* "format": jwt_vc_json | jwt_vc_json-ld | ldp_vc
* REQUIRED
* JSON object containing (and isolating) the detailed description of the credential type.
* This object MUST be processed using full JSON-LD processing.
* It consists of the following sub claims:
* @context: REQUIRED. JSON array
* types: REQUIRED. JSON array. This claim contains the type values the Wallet shall request
* in the subsequent Credential Request.
*/
@Valid
@NotNull(message = ErrorConstants.INVALID_REQUEST)
private CredentialDefinition credential_definition;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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.core.dto;

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

@Data
public class CredentialResponse<T> {

/**
* JSON string denoting the format of the issued Credential.
*/
private String format;

/**
* Contains issued Credential. MUST be present when acceptance_token is not returned.
* MAY be a JSON string or a JSON object, depending on the Credential format.
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
private T credential;

/**
* A JSON string containing a security token subsequently used to obtain a Credential.
* MUST be present when credential is not returned
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
private String acceptance_token;

/**
* JSON string containing a nonce to be used to create a proof of possession of key material
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
private String c_nonce;

/**
* JSON integer denoting the lifetime in seconds of the c_nonce
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
private Integer c_nonce_expires_in;
}
20 changes: 20 additions & 0 deletions certify-core/src/main/java/io/mosip/certify/core/dto/Error.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 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.core.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Error {

private String errorCode;
private String errorMessage;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 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.core.dto;

import lombok.Data;
import org.springframework.stereotype.Component;

import java.util.Map;

@Data
@Component
public class ParsedAccessToken {

private Map<String, Object> claims;
private String accessTokenHash;
private boolean isActive;
}
Loading

0 comments on commit 492cebf

Please sign in to comment.