From fd91f3aa8083f9e33bcc8685f83efddfc04d5d71 Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Mon, 7 Aug 2023 09:23:59 +0200 Subject: [PATCH] add first forge actor --- .../fed_poc/forge.cljc | 14 +++++ .../fed_poc/security.cljc | 7 +++ src/main/resources/security.json | 51 +++++++++++++++++++ .../fed_poc/forge_test.cljc | 21 ++++++++ .../fed_poc/security_test.cljc | 8 +++ 5 files changed, 101 insertions(+) create mode 100644 src/main/cljc/org/domaindrivenarchitecture/fed_poc/forge.cljc create mode 100644 src/main/cljc/org/domaindrivenarchitecture/fed_poc/security.cljc create mode 100644 src/main/resources/security.json create mode 100644 src/test/cljc/org/domaindrivenarchitecture/fed_poc/forge_test.cljc create mode 100644 src/test/cljc/org/domaindrivenarchitecture/fed_poc/security_test.cljc diff --git a/src/main/cljc/org/domaindrivenarchitecture/fed_poc/forge.cljc b/src/main/cljc/org/domaindrivenarchitecture/fed_poc/forge.cljc new file mode 100644 index 0000000..57e5b42 --- /dev/null +++ b/src/main/cljc/org/domaindrivenarchitecture/fed_poc/forge.cljc @@ -0,0 +1,14 @@ +(ns org.domaindrivenarchitecture.fed-poc.forge + (:require [clojure.spec.alpha :as s] + [orchestra.core :refer [defn-spec]] + [org.domaindrivenarchitecture.fed-poc.spec-helper :as sh] + [org.domaindrivenarchitecture.fed-poc.owl :as owl] + [org.domaindrivenarchitecture.fed-poc.xsd :as xsd] + [org.domaindrivenarchitecture.fed-poc.activitystreams2 :as as])) + +;https://forgefed.org/ns#Repository +;TODO: definition in progress +(s/def ::Repository + (s/and + ::as/Object + (sh/map-spec (s/keys :opt [])))) diff --git a/src/main/cljc/org/domaindrivenarchitecture/fed_poc/security.cljc b/src/main/cljc/org/domaindrivenarchitecture/fed_poc/security.cljc new file mode 100644 index 0000000..7b6199e --- /dev/null +++ b/src/main/cljc/org/domaindrivenarchitecture/fed_poc/security.cljc @@ -0,0 +1,7 @@ +(ns org.domaindrivenarchitecture.fed-poc.security + (:require [clojure.spec.alpha :as s] + [orchestra.core :refer [defn-spec]] + [org.domaindrivenarchitecture.fed-poc.spec-helper :as sh] + [org.domaindrivenarchitecture.fed-poc.owl :as owl] + [org.domaindrivenarchitecture.fed-poc.xsd :as xsd])) + diff --git a/src/main/resources/security.json b/src/main/resources/security.json new file mode 100644 index 0000000..6faf97d --- /dev/null +++ b/src/main/resources/security.json @@ -0,0 +1,51 @@ +{ + "@context": { + "id": "@id", + "type": "@type", + + "dc": "http://purl.org/dc/terms/", + "sec": "https://w3id.org/security#", + "xsd": "http://www.w3.org/2001/XMLSchema#", + + "EcdsaKoblitzSignature2016": "sec:EcdsaKoblitzSignature2016", + "Ed25519Signature2018": "sec:Ed25519Signature2018", + "EncryptedMessage": "sec:EncryptedMessage", + "GraphSignature2012": "sec:GraphSignature2012", + "LinkedDataSignature2015": "sec:LinkedDataSignature2015", + "LinkedDataSignature2016": "sec:LinkedDataSignature2016", + "CryptographicKey": "sec:Key", + + "authenticationTag": "sec:authenticationTag", + "canonicalizationAlgorithm": "sec:canonicalizationAlgorithm", + "cipherAlgorithm": "sec:cipherAlgorithm", + "cipherData": "sec:cipherData", + "cipherKey": "sec:cipherKey", + "created": {"@id": "dc:created", "@type": "xsd:dateTime"}, + "creator": {"@id": "dc:creator", "@type": "@id"}, + "digestAlgorithm": "sec:digestAlgorithm", + "digestValue": "sec:digestValue", + "domain": "sec:domain", + "encryptionKey": "sec:encryptionKey", + "expiration": {"@id": "sec:expiration", "@type": "xsd:dateTime"}, + "expires": {"@id": "sec:expiration", "@type": "xsd:dateTime"}, + "initializationVector": "sec:initializationVector", + "iterationCount": "sec:iterationCount", + "nonce": "sec:nonce", + "normalizationAlgorithm": "sec:normalizationAlgorithm", + "owner": {"@id": "sec:owner", "@type": "@id"}, + "password": "sec:password", + "privateKey": {"@id": "sec:privateKey", "@type": "@id"}, + "privateKeyPem": "sec:privateKeyPem", + "publicKey": {"@id": "sec:publicKey", "@type": "@id"}, + "publicKeyBase58": "sec:publicKeyBase58", + "publicKeyPem": "sec:publicKeyPem", + "publicKeyWif": "sec:publicKeyWif", + "publicKeyService": {"@id": "sec:publicKeyService", "@type": "@id"}, + "revoked": {"@id": "sec:revoked", "@type": "xsd:dateTime"}, + "salt": "sec:salt", + "signature": "sec:signature", + "signatureAlgorithm": "sec:signingAlgorithm", + "signatureValue": "sec:signatureValue" + } + } + \ No newline at end of file diff --git a/src/test/cljc/org/domaindrivenarchitecture/fed_poc/forge_test.cljc b/src/test/cljc/org/domaindrivenarchitecture/fed_poc/forge_test.cljc new file mode 100644 index 0000000..dba2983 --- /dev/null +++ b/src/test/cljc/org/domaindrivenarchitecture/fed_poc/forge_test.cljc @@ -0,0 +1,21 @@ +(ns org.domaindrivenarchitecture.fed-poc.forge-test + (:require + [clojure.test :refer [deftest is are testing run-tests]] + [clojure.spec.alpha :as s] + [org.domaindrivenarchitecture.fed-poc.security :as sec] + [org.domaindrivenarchitecture.fed-poc.activitystreams2 :as as] + [org.domaindrivenarchitecture.fed-poc.forge :as sut])) + +(deftest Repository-test + (is (s/valid? ::sut/Repository + {::as/id "https://dev.example/aviva/treesim", + ::as/type "Repository", + :sec/publicKey {::sec/id "https://dev.example/aviva/treesim#main-key", + ::sec/owner "https://dev.example/aviva/treesim", + ::sec/publicKeyPem "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhki....."}, + ::sut/inbox "https://dev.example/aviva/treesim/inbox", + ::sut/outbox "https://dev.example/aviva/treesim/outbox", + ::sut/followers "https://dev.example/aviva/treesim/followers", + ::sut/team "https://dev.example/aviva/treesim/team", + ::sut/name "Tree Growth 3D Simulation", + ::sut/summary "

Tree growth 3D simulator for my nature exploration game

"}))) \ No newline at end of file diff --git a/src/test/cljc/org/domaindrivenarchitecture/fed_poc/security_test.cljc b/src/test/cljc/org/domaindrivenarchitecture/fed_poc/security_test.cljc new file mode 100644 index 0000000..b4022d5 --- /dev/null +++ b/src/test/cljc/org/domaindrivenarchitecture/fed_poc/security_test.cljc @@ -0,0 +1,8 @@ +(ns org.domaindrivenarchitecture.fed-poc.security-test + (:require + [clojure.test :refer [deftest is are testing run-tests]] + [clojure.spec.alpha :as s] + [org.domaindrivenarchitecture.fed-poc.security :as sut])) + +(deftest Repository-test + (is true)) \ No newline at end of file