Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Remco van 't Veer committed Jun 4, 2024
1 parent 1442e7b commit a01abb5
Show file tree
Hide file tree
Showing 21 changed files with 387 additions and 304 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ all: clean check target/dil-demo.jar
%.pem: %.p12
openssl pkcs12 -in $< -nocerts -nodes -legacy -out $@

pems: credentials/EU.EORI.NLPRECIOUSG.pem credentials/EU.EORI.NLSECURESTO.pem credentials/EU.EORI.NLSMARTPHON.pem
pems: credentials/EU.EORI.NLPRECIOUSG.pem credentials/EU.EORI.NLSECURESTO.pem credentials/EU.EORI.NLSMARTPHON.pem credentials/EU.EORI.NLFLEXTRANS.pem

certs: credentials/EU.EORI.NLPRECIOUSG.crt credentials/EU.EORI.NLSECURESTO.crt credentials/EU.EORI.NLSMARTPHON.crt
certs: credentials/EU.EORI.NLPRECIOUSG.crt credentials/EU.EORI.NLSECURESTO.crt credentials/EU.EORI.NLSMARTPHON.crt credentials/EU.EORI.NLFLEXTRANS.crt

classes/dil_demo/core.class: src/dil_demo/core.clj
mkdir -p classes
Expand Down
28 changes: 19 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ SPDX-License-Identifier: AGPL-3.0-or-later
This code simulates the following environments:

- [erp](http://localhost:8080/erp/)
- [tms](http://localhost:8080/tms/)
- [wms](http://localhost:8080/wms/)
- [tms-1](http://localhost:8080/tms-1/)
- [tms-2](http://localhost:8080/tms-2/)


## Run

Expand Down Expand Up @@ -42,20 +44,28 @@ ERP:
- `ERP_AR_ID`: EORI of the ERP authorization register
- `ERP_AR_ENDPOINT`: URL to the ERP authorization register

TMS:

- `TMS_EORI`: EORI used by TMS
- `TMS_KEY_FILE`: the file to read the TMS private key from
- `TMS_CHAIN_FILE`: the file to read the TMS certificate chain from
- `TMS_AR_ID`: EORI of the TMS authorization register
- `TMS_AR_ENDPOINT`: URL to the TMS authorization register

WMS:

- `WMS_EORI`: EORI used by WMS
- `WMS_KEY_FILE`: the file to read the WMS private key from
- `WMS_CHAIN_FILE`: the file to read the WMS certificate chain from

TMS 1:

- `TMS1_EORI`: EORI used by TMS 1
- `TMS1_KEY_FILE`: the file to read the TMS 1 private key from
- `TMS1_CHAIN_FILE`: the file to read the TMS 1 certificate chain from
- `TMS1_AR_ID`: EORI of the TMS 1 authorization register
- `TMS1_AR_ENDPOINT`: URL to the TMS 1 authorization register

TMS 2:

- `TMS2_EORI`: EORI used by TMS 2
- `TMS2_KEY_FILE`: the file to read the TMS 2 private key from
- `TMS2_CHAIN_FILE`: the file to read the TMS 2 certificate chain from
- `TMS2_AR_ID`: EORI of the TMS 2 authorization register
- `TMS2_AR_ENDPOINT`: URL to the TMS 2 authorization register

Run the web server with the following:

```sh
Expand Down
1 change: 1 addition & 0 deletions resources/public/assets/tms-1-chauffeur.css
File renamed without changes.
1 change: 1 addition & 0 deletions resources/public/assets/tms-2-chauffeur.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

:root {
--color-bg: #eeb45f;
--color-bg: #b4ee5f;
--color-button-primary: #f4f9c0;
--color-button-primary-border: #bbbf93;
--color-button-secondary: #f9c6c0;
Expand Down
31 changes: 22 additions & 9 deletions src/dil_demo/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
(defn ->config []
(let [erp-eori (get-env "ERP_EORI")
wms-eori (get-env "WMS_EORI")
tms-eori (get-env "TMS_EORI")
tms-1-eori (get-env "TMS1_EORI")
tms-2-eori (get-env "TMS2_EORI")
dataspace-id (get-env "DATASPACE_ID")
satellite-id (get-env "SATELLITE_ID")
satellite-endpoint (get-env "SATELLITE_ENDPOINT")]
Expand All @@ -30,27 +31,39 @@
:pass-multi (parse-long (get-env "AUTH_PASS_MULTI" "31415"))
:max-accounts (parse-long (get-env "AUTH_MAX_ACCOUNTS" "42"))}
:erp {:eori erp-eori
:site-name (get-env "ERP_NAME" "Smartphone Shop")
:dataspace-id dataspace-id
:satellite-id satellite-id
:ar-id (get-env "ERP_AR_ID")
:ar-endpoint (get-env "ERP_AR_ENDPOINT")
:satellite-endpoint satellite-endpoint
:key-file (get-env "ERP_KEY_FILE" (str "credentials/" erp-eori ".pem"))
:chain-file (get-env "ERP_CHAIN_FILE" (str "credentials/" erp-eori ".crt"))}
:tms {:eori tms-eori
:wms {:eori wms-eori
:site-name (get-env "WMS_NAME" "Secure Storage Warehousing")
:dataspace-id dataspace-id
:satellite-id satellite-id
:satellite-endpoint satellite-endpoint
:ar-id (get-env "TMS_AR_ID")
:ar-endpoint (get-env "TMS_AR_ENDPOINT")
:key-file (get-env "TMS_KEY_FILE" (str "credentials/" tms-eori ".pem"))
:chain-file (get-env "TMS_CHAIN_FILE" (str "credentials/" tms-eori ".crt"))}
:wms {:eori wms-eori
:key-file (get-env "WMS_KEY_FILE" (str "credentials/" wms-eori ".pem"))
:chain-file (get-env "WMS_CHAIN_FILE" (str "credentials/" wms-eori ".crt"))}
:tms-1 {:eori tms-1-eori
:site-name (get-env "TMS1_NAME" "Precious Goods Transport")
:dataspace-id dataspace-id
:satellite-id satellite-id
:satellite-endpoint satellite-endpoint
:key-file (get-env "WMS_KEY_FILE" (str "credentials/" wms-eori ".pem"))
:chain-file (get-env "WMS_CHAIN_FILE" (str "credentials/" wms-eori ".crt"))}}))
:ar-id (get-env "TMS1_AR_ID")
:ar-endpoint (get-env "TMS1_AR_ENDPOINT")
:key-file (get-env "TMS1_KEY_FILE" (str "credentials/" tms-1-eori ".pem"))
:chain-file (get-env "TMS1_CHAIN_FILE" (str "credentials/" tms-1-eori ".crt"))}
:tms-2 {:eori tms-2-eori
:site-name (get-env "TMS2_NAME" "Flex Transport")
:dataspace-id dataspace-id
:satellite-id satellite-id
:satellite-endpoint satellite-endpoint
:ar-id (get-env "TMS2_AR_ID")
:ar-endpoint (get-env "TMS2_AR_ENDPOINT")
:key-file (get-env "TMS2_KEY_FILE" (str "credentials/" tms-2-eori ".pem"))
:chain-file (get-env "TMS2_CHAIN_FILE" (str "credentials/" tms-2-eori ".crt"))}}))

(defonce server-atom (atom nil))

Expand Down
13 changes: 6 additions & 7 deletions src/dil_demo/data.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@

(ns dil-demo.data)

(def wms-name "Secure Storage Warehousing")
(def tms-name "Precious Goods Transport")
(def erp-name "Smartphone Shop")
;; NOTE: these have a ERP as demoed here
(def owners [:erp])

;; NOTE: these have a WMS as demoed here
(def warehouses [wms-name])
(def warehouses [:wms])

;; NOTE: these have a TMS as demoed here
(def carriers [:tms-1 :tms-2])

(def goods #{"Toiletpapier"
"Bananen"
Expand All @@ -30,9 +32,6 @@
"Bol, Waalwijk"
"Mechie Trommelenweg 1\n5145 ND Waalwijk\nNederland"

wms-name
"Kerkstraat 1\n1234 AZ Nergenshuizen\nNederland"

"Intel, Schiphol"
"Capronilaan 37\n1119 NG Schiphol-Rijk\nNederland"

Expand Down
6 changes: 3 additions & 3 deletions src/dil_demo/erp.clj
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
(fn delegation-wrapper [{:keys [client-data] :as req}]
(let [{::store/keys [commands] :as res} (app req)
trip (->> commands
(filter #(= [:put! :trips] (take 2 %)))
(map #(nth % 2))
(filter #(= [:publish! :trips] (take 2 %)))
(map #(nth % 3))
(first))]
(if trip
(let [[result log] (ishare-ar! client-data "Permit" (otm/trip->map trip))]
Expand All @@ -78,7 +78,7 @@
res))))

(defn make-handler [config]
(-> web/handler
(-> (web/make-handler config)
(web-utils/wrap-config config)
(wrap-policy-deletion)
(wrap-delegation)
Expand Down
Loading

0 comments on commit a01abb5

Please sign in to comment.