From ead50cfbb310feaaf6dfc7da6b59165428e4833a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magdalena=20Grodzi=C5=84ska?= Date: Sun, 12 Jan 2020 17:11:19 +0100 Subject: Create QuerySigner class --- src/main/java/pl/edu/mimuw/cloudatlas/querysigner/QuerySigner.java | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/main/java/pl/edu/mimuw/cloudatlas/querysigner/QuerySigner.java (limited to 'src/main/java/pl/edu/mimuw/cloudatlas/querysigner/QuerySigner.java') diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/querysigner/QuerySigner.java b/src/main/java/pl/edu/mimuw/cloudatlas/querysigner/QuerySigner.java new file mode 100644 index 0000000..e5e561d --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/querysigner/QuerySigner.java @@ -0,0 +1,4 @@ +package pl.edu.mimuw.cloudatlas.querysigner; + +public class QuerySigner { +} -- cgit v1.2.3 From da5df3957ba41d28256ab8183aae0dd3b6e0dcba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magdalena=20Grodzi=C5=84ska?= Date: Sun, 12 Jan 2020 21:05:28 +0100 Subject: Add query signer architecture --- .../mimuw/cloudatlas/querysigner/QuerySigner.java | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/main/java/pl/edu/mimuw/cloudatlas/querysigner/QuerySigner.java') diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/querysigner/QuerySigner.java b/src/main/java/pl/edu/mimuw/cloudatlas/querysigner/QuerySigner.java index e5e561d..69a25d7 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/querysigner/QuerySigner.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/querysigner/QuerySigner.java @@ -1,4 +1,30 @@ package pl.edu.mimuw.cloudatlas.querysigner; +import pl.edu.mimuw.cloudatlas.agent.EventBus; +import pl.edu.mimuw.cloudatlas.api.Api; +import pl.edu.mimuw.cloudatlas.querysignerapi.QuerySignerApi; + +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; +import java.rmi.server.UnicastRemoteObject; + public class QuerySigner { + + public static void runRegistry() { + try { + QuerySignerApiImplementation api = new QuerySignerApiImplementation(); + QuerySignerApi apiStub = + (QuerySignerApi) UnicastRemoteObject.exportObject(api, 0); + Registry registry = LocateRegistry.getRegistry(); + registry.rebind("QuerySignerApi", apiStub); + System.out.println("QuerySigner: api bound"); + } catch (Exception e) { + System.err.println("QuerySigner registry initialization exception:"); + e.printStackTrace(); + } + } + + public static void main(String[] args) { + runRegistry(); + } } -- cgit v1.2.3 From c48ec1604744ab330d18af1f55256c35dc5c34c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magdalena=20Grodzi=C5=84ska?= Date: Sun, 12 Jan 2020 22:58:08 +0100 Subject: Improve query signer and its api --- .../pl/edu/mimuw/cloudatlas/querysigner/QuerySigner.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/main/java/pl/edu/mimuw/cloudatlas/querysigner/QuerySigner.java') diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/querysigner/QuerySigner.java b/src/main/java/pl/edu/mimuw/cloudatlas/querysigner/QuerySigner.java index 69a25d7..90a86b7 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/querysigner/QuerySigner.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/querysigner/QuerySigner.java @@ -1,7 +1,5 @@ package pl.edu.mimuw.cloudatlas.querysigner; -import pl.edu.mimuw.cloudatlas.agent.EventBus; -import pl.edu.mimuw.cloudatlas.api.Api; import pl.edu.mimuw.cloudatlas.querysignerapi.QuerySignerApi; import java.rmi.registry.LocateRegistry; @@ -9,10 +7,18 @@ import java.rmi.registry.Registry; import java.rmi.server.UnicastRemoteObject; public class QuerySigner { + public static class InvalidQueryException extends Exception { + InvalidQueryException() { + super("Query invalid"); + } + } public static void runRegistry() { try { - QuerySignerApiImplementation api = new QuerySignerApiImplementation(); + // TODO reading from files + String publicKey = System.getProperty("public_key"); + String privateKey = System.getProperty("private_key"); + QuerySignerApiImplementation api = new QuerySignerApiImplementation(publicKey.getBytes(), privateKey.getBytes()); QuerySignerApi apiStub = (QuerySignerApi) UnicastRemoteObject.exportObject(api, 0); Registry registry = LocateRegistry.getRegistry(); -- cgit v1.2.3 From 23b8714b29816b608cb3aa330b6e93610e107126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magdalena=20Grodzi=C5=84ska?= Date: Mon, 13 Jan 2020 20:56:41 +0100 Subject: Create simple query data structure so that RMI doesn't blow up --- .../mimuw/cloudatlas/querysigner/QuerySigner.java | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/main/java/pl/edu/mimuw/cloudatlas/querysigner/QuerySigner.java') diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/querysigner/QuerySigner.java b/src/main/java/pl/edu/mimuw/cloudatlas/querysigner/QuerySigner.java index 90a86b7..d60a75d 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/querysigner/QuerySigner.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/querysigner/QuerySigner.java @@ -1,10 +1,16 @@ package pl.edu.mimuw.cloudatlas.querysigner; +import pl.edu.mimuw.cloudatlas.KeyGenerator; +import pl.edu.mimuw.cloudatlas.agent.NewApiImplementation; +import pl.edu.mimuw.cloudatlas.api.Api; import pl.edu.mimuw.cloudatlas.querysignerapi.QuerySignerApi; +import java.io.IOException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.rmi.server.UnicastRemoteObject; +import java.security.PrivateKey; +import java.security.PublicKey; public class QuerySigner { public static class InvalidQueryException extends Exception { @@ -13,12 +19,18 @@ public class QuerySigner { } } + private static QuerySignerApiImplementation initApi() throws IOException { + String publicKeyFile = System.getProperty("public_key_file"); + String privateKeyFile = System.getProperty("private_key_file"); + PublicKey publicKey = null; //KeyGenerator.getPublicKey(KeyGenerator.readKeyFromFile(publicKeyFile)); + PrivateKey privateKey = null; // KeyGenerator.getPrivateKey(KeyGenerator.readKeyFromFile(privateKeyFile)); + return new QuerySignerApiImplementation(publicKey, privateKey); + } + public static void runRegistry() { try { - // TODO reading from files - String publicKey = System.getProperty("public_key"); - String privateKey = System.getProperty("private_key"); - QuerySignerApiImplementation api = new QuerySignerApiImplementation(publicKey.getBytes(), privateKey.getBytes()); + QuerySignerApiImplementation api = initApi(); +// NewApiImplementation apii = new NewApiImplementation(null); QuerySignerApi apiStub = (QuerySignerApi) UnicastRemoteObject.exportObject(api, 0); Registry registry = LocateRegistry.getRegistry(); -- cgit v1.2.3 From 8103eb7e174c7c0bb33316ae9499bbc0fbb62ea5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magdalena=20Grodzi=C5=84ska?= Date: Mon, 13 Jan 2020 21:54:45 +0100 Subject: Fix key generation and reading --- .../java/pl/edu/mimuw/cloudatlas/querysigner/QuerySigner.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/main/java/pl/edu/mimuw/cloudatlas/querysigner/QuerySigner.java') diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/querysigner/QuerySigner.java b/src/main/java/pl/edu/mimuw/cloudatlas/querysigner/QuerySigner.java index d60a75d..735601d 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/querysigner/QuerySigner.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/querysigner/QuerySigner.java @@ -1,8 +1,5 @@ package pl.edu.mimuw.cloudatlas.querysigner; -import pl.edu.mimuw.cloudatlas.KeyGenerator; -import pl.edu.mimuw.cloudatlas.agent.NewApiImplementation; -import pl.edu.mimuw.cloudatlas.api.Api; import pl.edu.mimuw.cloudatlas.querysignerapi.QuerySignerApi; import java.io.IOException; @@ -22,15 +19,14 @@ public class QuerySigner { private static QuerySignerApiImplementation initApi() throws IOException { String publicKeyFile = System.getProperty("public_key_file"); String privateKeyFile = System.getProperty("private_key_file"); - PublicKey publicKey = null; //KeyGenerator.getPublicKey(KeyGenerator.readKeyFromFile(publicKeyFile)); - PrivateKey privateKey = null; // KeyGenerator.getPrivateKey(KeyGenerator.readKeyFromFile(privateKeyFile)); + PublicKey publicKey = KeyUtils.getPublicKey(publicKeyFile); + PrivateKey privateKey = KeyUtils.getPrivateKey(privateKeyFile); return new QuerySignerApiImplementation(publicKey, privateKey); } public static void runRegistry() { try { QuerySignerApiImplementation api = initApi(); -// NewApiImplementation apii = new NewApiImplementation(null); QuerySignerApi apiStub = (QuerySignerApi) UnicastRemoteObject.exportObject(api, 0); Registry registry = LocateRegistry.getRegistry(); -- cgit v1.2.3