diff --git a/threema-connector-product/README.md b/threema-connector-product/README.md index 23f3305..b8b02a3 100644 --- a/threema-connector-product/README.md +++ b/threema-connector-product/README.md @@ -11,11 +11,9 @@ Credentials and credits are required to send messages. The credentials can be cr ![Result screen](./images/resultScreen.png) ## Setup -This Connector requires an "End-to-End Threema ID". [Request new ID](https://gateway.threema.ch/en/id-request) -
-For generating the keys and requesting a new Threema.Gateway ID refer to [Generate keys](https://gateway.threema.ch/en/developer/howto/create-keys/php). - -To use the Threema Connector, add the following variables to your Axon Ivy Project: +1. Generate a new key pair using the "createKeyPair" process. +2. Create "End-to-End Threema ID" at: [Request new ID](https://gateway.threema.ch/en/id-request)
+3. Add the following variables to your Axon Ivy Project: ``` @variables.yaml@ diff --git a/threema-connector-product/product.json b/threema-connector-product/product.json index 13070f6..97d486b 100644 --- a/threema-connector-product/product.json +++ b/threema-connector-product/product.json @@ -44,27 +44,6 @@ } ] } - }, - { - "id": "maven-dropins", - "data": { - "dependencies": [ - { - "groupId": "com.axonivy.connector.threema", - "artifactId": "threema-connector", - "version": "${version}" - } - ], - "repositories": [ - { - "id": "maven.axonivy.com", - "url": "https://maven.axonivy.com", - "snapshots": { - "enabled": "true" - } - } - ] - } } ] } diff --git a/threema-connector-test/src_test/threema/connector/test/util/KeyPairGeneratorTest.java b/threema-connector-test/src_test/threema/connector/test/util/KeyPairGeneratorTest.java new file mode 100644 index 0000000..5bb233a --- /dev/null +++ b/threema-connector-test/src_test/threema/connector/test/util/KeyPairGeneratorTest.java @@ -0,0 +1,22 @@ +package threema.connector.test.util; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; + +import util.KeyPairGenerator; +import util.KeyPairGenerator.KeyPair; + +public class KeyPairGeneratorTest { + + @Test + void generateKeyPair() { + KeyPair keys = KeyPairGenerator.generate(); + assertThat(keys.publicKey()).isNotEmpty(); + assertThat(keys.privateKey()).isNotEmpty(); + + assertThat(keys.publicKey().length()).isEqualTo(64); + assertThat(keys.privateKey().length()).isEqualTo(64); + } + +} diff --git a/threema-connector/dataclasses/threema/connector/createKeyPairData.ivyClass b/threema-connector/dataclasses/threema/connector/createKeyPairData.ivyClass new file mode 100644 index 0000000..5e2b755 --- /dev/null +++ b/threema-connector/dataclasses/threema/connector/createKeyPairData.ivyClass @@ -0,0 +1,6 @@ +createKeyPairData #class +threema.connector #namespace +privateKey String #field +privateKey PERSISTENT #fieldModifier +publicKey String #field +publicKey PERSISTENT #fieldModifier diff --git a/threema-connector/pom.xml b/threema-connector/pom.xml index 0278c8f..5abdc54 100644 --- a/threema-connector/pom.xml +++ b/threema-connector/pom.xml @@ -32,23 +32,13 @@ - - - - - extract-threema-msgapi-tool - validate - - run - - - + dest="${project.basedir}/lib/threema-msgapi-tool.zip"/> - + + diff --git a/threema-connector/processes/createKeyPair.p.json b/threema-connector/processes/createKeyPair.p.json new file mode 100644 index 0000000..9427be7 --- /dev/null +++ b/threema-connector/processes/createKeyPair.p.json @@ -0,0 +1,67 @@ +{ + "format" : "10.0.0", + "id" : "18B67537F65B8CEE", + "config" : { + "data" : "threema.connector.createKeyPairData" + }, + "elements" : [ { + "id" : "f0", + "type" : "RequestStart", + "name" : "start.ivp", + "config" : { + "callSignature" : "start", + "outLink" : "start.ivp" + }, + "visual" : { + "at" : { "x" : 96, "y" : 64 } + }, + "connect" : { "id" : "f4", "to" : "f3" } + }, { + "id" : "f1", + "type" : "TaskEnd", + "visual" : { + "at" : { "x" : 696, "y" : 64 } + } + }, { + "id" : "f3", + "type" : "Script", + "name" : "generateKeyPair", + "config" : { + "output" : { + "code" : [ + "import util.KeyPairGenerator;", + "import util.KeyPairGenerator.KeyPair;", + "", + "KeyPair keys = KeyPairGenerator.generate();", + "", + "out.publicKey = keys.publicKey();", + "out.privateKey = keys.privateKey();" + ] + } + }, + "visual" : { + "at" : { "x" : 320, "y" : 64 } + }, + "connect" : { "id" : "f6", "to" : "f5" } + }, { + "id" : "f5", + "type" : "DialogCall", + "name" : "KeyPair", + "config" : { + "dialogId" : "threema.connector.KeyPair", + "startMethod" : "start(threema.connector.createKeyPairData)", + "call" : { + "params" : [ + { "name" : "createKeyPairData", "type" : "threema.connector.createKeyPairData" } + ], + "map" : { + "param.createKeyPairData" : "in" + } + } + }, + "visual" : { + "at" : { "x" : 508, "y" : 64 } + }, + "connect" : { "id" : "f2", "to" : "f1" } + } ] +} \ No newline at end of file diff --git a/threema-connector/src/util/KeyPairGenerator.java b/threema-connector/src/util/KeyPairGenerator.java new file mode 100644 index 0000000..1b12c98 --- /dev/null +++ b/threema-connector/src/util/KeyPairGenerator.java @@ -0,0 +1,19 @@ +package util; + +import javax.xml.bind.DatatypeConverter; + +import ch.threema.apitool.CryptTool; + +public class KeyPairGenerator { + + public record KeyPair(String publicKey, String privateKey) {} + + public static KeyPair generate() { + byte[] publicKey = new byte[32]; + byte[] privateKey = new byte[32]; + + CryptTool.generateKeyPair(publicKey, privateKey); + return new KeyPair(DatatypeConverter.printHexBinary(publicKey), DatatypeConverter.printHexBinary(privateKey)); + } + +} diff --git a/threema-connector/src_hd/threema/connector/KeyPair/KeyPair.rddescriptor b/threema-connector/src_hd/threema/connector/KeyPair/KeyPair.rddescriptor new file mode 100644 index 0000000..ae605f0 --- /dev/null +++ b/threema-connector/src_hd/threema/connector/KeyPair/KeyPair.rddescriptor @@ -0,0 +1,7 @@ + + + + viewTechnology + JSF + + diff --git a/threema-connector/src_hd/threema/connector/KeyPair/KeyPair.xhtml b/threema-connector/src_hd/threema/connector/KeyPair/KeyPair.xhtml new file mode 100644 index 0000000..ff800ef --- /dev/null +++ b/threema-connector/src_hd/threema/connector/KeyPair/KeyPair.xhtml @@ -0,0 +1,35 @@ + + + + KeyPair + + +

Newly generated Keypair

+ + + + + + + + + + + + +
+
+ + +
+
+ +
+
+
+ + \ No newline at end of file diff --git a/threema-connector/src_hd/threema/connector/KeyPair/KeyPairData.ivyClass b/threema-connector/src_hd/threema/connector/KeyPair/KeyPairData.ivyClass new file mode 100644 index 0000000..b47ddd9 --- /dev/null +++ b/threema-connector/src_hd/threema/connector/KeyPair/KeyPairData.ivyClass @@ -0,0 +1,4 @@ +KeyPairData #class +threema.connector.KeyPair #namespace +createKeyPairData threema.connector.createKeyPairData #field +createKeyPairData PERSISTENT #fieldModifier diff --git a/threema-connector/src_hd/threema/connector/KeyPair/KeyPairProcess.p.json b/threema-connector/src_hd/threema/connector/KeyPair/KeyPairProcess.p.json new file mode 100644 index 0000000..d7e4795 --- /dev/null +++ b/threema-connector/src_hd/threema/connector/KeyPair/KeyPairProcess.p.json @@ -0,0 +1,52 @@ +{ + "format" : "10.0.0", + "id" : "18B675A6BCE832D1", + "kind" : "HTML_DIALOG", + "config" : { + "data" : "threema.connector.KeyPair.KeyPairData" + }, + "elements" : [ { + "id" : "f0", + "type" : "HtmlDialogStart", + "name" : "start(createKeyPairData)", + "config" : { + "callSignature" : "start", + "input" : { + "params" : [ + { "name" : "createKeyPairData", "type" : "threema.connector.createKeyPairData" } + ], + "map" : { + "out.createKeyPairData" : "param.createKeyPairData" + } + }, + "guid" : "18B675A6BCFECF51" + }, + "visual" : { + "at" : { "x" : 96, "y" : 64 } + }, + "connect" : { "id" : "f2", "to" : "f1" } + }, { + "id" : "f1", + "type" : "HtmlDialogEnd", + "visual" : { + "at" : { "x" : 224, "y" : 64 } + } + }, { + "id" : "f3", + "type" : "HtmlDialogEventStart", + "name" : "close", + "config" : { + "guid" : "18B675A6BD2AE7CB" + }, + "visual" : { + "at" : { "x" : 96, "y" : 160 } + }, + "connect" : { "id" : "f5", "to" : "f4" } + }, { + "id" : "f4", + "type" : "HtmlDialogExit", + "visual" : { + "at" : { "x" : 224, "y" : 160 } + } + } ] +} \ No newline at end of file diff --git a/threema-connector/webContent/layouts/frame-10.xhtml b/threema-connector/webContent/layouts/frame-10.xhtml new file mode 100644 index 0000000..936a73b --- /dev/null +++ b/threema-connector/webContent/layouts/frame-10.xhtml @@ -0,0 +1,60 @@ + + + + + + + + + + <ui:insert name="title">Ivy Html Dialog</ui:insert> + + + + + + + + + +
+ + default content + +
+ + + + + + + +
+ \ No newline at end of file diff --git a/threema-connector/webContent/layouts/includes/exception-details.xhtml b/threema-connector/webContent/layouts/includes/exception-details.xhtml new file mode 100644 index 0000000..bbc3cce --- /dev/null +++ b/threema-connector/webContent/layouts/includes/exception-details.xhtml @@ -0,0 +1,109 @@ + + + + + + +

+ +

+ + +

Error id

+

#{errorPage.exceptionId}

+

Error Timestamp

+

#{errorPage.createdAt}

+
+ + + + +

Attributes

+
+ + + + + + + + + + + + + + + +
NameValue
+
+
+

Thrown by

+

Process: + +
Element: + +

+
+ + +

Process call stack

+ +
#{caller.callerElement}
+
+
+ +

Technical cause

+
#{causedBy.class.simpleName}: #{causedBy.message.trim()}
+
+
+ +

Request Uri

+

#{errorPage.getRequestUri()}

+
+

Servlet

+

#{errorPage.getServletName()}

+
+ +

Application

+

#{errorPage.applicationName}

+
+ + +

Thread local values

+
+ + + + + + + + + + + + + + + +
KeyValue
+
+
+
+ +

Stack-Trace

+
#{errorPage.getStackTrace()}
+
+ diff --git a/threema-connector/webContent/layouts/includes/exception.xhtml b/threema-connector/webContent/layouts/includes/exception.xhtml new file mode 100644 index 0000000..1b255a2 --- /dev/null +++ b/threema-connector/webContent/layouts/includes/exception.xhtml @@ -0,0 +1,47 @@ + + + + + + + + + +
+
+ + +
+ + + + + + + + + +
+ + \ No newline at end of file diff --git a/threema-connector/webContent/layouts/includes/footer.xhtml b/threema-connector/webContent/layouts/includes/footer.xhtml new file mode 100644 index 0000000..f21699e --- /dev/null +++ b/threema-connector/webContent/layouts/includes/footer.xhtml @@ -0,0 +1,18 @@ + + + +
+ + #{ivyAdvisor.applicationName} + + +
+
+ + \ No newline at end of file diff --git a/threema-connector/webContent/layouts/includes/progress-loader.xhtml b/threema-connector/webContent/layouts/includes/progress-loader.xhtml new file mode 100644 index 0000000..0d68a75 --- /dev/null +++ b/threema-connector/webContent/layouts/includes/progress-loader.xhtml @@ -0,0 +1,15 @@ + + + + +
+
+
Loading...
+
+
+ + + +
+
\ No newline at end of file