├── source
├── did-common-sdk-server
│ ├── .gitignore
│ ├── settings.gradle
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── src
│ │ └── main
│ │ │ └── java
│ │ │ └── org
│ │ │ └── omnione
│ │ │ └── did
│ │ │ └── common
│ │ │ ├── util
│ │ │ ├── HexUtil.java
│ │ │ ├── NonceGenerator.java
│ │ │ ├── IdGenerator.java
│ │ │ ├── DidValidator.java
│ │ │ ├── DidUtil.java
│ │ │ ├── QrMaker.java
│ │ │ ├── HttpClientUtil.java
│ │ │ ├── JsonUtil.java
│ │ │ └── DateTimeUtil.java
│ │ │ ├── exception
│ │ │ ├── HttpClientException.java
│ │ │ ├── ErrorResponse.java
│ │ │ ├── CommonSdkException.java
│ │ │ └── ErrorCode.java
│ │ │ └── vo
│ │ │ └── QrImageData.java
│ ├── build.gradle
│ ├── gradlew.bat
│ ├── README.md
│ └── gradlew
└── release
│ └── did-sdk-common-2.0.0.jar
├── CHANGELOG.md
├── MAINTAINERS.md
├── .github
├── pull_request_template.yml
├── workflows
│ ├── ci.yml
│ ├── auto-assign.yml
│ └── build.yml
└── ISSUE_TEMPLATE
│ ├── bug_report.yaml
│ └── feature_request.yaml
├── SECURITY.md
├── docs
├── api
│ ├── Server Common SDK_HexUtil.md
│ ├── Server Common SDK_DidUtil.md
│ ├── Server Common SDK_DidValidator.md
│ ├── Server Common SDK_JsonUtil.md
│ ├── Server Common SDK_QrMaker.md
│ ├── Server Common SDK_HttpClientUtil.md
│ └── Server Common SDK_DateTimeUtil.md
└── errorCode
│ └── Common_ErrorCode.md
├── dependencies-license.md
├── .gitignore
├── README_ko.md
├── RELEASE-PROCESS.md
├── README.md
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── CLA.md
└── LICENSE
/source/did-common-sdk-server/.gitignore:
--------------------------------------------------------------------------------
1 | **/.gradle/
2 | **/build/
--------------------------------------------------------------------------------
/source/did-common-sdk-server/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = "common"
--------------------------------------------------------------------------------
/source/release/did-sdk-common-2.0.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OmniOneID/did-common-sdk-server/HEAD/source/release/did-sdk-common-2.0.0.jar
--------------------------------------------------------------------------------
/source/did-common-sdk-server/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OmniOneID/did-common-sdk-server/HEAD/source/did-common-sdk-server/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## v1.0.0 (2024-10-18)
4 |
5 | ### 🚀 New Features
6 | - Common Server SDK
7 | - DateTime Util
8 | - DID Util
9 | - DID Validator Util
10 | - Http Client Util
11 | - ID Generator Util
12 | - JSON Util
13 | - Qr Maker Util
--------------------------------------------------------------------------------
/source/did-common-sdk-server/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/MAINTAINERS.md:
--------------------------------------------------------------------------------
1 | # Maintainers
2 |
3 | ## Overview
4 |
5 | This file lists the maintainers for this project. Maintainers are responsible for reviewing and merging pull requests, ensuring code quality, and managing releases.
6 | If you have any questions or require support, please reach out to the maintainers listed below.
7 |
8 | ## Maintainers
9 |
10 | | Name | GitHub | Email |
11 | | ----------- | ----------- | ---------------------- |
12 | | Yoongyu Lee | yoongyu-lee | yklee0911@raoncorp.com |
--------------------------------------------------------------------------------
/.github/pull_request_template.yml:
--------------------------------------------------------------------------------
1 | ## Description
2 |
3 |
4 | ## Related Issue (Optional)
5 |
6 | - Issue # (e.g., #123)
7 |
8 | ## Changes
9 |
10 | - Change 1
11 | - Change 2
12 |
13 | ## Screenshots (Optional)
14 |
15 |
16 | ## Additional Comments (Optional)
17 |
18 |
--------------------------------------------------------------------------------
/source/did-common-sdk-server/src/main/java/org/omnione/did/common/util/HexUtil.java:
--------------------------------------------------------------------------------
1 | package org.omnione.did.common.util;
2 |
3 | /**
4 | * Utility class for converting byte arrays to hexadecimal string representation.
5 | * This class provides a method to convert an array of bytes into a hexadecimal string.
6 | *
7 | */
8 | public class HexUtil {
9 | public static String toHexString(byte[] bytes) {
10 | StringBuilder hexString = new StringBuilder();
11 | for (byte b : bytes) {
12 | hexString.append(String.format("%02x", b));
13 | }
14 | return hexString.toString();
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/source/did-common-sdk-server/src/main/java/org/omnione/did/common/exception/HttpClientException.java:
--------------------------------------------------------------------------------
1 | package org.omnione.did.common.exception;
2 |
3 | public class HttpClientException extends Exception {
4 | private final int statusCode;
5 | private final String responseBody;
6 |
7 | public HttpClientException(int statusCode, String responseBody) {
8 | super("HTTP error with status code " + statusCode);
9 | this.statusCode = statusCode;
10 | this.responseBody = responseBody;
11 | }
12 |
13 | public int getStatusCode() {
14 | return statusCode;
15 | }
16 |
17 | public String getResponseBody() {
18 | return responseBody;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: Java CI with Gradle
2 | on:
3 | push:
4 | branches: [ main, develop ]
5 | pull_request:
6 | branches: [ main, develop ]
7 |
8 |
9 | jobs:
10 | build:
11 | runs-on: ubuntu-latest
12 | defaults:
13 | run:
14 | working-directory: source/did-common-sdk-server
15 | permissions:
16 | contents: read
17 | steps:
18 | - uses: actions/checkout@v4
19 | - name: Set up JDK 21
20 | uses: actions/setup-java@v4
21 | with:
22 | java-version: '21'
23 | distribution: 'temurin'
24 |
25 | - name: Test with Gradle Wrapper
26 | run: ./gradlew test
27 |
28 | - name: Build with Gradle Wrapper
29 | run: ./gradlew clean build
30 |
--------------------------------------------------------------------------------
/source/did-common-sdk-server/src/main/java/org/omnione/did/common/util/NonceGenerator.java:
--------------------------------------------------------------------------------
1 | package org.omnione.did.common.util;
2 |
3 | import java.security.SecureRandom;
4 | import java.util.Arrays;
5 |
6 | /**
7 | * NonceGenerator is a utility class that provides methods for generating
8 | * cryptographically secure random nonces. These nonces are often used
9 | * in security protocols to prevent replay attacks and ensure uniqueness.
10 | */
11 | public class NonceGenerator {
12 | /**
13 | * Generate a 16-byte random nonce.
14 | * @return 16-byte random nonce
15 | */
16 | public static byte[] generate16ByteNonce() {
17 | SecureRandom random = new SecureRandom();
18 | byte[] nonce = new byte[16];
19 | random.nextBytes(nonce);
20 |
21 | return nonce;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/source/did-common-sdk-server/src/main/java/org/omnione/did/common/vo/QrImageData.java:
--------------------------------------------------------------------------------
1 | package org.omnione.did.common.vo;
2 |
3 | /**
4 | * QR Code Image Data
5 | */
6 | public class QrImageData {
7 | private String mediaType;
8 | private String format;
9 | private byte[] qrIamge;
10 |
11 | public String getMediaType() {
12 | return mediaType;
13 | }
14 |
15 | public void setMediaType(String mediaType) {
16 | this.mediaType = mediaType;
17 | }
18 |
19 | public String getFormat() {
20 | return format;
21 | }
22 |
23 | public void setFormat(String format) {
24 | this.format = format;
25 | }
26 |
27 | public byte[] getQrIamge() {
28 | return qrIamge;
29 | }
30 |
31 | public void setQrIamge(byte[] qrIamge) {
32 | this.qrIamge = qrIamge;
33 | }
34 | }
35 |
36 |
--------------------------------------------------------------------------------
/source/did-common-sdk-server/src/main/java/org/omnione/did/common/util/IdGenerator.java:
--------------------------------------------------------------------------------
1 | package org.omnione.did.common.util;
2 |
3 | import java.util.UUID;
4 |
5 | /**
6 | * Utility class for generating UUIDs.
7 | * This class provides methods for generating random Transaction IDs and Offer IDs.
8 | */
9 | public class IdGenerator {
10 |
11 | /**
12 | * Generate a random Transaction ID.
13 | * This method uses the built-in Java UUID class to generate a random UUID string.
14 | * @return a random Transaction ID
15 | */
16 | public static String generateTxId() {
17 | return UUID.randomUUID().toString();
18 | }
19 |
20 | /**
21 | * Generate a random Offer ID.
22 | * This method uses the built-in Java UUID class to generate a random UUID string.
23 | * @return a random Offer ID
24 | */
25 | public static String generateOfferId() {
26 | return UUID.randomUUID().toString();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Policy
2 |
3 | ## Supported Versions
4 | In this project, the following versions have undergone security vulnerability assessments:
5 |
6 | | Version | Supported |
7 | | ------- | ------------------ |
8 | | 1.0.0 | ✅ |
9 |
10 | ## Reporting a Vulnerability
11 | If you discover a new security vulnerability, please report it via [technicalogy@omnione.net](mailto:technicalogy@omnione.net).
12 |
13 | ## Sensitive Information Protection
14 | Please ensure that sensitive information, such as API keys, passwords, and personal data, is never included in the code or documentation. Such information should be managed outside the code, preferably using environment variables.
15 |
16 | ## Security Policy Configuration
17 | - Vulnerability Management: If a vulnerability is discovered, follow the security reporting procedures and collaborate to apply security patches as quickly as possible.
18 | - Code Review: Any changes related to security must always go through the review process, and multiple contributors should be involved in the review to ensure thorough checks.
--------------------------------------------------------------------------------
/source/did-common-sdk-server/src/main/java/org/omnione/did/common/exception/ErrorResponse.java:
--------------------------------------------------------------------------------
1 | package org.omnione.did.common.exception;
2 |
3 |
4 | /**
5 | * Error Response
6 | */
7 | public class ErrorResponse {
8 | private final String code;
9 | private final String description;
10 |
11 | /**
12 | * Constructor
13 | *
14 | * @param code Error Code
15 | * @param description Error Description
16 | */
17 | public ErrorResponse(String code, String description) {
18 | this.code = code;
19 | this.description = description;
20 | }
21 |
22 | /**
23 | * Constructor
24 | *
25 | * @param errorCode Error Code
26 | */
27 | public ErrorResponse(ErrorCode errorCode) {
28 | this.code = errorCode.getCode();
29 | this.description = errorCode.getMessage();
30 | }
31 |
32 | public String getCode() {
33 | return code;
34 | }
35 |
36 | public String getDescription() {
37 | return description;
38 | }
39 |
40 | @Override
41 | public String toString() {
42 | return String.format("ErrorResponse{code='%s', description='%s'}", code, description);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/source/did-common-sdk-server/src/main/java/org/omnione/did/common/exception/CommonSdkException.java:
--------------------------------------------------------------------------------
1 | package org.omnione.did.common.exception;
2 |
3 |
4 | /**
5 | * Custom exception class for OpenDID-related errors.
6 | * This exception encapsulates an ErrorCode to provide more detailed error information.
7 | *
8 | */
9 |
10 | public class CommonSdkException extends RuntimeException{
11 | private ErrorCode errorCode;
12 | private ErrorResponse errorResponse;
13 |
14 | /**
15 | * Constructs a new OpenDidException with the specified error code.
16 | *
17 | * @param errorCode The ErrorCode enum value representing the specific error.
18 | */
19 | public CommonSdkException(ErrorCode errorCode) {
20 | super(errorCode.getMessage());
21 | this.errorCode = errorCode;
22 | }
23 |
24 | /**
25 | * Constructs a new OpenDidException with the specified error response.
26 | *
27 | * @param errorResponse The ErrorResponse object representing the specific error.
28 | */
29 | public CommonSdkException(ErrorResponse errorResponse) {
30 | super(errorResponse.getDescription());
31 | this.errorResponse = errorResponse;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.yaml:
--------------------------------------------------------------------------------
1 | name: Bug Report
2 | description: File a bug report.
3 | title: "[Bug]: "
4 | labels: ["bug", "triage"]
5 | assignees: [""]
6 | body:
7 | - type: markdown
8 | attributes:
9 | value: |
10 | Thanks for taking the time to fill out this bug report!
11 | - type: textarea
12 | id: what-happened
13 | attributes:
14 | label: What happened?
15 | description: Also tell us, what did you expect to happen?
16 | placeholder: Tell us what you see!
17 | validations:
18 | required: true
19 | - type: input
20 | id: version
21 | attributes:
22 | label: Version
23 | description: What version of our software are you running?
24 | validations:
25 | required: true
26 | - type: textarea
27 | id: logs
28 | attributes:
29 | label: Relevant log output
30 | description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
31 | render: shell
32 | - type: checkboxes
33 | id: terms
34 | attributes:
35 | label: Code of Conduct
36 | description: By submitting this issue, you agree to follow our [Code of Conduct](../blob/main/CODE_OF_CONDUCT.md).
37 | options:
38 | - label: I agree to follow this project's Code of Conduct
39 | required: true
40 |
--------------------------------------------------------------------------------
/source/did-common-sdk-server/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'java'
3 | id 'org.asciidoctor.convert' version '2.2.0'
4 | id 'com.github.jk1.dependency-license-report' version '2.0'
5 | }
6 |
7 | group = 'org.omnione.did'
8 | version = '2.0.0'
9 | sourceCompatibility = '21'
10 |
11 | configurations {
12 | compileOnly {
13 | extendsFrom annotationProcessor
14 | }
15 | }
16 |
17 | repositories {
18 | mavenCentral()
19 | }
20 |
21 | dependencies {
22 | implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.1'
23 | implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.15.1'
24 |
25 | // QR Image
26 | implementation 'com.google.zxing:javase:3.5.1'
27 |
28 |
29 | testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.9.3'
30 | }
31 |
32 | tasks.named('test') {
33 | useJUnitPlatform()
34 | }
35 |
36 | jar {
37 | archiveBaseName.set('did-sdk-common')
38 | archiveVersion.set(version)
39 | archiveClassifier.set('')
40 | }
41 |
42 | import com.github.jk1.license.render.*
43 | import com.github.jk1.license.filter.LicenseBundleNormalizer
44 | import com.github.jk1.license.filter.ExcludeTransitiveDependenciesFilter
45 |
46 | licenseReport {
47 | outputDir = "$projectDir/build/licenses"
48 | renderers = [new InventoryMarkdownReportRenderer()]
49 | filters = [new LicenseBundleNormalizer(), new ExcludeTransitiveDependenciesFilter()]
50 | }
51 |
--------------------------------------------------------------------------------
/docs/api/Server Common SDK_HexUtil.md:
--------------------------------------------------------------------------------
1 | ---
2 | puppeteer:
3 | pdf:
4 | format: A4
5 | displayHeaderFooter: true
6 | landscape: false
7 | scale: 0.8
8 | margin:
9 | top: 1.2cm
10 | right: 1cm
11 | bottom: 1cm
12 | left: 1cm
13 | image:
14 | quality: 100
15 | fullPage: false
16 | ---
17 |
18 | # Server Common SDK API - HexUtil
19 |
20 | - Date: 2024-09-02
21 | - Version: v1.0.0
22 |
23 | | Version | Date | History |
24 | | ------- | ---------- | ------------------------|
25 | | v1.0.0 | 2024-09-02 | Initial |
26 |
27 |
28 |
29 | # Table of Contents
30 |
31 | - [1. toHexString](#1-tohexstring)
32 |
33 | # APIs
34 |
35 | ## 1. toHexString
36 |
37 | ### Description
38 | Converts a byte array to a hexadecimal string.
39 |
40 | ### Declaration
41 |
42 | ```java
43 | public static String toHexString(byte[] bytes)
44 | ```
45 |
46 | ### Parameters
47 |
48 | | Name | Type | Description |
49 | |-------|---------|-----------------------|
50 | | bytes | byte[] | Byte array to convert |
51 |
52 | ### Returns
53 |
54 | | Type | Description |
55 | |--------|--------------------------------------------------|
56 | | String | The value of the byte array converted to a hexadecimal string |
57 |
58 | ### Usage
59 | ```java
60 | byte[] data = {0x01, 0x2A, 0x3F};
61 | String hex = HexUtil.toHexString(data); // returns "012a3f"
62 | ```
63 |
--------------------------------------------------------------------------------
/source/did-common-sdk-server/src/main/java/org/omnione/did/common/util/DidValidator.java:
--------------------------------------------------------------------------------
1 | package org.omnione.did.common.util;
2 |
3 | import java.util.regex.Matcher;
4 | import java.util.regex.Pattern;
5 |
6 |
7 | /**
8 | * The DidValidator class provides utility methods for validating and extracting
9 | * information from DID and DID KEy URL. It includes methods for:
10 | */
11 | public class DidValidator {
12 | private static final String DID_REGEX = "^did:[a-z0-9]+:(?:[a-zA-Z0-9._%-]*:)*[a-zA-Z0-9._%-]+$";
13 | private static final String DID_KEY_URL_REGEX = "^did:[a-z0-9]+:[a-zA-Z0-9._%-]+\\?versionId=\\d+#.+$";
14 |
15 | private static final Pattern DID_PATTERN = Pattern.compile(DID_REGEX);
16 | private static final Pattern DID_KEY_URL_PATTERN = Pattern.compile(DID_KEY_URL_REGEX);
17 |
18 | /**
19 | * Validate the format of a given DID string.
20 | * @param did The DID string to validate
21 | * @return true if the DID string is valid, false otherwise
22 | */
23 | public static boolean isValidDid(String did) {
24 | if (did == null) {
25 | return false;
26 | }
27 |
28 | Matcher matcher = DID_PATTERN.matcher(did);
29 | return matcher.matches();
30 | }
31 |
32 | /**
33 | * Validate the format of a given DID Key URL string.
34 | * @param didKeyUrl The DID Key URL string to validate
35 | * @return true if the DID Key URL string is valid, false otherwise
36 | */
37 | public static boolean isValidDidKeyUrl(String didKeyUrl) {
38 | if (didKeyUrl == null) {
39 | return false;
40 | }
41 |
42 | Matcher matcher = DID_KEY_URL_PATTERN.matcher(didKeyUrl);
43 | return matcher.matches();
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/.github/workflows/auto-assign.yml:
--------------------------------------------------------------------------------
1 | name: PR assignment
2 | on:
3 | pull_request_target:
4 | types: [opened, edited, synchronize, reopened, ready_for_review]
5 |
6 | permissions:
7 | contents: read
8 | issues: write
9 | pull-requests: write
10 |
11 | jobs:
12 | auto-assign:
13 | runs-on: ubuntu-latest
14 | steps:
15 | - name: Request Reviewers
16 | uses: actions/github-script@v6
17 | with:
18 | script: |
19 | const author = context.payload.pull_request.user.login;
20 | let reviewers = ['jinhwankim6557', 'gw-nam', 'yoongyu-lee'];
21 |
22 | if (reviewers.includes(author)) {
23 | if(reviewers.length === 1)
24 | reviewers = reviewers.map(reviewer => reviewer === author ? 'mikyung-lee' : reviewer);
25 | else {
26 | reviewers = reviewers.filter(reviewer => reviewer !== author);
27 | }
28 | }
29 |
30 | await github.rest.pulls.requestReviewers({
31 | owner: context.repo.owner,
32 | repo: context.repo.repo,
33 | pull_number: context.payload.pull_request.number,
34 | reviewers: reviewers
35 | });
36 | - name: Assign PR author and reviewers
37 | uses: actions/github-script@v6
38 | with:
39 | script: |
40 | const assignees = ['mikyung-lee', 'yoongyu-lee']; // assignees
41 |
42 | await github.rest.issues.addAssignees({
43 | owner: context.repo.owner,
44 | repo: context.repo.repo,
45 | issue_number: context.payload.pull_request.number,
46 | assignees: assignees
47 | });
--------------------------------------------------------------------------------
/docs/api/Server Common SDK_DidUtil.md:
--------------------------------------------------------------------------------
1 | ---
2 | puppeteer:
3 | pdf:
4 | format: A4
5 | displayHeaderFooter: true
6 | landscape: false
7 | scale: 0.8
8 | margin:
9 | top: 1.2cm
10 | right: 1cm
11 | bottom: 1cm
12 | left: 1cm
13 | image:
14 | quality: 100
15 | fullPage: false
16 | ---
17 |
18 | # Server Common SDK API - DidUtil
19 |
20 | - Date: 2024-09-02
21 | - Version: v1.0.0
22 |
23 | | Version | Date | History |
24 | | ------- | ---------- | ------------------------|
25 | | v1.0.0 | 2024-09-02 | Initial |
26 |
27 |
28 |
29 | # Table of Contents
30 |
31 | - [1. extractDid](#1-extractdid)
32 |
33 | # APIs
34 |
35 | ## 1. extractDid
36 |
37 | ### Description
38 | Extracts a DID from the given DID URL by removing query or fragment components.
39 |
40 | ### Declaration
41 |
42 | ```java
43 | public static String extractDid(String didKeyUrl)
44 | ```
45 |
46 | ### Parameters
47 |
48 | | Name | Type | Description |
49 | |-----------|--------|-----------------------------------------------------------------------------|
50 | | didKeyUrl | String | Full DID Key URL string including query parameters or fragments |
51 |
52 | ### Returns
53 |
54 | | Type | Description |
55 | |--------|-------------------------------------------------------------|
56 | | String | Pure DID without query parameters or fragments |
57 |
58 | ### Usage
59 | ```java
60 | String didKeyUrl = "did:example:123456?version=2#pin";
61 | String did = DidUtil.extractDid(didKeyUrl); // returns "did:example:123456"
62 | ```
63 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.yaml:
--------------------------------------------------------------------------------
1 | name: Feature request
2 | description: Suggest an idea for this project
3 | title: "[Feature]: "
4 | labels: ["enhancement"]
5 |
6 | body:
7 | - type: markdown
8 | attributes:
9 | value: |
10 | Thanks for taking the time to fill out this feature request!
11 |
12 | - type: textarea
13 | id: feature
14 | attributes:
15 | label: Feature Description
16 | description: Please provide a detailed description of the feature.
17 | placeholder: Describe the feature you are requesting.
18 | validations:
19 | required: true
20 |
21 | - type: textarea
22 | id: purpose
23 | attributes:
24 | label: Purpose
25 | description: What is the main purpose of this feature? Why is it needed?
26 | placeholder: Explain the purpose of the feature.
27 | validations:
28 | required: true
29 |
30 | - type: textarea
31 | id: background
32 | attributes:
33 | label: Background
34 | description: Provide any relevant context or background information for this feature.
35 | placeholder: Provide background information.
36 | validations:
37 | required: false
38 |
39 | - type: textarea
40 | id: expected_outcome
41 | attributes:
42 | label: Expected Outcome
43 | description: What are the expected results of implementing this feature?
44 | placeholder: Explain the expected results or impact.
45 | validations:
46 | required: true
47 |
48 | - type: checkboxes
49 | id: terms
50 | attributes:
51 | label: Code of Conduct
52 | description: By submitting this issue, you agree to follow our [Code of Conduct](../blob/main/CODE_OF_CONDUCT.md).
53 | options:
54 | - label: I agree to follow this project's Code of Conduct
55 | required: true
--------------------------------------------------------------------------------
/source/did-common-sdk-server/src/main/java/org/omnione/did/common/util/DidUtil.java:
--------------------------------------------------------------------------------
1 | package org.omnione.did.common.util;
2 |
3 | /**
4 | * The DidUtil class provides utility methods for working with DID.
5 | * This class includes methods for:
6 | */
7 | public class DidUtil {
8 |
9 | /**
10 | * Extract the DID from a given DID URL, removing any query or fragment components.
11 | * @param didKeyUrl The full DID URL string which may contain query parameters or fragments.
12 | * @return The DID without any query parameters or fragments.
13 | */
14 | public static String extractDid(String didKeyUrl) {
15 | if (didKeyUrl == null) {
16 | return null;
17 | }
18 |
19 | int queryIndex = didKeyUrl.indexOf('?');
20 | int fragmentIndex = didKeyUrl.indexOf('#');
21 |
22 | int endIndex = didKeyUrl.length();
23 |
24 | if (queryIndex != -1) {
25 | endIndex = queryIndex;
26 | }
27 |
28 | if (fragmentIndex != -1 && (fragmentIndex < endIndex)) {
29 | endIndex = fragmentIndex;
30 | }
31 |
32 | return didKeyUrl.substring(0, endIndex);
33 | }
34 |
35 | /**
36 | * Extract the key ID from a given DID Key URL, removing any query or fragment components.
37 | *
38 | * @param didKeyUrl The full DID Key URL string which may contain query parameters or fragments.
39 | * @return The key ID without any query parameters or fragments.
40 | */
41 | public static String extractKeyId(String didKeyUrl) {
42 | if (didKeyUrl == null) {
43 | return null;
44 | }
45 |
46 | int fragmentIndex = didKeyUrl.indexOf('#');
47 | if (fragmentIndex == -1) {
48 | throw new IllegalArgumentException("URL does not contain a fragment identifier (#).");
49 | }
50 |
51 | return didKeyUrl.substring(fragmentIndex + 1);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/dependencies-license.md:
--------------------------------------------------------------------------------
1 | # Project Dependency License Report
2 |
3 | This document provides a detailed overview of the licenses associated with the third-party dependencies used in this project. Each section lists dependencies under a specific license and includes information about the group, name, version, and license details of each dependency.
4 |
5 | ## Apache License, Version 2.0
6 |
7 | **1** **Group:** `com.fasterxml.jackson.core` **Name:** `jackson-databind` **Version:** `2.15.1`
8 | > - **Project URL**: [https://github.com/FasterXML/jackson](https://github.com/FasterXML/jackson)
9 | > - **Manifest License**: Apache License, Version 2.0 (Not Packaged)
10 | > - **POM License**: Apache License, Version 2.0 - [https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)
11 | > - **Embedded license files**: [jackson-databind-2.15.1.jar/META-INF/LICENSE](jackson-databind-2.15.1.jar/META-INF/LICENSE)
12 | - [jackson-databind-2.15.1.jar/META-INF/NOTICE](jackson-databind-2.15.1.jar/META-INF/NOTICE)
13 |
14 | **2** **Group:** `com.fasterxml.jackson.datatype` **Name:** `jackson-datatype-jsr310` **Version:** `2.15.1`
15 | > - **Manifest Project URL**: [https://github.com/FasterXML/jackson-modules-java8/jackson-datatype-jsr310](https://github.com/FasterXML/jackson-modules-java8/jackson-datatype-jsr310)
16 | > - **Manifest License**: Apache License, Version 2.0 (Not Packaged)
17 | > - **POM License**: Apache License, Version 2.0 - [https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)
18 | > - **Embedded license files**: [jackson-datatype-jsr310-2.15.1.jar/META-INF/LICENSE](jackson-datatype-jsr310-2.15.1.jar/META-INF/LICENSE)
19 | - [jackson-datatype-jsr310-2.15.1.jar/META-INF/NOTICE](jackson-datatype-jsr310-2.15.1.jar/META-INF/NOTICE)
20 |
21 | **3** **Group:** `com.google.zxing` **Name:** `javase` **Version:** `3.5.1`
22 | > - **POM License**: Apache License, Version 2.0 - [https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)
--------------------------------------------------------------------------------
/docs/api/Server Common SDK_DidValidator.md:
--------------------------------------------------------------------------------
1 | ---
2 | puppeteer:
3 | pdf:
4 | format: A4
5 | displayHeaderFooter: true
6 | landscape: false
7 | scale: 0.8
8 | margin:
9 | top: 1.2cm
10 | right: 1cm
11 | bottom: 1cm
12 | left: 1cm
13 | image:
14 | quality: 100
15 | fullPage: false
16 | ---
17 |
18 | # Server Common SDK API - DidValidator
19 |
20 | - Date: 2024-09-02
21 | - Version: v1.0.0
22 |
23 | | Version | Date | History |
24 | | ------- | ---------- | ------------------------|
25 | | v1.0.0 | 2024-09-02 | Initial |
26 |
27 |
28 |
29 | # Table of Contents
30 |
31 | - [1. isValidDid](#1-isvaliddid)
32 | - [2. isValidDidKeyUrl](#2-isvaliddidkeyurl)
33 |
34 | # APIs
35 |
36 | ## 1. isValidDid
37 |
38 | ### Description
39 | Validates the format of the given DID string.
40 |
41 | ### Declaration
42 |
43 | ```java
44 | public static boolean isValidDid(String did)
45 | ```
46 |
47 | ### Parameters
48 |
49 | | Name | Type | Description |
50 | |------|--------|------------------|
51 | | did | String | DID string to be verified |
52 |
53 | ### Returns
54 |
55 | | Type | Description |
56 | |---------|--------------------------------------------|
57 | | boolean | true if the DID is valid, otherwise false |
58 |
59 | ### Usage
60 | ```java
61 | String did = "did:omn:abcdefghijklmn";
62 | boolean isValid = DidValidator.isValidDid(did); // returns true if the DID is valid
63 | ```
64 |
65 |
66 |
67 | ## 2. isValidDidKeyUrl
68 |
69 | ### Description
70 | Verifies the format of the given DID Key URL string.
71 |
72 | ### Declaration
73 |
74 | ```java
75 | public static boolean isValidDidKeyUrl(String didKeyUrl)
76 | ```
77 |
78 | ### Parameters
79 |
80 | | Name | Type | Description |
81 | |-----------|--------|--------------------------------------|
82 | | didKeyUrl | String | DID Key URL string to be verified |
83 |
84 | ### Returns
85 |
86 | | Type | Description |
87 | |---------|--------------------------------------------|
88 | | boolean | true if valid, false otherwise |
89 |
90 | ### Usage
91 | ```java
92 | String didKeyUrl = "did:omn:raon?version=1#pin";
93 | boolean isValid = DidValidator.isValidDidKeyUrl(didKeyUrl); // returns true if the DID Key URL is valid
94 | ```
95 |
--------------------------------------------------------------------------------
/source/did-common-sdk-server/src/main/java/org/omnione/did/common/exception/ErrorCode.java:
--------------------------------------------------------------------------------
1 | package org.omnione.did.common.exception;
2 |
3 | /**
4 | * Enumeration of error codes used in the DID Verifier system.
5 | * Each error code contains a unique identifier, a descriptive message, and an associated HTTP status code.
6 | *
7 | */
8 |
9 | public enum ErrorCode {
10 |
11 | // Data Processing Errors (100-199)
12 | JSON_SERIALIZE_FAILED("00100", "Failed to Json serialize.", 500),
13 | JSON_SERIALIZE_SORT_FAILED("00101", "Failed to Json serialize and sort.", 500),
14 | JSON_DESERIALIZE_FAILED("00102", "Failed to Json deserialize.", 500),
15 | INVALID_DATE_TIME("00103", "Invalid date time format.", 400),
16 |
17 | // QR Code Errors (200-299)
18 | QR_CODE_GENERATION_FAILED("00200", "Failed to generate QR code image.", 500),
19 | QR_CODE_IO_ERROR("00201", "Failed to write QR code image to output stream.", 500),
20 | QR_CODE_ENCODING_ERROR("00202", "Failed to encode QR code content.", 500),
21 |
22 | // HTTP Client Errors (300-399)
23 | HTTP_CLIENT_ERROR("00300", "Failed to send HTTP request.", 500),
24 | ;
25 |
26 | private final String code;
27 | private final String message;
28 | private final int httpStatus;
29 |
30 | /**
31 | * Constructor for ErrorCode enum.
32 | *
33 | * @param code Error Code
34 | * @param message Error Message
35 | * @param httpStatus HTTP Status Code
36 | */
37 | ErrorCode(String code, String message, int httpStatus) {
38 | this.code = "S" + "SDK" + "UTL" + code;
39 | this.message = message;
40 | this.httpStatus = httpStatus;
41 | }
42 |
43 | /**
44 | * Get the error code.
45 | *
46 | * @return Error Code
47 | */
48 | public static String getMessageByCode(String code) {
49 | for (ErrorCode errorCode : values()) {
50 | if (errorCode.getCode().equals(code)) {
51 | return errorCode.getMessage();
52 | }
53 | }
54 | return "Unknown error code: " + code;
55 | }
56 | @Override
57 | public String toString() {
58 | return String.format("ErrorCode{code='%s', message='%s', httpStatus=%d}", code, message, httpStatus);
59 | }
60 |
61 | public String getMessage() {
62 | return message;
63 | }
64 | public String getCode() {
65 | return code;
66 | }
67 | public int getHttpStatus() {
68 | return httpStatus;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/source/did-common-sdk-server/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: Build and Upload JAR to GitHub Releases
2 |
3 | on:
4 | pull_request:
5 | branches:
6 | - main
7 | types: [closed]
8 |
9 | jobs:
10 | build:
11 | if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/QA-')
12 | runs-on: ubuntu-latest
13 | permissions:
14 | contents: write
15 | pull-requests: write
16 | repository-projects: write
17 |
18 | defaults:
19 | run:
20 | working-directory: source/did-common-sdk-server
21 | steps:
22 | - name: Checkout code
23 | uses: actions/checkout@v4
24 | with:
25 | fetch-depth: 0
26 |
27 | - name: Set up JDK 21
28 | uses: actions/setup-java@v4
29 | with:
30 | java-version: '21'
31 | distribution: 'temurin'
32 |
33 | - name: Test
34 | run: ./gradlew test
35 |
36 | - name: Build JAR
37 | run: |
38 | ./gradlew build
39 | echo "JAR file generated at:"
40 | find ./build/libs -name "*.jar"
41 |
42 | - name: Set release title
43 | id: set_release_title
44 | run: |
45 | release_tag=${GITHUB_HEAD_REF#release/QA-}
46 | echo "Release tag: $release_tag"
47 | echo "::set-output name=release_tag::$release_tag"
48 |
49 | - name: Get commit messages
50 | id: get_commit_messages
51 | run: |
52 | commits=$(git log ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} --pretty=format:"* %s")
53 | echo "$commits" > commit_messages.txt
54 | echo "::set-output name=commits::$commits"
55 |
56 | - name: Find JAR file
57 | id: find_jar
58 | run: |
59 | jar_path=$(find ./build/libs -name "*.jar" | head -n 1)
60 | echo "JAR path found: $jar_path"
61 | echo "::set-output name=jar_path::$jar_path"
62 |
63 | - name: Calculate SHA-256
64 | id: calculate_sha
65 | run: |
66 | sha256=$(sha256sum ${{ steps.find_jar.outputs.jar_path }} | awk '{ print $1 }')
67 | echo "SHA-256: $sha256"
68 | echo "::set-output name=jar_sha256::$sha256"
69 |
70 | - name: Create GitHub Release
71 | id: create_release
72 | uses: actions/create-release@v1
73 | env:
74 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75 | with:
76 | tag_name: ${{ steps.set_release_title.outputs.release_tag }}
77 | release_name: ${{ steps.set_release_title.outputs.release_tag }}
78 | body: |
79 | ## Changes:
80 | ${{ steps.get_commit_messages.outputs.commits }}
81 | ## Checksum:
82 | SHA-256: ${{ steps.calculate_sha.outputs.jar_sha256 }}
83 |
84 | - name: Upload JAR
85 | uses: actions/upload-release-asset@v1
86 | env:
87 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88 | with:
89 | upload_url: ${{ steps.create_release.outputs.upload_url }}
90 | asset_path: source/did-common-sdk-server/${{ steps.find_jar.outputs.jar_path }}
91 | asset_name: did-common-sdk-server-${{ steps.set_release_title.outputs.release_tag }}.jar
92 | asset_content_type: application/java-archive
93 |
--------------------------------------------------------------------------------
/docs/api/Server Common SDK_JsonUtil.md:
--------------------------------------------------------------------------------
1 | ---
2 | puppeteer:
3 | pdf:
4 | format: A4
5 | displayHeaderFooter: true
6 | landscape: false
7 | scale: 0.8
8 | margin:
9 | top: 1.2cm
10 | right: 1cm
11 | bottom: 1cm
12 | left: 1cm
13 | image:
14 | quality: 100
15 | fullPage: false
16 | ---
17 |
18 | # Server Common SDK API - JsonUtil
19 |
20 | - Date: 2024-09-02
21 | - Version: v1.0.0
22 |
23 | | Version | Date | History |
24 | | ------- | ---------- | ------------------------|
25 | | v1.0.0 | 2024-09-02 | Initial |
26 |
27 |
28 |
29 | # Table of Contents
30 |
31 | - [1. serializeAndSort](#1-serializeandsort)
32 | - [2. serializeToJson](#2-serializetojson)
33 | - [3. deserializeFromJson](#3-deserializefromjson)
34 |
35 |
36 | # APIs
37 |
38 | ## 1. serializeAndSort
39 |
40 | ### Description
41 | Serialize an object into a JSON string, sort the keys alphabetically, and remove all whitespace. This method is used to serialize the original text for signing in OpenDID.
42 |
43 | ### Declaration
44 |
45 | ```java
46 | public static String serializeAndSort(Object obj) throws JsonProcessingException
47 | ```
48 |
49 | ### Parameters
50 |
51 | | Name | Type | Description |
52 | |------|--------|-----------------------|
53 | | obj | Object | Object to be serialized |
54 |
55 | ### Returns
56 |
57 | | Type | Description |
58 | |--------|-------------------------------------------------|
59 | | String | JSON string with sorted keys and no whitespace |
60 |
61 | ### Usage
62 | ```java
63 | MyObject obj = new MyObject();
64 | String jsonString = JsonUtil.serializeAndSort(obj);
65 | ```
66 |
67 |
68 |
69 | ## 2. serializeToJson
70 |
71 | ### Description
72 | Converts any object to a JSON string.
73 |
74 | ### Declaration
75 |
76 | ```java
77 | public static String serializeToJson(Object obj) throws JsonProcessingException
78 | ```
79 |
80 | ### Parameters
81 |
82 | | Name | Type | Description |
83 | |------|--------|-------------------|
84 | | obj | Object | Object to convert |
85 |
86 | ### Returns
87 |
88 | | Type | Description |
89 | |--------|---------------|
90 | | String | JSON String |
91 |
92 | ### Usage
93 | ```java
94 | MyObject obj = new MyObject();
95 | String jsonString = JsonUtil.serializeToJson(obj);
96 | ```
97 |
98 |
99 |
100 | ## 3. deserializeFromJson
101 |
102 | ### Description
103 | Deserializes a JSON string into an object of the specified class type.
104 |
105 | ### Declaration
106 |
107 | ```java
108 | public static T deserializeFromJson(String jsonString, Class clazz) throws JsonProcessingException
109 | ```
110 |
111 | ### Parameters
112 |
113 | | Name | Type | Description |
114 | |------------|----------|----------------------------------|
115 | | jsonString | String | JSON string |
116 | | clazz | Class | Class type to deserialize |
117 |
118 | ### Returns
119 |
120 | | Type | Description |
121 | |------|-----------------------------|
122 | | T | Deserialized object |
123 |
124 | ### Usage
125 | ```java
126 | String jsonString = "{"name":"example", "age":30}";
127 | MyObject obj = JsonUtil.deserializeFromJson(jsonString, MyObject.class);
128 | ```
129 |
--------------------------------------------------------------------------------
/source/did-common-sdk-server/src/main/java/org/omnione/did/common/util/QrMaker.java:
--------------------------------------------------------------------------------
1 | package org.omnione.did.common.util;
2 |
3 | import com.google.zxing.BarcodeFormat;
4 | import com.google.zxing.EncodeHintType;
5 | import com.google.zxing.WriterException;
6 | import com.google.zxing.client.j2se.MatrixToImageWriter;
7 | import com.google.zxing.common.BitMatrix;
8 | import com.google.zxing.qrcode.QRCodeWriter;
9 | import org.omnione.did.common.exception.ErrorCode;
10 | import org.omnione.did.common.exception.CommonSdkException;
11 | import org.omnione.did.common.vo.QrImageData;
12 |
13 | import java.io.ByteArrayOutputStream;
14 | import java.io.IOException;
15 | import java.util.HashMap;
16 | import java.util.Map;
17 |
18 | /**
19 | * QR Code Image Generator
20 | */
21 | public class QrMaker {
22 | private static final QRCodeWriter QR_CODE_WRITER = new QRCodeWriter();
23 | private static final String DEFAULT_IMAGE_FORMAT = "PNG";
24 | private static final int DEFAULT_WIDTH = 300;
25 | private static final int DEFAULT_HEIGHT = 300;
26 |
27 | /**
28 | * Generate a QR code image from the given data.
29 | *
30 | * @param data The data to be encoded in the QR code.
31 | * @return The QR code image data.
32 | * @throws CommonSdkException If the QR code generation fails.
33 | */
34 | public static QrImageData makeQrImage(final Object data) {
35 | byte[] qrImage;
36 | qrImage = makeQrImage(JsonUtil.serializeToJson(data), DEFAULT_IMAGE_FORMAT, DEFAULT_WIDTH, DEFAULT_HEIGHT);
37 |
38 | QrImageData qrImageData = new QrImageData();
39 | qrImageData.setFormat("image");
40 | qrImageData.setMediaType(DEFAULT_IMAGE_FORMAT);
41 | qrImageData.setQrIamge(qrImage);
42 |
43 | return qrImageData;
44 |
45 | }
46 | /**
47 | * Generate a QR code image from the given data.
48 | *
49 | * @param contents The data to be encoded in the QR code.
50 | * @param format The image format to use.
51 | * @param width The width of the QR code image.
52 | * @param height The height of the QR code image.
53 | * @return The QR code image data.
54 | */
55 | public static byte[] makeQrImage(final String contents, final String format, int width, int height) {
56 | try {
57 | BitMatrix bitMatrix = makeQrBitMatrix(contents, width, height);
58 |
59 | try (ByteArrayOutputStream pngOutputStream = new ByteArrayOutputStream()) {
60 | MatrixToImageWriter.writeToStream(bitMatrix, format, pngOutputStream);
61 | return pngOutputStream.toByteArray();
62 | } catch (IOException e) {
63 | throw new CommonSdkException(ErrorCode.QR_CODE_IO_ERROR);
64 | }
65 | } catch (WriterException e) {
66 | throw new CommonSdkException(ErrorCode.QR_CODE_ENCODING_ERROR);
67 | }
68 | }
69 |
70 | /**
71 | * Generates a QR code BitMatrix from the given content.
72 | *
73 | * @param contents The string content to be encoded in the QR code
74 | * @param width The desired width of the QR code
75 | * @param height The desired height of the QR code
76 | * @return BitMatrix representation of the QR code
77 | * @throws CommonSdkException If there's an error during QR code generation
78 | */
79 | public static BitMatrix makeQrBitMatrix(String contents, int width, int height) throws WriterException {
80 | Map hints = new HashMap<>();
81 | hints.put(EncodeHintType.MARGIN, 0);
82 | return QR_CODE_WRITER.encode(contents, BarcodeFormat.QR_CODE, width, height, hints);
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/docs/api/Server Common SDK_QrMaker.md:
--------------------------------------------------------------------------------
1 | ---
2 | puppeteer:
3 | pdf:
4 | format: A4
5 | displayHeaderFooter: true
6 | landscape: false
7 | scale: 0.8
8 | margin:
9 | top: 1.2cm
10 | right: 1cm
11 | bottom: 1cm
12 | left: 1cm
13 | image:
14 | quality: 100
15 | fullPage: false
16 | ---
17 |
18 | # Server Common SDK API - QrMaker
19 |
20 | - Date: 2024-09-02
21 | - Version: v1.0.0
22 |
23 | | Version | Date | History |
24 | | ------- | ---------- | ------------------------|
25 | | v1.0.0 | 2024-09-02 | Initial |
26 |
27 |
28 |
29 | # Table of Contents
30 |
31 | - [1. makeQrImage (Object)](#1-makeqrimage-object)
32 | - [2. makeQrImage (String)](#2-makeqrimage-string)
33 | - [3. makeQrBitMatrix](#3-makeqrbitmatrix)
34 |
35 | # APIs
36 |
37 | ## 1. makeQrImage (Object)
38 |
39 | ### Description
40 | Converts the given Object into a JSON string, then into a QR code image, and returns it as a QrImageData object.
41 | The width and height of the image are set to default values.
42 | ### Declaration
43 |
44 | ```java
45 | public static QrImageData makeQrImage(final Object data) throws IOException, WriterException
46 | ```
47 |
48 | ### Parameters
49 |
50 | | Name | Type | Description |
51 | |------|--------|--------------|
52 | | data | Object | Data object to be converted to QR code |
53 |
54 | ### Returns
55 |
56 | | Type | Description |
57 | |------------|------------------------|
58 | | QrImageData| QR code image data object |
59 |
60 | ### Usage
61 | ```java
62 | MyObject data = new MyObject();
63 | QrImageData qrImageData = QrMaker.makeQrImage(data);
64 | ```
65 |
66 |
67 |
68 | ## 2. makeQrImage (String)
69 |
70 | ### Description
71 | Converts the given string into a QR code image and returns it as a byte array.
72 |
73 | ### Declaration
74 |
75 | ```java
76 | public static byte[] makeQrImage(final String contents, final String format, int width, int height) throws IOException, WriterException
77 | ```
78 |
79 | ### Parameters
80 |
81 | | Name | Type | Description |
82 | |----------|--------|-----------------------------------------|
83 | | contents | String | String to convert to QR code |
84 | | format | String | Image format (e.g., PNG) |
85 | | width | int | Image width |
86 | | height | int | Image height |
87 |
88 | ### Returns
89 |
90 | | Type | Description |
91 | |--------|-----------------------------------|
92 | | byte[] | Byte array of the QR code image |
93 |
94 | ### Usage
95 | ```java
96 | String contents = "Hello, World!";
97 | byte[] qrImage = QrMaker.makeQrImage(contents, "PNG", 300, 300);
98 | ```
99 |
100 |
101 |
102 | ## 3. makeQrBitMatrix
103 |
104 | ### Description
105 | Converts the given string content into a QR code BitMatrix.
106 |
107 | ### Declaration
108 |
109 | ```java
110 | public static BitMatrix makeQrBitMatrix(String contents, int width, int height) throws WriterException
111 | ```
112 |
113 | ### Parameters
114 |
115 | | Name | Type | Description |
116 | |----------|--------|----------------------------------|
117 | | contents | String | String to convert to QR code |
118 | | width | int | Bit matrix width |
119 | | height | int | Bit matrix height |
120 |
121 | ### Returns
122 |
123 | | Type | Description |
124 | |----------|---------------------------|
125 | | BitMatrix| QR code bit matrix |
126 |
127 | ### Usage
128 | ```java
129 | String contents = "Hello, World!";
130 | BitMatrix bitMatrix = QrMaker.makeQrBitMatrix(contents, 300, 300);
131 | ```
132 |
--------------------------------------------------------------------------------
/docs/errorCode/Common_ErrorCode.md:
--------------------------------------------------------------------------------
1 | ---
2 | puppeteer:
3 | pdf:
4 | format: A4
5 | displayHeaderFooter: true
6 | landscape: false
7 | scale: 0.8
8 | margin:
9 | top: 1.2cm
10 | right: 1cm
11 | bottom: 1cm
12 | left: 1cm
13 | image:
14 | quality: 100
15 | fullPage: false
16 | ---
17 |
18 | Common Util SDK Error
19 | ==
20 |
21 | - Date: 2024-09-02
22 | - Version: v1.0.0
23 |
24 | | Version | Date | History |
25 | | ------- | ---------- | ------------------------|
26 | | v1.0.0 | 2024-09-02 | Initial |
27 |
28 |
29 |
30 | # Table of Contents
31 |
32 | - [Model](#model)
33 | - [Error Response](#error-response)
34 | - [Error Code](#error-code)
35 | - [1. Common Util SDK](#1-common-util-sdk)
36 | - [1-1. Data Processing (00100 ~ 00199)](#1-1-data-processing-00100--00199)
37 | - [1-2. QR CODE (00200 ~ 00299)](#1-2-qr-code-00200--00299)
38 | - [1-3. HTTP Client (00300 ~ 00399)](#1-3-http-client-00300--00399)
39 |
40 | # Model
41 |
42 | ## Error Response
43 |
44 | ### Description
45 |
46 | ```
47 | Error struct for Common Util SDK. It has code and message pair.
48 | Code starts with SSDKUTL.
49 | ```
50 |
51 | ### Declaration
52 |
53 | ```java
54 | public class ErrorResponse {
55 | private final String code;
56 | private final String message;
57 | }
58 | ```
59 |
60 | ### Property
61 |
62 | | Name | Type | Description | **M/O** | **Note** |
63 | |---------|--------|------------------------------------|---------| -------- |
64 | | code | String | Error code. It starts with SSDKUTL | M | |
65 | | message | String | Error description | M | |
66 |
67 |
68 |
69 | # Error Code
70 |
71 | ## 1. Common Util SDK
72 |
73 | ### 1-1. Data Processing (00100 ~ 00199)
74 |
75 | | Error Code | Error Message | Description | Action Required |
76 | |--------------|-------------------------------------|-------------|-----------------------------------------------------------------------------------|
77 | | SSDKUTL00100 | Failed to Json serialize. | - | Check input data structure and ensure all fields are serializable. |
78 | | SSDKUTL00101 | Failed to Json serialize and sort. | - | Verify the sorting criteria and ensure all fields have comparable values. |
79 | | SSDKUTL00102 | Failed to Json deserialize. | - | Validate the JSON string format and ensure it matches the target object structure.|
80 | | SSDKUTL00103 | Invalid date time format. | - | Check the date-time string and ensure it follows the expected format (e.g., ISO 8601).|
81 |
82 | ### 1-2. QR CODE (00200 ~ 00299)
83 |
84 | | Error Code | Error Message | Description | Action Required |
85 | |--------------|--------------------------------------------------|-------------|------------------------------------------------------------------------------------|
86 | | SSDKUTL00200 | Failed to generate QR code image. | - | Verify the input data for QR code generation and check available memory. |
87 | | SSDKUTL00201 | Failed to write QR code image to output stream. | - | Check write permissions and available disk space. Ensure output stream is open. |
88 | | SSDKUTL00202 | Failed to encode QR code content. | - | Validate the content size and character set. Ensure it's within QR code capacity. |
89 |
90 | ### 1-3. HTTP Client (00300 ~ 00399)
91 |
92 | | Error Code | Error Message | Description | Action Required |
93 | |--------------|------------------------------|-------------|-----------------------------------------------------------------------------------------|
94 | | SSDKUTL00300 | Failed to send HTTP request. | - | Check network connectivity, verify URL, and ensure proper request formation (headers, body, etc.).|
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by https://www.toptal.com/developers/gitignore/api/intellij,gradle,java
2 | # Edit at https://www.toptal.com/developers/gitignore?templates=intellij,gradle,java
3 |
4 | ### Intellij ###
5 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
6 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
7 |
8 | # User-specific stuff
9 | .idea/
10 |
11 | # AWS User-specific
12 | .idea/**/aws.xml
13 |
14 | # Generated files
15 | .idea/**/contentModel.xml
16 |
17 | # Sensitive or high-churn files
18 | .idea/**/dataSources/
19 | .idea/**/dataSources.ids
20 | .idea/**/dataSources.local.xml
21 | .idea/**/sqlDataSources.xml
22 | .idea/**/dynamic.xml
23 | .idea/**/uiDesigner.xml
24 | .idea/**/dbnavigator.xml
25 |
26 | # Gradle
27 | .idea/**/gradle.xml
28 | .idea/**/libraries
29 | .gradle/
30 |
31 | # Gradle and Maven with auto-import
32 | # When using Gradle or Maven with auto-import, you should exclude module files,
33 | # since they will be recreated, and may cause churn. Uncomment if using
34 | # auto-import.
35 | # .idea/artifacts
36 | # .idea/compiler.xml
37 | # .idea/jarRepositories.xml
38 | # .idea/modules.xml
39 | # .idea/*.iml
40 | # .idea/modules
41 | # *.iml
42 | # *.ipr
43 |
44 | # CMake
45 | cmake-build-*/
46 |
47 | # Mongo Explorer plugin
48 | .idea/**/mongoSettings.xml
49 |
50 | # File-based project format
51 | *.iws
52 |
53 | # IntelliJ
54 | out/
55 |
56 | # mpeltonen/sbt-idea plugin
57 | .idea_modules/
58 |
59 | # JIRA plugin
60 | atlassian-ide-plugin.xml
61 |
62 | # Cursive Clojure plugin
63 | .idea/replstate.xml
64 |
65 | # SonarLint plugin
66 | .idea/sonarlint/
67 |
68 | # Crashlytics plugin (for Android Studio and IntelliJ)
69 | com_crashlytics_export_strings.xml
70 | crashlytics.properties
71 | crashlytics-build.properties
72 | fabric.properties
73 |
74 | # Editor-based Rest Client
75 | .idea/httpRequests
76 |
77 | # Android studio 3.1+ serialized cache file
78 | .idea/caches/build_file_checksums.ser
79 |
80 | ### Intellij Patch ###
81 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
82 |
83 | # *.iml
84 | # modules.xml
85 | # .idea/misc.xml
86 | # *.ipr
87 |
88 | # Sonarlint plugin
89 | # https://plugins.jetbrains.com/plugin/7973-sonarlint
90 | .idea/**/sonarlint/
91 |
92 | # SonarQube Plugin
93 | # https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
94 | .idea/**/sonarIssues.xml
95 |
96 | # Markdown Navigator plugin
97 | # https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
98 | .idea/**/markdown-navigator.xml
99 | .idea/**/markdown-navigator-enh.xml
100 | .idea/**/markdown-navigator/
101 |
102 | # Cache file creation bug
103 | # See https://youtrack.jetbrains.com/issue/JBR-2257
104 | .idea/$CACHE_FILE$
105 |
106 | # CodeStream plugin
107 | # https://plugins.jetbrains.com/plugin/12206-codestream
108 | .idea/codestream.xml
109 |
110 | # Azure Toolkit for IntelliJ plugin
111 | # https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
112 | .idea/**/azureSettings.xml
113 |
114 | ### Java ###
115 | # Compiled class file
116 | *.class
117 |
118 | # Log file
119 | *.log
120 |
121 | # BlueJ files
122 | *.ctxt
123 |
124 | # Mobile Tools for Java (J2ME)
125 | .mtj.tmp/
126 |
127 | # Package Files #
128 | *.jar
129 | *.war
130 | *.nar
131 | *.ear
132 | *.zip
133 | *.tar.gz
134 | *.rar
135 |
136 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
137 | hs_err_pid*
138 | replay_pid*
139 |
140 | ### Gradle ###
141 | .gradle
142 | **/build/
143 | !src/**/build/
144 |
145 | # Ignore Gradle GUI config
146 | gradle-app.setting
147 |
148 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
149 | !gradle-wrapper.jar
150 |
151 | # Avoid ignore Gradle wrappper properties
152 | !gradle-wrapper.properties
153 |
154 | # Cache of project
155 | .gradletasknamecache
156 |
157 | # Eclipse Gradle plugin generated files
158 | # Eclipse Core
159 | .project
160 | # JDT-specific (Eclipse Java Development Tools)
161 | .classpath
162 |
163 | ### Gradle Patch ###
164 | # Java heap dump
165 | *.hprof
166 |
167 | *.jar
168 | !release/
169 | !release/*.jar
170 |
171 | # End of https://www.toptal.com/developers/gitignore/api/intellij,gradle,java
--------------------------------------------------------------------------------
/README_ko.md:
--------------------------------------------------------------------------------
1 | Server Common SDK
2 | ==
3 |
4 | Server Common SDK Repository에 오신 것을 환영합니다.
5 | 이 Repository는 Server Common SDK의 소스 코드, 문서, 관련 리소스를 포함하고 있습니다.
6 |
7 | ## 폴더 구조
8 | 프로젝트 디렉터리 내 주요 폴더와 문서에 대한 개요:
9 |
10 | ```
11 | did-common-sdk-server
12 | ├── CHANGELOG.md
13 | ├── CLA.md
14 | ├── CODE_OF_CONDUCT.md
15 | ├── CONTRIBUTING.md
16 | ├── LICENSE
17 | ├── dependencies-license.md
18 | ├── MAINTAINERS.md
19 | ├── README.md
20 | ├── README_ko.md
21 | ├── RELEASE-PROCESS.md
22 | ├── SECURITY.md
23 | ├── docs
24 | │ └── api
25 | │ └── Server Common SDK_DateTimeUtil.md
26 | │ └── Server Common SDK_DidUtil.md
27 | │ └── Server Common SDK_DidValidator.md
28 | │ └── Server Common SDK_HexUtil.md
29 | │ └── Server Common SDK_HttpClientUtil.md
30 | │ └── Server Common SDK_JsonUtil.md
31 | │ └── Server Common SDK_QrMaker.md
32 | │ └── errorCode
33 | │ └── Common_ErrorCode.md
34 | └── source
35 | └── did-common-sdk-server
36 | ├── gradle
37 | └── src
38 | └── build.gradle
39 | └── README.md
40 | ```
41 |
42 |
43 |
44 | 각 폴더와 파일에 대한 설명은 다음과 같습니다:
45 |
46 | | 이름 | 설명 |
47 | |----------------------------------|-------------------------|
48 | | CHANGELOG.md | 프로젝트의 버전별 변경 사항 |
49 | | CODE_OF_CONDUCT.md | 기여자 행동 강령 |
50 | | CONTRIBUTING.md | 기여 지침과 절차 |
51 | | LICENSE | 라이선스 |
52 | | dependencies-license.md | 프로젝트 의존 라이브러리의 라이선스 정보 |
53 | | MAINTAINERS.md | 프로젝트 유지 관리자 지침 |
54 | | RELEASE-PROCESS.md | 새 버전 릴리스 절차 |
55 | | SECURITY.md | 보안 정책 및 취약성 보고 방법 |
56 | | docs | 문서화 |
57 | | ┖ api | API 가이드 문서 |
58 | | ┖ errorCode | 오류 코드 및 문제 해결 가이드 |
59 | | source | 서버 소스 코드 프로젝트 |
60 | | ┖ did-wallet-server | Wallet 서버 소스 코드 및 빌드 파일 |
61 | | ┖ gradle | Gradle 빌드 설정 및 스크립트 |
62 | | ┖ src | 주요 소스 코드 디렉터리 |
63 | | ┖ build.gradle | Gradle 빌드 설정 파일 |
64 | | ┖ README.md | 소스 코드 개요 및 지침 |
65 |
66 |
67 |
68 | ## 라이브러리
69 |
70 | 이 프로젝트에서 사용되는 라이브러리는 두 가지 주요 범주로 구성됩니다.
71 |
72 | 1. **서드파티 라이브러리**: 이 라이브러리들은 [build.gradle](source/did-common-sdk-server/build.gradle) 파일을 통해 관리되는 오픈 소스 종속성입니다. 서드파티 라이브러리와 그 라이선스에 대한 자세한 목록은 [dependencies-license.md](dependencies-license.md) 파일을 참조하십시오.
73 |
74 | ## API Reference
75 |
76 |
77 | | Class | 주요 기능 | API 문서 링크 |
78 | | -------------- | ------------------------------------------------------------------ | ------------------------------------------- |
79 | | DateTimeUtil | 현재 UTC 시간 가져오기, 시간 추가, 시간 문자열 파싱 | [Server Common SDK - DateTimeUtil API](./docs/api/Server%20Common%20SDK_DateTimeUtil.md) |
80 | | DidValidator | DID 검증, DID 키 검증 URL | [Server Common SDK - DidValidator API](./docs/api/Server%20Common%20SDK_DidValidator.md) |
81 | | HexUtil | 바이트 배열을 16진수 문자열로 변환 | [Server Common SDK - HexUtil API](./docs/api/Server%20Common%20SDK_HexUtil.md) |
82 | | HttpClientUtil | HTTP GET 요청, HTTP POST 요청 | [Server Common SDK - HttpClientUtil API](./docs/api/Server%20Common%20SDK_HttpClientUtil.md) |
83 | | JsonUtil | 객체를 JSON 문자열로 직렬화, JSON 문자열을 객체로 역직렬화 | [Server Common SDK - JsonUtil API](./docs/api/Server%20Common%20SDK_JsonUtil.md) |
84 | | QrMaker | 데이터를 QR 코드 이미지로 변환하여 바이트 배열로 반환 | [Server Common SDK - QrMaker API](./docs/api/Server%20Common%20SDK_QrMaker.md) |
85 |
86 | ## Change Log
87 |
88 | Change Log에는 버전별 변경 사항과 업데이트가 자세히 기록되어 있습니다. 다음에서 확인할 수 있습니다:
89 | - [Change Log](CHANGELOG.md)
90 |
91 | ## OpenDID 시연 영상
92 | OpenDID 시스템의 시연 영상을 보려면 [데모 Repository](https://github.com/OmniOneID/did-demo-server)를 방문하십시오.
93 |
94 | 이 영상에서는 사용자 등록, VC 발급, VP 제출 프로세스 등 주요 기능을 시연합니다.
95 |
96 | ## 기여
97 |
98 | 기여 절차와 행동 강령에 대한 자세한 내용은 [CONTRIBUTING.md](CONTRIBUTING.md)와 [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md)를 참조해 주십시오.
99 |
100 | ## 라이선스
101 | [Apache 2.0](LICENSE)
102 |
--------------------------------------------------------------------------------
/source/did-common-sdk-server/README.md:
--------------------------------------------------------------------------------
1 |
2 | # Server Common SDK Installation Guide
3 |
4 | This document serves as a guide for using the Server Common SDK. The Server Common SDK provides various utility classes that can be shared across all service servers of Open DID.
5 |
6 | ## Software Specifications
7 | | Category | Description |
8 | |---------------|-------------------------------|
9 | | OS | Linux, macOS, Windows |
10 | | Language | Java 17 |
11 | | Build System | Gradle 8.2 |
12 |
13 |
14 |
15 | ## Build Instructions
16 | Generate a JAR file using the `build.gradle` file of this SDK project.
17 |
18 | 1. Open the project's `build.gradle` file and add the following JAR task configuration:
19 | ```groovy
20 | jar {
21 | archiveBaseName.set('did-sdk-common')
22 | archiveVersion.set(version)
23 | archiveClassifier.set('')
24 | }
25 | ```
26 | 2. Open the Gradle window and execute the `Tasks > other > jar` task in the project.
27 | 3. Once the execution is complete, the file `did-sdk-common-1.0.0.jar` will be generated in the `build/libs` folder.
28 |
29 |
30 |
31 | ## How to Apply SDK
32 | 1. Copy the `did-sdk-common-1.0.0.jar` file to the `libs` folder of the app project.
33 | 2. Add the following dependency to the `build.gradle` file of the app project.
34 |
35 | ```groovy
36 | implementation files('libs/did-sdk-common-1.0.0.jar')
37 | implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.1'
38 | implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.15.1'
39 | implementation 'com.google.zxing:javase:3.5.1'
40 | ```
41 | 3. Ensure that dependencies are properly added by synchronizing `Gradle`.
42 |
43 |
44 |
45 | ## API Specification and Key Features
46 | | Class | Key Features | API Documentation Link |
47 | | -------------- | ------------------------------------------------------------------ | ------------------------------------------- |
48 | | DateTimeUtil | Gets current UTC time, add time, parse time strings | [Server Common SDK - DateTimeUtil API](../../docs/api/Server%20Common%20SDK_DateTimeUtil.md) |
49 | | DidValidator | DID Verification , DID Key Verification URL | [Server Common SDK - DidValidator API](../../docs/api/Server%20Common%20SDK_DidValidator.md) |
50 | | HexUtil | Convert byte array to hexadecimal string | [Server Common SDK - HexUtil API](../../docs/api/Server%20Common%20SDK_HexUtil.md) |
51 | | HttpClientUtil | HTTP GET Reguest, HTTP POST Reguest | [Server Common SDK - HttpClientUtil API](../../docs/api/Server%20Common%20SDK_HttpClientUtil.md) |
52 | | JsonUtil | Serialize object to JSON string, deserialize JSON string to object | [Server Common SDK - JsonUtil API](../../docs/api/Server%20Common%20SDK_JsonUtil.md) |
53 | | QrMaker | Convert data to QR code image and return as byte array | [Server Common SDK - QrMaker API](../../docs/api/Server%20Common%20SDK_QrMaker.md) |
54 |
55 | ### DateTimeUtil
56 | The DateTimeUtil class provides utility methods for date and time manipulation. Key features include:
57 |
58 | * Get current UTC time: Returns the current UTC time in ISO 8601 format.
59 | * Add time: Adds specified time to the current time.
60 | * Parse time string: Parses a string in ISO 8601 format into an Instant object.
61 |
62 | ### DidValidator
63 | The DidValidator class provides utility methods for validating DID and DID Key URL formats. Key features include:
64 |
65 | * Validate DID: Validates the format of the given DID string.
66 | * Validate DID Key URL: Validates the format of the given DID Key URL string.
67 |
68 | ### HexUtil
69 | The HexUtil class provides utility methods for converting byte arrays to hexadecimal strings. Key features include:
70 |
71 | * Convert byte array to hexadecimal string: Converts the given byte array to a hexadecimal string.
72 |
73 | ### HttpClientUtil
74 | The HttpClientUtil class provides utility methods for sending HTTP GET and POST requests. Key features include:
75 |
76 | * HTTP GET request: Sends an HTTP GET request to the specified URL and returns the response body.
77 | * HTTP POST request: Sends an HTTP POST request to the specified URL and returns the response body.
78 |
79 | ### JsonUtil
80 | The JsonUtil class provides utility methods for JSON serialization and deserialization. Key features include:
81 |
82 | * Serialize object to JSON string: Converts an object to a JSON string.
83 | * Deserialize JSON string to object: Converts a JSON string to an object of the specified class type.
84 |
85 | ### QrMaker
86 | The QrMaker class provides utility methods for generating QR codes. Key features include:
87 |
88 | * Generate QR code: Converts the given data into a QR code image and returns it as a byte array.
89 |
--------------------------------------------------------------------------------
/RELEASE-PROCESS.md:
--------------------------------------------------------------------------------
1 | # Release Process
2 |
3 | This document describes the Release Process for QA validation and deployment of feature additions and modifications for each repository. It covers version management and QA validation procedures for each module, as well as the process for managing the integrated Release of all modules.
4 |
5 | ## 1. Versioning
6 |
7 | The project follows a versioning rule in the format "X.Y.Z" where:
8 | - X (Major): Significant changes that are not backward compatible
9 | - Y (Minor): New features that are backward compatible
10 | - Z (Patch): Bug fixes or minor improvements that are backward compatible
11 |
12 | > When the Major version is updated, both Minor and Patch are reset to 0.
13 | >
14 | > When the Minor version is updated, the Patch is reset to 0.
15 |
16 | The integrated module version follows a four-digit format "W.X.Y.Z" assigned after QA approval.
17 |
18 | - W.X: Official product number
19 | - Y: Release
20 | - Z: Bug fix
21 |
22 | ## 2. Release Procedure for Each Repository
23 |
24 | Each module (repository) is managed independently, following these steps:
25 |
26 | 1. **Change Log Review**
27 | Review the [CHANGE LOG](CHANGELOG.md) for each module to ensure all changes are recorded.
28 |
29 | 2. **Create a Release Branch**
30 | If there are changes or modifications, create a branch "release/QA-VX.Y.Z" for QA validation.
31 | - Example: If there are bug fixes or minor improvements for V1.0.0, create a branch "release/QA-V1.0.1".
32 |
33 | For modules without changes, use the existing version (V1.0.0) and the already distributed JAR or library.
34 |
35 | 3. **QA Validation**
36 | - Perform QA validation on the Release branch, addressing any issues identified during the process.
37 | - Approve the Release once QA validation is complete.
38 |
39 | 4. **Merge into Main and Develop Branches**
40 | - Merge the validated Release branch (release/QA-VX.Y.Z) into both `main` and `develop` branches.
41 |
42 | 5. **Create a Release for Each Repository**
43 | - When the validated branch is merged into `main`, trigger the [CI/CD pipeline](https://github.com/OmniOneID/did-release/blob/main/docs/CI_CD_PIPELINE.md) using GitHub Actions to create the Release and perform version tagging. The generated [Release](https://github.com/OmniOneID/did-common-sdk-server/releases) includes the following:
44 | - Version name
45 | - Summary of the changelog
46 | - Source code archive
47 | - Distributed files
48 | - Delete the release/QA-VX.Y.Z branch after the release.
49 |
50 | ## 3. Integrated Release Management (did-release Repository)
51 |
52 | After QA approval, manage the complete version control of all modules in a separate repository called [did-release](https://github.com/OmniOneID/did-release/).
53 |
54 | 1. **Managing QA Request Branches**
55 | - Create a directory for the QA request version (format: W.X.Y.Z, e.g., V1.0.1.0). The directory name should be /release-VW.X.Y.Z (e.g., /release-V1.0.1.0).
56 | - Gather the version names of the branches created for QA validation (release/QA-VX.Y.Z) and document version information and modifications in a table within the directory. Name the file 'QA-PLAN-VW.X.Y.Z.md' and register it in the issue menu of the `did-release` repository.
57 | - Include versions of unchanged modules as well.
58 |
59 | 2. **Individual Releases After QA Approval**
60 | - Once all modules have passed QA validation, and their respective `release/QA-VX.Y.Z` branches are merged into `main` and `develop`, create releases for each repository.
61 |
62 | 3. **Publishing the Integrated Release**
63 | - After all modules are approved and released, manage the integrated Release in the `did-release` repository.
64 | - Retrieve the latest version tags for each module and post them in the Release menu of the `did-release`.
65 | - Document the release information in a file named release-VW.X.Y.Z.md within the previously created directory.
66 |
67 | - Example:
68 |
69 | ## Release Note V1.0.1.0
70 |
71 | | Repository | Version | Changelog | Release |
72 | | --------------------- | ------- | -------------------------------------------------------------------------------------- | ------- |
73 | | did-common-sdk-server | V1.0.0 | [Changelog](https://github.com/OmniOneID/did-common-sdk-server/blob/main/CHANGELOG.md) | |
74 |
75 |
76 |
77 | ## 4. Automating Integrated Release Script
78 |
79 | Use GitHub Actions or Shell scripts to automate the following tasks:
80 | - Retrieve the release tag information for each module and publish the integrated Release.
81 | - Once all module releases are completed, gather the latest Release information for each module and publish the final version in the `did-release` repository to manage the overall project release.
82 | - The integrated release version follows the "W.X.Y.Z" format, based on the most significant changes.
83 |
84 | This process enables efficient management of individual module versions and the overall integrated project release.
--------------------------------------------------------------------------------
/docs/api/Server Common SDK_HttpClientUtil.md:
--------------------------------------------------------------------------------
1 | ---
2 | puppeteer:
3 | pdf:
4 | format: A4
5 | displayHeaderFooter: true
6 | landscape: false
7 | scale: 0.8
8 | margin:
9 | top: 1.2cm
10 | right: 1cm
11 | bottom: 1cm
12 | left: 1cm
13 | image:
14 | quality: 100
15 | fullPage: false
16 | ---
17 |
18 | # Server Common SDK API - HttpClientUtil
19 |
20 | - Date: 2024-09-02
21 | - Version: v1.0.0
22 |
23 | | Version | Date | History |
24 | | ------- | ---------- | ------------------------|
25 | | v1.0.0 | 2024-09-02 | Initial |
26 |
27 |
28 |
29 | # Table of Contents
30 |
31 | - [1. getData](#1-getdata)
32 | - [2. getData (with Class Type)](#2-getdata-with-class-type)
33 | - [3. postData](#3-postdata)
34 | - [4. postData (with Class Type)](#4-postdata-with-class-type)
35 |
36 |
37 | # APIs
38 |
39 | ## 1. getData
40 |
41 | ### Description
42 | Sends an HTTP GET request to the given URL and returns the response body as a string.
43 |
44 | ### Declaration
45 |
46 | ```java
47 | public static String getData(String url) throws IOException, InterruptedException, HttpClientException
48 | ```
49 |
50 | ### Parameters
51 |
52 | | Name | Type | Description |
53 | |------|--------|--------------|
54 | | url | String | URL to request |
55 |
56 | ### Returns
57 |
58 | | Type | Description |
59 | |--------|------------------|
60 | | String | Response body |
61 |
62 | ### Usage
63 | ```java
64 | String url = "https://reqres.in/api/users?page=2";
65 | String response = HttpClientUtil.getData(url);
66 | System.out.println("GET Response: " + response);
67 | ```
68 |
69 |
70 |
71 | ## 2. getData (with Class Type)
72 |
73 | ### Description
74 | Sends an HTTP GET request to the given URL and parses the response body into the specified class type.
75 |
76 | ### Declaration
77 |
78 | ```java
79 | public static T getData(String url, Class responseType) throws IOException, InterruptedException, HttpClientException
80 | ```
81 |
82 | ### Parameters
83 |
84 | | Name | Type | Description |
85 | |--------------|----------|----------------------|
86 | | url | String | Requested URL |
87 | | responseType | Class | Class type to parse the response |
88 |
89 | ### Returns
90 |
91 | | Type | Description |
92 | |------|---------------------|
93 | | T | Parsed response body |
94 |
95 | ### Usage
96 | ```java
97 | String url = "https://reqres.in/api/users?page=2";
98 | MyResponse response = HttpClientUtil.getData(url, MyResponse.class);
99 | System.out.println("GET Response: " + response);
100 | ```
101 |
102 |
103 |
104 | ## 3. postData
105 |
106 | ### Description
107 | Sends an HTTP POST request with the specified request body to the given URL and returns the response body as a string.
108 |
109 | ### Declaration
110 |
111 | ```java
112 | public static String postData(String url, String requestBody) throws IOException, InterruptedException, HttpClientException
113 | ```
114 |
115 | ### Parameters
116 |
117 | | Name | Type | Description |
118 | |-------------|--------|-------------------|
119 | | url | String | URL to request |
120 | | requestBody | String | Request body |
121 |
122 | ### Returns
123 |
124 | | Type | Description |
125 | |--------|------------------|
126 | | String | Response body |
127 |
128 | ### Usage
129 | ```java
130 | String url = "https://reqres.in/api/users";
131 | String requestBody = "{\"name\":\"manager\", \"job\": \"manager\"}";
132 | String response = HttpClientUtil.postData(url, requestBody);
133 | System.out.println("POST Response: " + response);
134 | ```
135 |
136 |
137 |
138 | ## 4. postData (with Class Type)
139 |
140 | ### Description
141 | Sends an HTTP POST request to the given URL with the specified request body and parses the response body into the specified class type.
142 |
143 | ### Declaration
144 |
145 | ```java
146 | public static T postData(String url, String requestBody, Class responseType) throws IOException, InterruptedException, HttpClientException
147 | ```
148 |
149 | ### Parameters
150 |
151 | | Name | Type | Description |
152 | |-------------|----------|------------------------------------|
153 | | url | String | Request URL |
154 | | requestBody | String | Request Body |
155 | | responseType| Class | Class type for parsing the response|
156 |
157 | ### Returns
158 |
159 | | Type | Description |
160 | |------|-----------------------|
161 | | T | Parsed Response Body |
162 |
163 | ### Usage
164 | ```java
165 | String url = "https://reqres.in/api/users";
166 | String requestBody = "{\"name\":\"manager\", \"job\": \"manager\"}";
167 | MyResponse response = HttpClientUtil.postData(url, requestBody, MyResponse.class);
168 | System.out.println("POST Response: " + response);
169 | ```
170 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Server Common SDK
2 | ==
3 |
4 | Welcome to the Server Common SDK Repository.
5 | This repository contains the source code, documentation, and related resources for the Server Common SDK.
6 |
7 | ## Folder Structure
8 | Overview of the major folders and documents in the project directory:
9 |
10 | ```
11 | did-common-sdk-server
12 | ├── CHANGELOG.md
13 | ├── CLA.md
14 | ├── CODE_OF_CONDUCT.md
15 | ├── CONTRIBUTING.md
16 | ├── LICENSE
17 | ├── dependencies-license.md
18 | ├── MAINTAINERS.md
19 | ├── README.md
20 | ├── README_ko.md
21 | ├── RELEASE-PROCESS.md
22 | ├── SECURITY.md
23 | ├── docs
24 | │ └── api
25 | │ └── Server Common SDK_DateTimeUtil.md
26 | │ └── Server Common SDK_DidUtil.md
27 | │ └── Server Common SDK_DidValidator.md
28 | │ └── Server Common SDK_HexUtil.md
29 | │ └── Server Common SDK_HttpClientUtil.md
30 | │ └── Server Common SDK_JsonUtil.md
31 | │ └── Server Common SDK_QrMaker.md
32 | │ └── errorCode
33 | │ └── Common_ErrorCode.md
34 | └── source
35 | └── did-common-sdk-server
36 | ├── gradle
37 | └── src
38 | └── build.gradle
39 | └── README.md
40 | ```
41 |
42 |
43 |
44 | Below is a description of each folder and file in the directory:
45 |
46 | | Name | Description |
47 | | ----------------------- | ----------------------------------------------- |
48 | | CHANGELOG.md | Version-specific changes in the project |
49 | | CODE_OF_CONDUCT.md | Code of conduct for contributors |
50 | | CONTRIBUTING.md | Contribution guidelines and procedures |
51 | | LICENSE | License |
52 | | dependencies-license.md | Licenses for the project’s dependency libraries |
53 | | MAINTAINERS.md | Guidelines for project maintainers |
54 | | RELEASE-PROCESS.md | Procedures for releasing new versions |
55 | | SECURITY.md | Security policies and vulnerability reporting |
56 | | docs | Documentation |
57 | | ┖ api | API guide documentation |
58 | | ┖ errorCode | Error codes and troubleshooting guides |
59 | | source | Server source code project |
60 | | ┖ did-common-sdk-server | Common SDK source code and build files |
61 | | ┖ gradle | Gradle build configurations and scripts |
62 | | ┖ src | Main source code directory |
63 | | ┖ build.gradle | Gradle build configuration file |
64 | | ┖ README.md | Overview and instructions for the source code |
65 |
66 |
67 |
68 |
69 | ## Libraries
70 |
71 | Libraries used in this project are organized into two main categories:
72 |
73 | 1. **Third-Party Libraries**: These libraries are open-source dependencies managed via the [build.gradle](source/did-common-sdk-server/build.gradle) file. For a detailed list of third-party libraries and their licenses, please refer to the [dependencies-license.md](dependencies-license.md) file.
74 |
75 | ## API Reference
76 |
77 | | Class | Key Features | API Documentation Link |
78 | | -------------- | ------------------------------------------------------------------ | ------------------------------------------- |
79 | | DateTimeUtil | Gets current UTC time, add time, parse time strings | [Server Common SDK - DateTimeUtil API](./docs/api/Server%20Common%20SDK_DateTimeUtil.md) |
80 | | DidValidator | DID Verification , DID Key Verification URL | [Server Common SDK - DidValidator API](./docs/api/Server%20Common%20SDK_DidValidator.md) |
81 | | HexUtil | Convert byte array to hexadecimal string | [Server Common SDK - HexUtil API](./docs/api/Server%20Common%20SDK_HexUtil.md) |
82 | | HttpClientUtil | HTTP GET Reguest, HTTP POST Reguest | [Server Common SDK - HttpClientUtil API](./docs/api/Server%20Common%20SDK_HttpClientUtil.md) |
83 | | JsonUtil | Serialize object to JSON string, deserialize JSON string to object | [Server Common SDK - JsonUtil API](./docs/api/Server%20Common%20SDK_JsonUtil.md) |
84 | | QrMaker | Convert data to QR code image and return as byte array | [Server Common SDK - QrMaker API](./docs/api/Server%20Common%20SDK_QrMaker.md) |
85 |
86 | ## Change Log
87 |
88 | The Change Log provides a detailed record of version-specific changes and updates. You can find it here:
89 | - [Change Log](./CHANGELOG.md)
90 |
91 | ## OpenDID Demonstration Videos
92 | To watch our demonstration videos of the OpenDID system in action, please visit our [Demo Repository](https://github.com/OmniOneID/did-demo-server).
93 |
94 | These videos showcase key features including user registration, VC issuance, and VP submission processes.
95 |
96 | ## Contributing
97 |
98 | Please read [CONTRIBUTING.md](CONTRIBUTING.md) and [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) for details on our code of conduct, and the process for submitting pull requests to us.
99 |
100 | ## License
101 | [Apache 2.0](LICENSE)
102 |
--------------------------------------------------------------------------------
/docs/api/Server Common SDK_DateTimeUtil.md:
--------------------------------------------------------------------------------
1 | ---
2 | puppeteer:
3 | pdf:
4 | format: A4
5 | displayHeaderFooter: true
6 | landscape: false
7 | scale: 0.8
8 | margin:
9 | top: 1.2cm
10 | right: 1cm
11 | bottom: 1cm
12 | left: 1cm
13 | image:
14 | quality: 100
15 | fullPage: false
16 | ---
17 |
18 |
19 | # Server Common SDK API - DateTimeUtil
20 |
21 | - Date: 2024-09-02
22 | - Version: v1.0.0
23 |
24 | | Version | Date | History |
25 | | ------- | ---------- | ------------------------|
26 | | v1.0.0 | 2024-09-02 | Initial |
27 |
28 |
29 |
30 | # Table of Contents
31 |
32 |
33 |
34 | - [1. getCurrentUTCTimeString](#1-getcurrentutctimestring)
35 | - [2. addHoursToCurrentTimeString](#2-addhourstocurrenttimestring)
36 | - [3. addToCurrentTimeString](#3-addtocurrenttimestring)
37 | - [4. isExpired](#4-isexpired)
38 | - [5. parseUtcTimeStringToInstant](#5-parseutctimestringtoinstant)
39 |
40 |
41 |
42 | # APIs
43 |
44 | ## 1. getCurrentUTCTimeString
45 |
46 | ### Description
47 | Returns the current UTC time as a string in ISO 8601 format.
48 |
49 | ### Declaration
50 |
51 | ```java
52 | public static String getCurrentUTCTimeString()
53 | ```
54 |
55 | ### Returns
56 |
57 | | Type | Description |
58 | |--------|---------------------------------------|
59 | | String | Current UTC time in ISO 8601 format |
60 |
61 | ### Usage
62 | ```java
63 | String localTimeString = getCurrentUTCTimeString();
64 | System.out.println("Current Local Time: " + localTimeString);
65 | ```
66 |
67 |
68 |
69 | ## 2. addHoursToCurrentTimeString
70 |
71 | ### Description
72 | Adds the specified number of hours to the current time and returns the result as an ISO 8601 formatted string.
73 |
74 | ### Declaration
75 |
76 | ```java
77 | public static String addHoursToCurrentTimeString(int hours)
78 | ```
79 |
80 | ### Parameters
81 |
82 | | Name | Type | Description |
83 | |-------|------|------------------------|
84 | | hours | int | Number of hours to add |
85 |
86 | ### Returns
87 |
88 | | Type | Description |
89 | |--------|---------------------------------------------|
90 | | String | Updated time in ISO 8601 format |
91 |
92 | ### Usage
93 | ```java
94 | String newTimeWithAddedHours = addHoursToCurrentTimeString(5);
95 | System.out.println("Time after adding 5 hours: " + newTimeWithAddedHours);
96 | ```
97 |
98 |
99 |
100 | ## 3. addToCurrentTimeString
101 |
102 | ### Description
103 | Adds a specified unit of time to the current time and returns the result as a string in ISO 8601 format.
104 |
105 | ### Declaration
106 |
107 | ```java
108 | public static String addToCurrentTimeString(long amountToAdd, ChronoUnit unit)
109 | ```
110 |
111 | ### Parameters
112 |
113 | | Name | Type | Description |
114 | |-------------|-----------|----------------------------------|
115 | | amountToAdd | long | Amount of time to add |
116 | | unit | ChronoUnit| Unit of time to add (e.g., HOURS)|
117 |
118 | ### Returns
119 |
120 | | Type | Description |
121 | |--------|--------------------------------------------|
122 | | String | Updated time in ISO 8601 format |
123 |
124 | ### Usage
125 | ```java
126 | String newTimeWithAddedMinutes = addToCurrentTimeString(30, ChronoUnit.MINUTES);
127 | System.out.println("Time after adding 30 minutes: " + newTimeWithAddedMinutes);
128 | ```
129 |
130 |
131 |
132 | ## 4. isExpired
133 |
134 | ### Description
135 | Checks if the specified time has expired. This method compares the current time with the provided expiration time to determine whether the current time is after the expiration time.
136 |
137 | ### Declaration
138 |
139 | ```java
140 | public static boolean isExpired(Instant expiredAt)
141 | ```
142 |
143 | ### Parameters
144 |
145 | | Name | Type | Description |
146 | |-----------|---------|----------------------------------|
147 | | expiredAt | Instant | The expiration time to verify |
148 |
149 | ### Returns
150 |
151 | | Type | Description |
152 | |---------|----------------------------------------------|
153 | | boolean | true if expired, false otherwise |
154 |
155 | ### Usage
156 | ```java
157 | Instant futureTime = Instant.now().plusSeconds(60);
158 | boolean isFutureExpired = isExpired(futureTime);
159 | System.out.println("Is future time expired? " + isFutureExpired);
160 |
161 | Instant pastTime = Instant.now().minusSeconds(60);
162 | boolean isPastExpired = isExpired(pastTime);
163 | System.out.println("Is past time expired? " + isPastExpired);
164 | ```
165 |
166 |
167 |
168 | ## 5. parseUtcTimeStringToInstant
169 |
170 | ### Description
171 | Parses a string in ISO 8601 format into an Instant object.
172 |
173 | ### Declaration
174 |
175 | ```java
176 | public static Instant parseUtcTimeStringToInstant(String timeString)
177 | ```
178 |
179 | ### Parameters
180 |
181 | | Name | Type | Description |
182 | |------------|--------|---------------------------------------|
183 | | timeString | String | ISO 8601 format time string |
184 |
185 | ### Returns
186 |
187 | | Type | Description |
188 | |---------|-----------------|
189 | | Instant | Instant object |
190 |
191 | ### Usage
192 | ```java
193 | Instant parsedTime = parseUtcTimeStringToInstant(newTimeWithAddedHours);
194 | ```
195 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | We as members, contributors, and leaders pledge to make participation in our
6 | community a harassment-free experience for everyone, regardless of age, body
7 | size, visible or invisible disability, ethnicity, sex characteristics, gender
8 | identity and expression, level of experience, education, socio-economic status,
9 | nationality, personal appearance, race, religion, or sexual identity
10 | and orientation.
11 |
12 | We pledge to act and interact in ways that contribute to an open, welcoming,
13 | diverse, inclusive, and healthy community.
14 |
15 | ## Our Standards
16 |
17 | Examples of behavior that contributes to a positive environment for our
18 | community include:
19 |
20 | * Demonstrating empathy and kindness toward other people
21 | * Being respectful of differing opinions, viewpoints, and experiences
22 | * Giving and gracefully accepting constructive feedback
23 | * Accepting responsibility and apologizing to those affected by our mistakes,
24 | and learning from the experience
25 | * Focusing on what is best not just for us as individuals, but for the
26 | overall community
27 |
28 | Examples of unacceptable behavior include:
29 |
30 | * The use of sexualized language or imagery, and sexual attention or
31 | advances of any kind
32 | * Trolling, insulting or derogatory comments, and personal or political attacks
33 | * Public or private harassment
34 | * Publishing others' private information, such as a physical or email
35 | address, without their explicit permission
36 | * Other conduct which could reasonably be considered inappropriate in a
37 | professional setting
38 |
39 | ## Enforcement Responsibilities
40 |
41 | Community leaders are responsible for clarifying and enforcing our standards of
42 | acceptable behavior and will take appropriate and fair corrective action in
43 | response to any behavior that they deem inappropriate, threatening, offensive,
44 | or harmful.
45 |
46 | Community leaders have the right and responsibility to remove, edit, or reject
47 | comments, commits, code, wiki edits, issues, and other contributions that are
48 | not aligned to this Code of Conduct, and will communicate reasons for moderation
49 | decisions when appropriate.
50 |
51 | ## Scope
52 |
53 | This Code of Conduct applies within all community spaces, and also applies when
54 | an individual is officially representing the community in public spaces.
55 | Examples of representing our community include using an official e-mail address,
56 | posting via an official social media account, or acting as an appointed
57 | representative at an online or offline event.
58 |
59 | ## Enforcement
60 |
61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
62 | reported at [technology@omnione.net](mailto:technology@omnione.net).
63 | to the community leaders responsible for enforcement.
64 |
65 | All complaints will be reviewed and investigated promptly and fairly.
66 |
67 | All community leaders are obligated to respect the privacy and security of the
68 | reporter of any incident.
69 |
70 | ## Enforcement Guidelines
71 |
72 | Community leaders will follow these Community Impact Guidelines in determining
73 | the consequences for any action they deem in violation of this Code of Conduct:
74 |
75 | ### 1. Correction
76 |
77 | **Community Impact**: Use of inappropriate language or other behavior deemed
78 | unprofessional or unwelcome in the community.
79 |
80 | **Consequence**: A private, written warning from community leaders, providing
81 | clarity around the nature of the violation and an explanation of why the
82 | behavior was inappropriate. A public apology may be requested.
83 |
84 | ### 2. Warning
85 |
86 | **Community Impact**: A violation through a single incident or series
87 | of actions.
88 |
89 | **Consequence**: A warning with consequences for continued behavior. No
90 | interaction with the people involved, including unsolicited interaction with
91 | those enforcing the Code of Conduct, for a specified period of time. This
92 | includes avoiding interactions in community spaces as well as external channels
93 | like social media. Violating these terms may lead to a temporary or
94 | permanent ban.
95 |
96 | ### 3. Temporary Ban
97 |
98 | **Community Impact**: A serious violation of community standards, including
99 | sustained inappropriate behavior.
100 |
101 | **Consequence**: A temporary ban from any sort of interaction or public
102 | communication with the community for a specified period of time. No public or
103 | private interaction with the people involved, including unsolicited interaction
104 | with those enforcing the Code of Conduct, is allowed during this period.
105 | Violating these terms may lead to a permanent ban.
106 |
107 | ### 4. Permanent Ban
108 |
109 | **Community Impact**: Demonstrating a pattern of violation of community
110 | standards, including sustained inappropriate behavior, harassment of an
111 | individual, or aggression toward or disparagement of classes of individuals.
112 |
113 | **Consequence**: A permanent ban from any sort of public interaction within
114 | the community.
115 |
116 | ## Attribution
117 |
118 | This Code of Conduct is adapted from the [Contributor Covenant][homepage],
119 | version 2.0, available at
120 | [https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].
121 |
122 | Community Impact Guidelines were inspired by
123 | [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
124 |
125 | For answers to common questions about this code of conduct, see the FAQ at
126 | [https://www.contributor-covenant.org/faq][FAQ]. Translations are available
127 | at [https://www.contributor-covenant.org/translations][translations].
128 |
129 | [homepage]: https://www.contributor-covenant.org
130 |
131 | [v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html
132 |
133 | [Mozilla CoC]: https://github.com/mozilla/diversity
134 |
135 | [FAQ]: https://www.contributor-covenant.org/faq
136 |
137 | [translations]: https://www.contributor-covenant.org/translations
--------------------------------------------------------------------------------
/source/did-common-sdk-server/src/main/java/org/omnione/did/common/util/HttpClientUtil.java:
--------------------------------------------------------------------------------
1 | package org.omnione.did.common.util;
2 |
3 | import com.fasterxml.jackson.databind.ObjectMapper;
4 | import org.omnione.did.common.exception.ErrorCode;
5 | import org.omnione.did.common.exception.HttpClientException;
6 | import org.omnione.did.common.exception.CommonSdkException;
7 |
8 | import java.io.IOException;
9 | import java.net.URI;
10 | import java.net.http.HttpClient;
11 | import java.net.http.HttpRequest;
12 | import java.net.http.HttpResponse;
13 |
14 | /**
15 | * Utility class for sending HTTP GET and POST requests using HttpClient.
16 | */
17 | public class HttpClientUtil {
18 | private static final HttpClient httpClient = HttpClient.newHttpClient();
19 | private static final ObjectMapper objectMapper = new ObjectMapper();
20 |
21 | /**
22 | * Send an HTTP GET request to the given URL and returns the response body as a String.
23 | * @param url URL to send the request to
24 | * @return Response body as a String
25 | * @throws CommonSdkException if the HTTP request fails
26 | */
27 | public static String getData(String url) throws HttpClientException {
28 | try {
29 | HttpRequest request = HttpRequest.newBuilder()
30 | .uri(URI.create(url))
31 | .GET()
32 | .build();
33 |
34 | HttpResponse response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
35 | int statusCode = response.statusCode();
36 | if (statusCode < 200 || statusCode >= 300) {
37 | throw new HttpClientException(statusCode, response.body());
38 | }
39 | return response.body();
40 | } catch (IOException | InterruptedException e) {
41 | throw new CommonSdkException(ErrorCode.HTTP_CLIENT_ERROR);
42 | } catch (HttpClientException e) {
43 | throw e;
44 | }
45 | }
46 |
47 | /**
48 | * Send an HTTP POST request to the given URL with the specified request body and returns the response body parsed as the specified class type.
49 | * @param url URL to send the request to
50 | * @param responseType Class type to parse the response body to
51 | * @return Response body parsed as the specified class type
52 | * @throws CommonSdkException if the HTTP request fails
53 | */
54 | public static T getData(String url, Class responseType) throws HttpClientException {
55 | try {
56 | HttpRequest request = HttpRequest.newBuilder()
57 | .uri(URI.create(url))
58 | .GET()
59 | .build();
60 |
61 | HttpResponse response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
62 | int statusCode = response.statusCode();
63 | if (statusCode >= 200 && statusCode < 300) {
64 | return objectMapper.readValue(response.body(), responseType);
65 | } else {
66 | throw new HttpClientException(statusCode, response.body());
67 | }
68 | } catch (IOException | InterruptedException e) {
69 | throw new CommonSdkException(ErrorCode.HTTP_CLIENT_ERROR);
70 | } catch (HttpClientException e) {
71 | throw e;
72 | }
73 | }
74 |
75 | /**
76 | * Send an HTTP POST request to the given URL with the specified request body and returns the response body as a String.
77 | * @param url URL to send the request to
78 | * @param requestBody Request body to send
79 | * @return Response body as a String
80 | * @throws CommonSdkException if the HTTP request fails
81 | */
82 | public static String postData(String url, String requestBody) throws IOException, InterruptedException, HttpClientException {
83 | try {
84 | HttpRequest request = HttpRequest.newBuilder()
85 | .uri(URI.create(url))
86 | .POST(HttpRequest.BodyPublishers.ofString(requestBody))
87 | .header("Content-Type", "application/json")
88 | .build();
89 | HttpResponse response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
90 | int statusCode = response.statusCode();
91 | if (statusCode < 200 || statusCode >= 300) {
92 | throw new HttpClientException(statusCode, response.body());
93 | }
94 | return response.body();
95 | } catch (IOException | InterruptedException e) {
96 | throw new CommonSdkException(ErrorCode.HTTP_CLIENT_ERROR);
97 | } catch (HttpClientException e) {
98 | throw e;
99 | }
100 | }
101 |
102 | /**
103 | * Send an HTTP POST request to the given URL with the specified request body and returns the response body parsed as the specified class type.
104 | *
105 | * @param url URL to send the request to
106 | * @param requestBody Request body to send
107 | * @param responseType Class type to parse the response body to
108 | * @return Response body parsed as the specified class type
109 | * @throws CommonSdkException if the HTTP request fails
110 | */
111 | public static T postData(String url, String requestBody, Class responseType) throws HttpClientException {
112 | try {
113 | HttpRequest request = HttpRequest.newBuilder()
114 | .uri(URI.create(url))
115 | .POST(HttpRequest.BodyPublishers.ofString(requestBody))
116 | .header("Content-Type", "application/json")
117 | .build();
118 |
119 | HttpResponse response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
120 |
121 | int statusCode = response.statusCode();
122 | if (statusCode >= 200 && statusCode < 300) {
123 | return objectMapper.readValue(response.body(), responseType);
124 | } else {
125 | throw new HttpClientException(statusCode, response.body());
126 | }
127 | } catch (IOException | InterruptedException e) {
128 | throw new CommonSdkException(ErrorCode.HTTP_CLIENT_ERROR);
129 | } catch (HttpClientException e) {
130 | throw e;
131 | }
132 | }
133 | }
134 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contribution Guidelines
2 | We appreciate your contributions! We want to make contributing to this project as easy and transparent as possible, whether it's:
3 |
4 | - Reporting a bug
5 | - Discussing the current state of the code
6 | - Submitting a fix
7 | - Proposing new features
8 |
9 | ## Contribution Process
10 | Thank you for contributing to the project! This guide explains how to contribute to the project, the code style rules, and the review criteria. Please familiarize yourself with the following content before making any contributions.
11 |
12 | 1. **Creating an Issue**
13 | - Before starting any work, create an issue related to the task you wish to work on. All work, including bug fixes, feature improvements, and new proposals, should be initiated after the issue is registered.
14 | - When creating an issue, use the provided issue template and fill in accurate information.
15 | 2. **Issue Assignment**
16 | - Once the issue is created, the administrator will review and may assign the issue to an external contributor.
17 | - Before being assigned, make sure that the same task is not already in progress.
18 | 3. **Fork and Branch Creation**
19 | - Refer to [Pull Request Guidelines](#pull-request-guidelines)
20 | 4. **Writing Code**
21 | - Ensure that the code strictly follows the project's [Coding Style](#coding-style) guidelines.
22 | - Submit the PR after confirming that all tests pass successfully.
23 | 5. **Creating a Pull Request (PR)**
24 | - Commit your work and create a PR.
25 | - In the PR description, provide detailed information about the changes and link the related issue number to connect it to the issue.
26 | - Write concise and clear commit messages.
27 | - Refer to [Commit Message Guideline](#commit-message-guidelines)
28 | 6. **Code Review**
29 | - Once the PR is created, the administrator will review the code. Update the PR by incorporating the reviewer’s feedback.
30 | - Once the review is complete, the administrator will merge the PR.
31 |
32 | ## Detailed Contribution Guide via GitHub
33 | Please refer to [Detailed Contribution Guide via GitHub](https://github.com/OmniOneID/did-doc-architecture/blob/main/how_to_contribute_to_open_did.md) for detailed instructions on how to contribute to the project. This guide includes command examples and screenshots to help you better understand the process.
34 |
35 | ## Code Review Standards
36 | We conduct code reviews based on the following standards to ensure that your contribution maintains consistency with the project and upholds quality:
37 |
38 | 1. **Code Quality**
39 | - Write code that is easy to read and maintain.
40 | - Avoid overly complex logic, and if possible, suggest better solutions.
41 | - Minimize duplicated code and check if the code can be refactored into reusable modules.
42 | 2. **Feature Verification**
43 | - Test the new feature or bug fix to ensure it works as intended.
44 | - All tests must pass before submitting the PR.
45 | - Include any additional necessary tests in the PR.
46 | 3. **Code Style Compliance**
47 | - Ensure that your code follows the project's [Coding Style](#coding-style).
48 | - Feedback will be given if there are formatting issues or violations of naming conventions.
49 | 4. **Commit Messages**
50 | - Ensure that commit messages clearly describe the changes made.
51 | - Avoid including too many modifications in a single commit. If possible, divide changes into smaller commits.
52 | 5. **Documentation**
53 | - If new features, APIs, or configuration changes are introduced, make sure to update or add relevant documentation.
54 | - Write appropriate comments in the code, especially for explaining complex logic.
55 |
56 | ## Code of Conduct
57 | We are committed to fostering a contribution environment where everyone is treated with respect. Please make sure to read and follow the [Code of Conduct](CODE_OF_CONDUCT.md) before starting your contribution.
58 |
59 | ## Issue Reporting Guidelines
60 | We use GitHub Issues to track and manage bugs.
61 | If you encounter a bug, please open a new issue on GitHub. When reporting an issue, please use the provided issue template to clearly describe the problem. This helps us resolve the issue more quickly.
62 |
63 | ### Writing a Good Bug Report
64 | A good bug report includes the following:
65 | - A quick summary or background of the issue.
66 | - Steps to reproduce the bug (be specific and detailed).
67 | - Expected vs. actual results.
68 | - Any additional context or information that could help us diagnose the issue.
69 |
70 | ## Pull Request Guidelines
71 | 1. **Fork** from the `develop` branch of the remote repository.
72 | 2. **Develop the feature**, and ensure the code has been properly tested.
73 | 3. If necessary, update the **documentation** to reflect the changes.
74 | 4. Verify that all tests pass and that the code adheres to our coding style and linting rules.
75 | 5. Once the work is complete, submit a **pull request** to the `develop` branch.
76 | 6. When creating the pull request, assign an appropriate **reviewer** to review the code changes.
77 | It is recommended to choose someone familiar with the codebase, considering their availability for providing feedback.
78 | 7. Also, assign **assignees** to clarify responsibility for the task.
79 | Assign **all maintainers of the repository** as assignees to ensure accountability and a smooth review process.
80 |
81 | > **Note**: Assignees are responsible for ensuring the pull request is reviewed and merged appropriately. Assigning all maintainers as assignees is a crucial step to ensure they are aware of the changes and can respond quickly.
82 |
83 | ## Coding Style
84 | Our coding style is based on the [OpenDID Coding Style](https://github.com/OmniOneID/did-doc-architecture/blob/main/docs/rules/coding_style.md). Adhering to these guidelines ensures that the code is clean, readable, and maintainable.
85 |
86 | ## Document Creation and Editing Guide
87 | Our document creation process follows the [OpenDID Document Guide](https://github.com/OmniOneID/did-doc-architecture/blob/main/docs/guide/docs/write_document_guide.md). Most of the design documents we create use the Markdown (*.md) format, ensuring consistency and ease of collaboration.
88 |
89 | ## Commit Message Guidelines
90 | Our commit messages follow the [OpenDID Commit Rule](https://github.com/OmniOneID/did-doc-architecture/blob/main/docs/rules/git_code_commit_rule.md). Well-structured commit messages help others understand the intent behind your changes and make it easier to navigate the code history.
91 |
92 | ## Signing the CLA
93 | Before we can accept your pull request, you must submit a CLA. This only needs to be done once. Complete your CLA here: [Contributor License Agreement](CLA.md)
94 |
95 | ## License
96 | [Apache 2.0](LICENSE)
--------------------------------------------------------------------------------
/CLA.md:
--------------------------------------------------------------------------------
1 | # Individual Software Grant and Contributor License Agreement
2 | ## Based on the Apache Software Foundation Software Grant and Individual Contributor License Agreement
3 | ### http://www.apache.org/licenses/
4 |
5 | Thank you for your interest in the OpenDID project (the “Project”). In order to clarify the
6 | intellectual property license granted with Contributions (defined below) from any person or
7 | entity, the Project must have a Contributor License Agreement (“CLA”) on file that has been
8 | signed by each Contributor, indicating agreement to the license terms below. This license is for
9 | your protection as a Contributor as well as the protection of the Project and its users; it does
10 | not change your rights to use your own Contributions for any other purpose.
11 |
12 | You accept and agree to the following terms and conditions for Your present and future
13 | Contributions submitted to the Project. In return, the Project shall not use Your Contributions in
14 | a way that is contrary to the public benefit or inconsistent with its nonprofit status and bylaws
15 | in effect at the time of the Contribution. Except for the license granted herein to the Project
16 | and recipients of software distributed by the Project, You reserve all right, title, and interest in
17 | and to Your Contributions.
18 |
19 | **1. Definitions.**
20 | This document is a CLA (Contributor License Agreement) that must be signed by all Contributors to the Project.
21 | **“You”** or **“Your”** shall mean the copyright owner or legal entity authorized by the copyright owner that is making this CLA with the Project. For legal entities, the entity making a Contribution and all other entities that control, are controlled by, or are under common control with that entity are considered to be a single Contributor. For the purposes of this definition, “control” means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
22 | **“Contribution”** shall mean the code, documentation or other original works of authorship expressly identified in Schedule A, as well as any original work of authorship, including any modifications or additions to an existing work, that is intentionally submitted by You to the Project for inclusion in, or documentation of, any of the products owned or managed by the Project (the **“Work”**). For the purposes of this definition, “submitted” means any form of electronic, verbal, or written communication sent to the Project or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Project for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by You as “Not a Contribution.”
23 |
24 | **2. Grant of Copyright License.**
25 | Subject to the terms and conditions of this CLA, You hereby grant to the Project and to recipients of software distributed by the Project a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute Your Contributions and such derivative works.
26 | For the avoidance of doubt, by agreeing to this CLA, You confirm that the Project and recipients of software distributed by the Project are free to use the code, documentation, or other original works of authorship that You submit as part of Your Contributions.
27 |
28 | **3. Grant of Patent License.**
29 | Subject to the terms and conditions of this CLA, You hereby grant to the Project and to recipients of software distributed by the Project a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by You that are necessarily infringed by Your Contribution(s) alone or by combination of Your Contribution(s) with the Work to which such Contribution(s) was submitted.
30 | Should any entity initiate patent litigation against you or any other entity (imcluding through a cross-claim or counterclaim in a lawsuit), alleging that your Contribution or the Work to which you have contributed constitutes direct or contributory patent infrigement, any patent licenses granted to that entity for the Contribution or Work shall be terminated as of the date such litigation is filed.
31 |
32 | **4. Representations with Respect to the License and Contributions.**
33 | You represent that you are legally entitled to grant the above license. If your employer(s) has rights to intellectual property that you create that includes your Contributions, you represent that you have received permission to make Contributions on behalf of that employer, that your employer has waived such rights for your Contributions to the Project, or that your employer has executed a separate Corporate CLA with the Project.
34 |
35 | **5. Additional Representations with Respect to Contributions.**
36 | You represent that each of Your Contributions is Your original creation (see section 7 for submissions on behalf of others). You represent that Your Contribution submissions include complete details of any third-party license or other restriction (including, but not limited to, related patents and trademarks) of which you are personally aware and which are associated with any part of Your Contributions.
37 |
38 | **6. Disclaimers.**
39 | You have no additional obligations, such as making further code support, after making a Contribution, and any support for Your Contribution is at Your discretion.
40 | You may provide support for free, for a fee, or not at all. Unless required by applicable law or agreed to in writing, You provide Your Contributions on an "AS IS" BASE, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
41 | Also, You shall retain the rights to Your Contribution and may use it for other projects or purposes.
42 |
43 | **7. Non-Original Creations.**
44 | Should You wish to submit work that is not Your original creation, You may submit it to the Project separately from any Contribution, identifying the complete details of its source and of any license or other restriction (including, but not limited to, related patents, trademarks, and license agreements) of which you are personally aware, and conspicuously marking the work as “Submitted on behalf of a third-party: [named here].”
45 | Additionally, if submitting non-original works, You must cleary specify the original author's license and submit it as a separate file.
46 | If You violate this obligation by submitting a third party's work without proper authorization, resulting in copyright infrigement, You shall be solely responsible for any legal liabilities arising from such infrigement.
47 |
48 | **8. Agreements.**
49 | You agree to notify the Project of any facts or circumstances of which you become aware that would make these representations inaccurate in any respect.
50 | "To sign this CLA, please follow the automated procedure on GitHub or download the PDF, sign it, and submit it to technology@omnione.net."
--------------------------------------------------------------------------------
/source/did-common-sdk-server/src/main/java/org/omnione/did/common/util/JsonUtil.java:
--------------------------------------------------------------------------------
1 | package org.omnione.did.common.util;
2 |
3 | import com.fasterxml.jackson.annotation.JsonInclude.Include;
4 | import com.fasterxml.jackson.core.JsonProcessingException;
5 | import com.fasterxml.jackson.core.type.TypeReference;
6 | import com.fasterxml.jackson.databind.JsonNode;
7 | import com.fasterxml.jackson.databind.ObjectMapper;
8 | import com.fasterxml.jackson.databind.SerializationFeature;
9 | import com.fasterxml.jackson.databind.node.ArrayNode;
10 | import com.fasterxml.jackson.databind.node.ObjectNode;
11 | import org.omnione.did.common.exception.ErrorCode;
12 | import org.omnione.did.common.exception.CommonSdkException;
13 |
14 | import java.util.Iterator;
15 | import java.util.Map;
16 | import java.util.TreeMap;
17 |
18 | /**
19 | * Utility class for JSON serialization and deserialization.
20 | * This class provides methods to serialize objects to JSON strings, sort the keys,
21 | * and remove all whitespace. It is used in OpenDID for serializing the original text
22 | * when signing.
23 | */
24 | public class JsonUtil {
25 | private static final ObjectMapper mapper = new ObjectMapper();
26 |
27 | static {
28 | mapper.setSerializationInclusion(Include.NON_NULL);
29 | mapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
30 | }
31 |
32 | /**
33 | * Serialize an object to a JSON string and sort the keys.
34 | * This method serializes the object to a JSON string and then sorts the keys in the JSON object.
35 | * It returns the sorted JSON string.
36 | * @param obj the object to serialize
37 | * @return the sorted JSON string
38 | * @throws CommonSdkException if an error occurs during serialization and sort
39 | */
40 | public static String serializeAndSort(Object obj) {
41 | try {
42 | String jsonString = mapper.writeValueAsString(obj);
43 | JsonNode node = mapper.readTree(jsonString);
44 | JsonNode sortedNode = sortJsonNode(node);
45 | String sortedJsonString = mapper.writeValueAsString(sortedNode);
46 | return removeEscapeCharactersExceptValues(sortedJsonString);
47 | } catch (JsonProcessingException e) {
48 | throw new CommonSdkException(ErrorCode.JSON_SERIALIZE_SORT_FAILED);
49 | }
50 |
51 | }
52 |
53 | /**
54 | * Remove all whitespace characters from a JSON string.
55 | * This method removes all whitespace characters from a JSON string.
56 | * It returns the JSON string without any whitespace characters.
57 | * @param jsonString the JSON string to process
58 | * @return the JSON string without any whitespace characters
59 | */
60 | private static String removeEscapeCharactersExceptValues(String jsonString) {
61 | StringBuilder result = new StringBuilder();
62 | boolean inValue = false;
63 |
64 | for (int i = 0; i < jsonString.length(); i++) {
65 | char currentChar = jsonString.charAt(i);
66 |
67 | if (currentChar == '\"') {
68 | inValue = !inValue;
69 | }
70 |
71 | if (currentChar == '\\' && (i + 1) < jsonString.length()) {
72 | char nextChar = jsonString.charAt(i + 1);
73 | if (!inValue && (nextChar == '\"' || nextChar == '/')) {
74 | continue;
75 | }
76 | }
77 | result.append(currentChar);
78 | }
79 |
80 | return result.toString();
81 | }
82 |
83 | /**
84 | * Sort the keys in a JSON node.
85 | * This method sorts the keys in a JSON node and returns the sorted node.
86 | * @param node the JSON node to sort
87 | * @return the sorted JSON node
88 | */
89 | private static JsonNode sortJsonNode(JsonNode node) {
90 | if (node.isObject()) {
91 | ObjectNode sortedNode = mapper.createObjectNode();
92 | Iterator> fields = node.fields();
93 | Map sortedMap = new TreeMap<>();
94 | while (fields.hasNext()) {
95 | Map.Entry field = fields.next();
96 | sortedMap.put(field.getKey(), sortJsonNode(field.getValue()));
97 | }
98 | sortedMap.forEach(sortedNode::set);
99 | return sortedNode;
100 | } else if (node.isArray()) {
101 | ArrayNode sortedArrayNode = mapper.createArrayNode();
102 | for (JsonNode item : node) {
103 | sortedArrayNode.add(sortJsonNode(item));
104 | }
105 | return sortedArrayNode;
106 | }
107 | return node;
108 | }
109 |
110 | /**
111 | * Convert any object to a JSON string.
112 | * This method converts any object to a JSON string and returns the JSON string.
113 | * @param obj the object to convert
114 | * @return the JSON string
115 | * @throws CommonSdkException if an error occurs during serialization
116 | */
117 | public static String serializeToJson(Object obj) {
118 | try {
119 | return mapper.writeValueAsString(obj);
120 | } catch (JsonProcessingException e) {
121 | throw new CommonSdkException(ErrorCode.JSON_SERIALIZE_FAILED);
122 | }
123 | }
124 |
125 | /**
126 | * Deserialize a JSON string into an object of the specified class type.
127 | *
128 | * This method is useful for converting a JSON string into a simple Java object (POJO).
129 | * However, it does not support complex generic types such as `List` or `Map`,
130 | * as Java erases generic type information at runtime.
131 | *
132 | *
133 | * @param jsonString the JSON string to deserialize
134 | * @param clazz the class type of the
135 | * @param the class type of the object to deserialize
136 | * @return the deserialized object
137 | * @throws CommonSdkException if an error occurs during deserialization
138 | */
139 | public static T deserializeFromJson(String jsonString, Class clazz) {
140 | try {
141 | return mapper.readValue(jsonString, clazz);
142 | } catch (JsonProcessingException e) {
143 | throw new CommonSdkException(ErrorCode.JSON_DESERIALIZE_FAILED);
144 | }
145 | }
146 |
147 | /**
148 | * Deserialize a JSON string into an object of a complex or generic type.
149 | *
150 | * This method supports deserialization into generic types such as `List` and `Map`.
151 | * It maintains type information by using `TypeReference`, preventing type erasure issues.
152 | *
153 | *
154 | *
155 | * Example usage:
156 | * {@code
157 | * List list = JsonUtil.deserializeFromJson(jsonString, new TypeReference>() {});
158 | * Map map = JsonUtil.deserializeFromJson(jsonString, new TypeReference
161 | *
162 | * @param jsonString the JSON string to deserialize
163 | * @param typeReference the TypeReference indicating the target type
164 | * @param the type of the object to deserialize
165 | * @return the deserialized object of type T
166 | * @throws CommonSdkException if an error occurs during deserialization
167 | */
168 | public static T deserializeFromJson(String jsonString, TypeReference typeReference) {
169 | try {
170 | return mapper.readValue(jsonString, typeReference);
171 | } catch (JsonProcessingException var3) {
172 | throw new CommonSdkException(ErrorCode.JSON_DESERIALIZE_FAILED);
173 | }
174 | }
175 | }
--------------------------------------------------------------------------------
/source/did-common-sdk-server/src/main/java/org/omnione/did/common/util/DateTimeUtil.java:
--------------------------------------------------------------------------------
1 | package org.omnione.did.common.util;
2 |
3 | import org.omnione.did.common.exception.ErrorCode;
4 | import org.omnione.did.common.exception.CommonSdkException;
5 |
6 | import java.time.Instant;
7 | import java.time.LocalDateTime;
8 | import java.time.ZoneId;
9 | import java.time.ZoneOffset;
10 | import java.time.ZonedDateTime;
11 | import java.time.format.DateTimeFormatter;
12 | import java.time.format.DateTimeParseException;
13 | import java.time.temporal.ChronoUnit;
14 |
15 | /**
16 | * Utility class for date and time operations.
17 | * This class provides methods for working with date and time in UTC format.
18 | */
19 |
20 | public class DateTimeUtil {
21 |
22 | /**
23 | * Return the current UTC time as a string in ISO 8601 format.
24 | * This method returns the current time in UTC as a string in the format "yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'".
25 | * @return The current UTC time as a string in ISO 8601 format.
26 | */
27 | public static String getCurrentUTCTimeString() {
28 | ZonedDateTime utcNow = ZonedDateTime.now(ZoneId.of("UTC"));
29 | ZonedDateTime localNow = utcNow.withZoneSameInstant(ZoneId.systemDefault());
30 |
31 | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'");
32 | return localNow.format(formatter);
33 | }
34 |
35 | /**
36 | * Return the current UTC time as a ZonedDateTime object.
37 | * This method returns the current time in UTC as a ZonedDateTime object.
38 | * @return The current UTC time as a ZonedDateTime object.
39 | */
40 | public static ZonedDateTime getCurrentUTCTime() {
41 | return ZonedDateTime.now(ZoneId.of("UTC"));
42 | }
43 |
44 | /**
45 | * Add the specified number of hours to the current time and return the result as a string in ISO 8601 format.
46 | * @param hours The number of hours to add to the current time.
47 | * @return The resulting time as a string in ISO 8601 format.
48 | */
49 | public static String addHoursToCurrentTimeString(int hours) {
50 | ZonedDateTime utcNow = ZonedDateTime.now(ZoneId.of("UTC")).plus(hours, ChronoUnit.HOURS);
51 | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'");
52 | return utcNow.format(formatter);
53 | }
54 |
55 | /**
56 | * Add the specified number of years to the current time and return the result as a ZonedDateTime object.
57 | * @param years The number of years to add to the current time.
58 | * @return The resulting time as a ZonedDateTime object.
59 | */
60 | public static ZonedDateTime addYearsToCurrentTime(int years) {
61 | return ZonedDateTime.now(ZoneId.of("UTC")).plusYears(years);
62 | }
63 |
64 | /**
65 | * Add the specified amount of time to the current time and return the result as a string in ISO 8601 format.
66 | * @param amountToAdd The amount of time to add to the current time.
67 | * @param unit The unit of time to add (e.g., ChronoUnit.HOURS, ChronoUnit.DAYS).
68 | * @return The resulting time as a string in ISO 8601 format.
69 | */
70 | public static String addToCurrentTimeString(long amountToAdd, ChronoUnit unit) {
71 | ZonedDateTime utcNow = ZonedDateTime.now(ZoneId.of("UTC")).plus(amountToAdd, unit);
72 | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'");
73 | return utcNow.format(formatter);
74 | }
75 |
76 | /**
77 | * Checks if the given Instant has expired.
78 | *
79 | * This method compares the current time (Instant.now()) with the provided
80 | * expiration time (expiredAt) and determines if the current time is after
81 | * the expiration time.
82 | *
83 | * @param expiredAt The expiration time to check against.
84 | * @return True if the expiration time has passed, false otherwise.
85 | *
86 | */
87 | public static boolean isExpired(Instant expiredAt) {
88 | Instant now = Instant.now();
89 |
90 | if (now.isAfter(expiredAt)) {
91 | return true;
92 | };
93 | return false;
94 | }
95 |
96 | /**
97 | * Parse a UTC date time string to an Instant.
98 | * This method parses a UTC date time string in ISO 8601 format and returns the corresponding Instant object.
99 | * @param timeString The UTC date time string to parse.
100 | * @return The Instant object representing the parsed date time.
101 | */
102 | public static Instant parseUtcTimeStringToInstant(String timeString) {
103 | return Instant.parse(timeString);
104 | }
105 |
106 |
107 | /**
108 | * Convert a UTC date time string to a formatted string.
109 | *
110 | * This method takes a UTC date time string as input and returns the date time string
111 | * in the format "yyyy-MM-dd HH:mm:ss".
112 | * @param utcDateTime The UTC date time string to convert.
113 | * @return The formatted date time string.
114 | */
115 | public static String convertUtcToFormattedString(String utcDateTime) {
116 | ZonedDateTime zonedDateTime = ZonedDateTime.parse(utcDateTime);
117 | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
118 |
119 | return zonedDateTime.format(formatter);
120 | }
121 |
122 | /**
123 | * Convert a UTC date time string to a formatted string.
124 | *
125 | * This method takes a UTC date time string and a format string as input
126 | * and returns the date time string in the specified format.
127 | * @param utcDateTime The UTC date time string to convert.
128 | * @param format The format string to use for the conversion.
129 | */
130 | public static String convertUtcToFormattedString(String utcDateTime, String format) {
131 | ZonedDateTime zonedDateTime = ZonedDateTime.parse(utcDateTime);
132 | DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
133 |
134 | return zonedDateTime.format(formatter);
135 | }
136 |
137 | /**
138 | * Check if the second date-time string is later than the first date-time string.
139 | *
140 | * This method takes two date-time strings in UTC format and returns true if the second
141 | * date-time is later than the first date-time.
142 | * @param firstUtcDateTime The first date-time string in UTC format.
143 | * @param secondUtcDateTime The second date-time string in UTC format.
144 | * @return True if the second date-time is later than the first date-time, false otherwise.
145 | *
146 | */
147 | public static boolean isSecondDateTimeLater(String firstUtcDateTime, String secondUtcDateTime) {
148 | try {
149 | ZonedDateTime firstDateTime = ZonedDateTime.parse(firstUtcDateTime);
150 | ZonedDateTime secondDateTime = ZonedDateTime.parse(secondUtcDateTime);
151 |
152 | return secondDateTime.isAfter(firstDateTime);
153 | } catch (DateTimeParseException e) {
154 | System.out.println("Error: One of the date-time strings is not valid: " + e.getMessage());
155 | throw new CommonSdkException(ErrorCode.INVALID_DATE_TIME);
156 | }
157 | }
158 |
159 | /**
160 | * Return the maximum possible UTC time as an Instant.
161 | *
162 | * This method provides the Instant representing the farthest future date, which
163 | * is useful to represent a non-expiring or permanent time.
164 | *
165 | * @return Instant representing the maximum UTC time.*
166 | */
167 | public static Instant getMaxUTCTime() {
168 | return LocalDateTime.of(9999, 12, 31, 23, 59, 59).toInstant(ZoneOffset.UTC);
169 | }
170 |
171 | public static String addMinutesToCurrentTimeString(int minutes) {
172 | ZonedDateTime utcNow = ZonedDateTime.now(ZoneId.of("UTC")).plus(minutes, ChronoUnit.MINUTES);
173 | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'");
174 | return utcNow.format(formatter);
175 | }
176 |
177 | public static String addSecondsToCurrentTimeString(int seconds) {
178 | ZonedDateTime utcNow = ZonedDateTime.now(ZoneId.of("UTC")).plus(seconds, ChronoUnit.SECONDS);
179 | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'");
180 | return utcNow.format(formatter);
181 | }
182 | }
183 |
--------------------------------------------------------------------------------
/source/did-common-sdk-server/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | #
21 | # Gradle start up script for POSIX generated by Gradle.
22 | #
23 | # Important for running:
24 | #
25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26 | # noncompliant, but you have some other compliant shell such as ksh or
27 | # bash, then to run this script, type that shell name before the whole
28 | # command line, like:
29 | #
30 | # ksh Gradle
31 | #
32 | # Busybox and similar reduced shells will NOT work, because this script
33 | # requires all of these POSIX shell features:
34 | # * functions;
35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37 | # * compound commands having a testable exit status, especially «case»;
38 | # * various built-in commands including «command», «set», and «ulimit».
39 | #
40 | # Important for patching:
41 | #
42 | # (2) This script targets any POSIX shell, so it avoids extensions provided
43 | # by Bash, Ksh, etc; in particular arrays are avoided.
44 | #
45 | # The "traditional" practice of packing multiple parameters into a
46 | # space-separated string is a well documented source of bugs and security
47 | # problems, so this is (mostly) avoided, by progressively accumulating
48 | # options in "$@", and eventually passing that to Java.
49 | #
50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52 | # see the in-line comments for details.
53 | #
54 | # There are tweaks for specific operating systems such as AIX, CygWin,
55 | # Darwin, MinGW, and NonStop.
56 | #
57 | # (3) This script is generated from the Groovy template
58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59 | # within the Gradle project.
60 | #
61 | # You can find Gradle at https://github.com/gradle/gradle/.
62 | #
63 | ##############################################################################
64 |
65 | # Attempt to set APP_HOME
66 |
67 | # Resolve links: $0 may be a link
68 | app_path=$0
69 |
70 | # Need this for daisy-chained symlinks.
71 | while
72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73 | [ -h "$app_path" ]
74 | do
75 | ls=$( ls -ld "$app_path" )
76 | link=${ls#*' -> '}
77 | case $link in #(
78 | /*) app_path=$link ;; #(
79 | *) app_path=$APP_HOME$link ;;
80 | esac
81 | done
82 |
83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84 |
85 | APP_NAME="Gradle"
86 | APP_BASE_NAME=${0##*/}
87 |
88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118 |
119 |
120 | # Determine the Java command to use to start the JVM.
121 | if [ -n "$JAVA_HOME" ] ; then
122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123 | # IBM's JDK on AIX uses strange locations for the executables
124 | JAVACMD=$JAVA_HOME/jre/sh/java
125 | else
126 | JAVACMD=$JAVA_HOME/bin/java
127 | fi
128 | if [ ! -x "$JAVACMD" ] ; then
129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130 |
131 | Please set the JAVA_HOME variable in your environment to match the
132 | location of your Java installation."
133 | fi
134 | else
135 | JAVACMD=java
136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137 |
138 | Please set the JAVA_HOME variable in your environment to match the
139 | location of your Java installation."
140 | fi
141 |
142 | # Increase the maximum file descriptors if we can.
143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144 | case $MAX_FD in #(
145 | max*)
146 | MAX_FD=$( ulimit -H -n ) ||
147 | warn "Could not query maximum file descriptor limit"
148 | esac
149 | case $MAX_FD in #(
150 | '' | soft) :;; #(
151 | *)
152 | ulimit -n "$MAX_FD" ||
153 | warn "Could not set maximum file descriptor limit to $MAX_FD"
154 | esac
155 | fi
156 |
157 | # Collect all arguments for the java command, stacking in reverse order:
158 | # * args from the command line
159 | # * the main class name
160 | # * -classpath
161 | # * -D...appname settings
162 | # * --module-path (only if needed)
163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
164 |
165 | # For Cygwin or MSYS, switch paths to Windows format before running java
166 | if "$cygwin" || "$msys" ; then
167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
169 |
170 | JAVACMD=$( cygpath --unix "$JAVACMD" )
171 |
172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
173 | for arg do
174 | if
175 | case $arg in #(
176 | -*) false ;; # don't mess with options #(
177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
178 | [ -e "$t" ] ;; #(
179 | *) false ;;
180 | esac
181 | then
182 | arg=$( cygpath --path --ignore --mixed "$arg" )
183 | fi
184 | # Roll the args list around exactly as many times as the number of
185 | # args, so each arg winds up back in the position where it started, but
186 | # possibly modified.
187 | #
188 | # NB: a `for` loop captures its iteration list before it begins, so
189 | # changing the positional parameters here affects neither the number of
190 | # iterations, nor the values presented in `arg`.
191 | shift # remove old arg
192 | set -- "$@" "$arg" # push replacement arg
193 | done
194 | fi
195 |
196 | # Collect all arguments for the java command;
197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198 | # shell script including quotes and variable substitutions, so put them in
199 | # double quotes to make sure that they get re-expanded; and
200 | # * put everything else in single quotes, so that it's not re-expanded.
201 |
202 | set -- \
203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
204 | -classpath "$CLASSPATH" \
205 | org.gradle.wrapper.GradleWrapperMain \
206 | "$@"
207 |
208 | # Use "xargs" to parse quoted args.
209 | #
210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
211 | #
212 | # In Bash we could simply go:
213 | #
214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
215 | # set -- "${ARGS[@]}" "$@"
216 | #
217 | # but POSIX shell has neither arrays nor command substitution, so instead we
218 | # post-process each arg (as a line of input to sed) to backslash-escape any
219 | # character that might be a shell metacharacter, then use eval to reverse
220 | # that process (while maintaining the separation between arguments), and wrap
221 | # the whole thing up as a single "set" statement.
222 | #
223 | # This will of course break if any of these variables contains a newline or
224 | # an unmatched quote.
225 | #
226 |
227 | eval "set -- $(
228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
229 | xargs -n1 |
230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
231 | tr '\n' ' '
232 | )" '"$@"'
233 |
234 | exec "$JAVACMD" "$@"
235 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright 2024 OmniOne.
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
--------------------------------------------------------------------------------