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

G2pc-registry changes #14

Open
wants to merge 64 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
d1aa5a3
Initial application structure
abhilashkadu Nov 9, 2023
89cd999
g2pc-core-lib sub repo added.
abhilashkadu Nov 9, 2023
efd4ca8
g2pc-dc-core-lib sub repo added.
abhilashkadu Nov 9, 2023
2d4ff49
g2pc-dp-core-lib sub repo added.
abhilashkadu Nov 9, 2023
7fe95fa
reference app g2pc-ref-dc-client sub repo added.
abhilashkadu Nov 9, 2023
46a7db0
reference app g2pc-ref-farmer-regsvc sub repo added.
abhilashkadu Nov 9, 2023
61d0324
reference app g2pc-ref-mno-regsvc sub repo added.
abhilashkadu Nov 9, 2023
dc13157
documents structure added.
abhilashkadu Nov 9, 2023
4f7b60d
Merge pull request #1 from abhilashkadu/alpha-1.0
vvujjini Nov 9, 2023
e16f8b9
registry draw.io file
vvujjini Nov 16, 2023
0c03d70
Update color index
vvujjini Nov 16, 2023
fda209a
Simplified index color codes
vvujjini Nov 28, 2023
fe6561f
index colour update
vvujjini Nov 28, 2023
72dab63
Refactored g2pc-core-lib changes.
abhilashkadu Dec 1, 2023
1b459c7
Refactored g2pc-dc-core-lib changes.
abhilashkadu Dec 1, 2023
6bb0686
Refactored g2pc-dp-core-lib changes.
abhilashkadu Dec 1, 2023
9eacb0e
Refactored g2pc-ref-dc-client changes.
abhilashkadu Dec 1, 2023
8f00c0a
Refactored g2pc-ref-dc-client changes-1.
abhilashkadu Dec 1, 2023
3b169d8
Refactored g2pc-ref-farmer-regsvc changes.
abhilashkadu Dec 1, 2023
667ae0a
Refactored g2pc-ref-mno-regsvc changes.
abhilashkadu Dec 1, 2023
e09ff50
Merge pull request #2 from abhilashkadu/alpha-1.0
vvujjini Dec 4, 2023
d1c9715
g2pc-core-lib changes.
abhilashkadu Dec 11, 2023
79ed5f4
g2pc-dc-core-lib changes.
abhilashkadu Dec 11, 2023
3b3309f
g2pc-dp-core-lib changes.
abhilashkadu Dec 11, 2023
2e71a66
g2pc-ref-dc-client changes.
abhilashkadu Dec 11, 2023
01d1965
g2pc-ref-farmer-regsvc changes.
abhilashkadu Dec 11, 2023
9f08ca9
g2pc-ref-mno-regsvc changes.
abhilashkadu Dec 11, 2023
0e0f7ee
Credentials updated.
abhilashkadu Dec 11, 2023
a74d6ab
Merge pull request #3 from abhilashkadu/alpha-1.0
vvujjini Dec 12, 2023
9b07861
Doc README.md and reference images
kshitijapatange Dec 13, 2023
528f9c0
Merge pull request #4 from kshitijapatange/alpha-1.0
vvujjini Dec 14, 2023
9b52701
g2pc-core-lib-changes
abhilashkadu Dec 17, 2023
04c2bc4
g2pc-dp-core-lib changes.
abhilashkadu Dec 17, 2023
8208b72
g2pc-ref-dc-client changes.
abhilashkadu Dec 17, 2023
1ff015a
g2pc-ref-farmer-regsvc changes.
abhilashkadu Dec 17, 2023
2666fad
Merge pull request #5 from abhilashkadu/alpha-1.0
vvujjini Dec 18, 2023
40e950d
Dc implementation added README.md and reference images
kshitijapatange Dec 19, 2023
bc139d5
reference images url updates and keycloak configuration steps added.
kshitijapatange Dec 20, 2023
3b49b8b
Merge pull request #6 from kshitijapatange/alpha-1.0
vvujjini Dec 21, 2023
e0f92a8
Updated README.md file with /status and /on-status , updated images url
kshitijapatange Dec 29, 2023
87acae0
Merge pull request #8 from kshitijapatange/alpha-1.0
vvujjini Jan 2, 2024
0fafa33
Updated sftp connection document and images.
kshitijapatange Jan 4, 2024
5b6e8e8
Merge pull request #9 from kshitijapatange/alpha-1.0
vvujjini Jan 8, 2024
68b4116
Updated README.md file with /status and /on-status , updated images url
kshitijapatange Jan 22, 2024
0c73560
Merge pull request #10 from kshitijapatange/alpha-1.0
vvujjini Jan 30, 2024
fda5e36
Updated README.md file with sunbird rc integration changes
kshitijapatange Jan 30, 2024
b9590a1
numbering updated
kshitijapatange Feb 8, 2024
1cfbdfa
Merge pull request #11 from kshitijapatange/alpha-1.0
vvujjini Feb 8, 2024
a176c37
g2pc-core-lib changes.
abhilashkadu Feb 14, 2024
84f3857
g2pc-dc-core-lib changes.
abhilashkadu Feb 14, 2024
7f97b6e
g2pc-dp-core-lib changes.
abhilashkadu Feb 14, 2024
21e2416
g2pc-dp-core-lib changes.
abhilashkadu Feb 14, 2024
4d7b979
g2pc-ref-dc-client changes.
abhilashkadu Feb 14, 2024
8866212
g2pc-ref-dc-client changes.
abhilashkadu Feb 14, 2024
58205af
g2pc-ref-farmer-regsvc changes.
abhilashkadu Feb 14, 2024
cbe4145
g2pc-ref-mno-regsvc changes.
abhilashkadu Feb 14, 2024
c336169
g2pc-ref-mno-regsvc changes.
abhilashkadu Feb 14, 2024
8cd4a2a
g2pc-core-lib-changes.
abhilashkadu Feb 14, 2024
e8b7a5c
g2pc-dc-core-lib application.yml changes.
abhilashkadu Feb 14, 2024
a383d63
g2pc-dp-core-lib application.yml changes
abhilashkadu Feb 14, 2024
c601985
g2pc-ref-dc-client application.yml changes
abhilashkadu Feb 14, 2024
9b036ba
g2pc-ref-farmer-regsvc application.yml changes
abhilashkadu Feb 14, 2024
e3b3287
g2pc-ref-mno-regsvc application.yml changes
abhilashkadu Feb 14, 2024
e29e77b
Merge pull request #13 from abhilashkadu/alpha-1.0
vvujjini Feb 14, 2024
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -22,3 +22,6 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*

.vscode/
.idea/
3,267 changes: 3,267 additions & 0 deletions docs/README.md

Large diffs are not rendered by default.

338 changes: 338 additions & 0 deletions docs/g2pc-registry_design.drawio

Large diffs are not rendered by default.

Binary file added docs/src/images/.p12-dc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/images/.p12-dp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/images/DC-DP-communication.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/images/HeaderDTORelationship.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/images/Sign-encry-table.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/images/dc-on-search-sequence-dia.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/images/dc-package-structure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/images/dc-seq-diagram-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/images/dp-package-strcuture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/images/dp-scheduler-seq-diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/images/dp-scheduler-sequence-dia.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/images/dp-search-sequence-diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/images/dp-specs-json.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/images/dp-specs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/images/dp_schema.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/images/filezila-folder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/images/filezilla-site-create.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/images/filezilla.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/images/keycloak-add-realm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/images/keycloak-client-auth-setting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/images/keycloak-create-client.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/images/keycloak-dc-client.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/images/keycloak-dp-client-secret.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/images/keycloak-realm-creation.png
Binary file added docs/src/images/keycloak-token-expiry.png
Binary file added docs/src/images/on_search_seqeunce_dia.png
Binary file added docs/src/images/on_search_spec.png
Binary file added docs/src/images/patload_postman.png
Binary file added docs/src/images/payload_sequence_diagram.png
Binary file added docs/src/images/search-endpoint-spec.png
Binary file added docs/src/images/search_sequence_diagram.png
Binary file added docs/src/images/spring_boot_dc_creation.png
Binary file added docs/src/images/spring_boot_dp_creation.png
36 changes: 36 additions & 0 deletions g2pc-core-lib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
mvnw
mvnw.cmd
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/
.idea/

73 changes: 73 additions & 0 deletions g2pc-core-lib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# G2pc Core Lib

## JSON schema validations
This project is an implementation of the JSON Schema Draft v4,

### When to use Json schema
Let'+s assume that you already know what JSON Schema is,
and you want to utilize it in a Java application to validate JSON data. But - as you may have already discovered - there is also an other Java implementation of the JSON Schema specification. So here are some advices about which one to use:

1. if you use Jackson to handle JSON in Java code, then java-json-tools/json-schema-validator is obviously a better choice, since it uses Jackson
2. if you want to use the org.json API then this library is the better choice
3. if you need JSON Schema Draft 6 / 7 support, then you need this library.

### Maven Dependency
````
<dependency>
<groupId>com.github.erosb</groupId>
<artifactId>everit-json-schema</artifactId>
<version>1.14.2</version>
</dependency>
````

### Where we used the json schema
* We have 2 end-points , /search and /on-search.
* In these end-points we are receiving 2 payloads respectively.
* Each payload had header and message.
* We are using JSON schema to validate the header and message as per G2p specifications.

#### Below are some samples schema which written in this project.
````
{
"$schema": "https://json-schema.org/draft-04/schema#",
"$id": "https://example.com/message.schema.json",
"title": "header schema",
"description": "",
"additionalProperties": false,
"type": "object",
"properties": {
"type": {
"type": "string"
},
"version" : {
"type": [ "string", "null" ]
},
},
"total_count": {
"type": "number"
},
"is_msg_encrypted": {
"type": ["boolean","null"],
"default": "false"
},
"meta": {
"type": [ "object", "null" ]
}
},
"required": ["message_id","message_ts","action","sender_id","total_count"],
"definitions": {
"nonEmptyString": {
"type": "string",
"minLength": 1
}
}
}
````

Using below code we can read the above schema json
````
InputStream schemaStream = CommonUtils.class.getClassLoader()
.getResourceAsStream("schema/ResponseMessageschema.json");
````


119 changes: 119 additions & 0 deletions g2pc-core-lib/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<?xml version="1.0" encoding="UTF-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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.12</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>g2pc.core.lib</groupId>
<artifactId>g2pc-core-library</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>g2p-core</name>
<description>Common-g2pc-specifications-library</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.15.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>com.networknt</groupId>
<artifactId>json-schema-validator</artifactId>
<version>1.0.82</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>6.2.0</version>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>4.4.0</version>
</dependency>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>6.1.2</version>
</dependency>
<dependency>
<groupId>com.konghq</groupId>
<artifactId>unirest-java</artifactId>
<version>3.14.2</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>5.0.0-alpha2</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
</dependency>

<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.55</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-sftp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.10.0</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.10.2</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package g2pc.core.lib.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ElasticsearchConfig {

@Value("${sunbird.elasticsearch.host}")
private String elasticsearchHost;

@Value("${sunbird.elasticsearch.port}")
private int elasticsearchPort;

@Value("${sunbird.elasticsearch.scheme}")
private String elasticsearchScheme;

@Bean
public RestHighLevelClient client() {
return new RestHighLevelClient(
RestClient.builder(
new HttpHost(elasticsearchHost, elasticsearchPort, elasticsearchScheme)
)
);
}
}
23 changes: 23 additions & 0 deletions g2pc-core-lib/src/main/java/g2pc/core/lib/config/G2pUnirest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package g2pc.core.lib.config;


import kong.unirest.GetRequest;
import kong.unirest.HttpRequestWithBody;
import kong.unirest.UnirestException;

public interface G2pUnirest {

String getG2pApiCall(String uri, String token) throws UnirestException;

String getG2pApiCall(String uri) throws UnirestException;

HttpRequestWithBody g2pPost(String uri);

HttpRequestWithBody g2pPut(String uri);

HttpRequestWithBody g2pDelete(String uri);

HttpRequestWithBody g2pPatch(String uri);

GetRequest g2pGet(String uri);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package g2pc.core.lib.config;


import g2pc.core.lib.security.context.UnirestContext;
import kong.unirest.GetRequest;
import kong.unirest.HttpRequestWithBody;
import kong.unirest.Unirest;
import kong.unirest.UnirestException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.util.Collections;
import java.util.Map;

@Configuration
@Slf4j
@EnableScheduling
@Lazy
public class G2pUnirestHelper implements G2pUnirest {

private static final String AUTH = "Authorization";


protected GetRequest setG2pHeaders(GetRequest request) {
return setG2pHeaders(request, Collections.emptyMap());
}

protected GetRequest setG2pHeaders(GetRequest request, Map<String, String> keyVal) {
if (null != keyVal)
keyVal.forEach((k, v) -> request.header(k, v));
return request;
}

protected HttpRequestWithBody setG2pHeaders(HttpRequestWithBody request) {
UnirestContext unirestContext = new UnirestContext();
if (null != unirestContext && StringUtils.isNotBlank(unirestContext.getJwtHeader())) {
request.header(AUTH, unirestContext.getJwtHeader());
}
return request;
}

public String getG2pApiCall(String uri, String token) throws UnirestException {

return setG2pHeaders(Unirest.get(uri), Map.of(AUTH, "Bearer " + token))
.asString()
.getBody();

}

public String getG2pApiCall(String uri) throws UnirestException {

return setG2pHeaders(Unirest.get(uri))
.asString()
.getBody();

}

public HttpRequestWithBody g2pPost(String uri) {
return setG2pHeaders(Unirest.post(uri));
}

public HttpRequestWithBody g2pPut(String uri) {
return setG2pHeaders(Unirest.put(uri));
}

public HttpRequestWithBody g2pDelete(String uri) {
return setG2pHeaders(Unirest.delete(uri));
}

public HttpRequestWithBody g2pPatch(String uri) {
return setG2pHeaders(Unirest.patch(uri));
}

public GetRequest g2pGet(String uri) {
return setG2pHeaders(Unirest.get(uri));
}

}
Loading