diff --git a/shnippet.config.json b/shnippet.config.json
index 150a342b0..9c4edba10 100644
--- a/shnippet.config.json
+++ b/shnippet.config.json
@@ -1,7 +1,7 @@
{
"rootDirectory": "./site/testsuites",
"outputDirectory": "./site/snippets",
- "fileExtensions": [".js", ".ts", ".kt", ".gradle", ".xml", ".bash"],
+ "fileExtensions": [".java", ".js", ".ts", ".kt", ".gradle", ".xml", ".bash"],
"exclude": ["pfiOverviewReadOfferingsJs", "pfiOverviewWriteJs", "pfiOverviewWriteOfferingsJs"],
"snippetTags": {
"start": ":snippet-start:",
diff --git a/site/docs/web5/build/decentralized-identifiers/how-to-create-did.mdx b/site/docs/web5/build/decentralized-identifiers/how-to-create-did.mdx
index bcfe543dd..648f1dfde 100644
--- a/site/docs/web5/build/decentralized-identifiers/how-to-create-did.mdx
+++ b/site/docs/web5/build/decentralized-identifiers/how-to-create-did.mdx
@@ -9,7 +9,7 @@ import createADidDependencyGradle from '!!raw-loader!@site/snippets/testsuite-ja
import createADidDependencyMaven from '!!raw-loader!@site/snippets/testsuite-javascript/__tests__/web5/build/decentralized-identifiers/createADidDependencyMaven.snippet.xml';
import createADidDependency from '!!raw-loader!@site/snippets/testsuite-javascript/__tests__/web5/build/decentralized-identifiers/createADidDependency.snippet.bash';
-
+
# Create a DID
@@ -34,7 +34,20 @@ You can create a DID using any of the [Web5-supported DID methods](/docs/web5/le
nestedSnippets: {
Gradle: {
snippet: createADidDependencyGradle,
- language: 'js',
+ language: 'kt',
+ },
+ Maven: {
+ snippet: createADidDependencyMaven,
+ language: 'xml',
+ },
+ },
+ },
+ {
+ language: 'Java',
+ nestedSnippets: {
+ Gradle: {
+ snippet: createADidDependencyGradle,
+ language: 'kt',
},
Maven: {
snippet: createADidDependencyMaven,
@@ -63,6 +76,7 @@ The following DID methods are supported:
snippets={[
{ snippetName: 'createDidDht', language: 'JavaScript' },
{ snippetName: 'createDidDhtKt', language: 'Kotlin' },
+ { snippetName: 'createDidDhtJava', language: 'Java' },
]}
/>
@@ -73,6 +87,7 @@ The following DID methods are supported:
snippets={[
{ snippetName: 'createDidJwk', language: 'JavaScript' },
{ snippetName: 'createDidJwkKt', language: 'Kotlin' },
+ { snippetName: 'createDidJwkJava', language: 'Java' },
]}
/>
@@ -229,4 +244,4 @@ In the example below, the `d` property of the private key component is masked. T
}
]
}
-```
\ No newline at end of file
+```
diff --git a/site/docusaurus.config.js b/site/docusaurus.config.js
index 62260c237..800f06d60 100644
--- a/site/docusaurus.config.js
+++ b/site/docusaurus.config.js
@@ -256,7 +256,8 @@ let config = {
},
],
},
- additionalLanguages: ['kotlin', 'swift', 'dart', 'rust'],
+ // Must add Scala here to work around a Redoc bug: https://github.com/facebook/docusaurus/issues/7209
+ additionalLanguages: ['kotlin', 'swift', 'dart', 'rust', 'java', 'scala'],
},
}),
};
diff --git a/site/src/components/CodeSnippet.jsx b/site/src/components/CodeSnippet.jsx
index 2d3e26e75..5e852543f 100644
--- a/site/src/components/CodeSnippet.jsx
+++ b/site/src/components/CodeSnippet.jsx
@@ -5,6 +5,7 @@ import codeSnippets from '../../src/util/code-snippets-map.json'; // Import for
// Define the language map for the new system
const languageExtensionMap = {
javascript: 'js',
+ java: 'java',
kotlin: 'kt',
swift: 'swift',
dart: 'dart',
diff --git a/site/testsuites/kotlin-testsuite.iml b/site/testsuites/kotlin-testsuite.iml
new file mode 100644
index 000000000..e224c4a52
--- /dev/null
+++ b/site/testsuites/kotlin-testsuite.iml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/site/testsuites/testsuite-kotlin/kotlin-testsuite.iml b/site/testsuites/testsuite-kotlin/kotlin-testsuite.iml
new file mode 100644
index 000000000..79a6d7176
--- /dev/null
+++ b/site/testsuites/testsuite-kotlin/kotlin-testsuite.iml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/site/testsuites/testsuite-kotlin/pom.xml b/site/testsuites/testsuite-kotlin/pom.xml
index 00bc2c219..ced5d3c7f 100644
--- a/site/testsuites/testsuite-kotlin/pom.xml
+++ b/site/testsuites/testsuite-kotlin/pom.xml
@@ -13,6 +13,7 @@
UTF-8
+ 17
17
true
3.25.2
@@ -121,8 +122,8 @@
- ${project.basedir}/src/main/kotlin
- ${project.basedir}/src/test/kotlin
+ ${project.basedir}/src/main/java
+ ${project.basedir}/src/test/java
@@ -179,6 +180,66 @@
${kotlin.jvm.target}
+
+
+ compile
+ process-sources
+
+ compile
+
+
+
+ ${project.basedir}/src/main/java
+ ${project.basedir}/src/main/kotlin
+
+
+
+
+ test-compile
+ process-test-sources
+
+ test-compile
+
+
+
+ ${project.basedir}/src/test/java
+ ${project.basedir}/src/test/kotlin
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ ${java.version}
+
+
+
+ default-compile
+ none
+
+
+ default-testCompile
+ none
+
+
+ java-compile
+ compile
+
+ compile
+
+
+
+ java-test-compile
+ test-compile
+
+ testCompile
+
+
+
diff --git a/site/testsuites/testsuite-kotlin/src/test/java/website/tbd/developer/site/java/docs/web5/build/decentralizedidentifiers/HowToCreateDidTest.java b/site/testsuites/testsuite-kotlin/src/test/java/website/tbd/developer/site/java/docs/web5/build/decentralizedidentifiers/HowToCreateDidTest.java
new file mode 100644
index 000000000..0192c2946
--- /dev/null
+++ b/site/testsuites/testsuite-kotlin/src/test/java/website/tbd/developer/site/java/docs/web5/build/decentralizedidentifiers/HowToCreateDidTest.java
@@ -0,0 +1,63 @@
+package website.tbd.developer.site.java.docs.web5.build.decentralizedidentifiers;
+
+import foundation.identity.did.DIDDocument;
+import org.junit.jupiter.api.Test;
+import web5.sdk.crypto.InMemoryKeyManager;
+import web5.sdk.dids.DidResolutionResult;
+import web5.sdk.dids.methods.dht.CreateDidDhtOptions;
+import web5.sdk.dids.methods.dht.DidDht;
+import web5.sdk.dids.methods.jwk.DidJwk;
+import web5.sdk.dids.methods.key.DidKey;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class HowToCreateDidTest
+{
+
+ @Test
+ void createDidDht(){
+
+ // :snippet-start: createDidDhtJava
+ // Creates a DID using the DHT method and publishes the DID Document to the DHT
+ final DidDht didDht = DidDht.Default.create(
+ new InMemoryKeyManager(),
+ new CreateDidDhtOptions(null,null,true,null,null));
+
+ // DID String
+ final String did = didDht.getUri();
+
+ // DID and its associated data which can be exported and used in different contexts/apps
+ final DidResolutionResult portableDid = DidDht.Default.resolve(did,null);
+
+ // DID Document
+ final DIDDocument didDocument = portableDid.getDidDocument();
+ // :snippet-end:
+
+ assertNotNull(did,"DID should not be null");
+ assertTrue(did.startsWith("did:dht"),"Did should start with 'did:dht'");
+ assertEquals(did, didDocument.getId().toString(),"ID of DID Document should match DID");
+ }
+
+ @Test
+ void createDidJwt() {
+ // :snippet-start: createDidJwkJava
+ // Creates a DID using the did:jwk method
+ final DidJwk didJwk = DidJwk.Companion.create(new InMemoryKeyManager(), null);
+
+ // DID and its associated data which can be exported and used in different contexts/apps
+ final DidResolutionResult portableDid = didJwk.resolve();
+
+ // DID String
+ final String did = didJwk.getUri();
+
+ // DID Document
+ final DIDDocument didDocument = portableDid.getDidDocument();
+ // :snippet-end:
+
+ assertNotNull(did, "DID should not be null");
+ assertTrue(did.startsWith("did:jwk"), "DID should start with 'did:jwk'");
+ assertNotNull(didDocument, "DID Document should not be null");
+ assertEquals(did, didDocument.getId().toString(),"ID od DID Document should match DID");
+ }
+
+}