From d3af34d04622b0ee027d71e6ca0810ad41adc72b Mon Sep 17 00:00:00 2001 From: Arbel Deutsch Peled Date: Thu, 12 Nov 2015 21:30:53 +0200 Subject: [PATCH 01/13] SQLite post working. --- .gitignore | 1 + bulletin-board-server/build.gradle | 8 ++- .../sqlserver/BulletinBoardSQLServer.java | 56 +++++++++++++----- .../sqlserver/SQLiteBulletinBoardServer.java | 18 +++--- .../webapp/HelloProtoWebApp.java | 40 +++++++++++-- .../webapp/SQLiteServerTest.java | 57 +++++++++++++++++++ .../src/test/java/HelloIntegrationTest.java | 2 +- .../bulletinboard/SQLiteIntegrationTest.java | 41 ------------- .../bulletinboard/BulletinBoardServer.java | 3 +- .../meerkat/bulletinboard/MessageFilter.java | 27 --------- .../src/main/proto/meerkat/voting.proto | 24 ++++++++ 11 files changed, 180 insertions(+), 97 deletions(-) create mode 100644 bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/SQLiteServerTest.java delete mode 100644 bulletin-board-server/src/test/java/meerkat/bulletinboard/SQLiteIntegrationTest.java delete mode 100644 meerkat-common/src/main/java/meerkat/bulletinboard/MessageFilter.java diff --git a/.gitignore b/.gitignore index 429a385..9793e15 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ out *.prefs *.project *.classpath +bulletin-board-server/local-instances/meerkat.db diff --git a/bulletin-board-server/build.gradle b/bulletin-board-server/build.gradle index ae8e028..e9f3a90 100644 --- a/bulletin-board-server/build.gradle +++ b/bulletin-board-server/build.gradle @@ -9,8 +9,10 @@ apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'idea' +//apply plugin: 'application' + //apply plugin: 'jetty' -//mainClassName = 'Demo' +//mainClassName = 'SQLiteIntegrationTest' apply plugin: 'maven-publish' @@ -42,6 +44,8 @@ dependencies { // Jersey for RESTful API compile 'org.glassfish.jersey.containers:jersey-container-servlet:2.22.+' + compile 'org.xerial:sqlite-jdbc:3.7.+' + // Logging compile 'org.slf4j:slf4j-api:1.7.7' @@ -68,6 +72,8 @@ task integrationTest(type: Test) { gretty { httpPort = 8081 + contextPath = '/' + servletContainer = 'jetty9' integrationTestTask = 'integrationTest' } diff --git a/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/BulletinBoardSQLServer.java b/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/BulletinBoardSQLServer.java index 0ed06c9..de4e52e 100644 --- a/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/BulletinBoardSQLServer.java +++ b/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/BulletinBoardSQLServer.java @@ -2,6 +2,9 @@ package meerkat.bulletinboard.sqlserver; import java.util.List; +import javax.ws.rs.POST; +import javax.ws.rs.Path; + import com.google.protobuf.ProtocolStringList; import java.sql.Connection; @@ -11,7 +14,7 @@ import java.sql.SQLException; import java.sql.Statement; import meerkat.bulletinboard.BulletinBoardServer; -import meerkat.bulletinboard.MessageFilter; +import meerkat.protobuf.Voting.MessageFilterList; import meerkat.comm.CommunicationException; import meerkat.protobuf.Crypto.SignatureVerificationKey; import meerkat.protobuf.Voting.BulletinBoardMessage; @@ -19,6 +22,7 @@ import meerkat.crypto.Digest; import meerkat.crypto.concrete.SHA256Digest; import meerkat.protobuf.Voting.MessageID; +@Path("/SQLServer") public abstract class BulletinBoardSQLServer implements BulletinBoardServer{ protected Connection connection; @@ -53,6 +57,7 @@ public abstract class BulletinBoardSQLServer implements BulletinBoardServer{ * @return TRUE if the message is authenticated and FALSE otherwise. */ private boolean verifyMessage(BulletinBoardMessage msg) { + //TODO: Replace with actual verification. return true; } @@ -60,8 +65,9 @@ public abstract class BulletinBoardSQLServer implements BulletinBoardServer{ * This procedure makes sure that all tags in the given list have an entry in the tags list. * @param tagIterator */ - protected abstract void insertNewTags(String[] tags) throws CommunicationException; + protected abstract void insertNewTags(String[] tags) throws SQLException; + @POST @Override public boolean postMessage(BulletinBoardMessage msg) throws CommunicationException { if (!verifyMessage(msg)) { @@ -85,17 +91,29 @@ public abstract class BulletinBoardSQLServer implements BulletinBoardServer{ sql = "INSERT INTO MsgTable (Id, Data, Signature) VALUES(?,?,?)"; pstmt = connection.prepareStatement(sql); pstmt.setBytes(1, msgID); - pstmt.setBytes(2,msg.getMsg().getData().toByteArray()); - pstmt.setBytes(3,msg.getSig().toByteArray()); + pstmt.setBytes(2, msg.getMsg().getData().toByteArray()); + pstmt.setBytes(3, msg.getSig().toByteArray()); pstmt.executeUpdate(); pstmt.close(); + } catch (SQLException e) { + throw new CommunicationException("Error inserting into MsgTable: " + e.getMessage()); + } + + try { + tagList = msg.getMsg().getTagsList(); tags = new String[tagList.size()]; + tags = tagList.toArray(tags); insertNewTags(tags); - sql = "INSERT INTO MsgTagTable (MsgId, TagId) SELECT (?, TagId) FROM TagTable WHERE tag=?"; + } catch (SQLException e) { + throw new CommunicationException(e.getMessage()); + } + + try{ + sql = "INSERT INTO MsgTagTable (TagId, MsgId) SELECT TagTable.Id, ? AS MsgId FROM TagTable WHERE tag = ?"; pstmt = connection.prepareStatement(sql); for (String tag : tags){ @@ -108,19 +126,21 @@ public abstract class BulletinBoardSQLServer implements BulletinBoardServer{ pstmt.close(); } catch (SQLException e) { - throw new CommunicationException("Error accessing DB: " + e.getMessage()); + throw new CommunicationException("Error Linking tags: " + e.getMessage()); } return true; } @Override - public List readMessages(MessageFilter filter, int max) { + public List readMessages(MessageFilterList filterList, int max) { // TODO Auto-generated method stub return null; } - public void testPrint(){ + public String testPrint(){ + + String s = ""; try { @@ -128,20 +148,30 @@ public abstract class BulletinBoardSQLServer implements BulletinBoardServer{ ResultSet rs = statement.executeQuery("select * from MsgTable"); while (rs.next()) { // read the result set - System.out.println("data = " + rs.getString("Data")); - System.out.println("id = " + rs.getInt("Id")); + s += "entry = " + rs.getInt("EntryNum") + " \n"; + s += "id = " + new String(rs.getBytes("Id")) + " \n"; + s += "data = " + new String(rs.getBytes("Data")) + " \n"; + s += "signature = " + new String(rs.getBytes("Signature")) + "\t\n
"; + } + + rs = statement.executeQuery("select * from TagTable"); + while (rs.next()) { + // read the result set + s += "Tag = " + rs.getString("Tag") + " \n"; + s += "TagId = " + rs.getInt("Id") + "\t\n
"; } rs = statement.executeQuery("select * from MsgTagTable"); while (rs.next()) { // read the result set - System.out.println("MsgId = " + rs.getInt("MsgId")); - System.out.println("TagId = " + rs.getString("TagId")); + s += "MsgId = " + new String(rs.getBytes("MsgId")) + " \n"; + s += "TagId = " + rs.getInt("TagId") + "\t\n
"; } } catch(SQLException e){ - System.out.println("Error reading from DB"); + s += "Error reading from DB"; } + return s; } } diff --git a/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/SQLiteBulletinBoardServer.java b/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/SQLiteBulletinBoardServer.java index 6c9cf40..104ea57 100644 --- a/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/SQLiteBulletinBoardServer.java +++ b/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/SQLiteBulletinBoardServer.java @@ -6,7 +6,7 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.List; -import meerkat.bulletinboard.MessageFilter; +import meerkat.protobuf.Voting.MessageFilterList; import meerkat.bulletinboard.sqlserver.BulletinBoardSQLServer; import meerkat.comm.CommunicationException; import meerkat.protobuf.Voting.BulletinBoardMessage; @@ -27,13 +27,13 @@ public class SQLiteBulletinBoardServer extends BulletinBoardSQLServer { try{ - connection = DriverManager.getConnection("jdbc:sqlite:./local-instances/meerkat.db"); + connection = DriverManager.getConnection("jdbc:sqlite:local-instances/meerkat.db"); Statement statement = connection.createStatement(); statement.setQueryTimeout(TIMEOUT); - statement.executeUpdate("CREATE TABLE IF NOT EXISTS MsgTable (EntryNum INTEGER, Id varbinary(1000) UNIQUE, Data varbinary(1000), Signature varbinary(1000), PRIMARY KEY (EntryNum ASC))"); - statement.executeUpdate("CREATE TABLE IF NOT EXISTS TagTable (Id int, Tag v archar(50) UNIQUE, PRIMARY KEY (Id ASC))"); - statement.executeUpdate("CREATE TABLE IF NOT EXISTS MsgTagTable (MsgId varbinary(1000), TagId int, FOREIGN KEY (MsgId) REFERENCES MsgTable(Id), FOREIGN KEY (TagId) REFERENCES TagTable(Id))"); + statement.executeUpdate("CREATE TABLE IF NOT EXISTS MsgTable (EntryNum INTEGER PRIMARY KEY, Id BLOB UNIQUE, Data BLOB, Signature BLOB)"); + statement.executeUpdate("CREATE TABLE IF NOT EXISTS TagTable (Id INTEGER PRIMARY KEY, Tag varchar(50) UNIQUE)"); + statement.executeUpdate("CREATE TABLE IF NOT EXISTS MsgTagTable (MsgId BLOB, TagId INTEGER, FOREIGN KEY (MsgId) REFERENCES MsgTable(Id), FOREIGN KEY (TagId) REFERENCES TagTable(Id))"); statement.close(); @@ -41,7 +41,7 @@ public class SQLiteBulletinBoardServer extends BulletinBoardSQLServer { } catch (SQLException e) { - throw new CommunicationException("Couldn't form a connection with the database"); + throw new CommunicationException("Couldn't form a connection with the database" + e.getMessage()); } @@ -49,7 +49,7 @@ public class SQLiteBulletinBoardServer extends BulletinBoardSQLServer { @Override - public List readMessages(MessageFilter filter, int max) { + public List readMessages(MessageFilterList filterList, int max) { // TODO Auto-generated method stub return null; } @@ -68,7 +68,7 @@ public class SQLiteBulletinBoardServer extends BulletinBoardSQLServer { @Override - protected void insertNewTags(String[] tags) throws CommunicationException { + protected void insertNewTags(String[] tags) throws SQLException { PreparedStatement pstmt; String sql; @@ -87,7 +87,7 @@ public class SQLiteBulletinBoardServer extends BulletinBoardSQLServer { pstmt.close(); } catch (SQLException e){ - throw new CommunicationException("Error adding new tags to table"); + throw new SQLException("Error adding new tags to table: " + e.getMessage()); } } diff --git a/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/HelloProtoWebApp.java b/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/HelloProtoWebApp.java index cbe2ae5..ab2d952 100644 --- a/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/HelloProtoWebApp.java +++ b/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/HelloProtoWebApp.java @@ -1,22 +1,54 @@ package meerkat.bulletinboard.webapp; +import com.google.protobuf.ByteString; import com.google.protobuf.Message; import meerkat.bulletinboard.service.HelloProtoBuf; +import meerkat.protobuf.Crypto.Signature; +import meerkat.protobuf.Crypto.SignatureType; +import meerkat.protobuf.Voting.BulletinBoardMessage; +import meerkat.protobuf.Voting.UnsignedBulletinBoardMessage; import meerkat.rest.Constants; -import service.HelloWorldService; +import javax.annotation.PostConstruct; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; @Path("/proto") public class HelloProtoWebApp { - private static HelloProtoBuf helloProtoBuf = new HelloProtoBuf(); - + private HelloProtoBuf helloProtoBuf; + + @PostConstruct + public void init(){ + //helloProtoBuf = new HelloProtoBuf(); + } + @GET @Produces(Constants.MEDIATYPE_PROTOBUF) public Message hello() { - return helloProtoBuf.sayHello(); + byte[] b1 = {(byte) 1, (byte)2, (byte) 3, (byte) 4}; + byte[] b2 = {(byte) 11, (byte)12, (byte) 13, (byte) 14}; + + Message msg; + + if (helloProtoBuf != null){ + msg = helloProtoBuf.sayHello(); + } + else{ + msg = BulletinBoardMessage.newBuilder() + .setMsg(UnsignedBulletinBoardMessage.newBuilder() + .addTags("signature") + .addTags("Trustee") + .setData(ByteString.copyFrom(b1)) + .build()) + .setSig(Signature.newBuilder() + .setType(SignatureType.DSA) + .setData(ByteString.copyFrom(b2)) + .build()) + .build(); + } + + return msg; } } diff --git a/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/SQLiteServerTest.java b/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/SQLiteServerTest.java new file mode 100644 index 0000000..7206ad0 --- /dev/null +++ b/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/SQLiteServerTest.java @@ -0,0 +1,57 @@ +package meerkat.bulletinboard.webapp; + + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; + +import com.google.protobuf.ByteString; + +import meerkat.bulletinboard.sqlserver.SQLiteBulletinBoardServer; +import meerkat.comm.CommunicationException; +import meerkat.protobuf.Crypto.*; +import meerkat.protobuf.Voting.*; + +@Path("/test") +public class SQLiteServerTest { + + @GET + public Response main(){ + byte[] b1 = {(byte) 1, (byte)2, (byte) 3, (byte) 4}; + byte[] b2 = {(byte) 11, (byte)12, (byte) 13, (byte) 14}; + + Response response; + + BulletinBoardMessage msg; + try{ + msg = BulletinBoardMessage.newBuilder() + .setMsg(UnsignedBulletinBoardMessage.newBuilder() + .addTags("Signature") + .addTags("Trustee") + .setData(ByteString.copyFrom(b1)) + .build()) + .setSig(Signature.newBuilder() + .setType(SignatureType.DSA) + .setData(ByteString.copyFrom(b2)) + .build()) + .build(); + + SQLiteBulletinBoardServer bbs = new SQLiteBulletinBoardServer(); + + + bbs.init(); + + bbs.postMessage(msg); + response = Response.status(Status.OK).entity(bbs.testPrint()).build(); + + bbs.close(); + + } catch(CommunicationException e){ + response = Response.status(Status.OK).entity(e.getMessage()).build();; + } + + return response; + } + +} diff --git a/bulletin-board-server/src/test/java/HelloIntegrationTest.java b/bulletin-board-server/src/test/java/HelloIntegrationTest.java index 9de027e..3a01d5e 100644 --- a/bulletin-board-server/src/test/java/HelloIntegrationTest.java +++ b/bulletin-board-server/src/test/java/HelloIntegrationTest.java @@ -8,7 +8,7 @@ import org.junit.Test; public class HelloIntegrationTest { private static String PROP_GETTY_URL = "gretty.httpBaseURI"; - private static String BASE_URL = System.getProperty(PROP_GETTY_URL); + private static String BASE_URL = System.getProperty(PROP_GETTY_URL); private static String HELLO_URL = BASE_URL + "/hello"; @Test diff --git a/bulletin-board-server/src/test/java/meerkat/bulletinboard/SQLiteIntegrationTest.java b/bulletin-board-server/src/test/java/meerkat/bulletinboard/SQLiteIntegrationTest.java deleted file mode 100644 index 0ebb8e0..0000000 --- a/bulletin-board-server/src/test/java/meerkat/bulletinboard/SQLiteIntegrationTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package meerkat.bulletinboard; - - -import com.google.protobuf.ByteString; - -import meerkat.bulletinboard.sqlserver.SQLiteBulletinBoardServer; -import meerkat.comm.CommunicationException; -import meerkat.protobuf.Crypto.*; -import meerkat.protobuf.Voting.*; - -public class SQLiteIntegrationTest { - public static void main(){ - byte[] b1 = {(byte) 1, (byte)2, (byte) 3, (byte) 4}; - byte[] b2 = {(byte) 11, (byte)12, (byte) 13, (byte) 14}; - - BulletinBoardMessage msg = BulletinBoardMessage.newBuilder() - .setMsg(UnsignedBulletinBoardMessage.newBuilder() - .setTags(0, "signature") - .setTags(1, "Trustee") - .setData(ByteString.copyFrom(b1)) - .build()) - .setSig(Signature.newBuilder() - .setType(SignatureType.DSA) - .setData(ByteString.copyFrom(b2)) - .build()) - .build(); - - SQLiteBulletinBoardServer bbs = new SQLiteBulletinBoardServer(); - - try{ - bbs.init(); - - bbs.postMessage(msg); - bbs.testPrint(); - - bbs.close(); - } catch(CommunicationException e){ - System.out.println(e.getMessage()); - } - } -} diff --git a/meerkat-common/src/main/java/meerkat/bulletinboard/BulletinBoardServer.java b/meerkat-common/src/main/java/meerkat/bulletinboard/BulletinBoardServer.java index fdd0b3c..05bdf47 100644 --- a/meerkat-common/src/main/java/meerkat/bulletinboard/BulletinBoardServer.java +++ b/meerkat-common/src/main/java/meerkat/bulletinboard/BulletinBoardServer.java @@ -4,6 +4,7 @@ import java.util.List; import meerkat.comm.CommunicationException; import meerkat.protobuf.Voting.BulletinBoardMessage; +import meerkat.protobuf.Voting.MessageFilterList; /** * Created by Arbel on 07/11/15. @@ -35,7 +36,7 @@ public interface BulletinBoardServer{ * @param max maximum number of messages to return (0=no limit) * @return */ - List readMessages(MessageFilter filter, int max); + List readMessages(MessageFilterList filterList, int max); /** * This method closes the connection to the DB. diff --git a/meerkat-common/src/main/java/meerkat/bulletinboard/MessageFilter.java b/meerkat-common/src/main/java/meerkat/bulletinboard/MessageFilter.java deleted file mode 100644 index 08dcb52..0000000 --- a/meerkat-common/src/main/java/meerkat/bulletinboard/MessageFilter.java +++ /dev/null @@ -1,27 +0,0 @@ -package meerkat.bulletinboard; - -/** - * Created by talm on 25/10/15. - * - * A filter for messages (run on the BB server side). - * - * TODO: define a limited filter language (e.g., by tag, by signer, by time, etc.) that can - * be efficiently run on the BB database. - * - */ -public abstract class MessageFilter { - public enum FilterType{ - ENTRY_NUM, - ID, - TAG, - SIGNER, - TIME - } - - FilterType filterType; - - public MessageFilter(FilterType filterType){ - - } - -} diff --git a/meerkat-common/src/main/proto/meerkat/voting.proto b/meerkat-common/src/main/proto/meerkat/voting.proto index 5d2586a..c7dcad3 100644 --- a/meerkat-common/src/main/proto/meerkat/voting.proto +++ b/meerkat-common/src/main/proto/meerkat/voting.proto @@ -28,6 +28,30 @@ message BulletinBoardMessage { meerkat.Signature sig = 2; } +enum FilterType { + ID = 0; // Match exact message ID + EXACT_ENTRY = 1; // Match exact entry number in database (chronological) + MAX_ENTRY = 2; // Find all entries in database up to specified entry number (chronological) + SIGNATURE = 3; // Find all entries in database that correspond to specific signature (signer) + TAG = 4; // Find all entries in database that have a specific tag +} + +message MessageFilter { + + FilterType type = 1; + + // Concrete data input to filter + bytes filter = 2; +} + +message MessageFilterList { + + // Combination of filters. + // To be implemented using intersection ("AND") operations. + repeated MessageFilter filters = 1; + +} + // A ballot question. This is an opaque // data type that is parsed by the UI to display // the question. From d9ebe54599469a8cc504668adda74bd0ec7df580 Mon Sep 17 00:00:00 2001 From: Arbel Deutsch Peled Date: Fri, 13 Nov 2015 19:44:20 +0200 Subject: [PATCH 02/13] Removing old incompatible versions of certificates --- .../src/test/resources/certs/.gitattributes | 1 - .../src/test/resources/certs/README.md | 6 -- .../user1-key-with-password-secret.p12 | Bin 1301 -> 0 bytes .../user1-key-with-password-secret.pem | 8 --- .../certs/enduser-certs/user1-key.der | Bin 118 -> 0 bytes .../certs/enduser-certs/user1-key.pem | 5 -- .../certs/enduser-certs/user1-pubkey.pem | 4 -- .../resources/certs/enduser-certs/user1.crt | 19 ------ .../resources/certs/enduser-certs/user1.csr | 9 --- .../certs/enduser-certs/user2-key.pem | 5 -- .../certs/enduser-certs/user2-pubkey.pem | 4 -- .../resources/certs/enduser-certs/user2.crt | 19 ------ .../resources/certs/enduser-certs/user2.csr | 9 --- .../resources/certs/enduser-certs/user2.der | Bin 794 -> 0 bytes .../certs/intermediate-ca-1/1000.pem | 19 ------ .../certs/intermediate-ca-1/1001.pem | 19 ------ .../certs/intermediate-ca-1/certindex | 2 - .../certs/intermediate-ca-1/certindex.attr | 1 - .../intermediate-ca-1/certindex.attr.old | 1 - .../certs/intermediate-ca-1/certindex.old | 1 - .../certs/intermediate-ca-1/certserial | 1 - .../certs/intermediate-ca-1/certserial.old | 1 - .../certs/intermediate-ca-1/crlnumber | 1 - .../intermediate-ca-1-private-key.pem | 5 -- .../intermediate-ca-1/intermediate-ca-1.crt | 21 ------ .../intermediate-ca-1/intermediate-ca-1.csr | 10 --- .../openssl-intermediate-ca.conf | 46 ------------- .../src/test/resources/certs/root-ca/1000.pem | 21 ------ .../test/resources/certs/root-ca/certindex | 1 - .../resources/certs/root-ca/certindex.attr | 1 - .../resources/certs/root-ca/certindex.old | 0 .../test/resources/certs/root-ca/certserial | 1 - .../resources/certs/root-ca/certserial.old | 1 - .../test/resources/certs/root-ca/crlnumber | 1 - .../resources/certs/root-ca/openssl-ca.conf | 61 ------------------ ...ot-ca-private-key-with-password-secret.pem | 8 --- .../certs/root-ca/root-ca-private-key.der | Bin 118 -> 0 bytes .../certs/root-ca/root-ca-private-key.pem | 5 -- .../test/resources/certs/root-ca/root-ca.crt | 17 ----- .../src/test/resources/certs/secp256k1.pem | 3 - .../certs/signed-messages/helloworld.txt | 1 - .../signed-messages/helloworld.txt.sha256sig | Bin 72 -> 0 bytes 42 files changed, 338 deletions(-) delete mode 100644 meerkat-common/src/test/resources/certs/.gitattributes delete mode 100644 meerkat-common/src/test/resources/certs/README.md delete mode 100644 meerkat-common/src/test/resources/certs/enduser-certs/user1-key-with-password-secret.p12 delete mode 100644 meerkat-common/src/test/resources/certs/enduser-certs/user1-key-with-password-secret.pem delete mode 100644 meerkat-common/src/test/resources/certs/enduser-certs/user1-key.der delete mode 100644 meerkat-common/src/test/resources/certs/enduser-certs/user1-key.pem delete mode 100644 meerkat-common/src/test/resources/certs/enduser-certs/user1-pubkey.pem delete mode 100644 meerkat-common/src/test/resources/certs/enduser-certs/user1.crt delete mode 100644 meerkat-common/src/test/resources/certs/enduser-certs/user1.csr delete mode 100644 meerkat-common/src/test/resources/certs/enduser-certs/user2-key.pem delete mode 100644 meerkat-common/src/test/resources/certs/enduser-certs/user2-pubkey.pem delete mode 100644 meerkat-common/src/test/resources/certs/enduser-certs/user2.crt delete mode 100644 meerkat-common/src/test/resources/certs/enduser-certs/user2.csr delete mode 100644 meerkat-common/src/test/resources/certs/enduser-certs/user2.der delete mode 100644 meerkat-common/src/test/resources/certs/intermediate-ca-1/1000.pem delete mode 100644 meerkat-common/src/test/resources/certs/intermediate-ca-1/1001.pem delete mode 100644 meerkat-common/src/test/resources/certs/intermediate-ca-1/certindex delete mode 100644 meerkat-common/src/test/resources/certs/intermediate-ca-1/certindex.attr delete mode 100644 meerkat-common/src/test/resources/certs/intermediate-ca-1/certindex.attr.old delete mode 100644 meerkat-common/src/test/resources/certs/intermediate-ca-1/certindex.old delete mode 100644 meerkat-common/src/test/resources/certs/intermediate-ca-1/certserial delete mode 100644 meerkat-common/src/test/resources/certs/intermediate-ca-1/certserial.old delete mode 100644 meerkat-common/src/test/resources/certs/intermediate-ca-1/crlnumber delete mode 100644 meerkat-common/src/test/resources/certs/intermediate-ca-1/intermediate-ca-1-private-key.pem delete mode 100644 meerkat-common/src/test/resources/certs/intermediate-ca-1/intermediate-ca-1.crt delete mode 100644 meerkat-common/src/test/resources/certs/intermediate-ca-1/intermediate-ca-1.csr delete mode 100644 meerkat-common/src/test/resources/certs/intermediate-ca-1/openssl-intermediate-ca.conf delete mode 100644 meerkat-common/src/test/resources/certs/root-ca/1000.pem delete mode 100644 meerkat-common/src/test/resources/certs/root-ca/certindex delete mode 100644 meerkat-common/src/test/resources/certs/root-ca/certindex.attr delete mode 100644 meerkat-common/src/test/resources/certs/root-ca/certindex.old delete mode 100644 meerkat-common/src/test/resources/certs/root-ca/certserial delete mode 100644 meerkat-common/src/test/resources/certs/root-ca/certserial.old delete mode 100644 meerkat-common/src/test/resources/certs/root-ca/crlnumber delete mode 100644 meerkat-common/src/test/resources/certs/root-ca/openssl-ca.conf delete mode 100644 meerkat-common/src/test/resources/certs/root-ca/root-ca-private-key-with-password-secret.pem delete mode 100644 meerkat-common/src/test/resources/certs/root-ca/root-ca-private-key.der delete mode 100644 meerkat-common/src/test/resources/certs/root-ca/root-ca-private-key.pem delete mode 100644 meerkat-common/src/test/resources/certs/root-ca/root-ca.crt delete mode 100644 meerkat-common/src/test/resources/certs/secp256k1.pem delete mode 100644 meerkat-common/src/test/resources/certs/signed-messages/helloworld.txt delete mode 100644 meerkat-common/src/test/resources/certs/signed-messages/helloworld.txt.sha256sig diff --git a/meerkat-common/src/test/resources/certs/.gitattributes b/meerkat-common/src/test/resources/certs/.gitattributes deleted file mode 100644 index f8fcd2f..0000000 --- a/meerkat-common/src/test/resources/certs/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -signed-messages/* -text \ No newline at end of file diff --git a/meerkat-common/src/test/resources/certs/README.md b/meerkat-common/src/test/resources/certs/README.md deleted file mode 100644 index f7283d9..0000000 --- a/meerkat-common/src/test/resources/certs/README.md +++ /dev/null @@ -1,6 +0,0 @@ -Certs and private keys for testing generated using OpenSSL - -.crt and .pem files are in PEM format -.der files are in binary DER format - -files that have a name of the form *-with-password-xxxx.pem are encrypted with the password xxxx diff --git a/meerkat-common/src/test/resources/certs/enduser-certs/user1-key-with-password-secret.p12 b/meerkat-common/src/test/resources/certs/enduser-certs/user1-key-with-password-secret.p12 deleted file mode 100644 index 6281f9d5ae0e130fe5b1456eb0b5fe67d6a732df..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1301 zcmV+w1?u`Rf&~!*0Ru3C1lI-$Duzgg_YDCD0ic2e$OM7}#4v&cz%YUXzXk~^hDe6@ z4FLxRpn?OiFoFZD0s#Opf&--n2`Yw2hW8Bt2LUh~1_~;MNQUw(I~ zGNqQ80s;sCfPw>fJ8IJVIDMrkZhe|Dcn7wOpkFb&nQsnx({lQXdj=~1Z>P^E;doZ* zv^|Qre2mu}l0c6v|0~oKWBBOK8*=5Jild)#4v?aDwN``n6B$6xSk~u}+?&ax zlwts59AB{8;;#rbw487L(9Wre6xF`a^s8CwqgKVx4bAb}SMgr>!U?K}$rk<@6GHm3(d8`H%~l$ z;1RZ*6$nseSyB}}%ph@;F$_sgCf8fDieC2G`|s5F2G?|d&4xE%m|a`pQ1eb`ayqRy0+=Wu1s{Kz0UmC2>y=-5@#qQvR? z(DSz1619xxwYC;D$XyQ(2az?1>+T$V3lv9XV{qPjAoNzOJ#10@BF>&F8Mqtt& zJ5kY<;o$BdlPt^E7W0y({xi_nZ}P26iD8ZdeK`Pdk$CRy^IFHM|aG($JymNP+!NI=l^e^0imC%Fk-6@5uo-5Ty45{-izn znL6c#0n@os>1$X{dzRObEl0XzGK$R?^layAJO>?w!dYaa&&WU)q^_8+BEFpEelROk zHUG42!V-YfsNn)1;{V~Xh<}UvTzVJ-3O8k@nt-0FS{57m(HKpFZ`vOV?zwBtG0;!@7FoEVUf#U`XDuzgg_YDCI z3IPJ3fvhlrsW2P{3Mz(3hW8Bt3;_c$4g?6=j(pEfEK9Hg0tf&Efr!OXhx8-^4UkvZ zzzvrEI@yGPc4F;YV)mgGv-X0(P!`(!;HNE!VkNP_mMQw!%>b-Yt3-nZdiJg}rx-#E zgR@?`g_C^>a)-q5J~_h* zDyXPua$eO}E_qsiM^K1^TJ<2yqhB#4Fe3&DDuzgg_YDCF6)_eB6y$?U5+Bl2@(8Je zOt_{aDZ-v4r7$rtAutIB1uG5%0vZJX1QbJiOe+w{yU;)Per>RxI@lTl5>5mNlvBCc LE?!A(0s;sCJrq%4 diff --git a/meerkat-common/src/test/resources/certs/enduser-certs/user1-key-with-password-secret.pem b/meerkat-common/src/test/resources/certs/enduser-certs/user1-key-with-password-secret.pem deleted file mode 100644 index e859995..0000000 --- a/meerkat-common/src/test/resources/certs/enduser-certs/user1-key-with-password-secret.pem +++ /dev/null @@ -1,8 +0,0 @@ ------BEGIN EC PRIVATE KEY----- -Proc-Type: 4,ENCRYPTED -DEK-Info: AES-256-CBC,243D718A0D80C59590E582A26E87A49C - -RG6ITUTIdbJdWYX57oMn3tTCzHJSTjXAIZLjoVxy/v4UFYjluaFhGonIlbH1q2pP -ueu29Q3eT6144ypB8ARUJ1x0kRX1OL9zNHgdF9ulrCf9/nhGyC2nL+tHZ0YPbxoQ -+6yCQcRWvjUXLVzPEUnwMuHXJDpaXES8X0R4CISQKIA= ------END EC PRIVATE KEY----- diff --git a/meerkat-common/src/test/resources/certs/enduser-certs/user1-key.der b/meerkat-common/src/test/resources/certs/enduser-certs/user1-key.der deleted file mode 100644 index 6f174060b7c8dce9c94288ad1ddd589e1860dfcd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 118 zcmV-+0Ez!FbOHeZ1R#6DY6^ynp_;nYq$G=#<{Fw@d;lbbaK<$ZKft;loJ`zLTr9Gq8k*iHs1RRG0UI+MH Yjhqd;0XqY=z{0-099f}V7;H05IqJ77b^rhX diff --git a/meerkat-common/src/test/resources/certs/enduser-certs/user1-key.pem b/meerkat-common/src/test/resources/certs/enduser-certs/user1-key.pem deleted file mode 100644 index 6619e37..0000000 --- a/meerkat-common/src/test/resources/certs/enduser-certs/user1-key.pem +++ /dev/null @@ -1,5 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIGEAgEAMBAGByqGSM49AgEGBSuBBAAKBG0wawIBAQQge8JqCoaLoZq61aQki5Xm -GppcfAAkhHDGNQw/wLof5LmhRANCAAQJD1kW6BsNkRY9tslaugpOJOaoKX4uBz4S -Q96lPaPWkatNVgQchwNeB/hdjZwNuwE7A7XAwr69HFmhXRhsM005 ------END PRIVATE KEY----- diff --git a/meerkat-common/src/test/resources/certs/enduser-certs/user1-pubkey.pem b/meerkat-common/src/test/resources/certs/enduser-certs/user1-pubkey.pem deleted file mode 100644 index 1c0a0c1..0000000 --- a/meerkat-common/src/test/resources/certs/enduser-certs/user1-pubkey.pem +++ /dev/null @@ -1,4 +0,0 @@ ------BEGIN PUBLIC KEY----- -MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAECQ9ZFugbDZEWPbbJWroKTiTmqCl+Lgc+ -EkPepT2j1pGrTVYEHIcDXgf4XY2cDbsBOwO1wMK+vRxZoV0YbDNNOQ== ------END PUBLIC KEY----- diff --git a/meerkat-common/src/test/resources/certs/enduser-certs/user1.crt b/meerkat-common/src/test/resources/certs/enduser-certs/user1.crt deleted file mode 100644 index d80093f..0000000 --- a/meerkat-common/src/test/resources/certs/enduser-certs/user1.crt +++ /dev/null @@ -1,19 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDFjCCArygAwIBAgICEAAwCgYIKoZIzj0EAwIwgYIxKTAnBgNVBAMMIE1lZXJr -YXQgVm90aW5nIEludGVybWVkaWF0ZSBDQSAxMRMwEQYDVQQIDApTb21lLVN0YXRl -MQswCQYDVQQGEwJJTDEVMBMGA1UECgwMSURDIEhlcnpsaXlhMRwwGgYDVQQLDBNN -ZWVya2F0IFZvdGluZyBUZWFtMB4XDTE1MTExMTE2MTM1NFoXDTI1MTEwODE2MTM1 -NFowbjEaMBgGA1UEAwwRUG9sbGluZyBTdGF0aW9uIDExEzARBgNVBAgMClNvbWUt -U3RhdGUxCzAJBgNVBAYTAklMMRUwEwYDVQQKDAxJREMgSGVyemxpeWExFzAVBgNV -BAsMDk1lZXJrYXQgVm90aW5nMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAECQ9ZFugb -DZEWPbbJWroKTiTmqCl+Lgc+EkPepT2j1pGrTVYEHIcDXgf4XY2cDbsBOwO1wMK+ -vRxZoV0YbDNNOaOCATYwggEyMAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFLamS8o2 -hFNd0vWy/irEBNWVNwFXMB8GA1UdIwQYMBaAFBeyv0c75eT6PNumHo9TZ2B9vtcp -MAsGA1UdDwQEAwIFoDATBgNVHSUEDDAKBggrBgEFBQcDATBEBgNVHR8EPTA7MDmg -N6A1hjNodHRwOi8vY3JsLmZhY3RjZW50ZXIub3JnL21lZXJrYXQtaW50ZXJtZWRp -YXRlMS5jcmwwegYIKwYBBQUHAQEEbjBsMEEGCCsGAQUFBzAChjVodHRwOi8vcGtp -LmZhY3RjZW50ZXIub3JnL21lZXJrYXQtaW50ZXJtZWRpYXRlLWNhLmNydDAnBggr -BgEFBQcwAYYbaHR0cDovL29jc3AuZmFjdGNlbnRlci5vcmcvMAoGCCqGSM49BAMC -A0gAMEUCIQD6QbhNNmB3AVVqhmXuiLA7WF6raShw6n0g/VloVGQebQIgEvxYclpO -MMynt5wH6X65rtn4Q1EGaDMvNbFweCDsldk= ------END CERTIFICATE----- diff --git a/meerkat-common/src/test/resources/certs/enduser-certs/user1.csr b/meerkat-common/src/test/resources/certs/enduser-certs/user1.csr deleted file mode 100644 index 20e1efc..0000000 --- a/meerkat-common/src/test/resources/certs/enduser-certs/user1.csr +++ /dev/null @@ -1,9 +0,0 @@ ------BEGIN CERTIFICATE REQUEST----- -MIIBOjCB4QIBADCBgTELMAkGA1UEBhMCSUwxEzARBgNVBAgMClNvbWUtU3RhdGUx -ETAPBgNVBAcMCEhlcnpsaXlhMRUwEwYDVQQKDAxJREMgSGVyemxpeWExFzAVBgNV -BAsMDk1lZXJrYXQgVm90aW5nMRowGAYDVQQDDBFQb2xsaW5nIFN0YXRpb24gMTBW -MBAGByqGSM49AgEGBSuBBAAKA0IABAkPWRboGw2RFj22yVq6Ck4k5qgpfi4HPhJD -3qU9o9aRq01WBByHA14H+F2NnA27ATsDtcDCvr0cWaFdGGwzTTmgADAKBggqhkjO -PQQDAgNIADBFAiEA8gmIhALr7O5M1QLReGH3jheildTIr1mDWl14WyMf9U4CIF23 -mInyo4VqNHLzxMLg5Cn3Oddokng3OXa63y4nTfv+ ------END CERTIFICATE REQUEST----- diff --git a/meerkat-common/src/test/resources/certs/enduser-certs/user2-key.pem b/meerkat-common/src/test/resources/certs/enduser-certs/user2-key.pem deleted file mode 100644 index 2d31bb8..0000000 --- a/meerkat-common/src/test/resources/certs/enduser-certs/user2-key.pem +++ /dev/null @@ -1,5 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIGEAgEAMBAGByqGSM49AgEGBSuBBAAKBG0wawIBAQQgYpBEO+XWm/n6VPeMVK76 -mrZkDTpiwLsDykG7M4fU5RKhRANCAAR71/kVGyA3hdxcLBBT3NPQF6R3LholmLRN -qhnvHqzJWuy7ev+Xbuxtt9AN0ajyeFDy8Oe1bUSidnLyQi+nXC0f ------END PRIVATE KEY----- diff --git a/meerkat-common/src/test/resources/certs/enduser-certs/user2-pubkey.pem b/meerkat-common/src/test/resources/certs/enduser-certs/user2-pubkey.pem deleted file mode 100644 index 5d86d4c..0000000 --- a/meerkat-common/src/test/resources/certs/enduser-certs/user2-pubkey.pem +++ /dev/null @@ -1,4 +0,0 @@ ------BEGIN PUBLIC KEY----- -MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEe9f5FRsgN4XcXCwQU9zT0Bekdy4aJZi0 -TaoZ7x6syVrsu3r/l27sbbfQDdGo8nhQ8vDntW1EonZy8kIvp1wtHw== ------END PUBLIC KEY----- diff --git a/meerkat-common/src/test/resources/certs/enduser-certs/user2.crt b/meerkat-common/src/test/resources/certs/enduser-certs/user2.crt deleted file mode 100644 index a211365..0000000 --- a/meerkat-common/src/test/resources/certs/enduser-certs/user2.crt +++ /dev/null @@ -1,19 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDFjCCArygAwIBAgICEAEwCgYIKoZIzj0EAwIwgYIxKTAnBgNVBAMMIE1lZXJr -YXQgVm90aW5nIEludGVybWVkaWF0ZSBDQSAxMRMwEQYDVQQIDApTb21lLVN0YXRl -MQswCQYDVQQGEwJJTDEVMBMGA1UECgwMSURDIEhlcnpsaXlhMRwwGgYDVQQLDBNN -ZWVya2F0IFZvdGluZyBUZWFtMB4XDTE1MTExMTE2MjAzM1oXDTI1MTEwODE2MjAz -M1owbjEaMBgGA1UEAwwRUG9sbGluZyBTdGF0aW9uIDIxEzARBgNVBAgMClNvbWUt -U3RhdGUxCzAJBgNVBAYTAklMMRUwEwYDVQQKDAxJREMgSGVyemxpeWExFzAVBgNV -BAsMDk1lZXJrYXQgVm90aW5nMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEe9f5FRsg -N4XcXCwQU9zT0Bekdy4aJZi0TaoZ7x6syVrsu3r/l27sbbfQDdGo8nhQ8vDntW1E -onZy8kIvp1wtH6OCATYwggEyMAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFKCdquYj -DGHqAHt+4PIDlw0h2UvuMB8GA1UdIwQYMBaAFBeyv0c75eT6PNumHo9TZ2B9vtcp -MAsGA1UdDwQEAwIFoDATBgNVHSUEDDAKBggrBgEFBQcDATBEBgNVHR8EPTA7MDmg -N6A1hjNodHRwOi8vY3JsLmZhY3RjZW50ZXIub3JnL21lZXJrYXQtaW50ZXJtZWRp -YXRlMS5jcmwwegYIKwYBBQUHAQEEbjBsMEEGCCsGAQUFBzAChjVodHRwOi8vcGtp -LmZhY3RjZW50ZXIub3JnL21lZXJrYXQtaW50ZXJtZWRpYXRlLWNhLmNydDAnBggr -BgEFBQcwAYYbaHR0cDovL29jc3AuZmFjdGNlbnRlci5vcmcvMAoGCCqGSM49BAMC -A0gAMEUCIQDpo5B0vvEJSax3YzOMfE8l0pfDUIKLdBWJVGeq0VLtIgIgVr0+4/0e -n+R+l1OVOLh2GirloOgbv5Ch5BQ2pQNAG2Y= ------END CERTIFICATE----- diff --git a/meerkat-common/src/test/resources/certs/enduser-certs/user2.csr b/meerkat-common/src/test/resources/certs/enduser-certs/user2.csr deleted file mode 100644 index bb3c2d0..0000000 --- a/meerkat-common/src/test/resources/certs/enduser-certs/user2.csr +++ /dev/null @@ -1,9 +0,0 @@ ------BEGIN CERTIFICATE REQUEST----- -MIIBOzCB4QIBADCBgTELMAkGA1UEBhMCSUwxEzARBgNVBAgMClNvbWUtU3RhdGUx -ETAPBgNVBAcMCEhlcnpsaXlhMRUwEwYDVQQKDAxJREMgSGVyemxpeWExFzAVBgNV -BAsMDk1lZXJrYXQgVm90aW5nMRowGAYDVQQDDBFQb2xsaW5nIFN0YXRpb24gMjBW -MBAGByqGSM49AgEGBSuBBAAKA0IABHvX+RUbIDeF3FwsEFPc09AXpHcuGiWYtE2q -Ge8erMla7Lt6/5du7G230A3RqPJ4UPLw57VtRKJ2cvJCL6dcLR+gADAKBggqhkjO -PQQDAgNJADBGAiEA6Ls/ojRaZT+u4YeOBYcPbRcJE3jSTe1Sm/lR7fDyEhMCIQCk -UOca+e2b8+CqM3CURBv6TqUMmZ3HeMRvEAxFPqOWSw== ------END CERTIFICATE REQUEST----- diff --git a/meerkat-common/src/test/resources/certs/enduser-certs/user2.der b/meerkat-common/src/test/resources/certs/enduser-certs/user2.der deleted file mode 100644 index 8e784093b249900ab82c852d5257c6e338711969..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 794 zcmXqLViq%KV%oESnTe5!iAjLbfQyYotIgw_EekV~L1UAlrhz&eb0`ZlkAiP%YEgD# zi9%R@NoHQUf@fYyYEf=#N@ik7s)Dnlf}x?XfgngJ2MWL72`${0w2gt>Wy(d-CGP0Tfr6X!KFH3R`OBLidO zC~;mRAlJYG$~DL{lroS2>1XB<49L&P0XYt2cV>Q`f)V+S5;qWqIEoL|Q3hcK0&MKy zAYx)(1!MycOjE+F?oy!-*mz3*Csm|EqyGruC+?tb7Z+2Jx zpPu(7cl!n2iz_}=1bq7Nd~2@DqOzh-PWsDZbmbQ}F`5}PF&Y{00Iii3W@P-&!eqc; zAPeI0v52vVESS6MnKDn}D~9U22cMXy^D5r-erF&Ll2&GsFc51H5#O}m-TLX1UpBXw z$@K@PC)Dn{u4%vxQozpwj7`=B;Lw*+qo`~hvA#t01me4gqr(^mZ8swk{1_djD z1ON)5L<2$q1fnR&U|n`@kTkW(@ Date: Fri, 13 Nov 2015 19:54:56 +0200 Subject: [PATCH 03/13] Adding new file versions --- bulletin-board-server/.gitignore | 1 + meerkat-common/.gitignore | 1 + .../src/test/resources/certs/.gitattributes | 1 + .../src/test/resources/certs/README.md | 6 ++ .../user1-key-with-password-secret.p12 | Bin 0 -> 1301 bytes .../user1-key-with-password-secret.pem | 8 +++ .../certs/enduser-certs/user1-key.der | Bin 0 -> 118 bytes .../certs/enduser-certs/user1-key.pem | 5 ++ .../certs/enduser-certs/user1-pubkey.pem | 4 ++ .../resources/certs/enduser-certs/user1.crt | 19 ++++++ .../resources/certs/enduser-certs/user1.csr | 9 +++ .../certs/enduser-certs/user2-key.pem | 5 ++ .../certs/enduser-certs/user2-pubkey.pem | 4 ++ .../resources/certs/enduser-certs/user2.crt | 19 ++++++ .../resources/certs/enduser-certs/user2.csr | 9 +++ .../resources/certs/enduser-certs/user2.der | Bin 0 -> 794 bytes .../certs/intermediate-ca-1/1000.pem | 19 ++++++ .../certs/intermediate-ca-1/1001.pem | 19 ++++++ .../certs/intermediate-ca-1/certindex | 2 + .../certs/intermediate-ca-1/certindex.attr | 1 + .../intermediate-ca-1/certindex.attr.old | 1 + .../certs/intermediate-ca-1/certindex.old | 1 + .../certs/intermediate-ca-1/certserial | 1 + .../certs/intermediate-ca-1/certserial.old | 1 + .../certs/intermediate-ca-1/crlnumber | 1 + .../intermediate-ca-1-private-key.pem | 5 ++ .../intermediate-ca-1/intermediate-ca-1.crt | 21 ++++++ .../intermediate-ca-1/intermediate-ca-1.csr | 10 +++ .../openssl-intermediate-ca.conf | 46 +++++++++++++ .../src/test/resources/certs/root-ca/1000.pem | 21 ++++++ .../test/resources/certs/root-ca/certindex | 1 + .../resources/certs/root-ca/certindex.attr | 1 + .../resources/certs/root-ca/certindex.old | 0 .../test/resources/certs/root-ca/certserial | 1 + .../resources/certs/root-ca/certserial.old | 1 + .../test/resources/certs/root-ca/crlnumber | 1 + .../resources/certs/root-ca/openssl-ca.conf | 61 ++++++++++++++++++ ...ot-ca-private-key-with-password-secret.pem | 8 +++ .../certs/root-ca/root-ca-private-key.der | Bin 0 -> 118 bytes .../certs/root-ca/root-ca-private-key.pem | 5 ++ .../test/resources/certs/root-ca/root-ca.crt | 17 +++++ .../src/test/resources/certs/secp256k1.pem | 3 + .../certs/signed-messages/helloworld.txt | 1 + .../signed-messages/helloworld.txt.sha256sig | Bin 0 -> 72 bytes restful-api-common/.gitignore | 1 + 45 files changed, 341 insertions(+) create mode 100644 bulletin-board-server/.gitignore create mode 100644 meerkat-common/.gitignore create mode 100644 meerkat-common/src/test/resources/certs/.gitattributes create mode 100644 meerkat-common/src/test/resources/certs/README.md create mode 100644 meerkat-common/src/test/resources/certs/enduser-certs/user1-key-with-password-secret.p12 create mode 100644 meerkat-common/src/test/resources/certs/enduser-certs/user1-key-with-password-secret.pem create mode 100644 meerkat-common/src/test/resources/certs/enduser-certs/user1-key.der create mode 100644 meerkat-common/src/test/resources/certs/enduser-certs/user1-key.pem create mode 100644 meerkat-common/src/test/resources/certs/enduser-certs/user1-pubkey.pem create mode 100644 meerkat-common/src/test/resources/certs/enduser-certs/user1.crt create mode 100644 meerkat-common/src/test/resources/certs/enduser-certs/user1.csr create mode 100644 meerkat-common/src/test/resources/certs/enduser-certs/user2-key.pem create mode 100644 meerkat-common/src/test/resources/certs/enduser-certs/user2-pubkey.pem create mode 100644 meerkat-common/src/test/resources/certs/enduser-certs/user2.crt create mode 100644 meerkat-common/src/test/resources/certs/enduser-certs/user2.csr create mode 100644 meerkat-common/src/test/resources/certs/enduser-certs/user2.der create mode 100644 meerkat-common/src/test/resources/certs/intermediate-ca-1/1000.pem create mode 100644 meerkat-common/src/test/resources/certs/intermediate-ca-1/1001.pem create mode 100644 meerkat-common/src/test/resources/certs/intermediate-ca-1/certindex create mode 100644 meerkat-common/src/test/resources/certs/intermediate-ca-1/certindex.attr create mode 100644 meerkat-common/src/test/resources/certs/intermediate-ca-1/certindex.attr.old create mode 100644 meerkat-common/src/test/resources/certs/intermediate-ca-1/certindex.old create mode 100644 meerkat-common/src/test/resources/certs/intermediate-ca-1/certserial create mode 100644 meerkat-common/src/test/resources/certs/intermediate-ca-1/certserial.old create mode 100644 meerkat-common/src/test/resources/certs/intermediate-ca-1/crlnumber create mode 100644 meerkat-common/src/test/resources/certs/intermediate-ca-1/intermediate-ca-1-private-key.pem create mode 100644 meerkat-common/src/test/resources/certs/intermediate-ca-1/intermediate-ca-1.crt create mode 100644 meerkat-common/src/test/resources/certs/intermediate-ca-1/intermediate-ca-1.csr create mode 100644 meerkat-common/src/test/resources/certs/intermediate-ca-1/openssl-intermediate-ca.conf create mode 100644 meerkat-common/src/test/resources/certs/root-ca/1000.pem create mode 100644 meerkat-common/src/test/resources/certs/root-ca/certindex create mode 100644 meerkat-common/src/test/resources/certs/root-ca/certindex.attr create mode 100644 meerkat-common/src/test/resources/certs/root-ca/certindex.old create mode 100644 meerkat-common/src/test/resources/certs/root-ca/certserial create mode 100644 meerkat-common/src/test/resources/certs/root-ca/certserial.old create mode 100644 meerkat-common/src/test/resources/certs/root-ca/crlnumber create mode 100644 meerkat-common/src/test/resources/certs/root-ca/openssl-ca.conf create mode 100644 meerkat-common/src/test/resources/certs/root-ca/root-ca-private-key-with-password-secret.pem create mode 100644 meerkat-common/src/test/resources/certs/root-ca/root-ca-private-key.der create mode 100644 meerkat-common/src/test/resources/certs/root-ca/root-ca-private-key.pem create mode 100644 meerkat-common/src/test/resources/certs/root-ca/root-ca.crt create mode 100644 meerkat-common/src/test/resources/certs/secp256k1.pem create mode 100644 meerkat-common/src/test/resources/certs/signed-messages/helloworld.txt create mode 100644 meerkat-common/src/test/resources/certs/signed-messages/helloworld.txt.sha256sig create mode 100644 restful-api-common/.gitignore diff --git a/bulletin-board-server/.gitignore b/bulletin-board-server/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/bulletin-board-server/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/meerkat-common/.gitignore b/meerkat-common/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/meerkat-common/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/meerkat-common/src/test/resources/certs/.gitattributes b/meerkat-common/src/test/resources/certs/.gitattributes new file mode 100644 index 0000000..f8fcd2f --- /dev/null +++ b/meerkat-common/src/test/resources/certs/.gitattributes @@ -0,0 +1 @@ +signed-messages/* -text \ No newline at end of file diff --git a/meerkat-common/src/test/resources/certs/README.md b/meerkat-common/src/test/resources/certs/README.md new file mode 100644 index 0000000..f7283d9 --- /dev/null +++ b/meerkat-common/src/test/resources/certs/README.md @@ -0,0 +1,6 @@ +Certs and private keys for testing generated using OpenSSL + +.crt and .pem files are in PEM format +.der files are in binary DER format + +files that have a name of the form *-with-password-xxxx.pem are encrypted with the password xxxx diff --git a/meerkat-common/src/test/resources/certs/enduser-certs/user1-key-with-password-secret.p12 b/meerkat-common/src/test/resources/certs/enduser-certs/user1-key-with-password-secret.p12 new file mode 100644 index 0000000000000000000000000000000000000000..6281f9d5ae0e130fe5b1456eb0b5fe67d6a732df GIT binary patch literal 1301 zcmV+w1?u`Rf&~!*0Ru3C1lI-$Duzgg_YDCD0ic2e$OM7}#4v&cz%YUXzXk~^hDe6@ z4FLxRpn?OiFoFZD0s#Opf&--n2`Yw2hW8Bt2LUh~1_~;MNQUw(I~ zGNqQ80s;sCfPw>fJ8IJVIDMrkZhe|Dcn7wOpkFb&nQsnx({lQXdj=~1Z>P^E;doZ* zv^|Qre2mu}l0c6v|0~oKWBBOK8*=5Jild)#4v?aDwN``n6B$6xSk~u}+?&ax zlwts59AB{8;;#rbw487L(9Wre6xF`a^s8CwqgKVx4bAb}SMgr>!U?K}$rk<@6GHm3(d8`H%~l$ z;1RZ*6$nseSyB}}%ph@;F$_sgCf8fDieC2G`|s5F2G?|d&4xE%m|a`pQ1eb`ayqRy0+=Wu1s{Kz0UmC2>y=-5@#qQvR? z(DSz1619xxwYC;D$XyQ(2az?1>+T$V3lv9XV{qPjAoNzOJ#10@BF>&F8Mqtt& zJ5kY<;o$BdlPt^E7W0y({xi_nZ}P26iD8ZdeK`Pdk$CRy^IFHM|aG($JymNP+!NI=l^e^0imC%Fk-6@5uo-5Ty45{-izn znL6c#0n@os>1$X{dzRObEl0XzGK$R?^layAJO>?w!dYaa&&WU)q^_8+BEFpEelROk zHUG42!V-YfsNn)1;{V~Xh<}UvTzVJ-3O8k@nt-0FS{57m(HKpFZ`vOV?zwBtG0;!@7FoEVUf#U`XDuzgg_YDCI z3IPJ3fvhlrsW2P{3Mz(3hW8Bt3;_c$4g?6=j(pEfEK9Hg0tf&Efr!OXhx8-^4UkvZ zzzvrEI@yGPc4F;YV)mgGv-X0(P!`(!;HNE!VkNP_mMQw!%>b-Yt3-nZdiJg}rx-#E zgR@?`g_C^>a)-q5J~_h* zDyXPua$eO}E_qsiM^K1^TJ<2yqhB#4Fe3&DDuzgg_YDCF6)_eB6y$?U5+Bl2@(8Je zOt_{aDZ-v4r7$rtAutIB1uG5%0vZJX1QbJiOe+w{yU;)Per>RxI@lTl5>5mNlvBCc LE?!A(0s;sCJrq%4 literal 0 HcmV?d00001 diff --git a/meerkat-common/src/test/resources/certs/enduser-certs/user1-key-with-password-secret.pem b/meerkat-common/src/test/resources/certs/enduser-certs/user1-key-with-password-secret.pem new file mode 100644 index 0000000..e859995 --- /dev/null +++ b/meerkat-common/src/test/resources/certs/enduser-certs/user1-key-with-password-secret.pem @@ -0,0 +1,8 @@ +-----BEGIN EC PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: AES-256-CBC,243D718A0D80C59590E582A26E87A49C + +RG6ITUTIdbJdWYX57oMn3tTCzHJSTjXAIZLjoVxy/v4UFYjluaFhGonIlbH1q2pP +ueu29Q3eT6144ypB8ARUJ1x0kRX1OL9zNHgdF9ulrCf9/nhGyC2nL+tHZ0YPbxoQ ++6yCQcRWvjUXLVzPEUnwMuHXJDpaXES8X0R4CISQKIA= +-----END EC PRIVATE KEY----- diff --git a/meerkat-common/src/test/resources/certs/enduser-certs/user1-key.der b/meerkat-common/src/test/resources/certs/enduser-certs/user1-key.der new file mode 100644 index 0000000000000000000000000000000000000000..6f174060b7c8dce9c94288ad1ddd589e1860dfcd GIT binary patch literal 118 zcmV-+0Ez!FbOHeZ1R#6DY6^ynp_;nYq$G=#<{Fw@d;lbbaK<$ZKft;loJ`zLTr9Gq8k*iHs1RRG0UI+MH Yjhqd;0XqY=z{0-099f}V7;H05IqJ77b^rhX literal 0 HcmV?d00001 diff --git a/meerkat-common/src/test/resources/certs/enduser-certs/user1-key.pem b/meerkat-common/src/test/resources/certs/enduser-certs/user1-key.pem new file mode 100644 index 0000000..6619e37 --- /dev/null +++ b/meerkat-common/src/test/resources/certs/enduser-certs/user1-key.pem @@ -0,0 +1,5 @@ +-----BEGIN PRIVATE KEY----- +MIGEAgEAMBAGByqGSM49AgEGBSuBBAAKBG0wawIBAQQge8JqCoaLoZq61aQki5Xm +GppcfAAkhHDGNQw/wLof5LmhRANCAAQJD1kW6BsNkRY9tslaugpOJOaoKX4uBz4S +Q96lPaPWkatNVgQchwNeB/hdjZwNuwE7A7XAwr69HFmhXRhsM005 +-----END PRIVATE KEY----- diff --git a/meerkat-common/src/test/resources/certs/enduser-certs/user1-pubkey.pem b/meerkat-common/src/test/resources/certs/enduser-certs/user1-pubkey.pem new file mode 100644 index 0000000..1c0a0c1 --- /dev/null +++ b/meerkat-common/src/test/resources/certs/enduser-certs/user1-pubkey.pem @@ -0,0 +1,4 @@ +-----BEGIN PUBLIC KEY----- +MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAECQ9ZFugbDZEWPbbJWroKTiTmqCl+Lgc+ +EkPepT2j1pGrTVYEHIcDXgf4XY2cDbsBOwO1wMK+vRxZoV0YbDNNOQ== +-----END PUBLIC KEY----- diff --git a/meerkat-common/src/test/resources/certs/enduser-certs/user1.crt b/meerkat-common/src/test/resources/certs/enduser-certs/user1.crt new file mode 100644 index 0000000..d80093f --- /dev/null +++ b/meerkat-common/src/test/resources/certs/enduser-certs/user1.crt @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDFjCCArygAwIBAgICEAAwCgYIKoZIzj0EAwIwgYIxKTAnBgNVBAMMIE1lZXJr +YXQgVm90aW5nIEludGVybWVkaWF0ZSBDQSAxMRMwEQYDVQQIDApTb21lLVN0YXRl +MQswCQYDVQQGEwJJTDEVMBMGA1UECgwMSURDIEhlcnpsaXlhMRwwGgYDVQQLDBNN +ZWVya2F0IFZvdGluZyBUZWFtMB4XDTE1MTExMTE2MTM1NFoXDTI1MTEwODE2MTM1 +NFowbjEaMBgGA1UEAwwRUG9sbGluZyBTdGF0aW9uIDExEzARBgNVBAgMClNvbWUt +U3RhdGUxCzAJBgNVBAYTAklMMRUwEwYDVQQKDAxJREMgSGVyemxpeWExFzAVBgNV +BAsMDk1lZXJrYXQgVm90aW5nMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAECQ9ZFugb +DZEWPbbJWroKTiTmqCl+Lgc+EkPepT2j1pGrTVYEHIcDXgf4XY2cDbsBOwO1wMK+ +vRxZoV0YbDNNOaOCATYwggEyMAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFLamS8o2 +hFNd0vWy/irEBNWVNwFXMB8GA1UdIwQYMBaAFBeyv0c75eT6PNumHo9TZ2B9vtcp +MAsGA1UdDwQEAwIFoDATBgNVHSUEDDAKBggrBgEFBQcDATBEBgNVHR8EPTA7MDmg +N6A1hjNodHRwOi8vY3JsLmZhY3RjZW50ZXIub3JnL21lZXJrYXQtaW50ZXJtZWRp +YXRlMS5jcmwwegYIKwYBBQUHAQEEbjBsMEEGCCsGAQUFBzAChjVodHRwOi8vcGtp +LmZhY3RjZW50ZXIub3JnL21lZXJrYXQtaW50ZXJtZWRpYXRlLWNhLmNydDAnBggr +BgEFBQcwAYYbaHR0cDovL29jc3AuZmFjdGNlbnRlci5vcmcvMAoGCCqGSM49BAMC +A0gAMEUCIQD6QbhNNmB3AVVqhmXuiLA7WF6raShw6n0g/VloVGQebQIgEvxYclpO +MMynt5wH6X65rtn4Q1EGaDMvNbFweCDsldk= +-----END CERTIFICATE----- diff --git a/meerkat-common/src/test/resources/certs/enduser-certs/user1.csr b/meerkat-common/src/test/resources/certs/enduser-certs/user1.csr new file mode 100644 index 0000000..20e1efc --- /dev/null +++ b/meerkat-common/src/test/resources/certs/enduser-certs/user1.csr @@ -0,0 +1,9 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIIBOjCB4QIBADCBgTELMAkGA1UEBhMCSUwxEzARBgNVBAgMClNvbWUtU3RhdGUx +ETAPBgNVBAcMCEhlcnpsaXlhMRUwEwYDVQQKDAxJREMgSGVyemxpeWExFzAVBgNV +BAsMDk1lZXJrYXQgVm90aW5nMRowGAYDVQQDDBFQb2xsaW5nIFN0YXRpb24gMTBW +MBAGByqGSM49AgEGBSuBBAAKA0IABAkPWRboGw2RFj22yVq6Ck4k5qgpfi4HPhJD +3qU9o9aRq01WBByHA14H+F2NnA27ATsDtcDCvr0cWaFdGGwzTTmgADAKBggqhkjO +PQQDAgNIADBFAiEA8gmIhALr7O5M1QLReGH3jheildTIr1mDWl14WyMf9U4CIF23 +mInyo4VqNHLzxMLg5Cn3Oddokng3OXa63y4nTfv+ +-----END CERTIFICATE REQUEST----- diff --git a/meerkat-common/src/test/resources/certs/enduser-certs/user2-key.pem b/meerkat-common/src/test/resources/certs/enduser-certs/user2-key.pem new file mode 100644 index 0000000..2d31bb8 --- /dev/null +++ b/meerkat-common/src/test/resources/certs/enduser-certs/user2-key.pem @@ -0,0 +1,5 @@ +-----BEGIN PRIVATE KEY----- +MIGEAgEAMBAGByqGSM49AgEGBSuBBAAKBG0wawIBAQQgYpBEO+XWm/n6VPeMVK76 +mrZkDTpiwLsDykG7M4fU5RKhRANCAAR71/kVGyA3hdxcLBBT3NPQF6R3LholmLRN +qhnvHqzJWuy7ev+Xbuxtt9AN0ajyeFDy8Oe1bUSidnLyQi+nXC0f +-----END PRIVATE KEY----- diff --git a/meerkat-common/src/test/resources/certs/enduser-certs/user2-pubkey.pem b/meerkat-common/src/test/resources/certs/enduser-certs/user2-pubkey.pem new file mode 100644 index 0000000..5d86d4c --- /dev/null +++ b/meerkat-common/src/test/resources/certs/enduser-certs/user2-pubkey.pem @@ -0,0 +1,4 @@ +-----BEGIN PUBLIC KEY----- +MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEe9f5FRsgN4XcXCwQU9zT0Bekdy4aJZi0 +TaoZ7x6syVrsu3r/l27sbbfQDdGo8nhQ8vDntW1EonZy8kIvp1wtHw== +-----END PUBLIC KEY----- diff --git a/meerkat-common/src/test/resources/certs/enduser-certs/user2.crt b/meerkat-common/src/test/resources/certs/enduser-certs/user2.crt new file mode 100644 index 0000000..a211365 --- /dev/null +++ b/meerkat-common/src/test/resources/certs/enduser-certs/user2.crt @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDFjCCArygAwIBAgICEAEwCgYIKoZIzj0EAwIwgYIxKTAnBgNVBAMMIE1lZXJr +YXQgVm90aW5nIEludGVybWVkaWF0ZSBDQSAxMRMwEQYDVQQIDApTb21lLVN0YXRl +MQswCQYDVQQGEwJJTDEVMBMGA1UECgwMSURDIEhlcnpsaXlhMRwwGgYDVQQLDBNN +ZWVya2F0IFZvdGluZyBUZWFtMB4XDTE1MTExMTE2MjAzM1oXDTI1MTEwODE2MjAz +M1owbjEaMBgGA1UEAwwRUG9sbGluZyBTdGF0aW9uIDIxEzARBgNVBAgMClNvbWUt +U3RhdGUxCzAJBgNVBAYTAklMMRUwEwYDVQQKDAxJREMgSGVyemxpeWExFzAVBgNV +BAsMDk1lZXJrYXQgVm90aW5nMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEe9f5FRsg +N4XcXCwQU9zT0Bekdy4aJZi0TaoZ7x6syVrsu3r/l27sbbfQDdGo8nhQ8vDntW1E +onZy8kIvp1wtH6OCATYwggEyMAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFKCdquYj +DGHqAHt+4PIDlw0h2UvuMB8GA1UdIwQYMBaAFBeyv0c75eT6PNumHo9TZ2B9vtcp +MAsGA1UdDwQEAwIFoDATBgNVHSUEDDAKBggrBgEFBQcDATBEBgNVHR8EPTA7MDmg +N6A1hjNodHRwOi8vY3JsLmZhY3RjZW50ZXIub3JnL21lZXJrYXQtaW50ZXJtZWRp +YXRlMS5jcmwwegYIKwYBBQUHAQEEbjBsMEEGCCsGAQUFBzAChjVodHRwOi8vcGtp +LmZhY3RjZW50ZXIub3JnL21lZXJrYXQtaW50ZXJtZWRpYXRlLWNhLmNydDAnBggr +BgEFBQcwAYYbaHR0cDovL29jc3AuZmFjdGNlbnRlci5vcmcvMAoGCCqGSM49BAMC +A0gAMEUCIQDpo5B0vvEJSax3YzOMfE8l0pfDUIKLdBWJVGeq0VLtIgIgVr0+4/0e +n+R+l1OVOLh2GirloOgbv5Ch5BQ2pQNAG2Y= +-----END CERTIFICATE----- diff --git a/meerkat-common/src/test/resources/certs/enduser-certs/user2.csr b/meerkat-common/src/test/resources/certs/enduser-certs/user2.csr new file mode 100644 index 0000000..bb3c2d0 --- /dev/null +++ b/meerkat-common/src/test/resources/certs/enduser-certs/user2.csr @@ -0,0 +1,9 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIIBOzCB4QIBADCBgTELMAkGA1UEBhMCSUwxEzARBgNVBAgMClNvbWUtU3RhdGUx +ETAPBgNVBAcMCEhlcnpsaXlhMRUwEwYDVQQKDAxJREMgSGVyemxpeWExFzAVBgNV +BAsMDk1lZXJrYXQgVm90aW5nMRowGAYDVQQDDBFQb2xsaW5nIFN0YXRpb24gMjBW +MBAGByqGSM49AgEGBSuBBAAKA0IABHvX+RUbIDeF3FwsEFPc09AXpHcuGiWYtE2q +Ge8erMla7Lt6/5du7G230A3RqPJ4UPLw57VtRKJ2cvJCL6dcLR+gADAKBggqhkjO +PQQDAgNJADBGAiEA6Ls/ojRaZT+u4YeOBYcPbRcJE3jSTe1Sm/lR7fDyEhMCIQCk +UOca+e2b8+CqM3CURBv6TqUMmZ3HeMRvEAxFPqOWSw== +-----END CERTIFICATE REQUEST----- diff --git a/meerkat-common/src/test/resources/certs/enduser-certs/user2.der b/meerkat-common/src/test/resources/certs/enduser-certs/user2.der new file mode 100644 index 0000000000000000000000000000000000000000..8e784093b249900ab82c852d5257c6e338711969 GIT binary patch literal 794 zcmXqLViq%KV%oESnTe5!iAjLbfQyYotIgw_EekV~L1UAlrhz&eb0`ZlkAiP%YEgD# zi9%R@NoHQUf@fYyYEf=#N@ik7s)Dnlf}x?XfgngJ2MWL72`${0w2gt>Wy(d-CGP0Tfr6X!KFH3R`OBLidO zC~;mRAlJYG$~DL{lroS2>1XB<49L&P0XYt2cV>Q`f)V+S5;qWqIEoL|Q3hcK0&MKy zAYx)(1!MycOjE+F?oy!-*mz3*Csm|EqyGruC+?tb7Z+2Jx zpPu(7cl!n2iz_}=1bq7Nd~2@DqOzh-PWsDZbmbQ}F`5}PF&Y{00Iii3W@P-&!eqc; zAPeI0v52vVESS6MnKDn}D~9U22cMXy^D5r-erF&Ll2&GsFc51H5#O}m-TLX1UpBXw z$@K@PC)Dn{u4%vxQozpwj7`=B;Lw*+qo`~hvA#t01me4gqr(^mZ8swk{1_djD z1ON)5L<2$q1fnR&U|n`@kTkW(@ Date: Sun, 15 Nov 2015 20:45:44 +0200 Subject: [PATCH 04/13] Trying out RESTful API --- .../sqlserver/BulletinBoardSQLServer.java | 25 +++++---- .../sqlserver/SQLiteBulletinBoardServer.java | 48 ++++++++++++---- .../webapp/HelloProtoWebApp.java | 56 +++++++++---------- .../webapp/SQLiteServerTest.java | 41 +++++++++++--- .../bulletinboard/BulletinBoardServer.java | 8 +-- .../src/main/proto/meerkat/voting.proto | 7 +++ 6 files changed, 120 insertions(+), 65 deletions(-) diff --git a/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/BulletinBoardSQLServer.java b/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/BulletinBoardSQLServer.java index de4e52e..d91b545 100644 --- a/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/BulletinBoardSQLServer.java +++ b/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/BulletinBoardSQLServer.java @@ -1,7 +1,9 @@ package meerkat.bulletinboard.sqlserver; +import java.util.Arrays; import java.util.List; +import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; @@ -18,11 +20,11 @@ import meerkat.protobuf.Voting.MessageFilterList; import meerkat.comm.CommunicationException; import meerkat.protobuf.Crypto.SignatureVerificationKey; import meerkat.protobuf.Voting.BulletinBoardMessage; +import meerkat.protobuf.Voting.BulletinBoardMessageList; import meerkat.crypto.Digest; import meerkat.crypto.concrete.SHA256Digest; import meerkat.protobuf.Voting.MessageID; -@Path("/SQLServer") public abstract class BulletinBoardSQLServer implements BulletinBoardServer{ protected Connection connection; @@ -67,7 +69,6 @@ public abstract class BulletinBoardSQLServer implements BulletinBoardServer{ */ protected abstract void insertNewTags(String[] tags) throws SQLException; - @POST @Override public boolean postMessage(BulletinBoardMessage msg) throws CommunicationException { if (!verifyMessage(msg)) { @@ -88,11 +89,11 @@ public abstract class BulletinBoardSQLServer implements BulletinBoardServer{ try { - sql = "INSERT INTO MsgTable (Id, Data, Signature) VALUES(?,?,?)"; + sql = "INSERT INTO MsgTable (MsgId, Msg, SignerId) VALUES(?,?,?)"; pstmt = connection.prepareStatement(sql); pstmt.setBytes(1, msgID); - pstmt.setBytes(2, msg.getMsg().getData().toByteArray()); - pstmt.setBytes(3, msg.getSig().toByteArray()); + pstmt.setBytes(2, msg.toByteArray()); + pstmt.setBytes(3, msg.getSig().getSignerId().toByteArray()); pstmt.executeUpdate(); pstmt.close(); @@ -113,7 +114,7 @@ public abstract class BulletinBoardSQLServer implements BulletinBoardServer{ } try{ - sql = "INSERT INTO MsgTagTable (TagId, MsgId) SELECT TagTable.Id, ? AS MsgId FROM TagTable WHERE tag = ?"; + sql = "INSERT INTO MsgTagTable (TagId, MsgId) SELECT TagTable.TagId, ? AS MsgId FROM TagTable WHERE Tag = ?"; pstmt = connection.prepareStatement(sql); for (String tag : tags){ @@ -133,7 +134,7 @@ public abstract class BulletinBoardSQLServer implements BulletinBoardServer{ } @Override - public List readMessages(MessageFilterList filterList, int max) { + public BulletinBoardMessageList readMessages(MessageFilterList filterList) { // TODO Auto-generated method stub return null; } @@ -149,22 +150,22 @@ public abstract class BulletinBoardSQLServer implements BulletinBoardServer{ while (rs.next()) { // read the result set s += "entry = " + rs.getInt("EntryNum") + " \n"; - s += "id = " + new String(rs.getBytes("Id")) + " \n"; - s += "data = " + new String(rs.getBytes("Data")) + " \n"; - s += "signature = " + new String(rs.getBytes("Signature")) + "\t\n
"; + s += "id = " + Arrays.toString(rs.getBytes("MsgId")) + " \n"; + s += "msg = " + Arrays.toString(rs.getBytes("Msg")) + " \n"; + s += "signer ID = " + Arrays.toString(rs.getBytes("SignerId")) + "\t\n
"; } rs = statement.executeQuery("select * from TagTable"); while (rs.next()) { // read the result set s += "Tag = " + rs.getString("Tag") + " \n"; - s += "TagId = " + rs.getInt("Id") + "\t\n
"; + s += "TagId = " + rs.getInt("TagId") + "\t\n
"; } rs = statement.executeQuery("select * from MsgTagTable"); while (rs.next()) { // read the result set - s += "MsgId = " + new String(rs.getBytes("MsgId")) + " \n"; + s += "MsgId = " + Arrays.toString(rs.getBytes("MsgId")) + " \n"; s += "TagId = " + rs.getInt("TagId") + "\t\n
"; } } catch(SQLException e){ diff --git a/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/SQLiteBulletinBoardServer.java b/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/SQLiteBulletinBoardServer.java index 104ea57..ffb5b9d 100644 --- a/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/SQLiteBulletinBoardServer.java +++ b/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/SQLiteBulletinBoardServer.java @@ -6,12 +6,24 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.List; +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Response; + import meerkat.protobuf.Voting.MessageFilterList; +import meerkat.rest.Constants; import meerkat.bulletinboard.sqlserver.BulletinBoardSQLServer; import meerkat.comm.CommunicationException; import meerkat.protobuf.Voting.BulletinBoardMessage; +import meerkat.protobuf.Voting.BulletinBoardMessageList; +@Path("/SQLServer") public class SQLiteBulletinBoardServer extends BulletinBoardSQLServer { protected static final int TIMEOUT = 20; @@ -20,8 +32,8 @@ public class SQLiteBulletinBoardServer extends BulletinBoardSQLServer { * This procedure initializes: * 1. The database connection * 2. The database tables (if they do not yet exist). - * 3. */ + @PostConstruct @Override public void init() throws CommunicationException { @@ -31,9 +43,9 @@ public class SQLiteBulletinBoardServer extends BulletinBoardSQLServer { Statement statement = connection.createStatement(); statement.setQueryTimeout(TIMEOUT); - statement.executeUpdate("CREATE TABLE IF NOT EXISTS MsgTable (EntryNum INTEGER PRIMARY KEY, Id BLOB UNIQUE, Data BLOB, Signature BLOB)"); - statement.executeUpdate("CREATE TABLE IF NOT EXISTS TagTable (Id INTEGER PRIMARY KEY, Tag varchar(50) UNIQUE)"); - statement.executeUpdate("CREATE TABLE IF NOT EXISTS MsgTagTable (MsgId BLOB, TagId INTEGER, FOREIGN KEY (MsgId) REFERENCES MsgTable(Id), FOREIGN KEY (TagId) REFERENCES TagTable(Id))"); + statement.executeUpdate("CREATE TABLE IF NOT EXISTS MsgTable (EntryNum INTEGER PRIMARY KEY, MsgId BLOB UNIQUE, Msg BLOB, SignerId BLOB)"); + statement.executeUpdate("CREATE TABLE IF NOT EXISTS TagTable (TagId INTEGER PRIMARY KEY, Tag varchar(50) UNIQUE)"); + statement.executeUpdate("CREATE TABLE IF NOT EXISTS MsgTagTable (MsgId BLOB, TagId INTEGER, FOREIGN KEY (MsgId) REFERENCES MsgTable(MsgId), FOREIGN KEY (TagId) REFERENCES TagTable(TagId))"); statement.close(); @@ -46,14 +58,8 @@ public class SQLiteBulletinBoardServer extends BulletinBoardSQLServer { } } - - - @Override - public List readMessages(MessageFilterList filterList, int max) { - // TODO Auto-generated method stub - return null; - } + @PreDestroy public void close() throws CommunicationException{ try{ @@ -91,5 +97,25 @@ public class SQLiteBulletinBoardServer extends BulletinBoardSQLServer { } } + +// @POST + @Consumes(Constants.MEDIATYPE_PROTOBUF) + @Override + public boolean postMessage(BulletinBoardMessage msg) throws CommunicationException { + return super.postMessage(msg); + } + +// @GET + @Consumes(Constants.MEDIATYPE_PROTOBUF) + @Produces(Constants.MEDIATYPE_PROTOBUF) + @Override + public BulletinBoardMessageList readMessages(MessageFilterList filterList) { + return super.readMessages(filterList); + } + + @GET + public String test(){ + return "hello"; + } } diff --git a/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/HelloProtoWebApp.java b/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/HelloProtoWebApp.java index ab2d952..491c295 100644 --- a/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/HelloProtoWebApp.java +++ b/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/HelloProtoWebApp.java @@ -1,6 +1,5 @@ package meerkat.bulletinboard.webapp; - import com.google.protobuf.ByteString; import com.google.protobuf.Message; import meerkat.bulletinboard.service.HelloProtoBuf; @@ -17,38 +16,37 @@ import javax.ws.rs.Produces; @Path("/proto") public class HelloProtoWebApp { - private HelloProtoBuf helloProtoBuf; - - @PostConstruct - public void init(){ - //helloProtoBuf = new HelloProtoBuf(); - } - - @GET - @Produces(Constants.MEDIATYPE_PROTOBUF) - public Message hello() { - byte[] b1 = {(byte) 1, (byte)2, (byte) 3, (byte) 4}; - byte[] b2 = {(byte) 11, (byte)12, (byte) 13, (byte) 14}; - - Message msg; - - if (helloProtoBuf != null){ - msg = helloProtoBuf.sayHello(); - } - else{ - msg = BulletinBoardMessage.newBuilder() + private HelloProtoBuf helloProtoBuf; + + @PostConstruct + public void init() { + // helloProtoBuf = new HelloProtoBuf(); + } + + @GET + @Produces(Constants.MEDIATYPE_PROTOBUF) + public Message hello() { + byte[] b1 = { (byte) 1, (byte) 2, (byte) 3, (byte) 4 }; + byte[] b2 = { (byte) 11, (byte) 12, (byte) 13, (byte) 14 }; + byte[] b3 = {(byte) 21, (byte)22, (byte) 23, (byte) 24}; + + Message msg; + + if (helloProtoBuf != null) { + msg = helloProtoBuf.sayHello(); + } else { + msg = BulletinBoardMessage.newBuilder() .setMsg(UnsignedBulletinBoardMessage.newBuilder() - .addTags("signature") + .addTags("Signature") .addTags("Trustee") - .setData(ByteString.copyFrom(b1)) - .build()) + .setData(ByteString.copyFrom(b1)).build()) .setSig(Signature.newBuilder() .setType(SignatureType.DSA) .setData(ByteString.copyFrom(b2)) - .build()) + .setSignerId(ByteString.copyFrom(b3)).build()) .build(); - } - - return msg; - } + } + + return msg; + } } diff --git a/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/SQLiteServerTest.java b/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/SQLiteServerTest.java index 7206ad0..6e702fc 100644 --- a/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/SQLiteServerTest.java +++ b/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/SQLiteServerTest.java @@ -3,23 +3,37 @@ package meerkat.bulletinboard.webapp; import javax.ws.rs.GET; import javax.ws.rs.Path; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.Entity; +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; +import meerkat.rest.Constants; +import meerkat.rest.Constants.*; + import com.google.protobuf.ByteString; import meerkat.bulletinboard.sqlserver.SQLiteBulletinBoardServer; import meerkat.comm.CommunicationException; import meerkat.protobuf.Crypto.*; import meerkat.protobuf.Voting.*; +import meerkat.rest.*; @Path("/test") public class SQLiteServerTest { + private static String PROP_GETTY_URL = "gretty.httpBaseURI"; + private static String BASE_URL = "http://localhost:8081";//System.getProperty(PROP_GETTY_URL); + private static String SQL_SERVER_URL = BASE_URL + "/SQLServer"; + @GET public Response main(){ byte[] b1 = {(byte) 1, (byte)2, (byte) 3, (byte) 4}; byte[] b2 = {(byte) 11, (byte)12, (byte) 13, (byte) 14}; + byte[] b3 = {(byte) 21, (byte)22, (byte) 23, (byte) 24}; Response response; @@ -34,23 +48,34 @@ public class SQLiteServerTest { .setSig(Signature.newBuilder() .setType(SignatureType.DSA) .setData(ByteString.copyFrom(b2)) + .setSignerId(ByteString.copyFrom(b3)) .build()) .build(); - SQLiteBulletinBoardServer bbs = new SQLiteBulletinBoardServer(); - - - bbs.init(); +// SQLiteBulletinBoardServer bbs = new SQLiteBulletinBoardServer(); +// +// +// bbs.init(); +// +// bbs.postMessage(msg); +// response = Response.status(Status.OK).entity(bbs.testPrint()).build(); +// +// bbs.close(); - bbs.postMessage(msg); - response = Response.status(Status.OK).entity(bbs.testPrint()).build(); + - bbs.close(); + Client client = ClientBuilder.newClient() + .register(ProtobufMessageBodyWriter.class) + .register(ProtobufMessageBodyWriter.class); + WebTarget webTarget = client.target(SQL_SERVER_URL); + response = webTarget.request(MediaType.TEXT_HTML).post(Entity.entity(msg, Constants.MEDIATYPE_PROTOBUF)); - } catch(CommunicationException e){ + } catch(Exception e){ response = Response.status(Status.OK).entity(e.getMessage()).build();; } +// response = Response.status(Status.OK).entity("OK").build(); + return response; } diff --git a/meerkat-common/src/main/java/meerkat/bulletinboard/BulletinBoardServer.java b/meerkat-common/src/main/java/meerkat/bulletinboard/BulletinBoardServer.java index 05bdf47..f312ed8 100644 --- a/meerkat-common/src/main/java/meerkat/bulletinboard/BulletinBoardServer.java +++ b/meerkat-common/src/main/java/meerkat/bulletinboard/BulletinBoardServer.java @@ -1,9 +1,8 @@ package meerkat.bulletinboard; -import java.util.List; - import meerkat.comm.CommunicationException; import meerkat.protobuf.Voting.BulletinBoardMessage; +import meerkat.protobuf.Voting.BulletinBoardMessageList; import meerkat.protobuf.Voting.MessageFilterList; /** @@ -32,11 +31,10 @@ public interface BulletinBoardServer{ /** * Read all messages posted matching the given filter. - * @param filter return only messages that match the filter (null means no filtering). - * @param max maximum number of messages to return (0=no limit) + * @param filter return only messages that match the filter (empty list means no filtering). * @return */ - List readMessages(MessageFilterList filterList, int max); + BulletinBoardMessageList readMessages(MessageFilterList filterList); /** * This method closes the connection to the DB. diff --git a/meerkat-common/src/main/proto/meerkat/voting.proto b/meerkat-common/src/main/proto/meerkat/voting.proto index c7dcad3..f730a89 100644 --- a/meerkat-common/src/main/proto/meerkat/voting.proto +++ b/meerkat-common/src/main/proto/meerkat/voting.proto @@ -28,12 +28,19 @@ message BulletinBoardMessage { meerkat.Signature sig = 2; } +message BulletinBoardMessageList { + + repeated BulletinBoardMessage messages = 1; + +} + enum FilterType { ID = 0; // Match exact message ID EXACT_ENTRY = 1; // Match exact entry number in database (chronological) MAX_ENTRY = 2; // Find all entries in database up to specified entry number (chronological) SIGNATURE = 3; // Find all entries in database that correspond to specific signature (signer) TAG = 4; // Find all entries in database that have a specific tag + MAX_MESSAGES = 5; // Return at most some specified number of messages } message MessageFilter { From 59089016627fc7c9ebfc871cfe65c45b60d2363e Mon Sep 17 00:00:00 2001 From: Tal Moran Date: Tue, 17 Nov 2015 00:24:27 +0200 Subject: [PATCH 05/13] Prevent jetty from scanning annotations in jars (reduces startup time) --- .../src/main/webapp/META-INF/jetty-env.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 bulletin-board-server/src/main/webapp/META-INF/jetty-env.xml diff --git a/bulletin-board-server/src/main/webapp/META-INF/jetty-env.xml b/bulletin-board-server/src/main/webapp/META-INF/jetty-env.xml new file mode 100644 index 0000000..c4d368f --- /dev/null +++ b/bulletin-board-server/src/main/webapp/META-INF/jetty-env.xml @@ -0,0 +1,12 @@ + + + + + org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern + none + + + org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern + none + + \ No newline at end of file From 782dfc8fa3b7c5f29bb24dc478be88e2bb75afa8 Mon Sep 17 00:00:00 2001 From: Tal Moran Date: Tue, 17 Nov 2015 00:26:35 +0200 Subject: [PATCH 06/13] Removed old (non meerkat) test code --- .../src/main/java/service/HelloWorldService.java | 9 --------- .../src/main/java/webapp/HelloWebApp.java | 16 ---------------- .../src/main/webapp/WEB-INF/web.xml | 2 +- 3 files changed, 1 insertion(+), 26 deletions(-) delete mode 100644 bulletin-board-server/src/main/java/service/HelloWorldService.java delete mode 100644 bulletin-board-server/src/main/java/webapp/HelloWebApp.java diff --git a/bulletin-board-server/src/main/java/service/HelloWorldService.java b/bulletin-board-server/src/main/java/service/HelloWorldService.java deleted file mode 100644 index dbdf159..0000000 --- a/bulletin-board-server/src/main/java/service/HelloWorldService.java +++ /dev/null @@ -1,9 +0,0 @@ -package service; - - - -public class HelloWorldService { - public String sayHello() { - return "Hello, World!"; - } -} diff --git a/bulletin-board-server/src/main/java/webapp/HelloWebApp.java b/bulletin-board-server/src/main/java/webapp/HelloWebApp.java deleted file mode 100644 index 0a518f7..0000000 --- a/bulletin-board-server/src/main/java/webapp/HelloWebApp.java +++ /dev/null @@ -1,16 +0,0 @@ -package webapp; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; - -import service.HelloWorldService; - -@Path("/hello") -public class HelloWebApp { - private static HelloWorldService helloWorldService = new HelloWorldService(); - - @GET - public String hello() { - return helloWorldService.sayHello(); - } -} diff --git a/bulletin-board-server/src/main/webapp/WEB-INF/web.xml b/bulletin-board-server/src/main/webapp/WEB-INF/web.xml index ba674d2..cc90843 100644 --- a/bulletin-board-server/src/main/webapp/WEB-INF/web.xml +++ b/bulletin-board-server/src/main/webapp/WEB-INF/web.xml @@ -6,7 +6,7 @@ jersey.config.server.provider.packages - webapp, meerkat + meerkat 1 From eaf7822731dcf0b9925172b1f9774b90b8038eef Mon Sep 17 00:00:00 2001 From: Tal Moran Date: Tue, 17 Nov 2015 00:27:34 +0200 Subject: [PATCH 07/13] Added TRACE-level logging by default to gretty executions --- bulletin-board-server/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bulletin-board-server/build.gradle b/bulletin-board-server/build.gradle index e9f3a90..3b3a082 100644 --- a/bulletin-board-server/build.gradle +++ b/bulletin-board-server/build.gradle @@ -73,8 +73,8 @@ task integrationTest(type: Test) { gretty { httpPort = 8081 contextPath = '/' - servletContainer = 'jetty9' integrationTestTask = 'integrationTest' + loggingLevel = 'TRACE' } From 7bb9172707cca4980137f64f9416202353f8768a Mon Sep 17 00:00:00 2001 From: Tal Moran Date: Tue, 17 Nov 2015 00:29:41 +0200 Subject: [PATCH 08/13] Moved SQL test to test source set; integration tests now appear to work --- .../sqlserver/SQLiteBulletinBoardServer.java | 27 ++++-- .../webapp/HelloProtoWebApp.java | 2 +- .../webapp/SQLiteServerTest.java | 82 ------------------- .../proto/meerkat/bulletin_board_server.proto | 9 ++ .../src/test/java/HelloIntegrationTest.java | 22 ----- .../HelloProtoIntegrationTest.java | 11 +-- .../SQLiteServerIntegrationTest.java | 75 +++++++++++++++++ 7 files changed, 113 insertions(+), 115 deletions(-) delete mode 100644 bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/SQLiteServerTest.java create mode 100644 bulletin-board-server/src/main/proto/meerkat/bulletin_board_server.proto delete mode 100644 bulletin-board-server/src/test/java/HelloIntegrationTest.java create mode 100644 bulletin-board-server/src/test/java/meerkat/bulletinboard/SQLiteServerIntegrationTest.java diff --git a/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/SQLiteBulletinBoardServer.java b/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/SQLiteBulletinBoardServer.java index ffb5b9d..a3782c1 100644 --- a/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/SQLiteBulletinBoardServer.java +++ b/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/SQLiteBulletinBoardServer.java @@ -4,7 +4,9 @@ import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Statement; +import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; @@ -13,8 +15,12 @@ import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import com.google.protobuf.Message; +import meerkat.protobuf.BulletinBoardServer; +import meerkat.protobuf.Bulletinboardserver; import meerkat.protobuf.Voting.MessageFilterList; import meerkat.rest.Constants; import meerkat.bulletinboard.sqlserver.BulletinBoardSQLServer; @@ -97,13 +103,23 @@ public class SQLiteBulletinBoardServer extends BulletinBoardSQLServer { } } - -// @POST - @Consumes(Constants.MEDIATYPE_PROTOBUF) + @Override public boolean postMessage(BulletinBoardMessage msg) throws CommunicationException { return super.postMessage(msg); } + + + @POST + @Consumes(Constants.MEDIATYPE_PROTOBUF) + @Produces(Constants.MEDIATYPE_PROTOBUF) + public Message doPostMessage(BulletinBoardMessage msg)throws CommunicationException { + boolean result = super.postMessage(msg); + + return BulletinBoardServer.Boolean.newBuilder() + .setValue(result) + .build(); + } // @GET @Consumes(Constants.MEDIATYPE_PROTOBUF) @@ -114,8 +130,9 @@ public class SQLiteBulletinBoardServer extends BulletinBoardSQLServer { } @GET - public String test(){ - return "hello"; + @Produces(MediaType.TEXT_PLAIN) + public String test() { + return "Hello World"; } } diff --git a/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/HelloProtoWebApp.java b/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/HelloProtoWebApp.java index 491c295..b144a5a 100644 --- a/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/HelloProtoWebApp.java +++ b/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/HelloProtoWebApp.java @@ -20,7 +20,7 @@ public class HelloProtoWebApp { @PostConstruct public void init() { - // helloProtoBuf = new HelloProtoBuf(); + helloProtoBuf = new HelloProtoBuf(); } @GET diff --git a/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/SQLiteServerTest.java b/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/SQLiteServerTest.java deleted file mode 100644 index 6e702fc..0000000 --- a/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/SQLiteServerTest.java +++ /dev/null @@ -1,82 +0,0 @@ -package meerkat.bulletinboard.webapp; - - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.Entity; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; - -import meerkat.rest.Constants; -import meerkat.rest.Constants.*; - -import com.google.protobuf.ByteString; - -import meerkat.bulletinboard.sqlserver.SQLiteBulletinBoardServer; -import meerkat.comm.CommunicationException; -import meerkat.protobuf.Crypto.*; -import meerkat.protobuf.Voting.*; -import meerkat.rest.*; - -@Path("/test") -public class SQLiteServerTest { - - private static String PROP_GETTY_URL = "gretty.httpBaseURI"; - private static String BASE_URL = "http://localhost:8081";//System.getProperty(PROP_GETTY_URL); - private static String SQL_SERVER_URL = BASE_URL + "/SQLServer"; - - @GET - public Response main(){ - byte[] b1 = {(byte) 1, (byte)2, (byte) 3, (byte) 4}; - byte[] b2 = {(byte) 11, (byte)12, (byte) 13, (byte) 14}; - byte[] b3 = {(byte) 21, (byte)22, (byte) 23, (byte) 24}; - - Response response; - - BulletinBoardMessage msg; - try{ - msg = BulletinBoardMessage.newBuilder() - .setMsg(UnsignedBulletinBoardMessage.newBuilder() - .addTags("Signature") - .addTags("Trustee") - .setData(ByteString.copyFrom(b1)) - .build()) - .setSig(Signature.newBuilder() - .setType(SignatureType.DSA) - .setData(ByteString.copyFrom(b2)) - .setSignerId(ByteString.copyFrom(b3)) - .build()) - .build(); - -// SQLiteBulletinBoardServer bbs = new SQLiteBulletinBoardServer(); -// -// -// bbs.init(); -// -// bbs.postMessage(msg); -// response = Response.status(Status.OK).entity(bbs.testPrint()).build(); -// -// bbs.close(); - - - - Client client = ClientBuilder.newClient() - .register(ProtobufMessageBodyWriter.class) - .register(ProtobufMessageBodyWriter.class); - WebTarget webTarget = client.target(SQL_SERVER_URL); - response = webTarget.request(MediaType.TEXT_HTML).post(Entity.entity(msg, Constants.MEDIATYPE_PROTOBUF)); - - } catch(Exception e){ - response = Response.status(Status.OK).entity(e.getMessage()).build();; - } - -// response = Response.status(Status.OK).entity("OK").build(); - - return response; - } - -} diff --git a/bulletin-board-server/src/main/proto/meerkat/bulletin_board_server.proto b/bulletin-board-server/src/main/proto/meerkat/bulletin_board_server.proto new file mode 100644 index 0000000..e31485b --- /dev/null +++ b/bulletin-board-server/src/main/proto/meerkat/bulletin_board_server.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package meerkat; + +option java_package = "meerkat.protobuf"; + +message Boolean { + bool value = 1; +} \ No newline at end of file diff --git a/bulletin-board-server/src/test/java/HelloIntegrationTest.java b/bulletin-board-server/src/test/java/HelloIntegrationTest.java deleted file mode 100644 index 3a01d5e..0000000 --- a/bulletin-board-server/src/test/java/HelloIntegrationTest.java +++ /dev/null @@ -1,22 +0,0 @@ -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.WebTarget; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import org.junit.Test; - -public class HelloIntegrationTest { - - private static String PROP_GETTY_URL = "gretty.httpBaseURI"; - private static String BASE_URL = System.getProperty(PROP_GETTY_URL); - private static String HELLO_URL = BASE_URL + "/hello"; - - @Test - public void testHello() throws Exception { - Client client = ClientBuilder.newClient(); - WebTarget webTarget = client.target(HELLO_URL); - String response = webTarget.request().get(String.class); - System.out.println(response); - assertThat(response, is("Hello, World!")); - } -} diff --git a/bulletin-board-server/src/test/java/meerkat/bulletinboard/HelloProtoIntegrationTest.java b/bulletin-board-server/src/test/java/meerkat/bulletinboard/HelloProtoIntegrationTest.java index 4a6cbb3..1bcb091 100644 --- a/bulletin-board-server/src/test/java/meerkat/bulletinboard/HelloProtoIntegrationTest.java +++ b/bulletin-board-server/src/test/java/meerkat/bulletinboard/HelloProtoIntegrationTest.java @@ -17,10 +17,10 @@ import static org.hamcrest.MatcherAssert.assertThat; * Created by talm on 10/11/15. */ public class HelloProtoIntegrationTest { - private static String PROP_GETTY_URL = "gretty.httpBaseURI"; - private static String BASE_URL = System.getProperty(PROP_GETTY_URL); - private static String HELLO_URL = BASE_URL + "/proto"; + private static String DEFAULT_BASE_URL = "http://localhost:8081/"; + private static String BASE_URL = System.getProperty(PROP_GETTY_URL, DEFAULT_BASE_URL); + private static String HELLO_URL = "proto"; @Test public void testHello() throws Exception { @@ -28,8 +28,9 @@ public class HelloProtoIntegrationTest { client.register(ProtobufMessageBodyReader.class); client.register(ProtobufMessageBodyWriter.class); - WebTarget webTarget = client.target(HELLO_URL); - Voting.BulletinBoardMessage response = webTarget.request(Constants.MEDIATYPE_PROTOBUF).get(Voting.BulletinBoardMessage.class); + WebTarget webTarget = client.target(BASE_URL).path(HELLO_URL); + Voting.BulletinBoardMessage response = webTarget.request(Constants.MEDIATYPE_PROTOBUF) + .get(Voting.BulletinBoardMessage.class); System.out.println(response.getMsg().getData()); diff --git a/bulletin-board-server/src/test/java/meerkat/bulletinboard/SQLiteServerIntegrationTest.java b/bulletin-board-server/src/test/java/meerkat/bulletinboard/SQLiteServerIntegrationTest.java new file mode 100644 index 0000000..6a6371d --- /dev/null +++ b/bulletin-board-server/src/test/java/meerkat/bulletinboard/SQLiteServerIntegrationTest.java @@ -0,0 +1,75 @@ +package meerkat.bulletinboard; + + +import com.google.protobuf.ByteString; +import meerkat.protobuf.Crypto.Signature; +import meerkat.protobuf.Crypto.SignatureType; +import meerkat.protobuf.Voting.BulletinBoardMessage; +import meerkat.protobuf.Voting.UnsignedBulletinBoardMessage; +import meerkat.rest.Constants; +import meerkat.rest.ProtobufMessageBodyReader; +import meerkat.rest.ProtobufMessageBodyWriter; +import org.junit.Before; +import org.junit.Test; + +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.Entity; +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.Response; + +public class SQLiteServerIntegrationTest { + + private static String PROP_GETTY_URL = "gretty.httpBaseURI"; + private static String DEFAULT_BASE_URL = "http://localhost:8081/"; + private static String BASE_URL = System.getProperty(PROP_GETTY_URL, DEFAULT_BASE_URL); + private static String SQL_SERVER_URL = "SQLServer"; + + Client client; + + @Before + public void setup() throws Exception { + client = ClientBuilder.newClient(); + client.register(ProtobufMessageBodyReader.class); + client.register(ProtobufMessageBodyWriter.class); + } + + @Test + public void testPost() throws Exception { + byte[] b1 = {(byte) 1, (byte) 2, (byte) 3, (byte) 4}; + byte[] b2 = {(byte) 11, (byte) 12, (byte) 13, (byte) 14}; + byte[] b3 = {(byte) 21, (byte) 22, (byte) 23, (byte) 24}; + + Response response; + + BulletinBoardMessage msg; + + msg = BulletinBoardMessage.newBuilder() + .setMsg(UnsignedBulletinBoardMessage.newBuilder() + .addTags("Signature") + .addTags("Trustee") + .setData(ByteString.copyFrom(b1)) + .build()) + .setSig(Signature.newBuilder() + .setType(SignatureType.DSA) + .setData(ByteString.copyFrom(b2)) + .setSignerId(ByteString.copyFrom(b3)) + .build()) + .build(); + +// SQLiteBulletinBoardServer bbs = new SQLiteBulletinBoardServer(); +// +// +// bbs.init(); +// +// bbs.postMessage(msg); +// response = Response.status(Status.OK).entity(bbs.testPrint()).build(); +// +// bbs.close(); + + System.err.println("******** Testing: " + SQL_SERVER_URL); + WebTarget webTarget = client.target(BASE_URL).path(SQL_SERVER_URL); + response = webTarget.request(Constants.MEDIATYPE_PROTOBUF).post(Entity.entity(msg, Constants.MEDIATYPE_PROTOBUF)); + } + +} From 47edf0df34269010e875a4f05a8fc019e122eede Mon Sep 17 00:00:00 2001 From: Arbel Deutsch Peled Date: Tue, 17 Nov 2015 22:27:01 +0200 Subject: [PATCH 09/13] Working version of Bulletin Board Server + refactoring of Bulletin Board ProtoBufs + successful integration test --- bulletin-board-server/build.gradle | 2 +- .../httpserver/BulletinBoardHttpServer.java | 2 +- .../bulletinboard/service/HelloProtoBuf.java | 5 +- .../sqlserver/BulletinBoardSQLServer.java | 22 +++---- .../sqlserver/SQLiteBulletinBoardServer.java | 30 ++------- .../webapp/HelloProtoWebApp.java | 6 +- .../HelloProtoIntegrationTest.java | 6 +- .../SQLiteServerIntegrationTest.java | 25 +++---- meerkat-common/src/main/java/Demo.java | 2 +- .../meerkat/bulletinboard/BulletinBoard.java | 2 +- .../bulletinboard/BulletinBoardServer.java | 8 +-- .../java/meerkat/crypto/DigitalSignature.java | 2 +- .../main/proto/meerkat/BulletinBoardAPI.proto | 65 +++++++++++++++++++ .../src/main/proto/meerkat/voting.proto | 53 --------------- .../crypto/concrete/TestECDSASignature.java | 6 +- 15 files changed, 109 insertions(+), 127 deletions(-) create mode 100644 meerkat-common/src/main/proto/meerkat/BulletinBoardAPI.proto diff --git a/bulletin-board-server/build.gradle b/bulletin-board-server/build.gradle index 3b3a082..cfe4233 100644 --- a/bulletin-board-server/build.gradle +++ b/bulletin-board-server/build.gradle @@ -71,7 +71,7 @@ task integrationTest(type: Test) { } gretty { - httpPort = 8081 + httpPort = 8082 contextPath = '/' integrationTestTask = 'integrationTest' loggingLevel = 'TRACE' diff --git a/bulletin-board-server/src/main/java/meerkat/bulletinboard/httpserver/BulletinBoardHttpServer.java b/bulletin-board-server/src/main/java/meerkat/bulletinboard/httpserver/BulletinBoardHttpServer.java index 10683cb..6d344fe 100644 --- a/bulletin-board-server/src/main/java/meerkat/bulletinboard/httpserver/BulletinBoardHttpServer.java +++ b/bulletin-board-server/src/main/java/meerkat/bulletinboard/httpserver/BulletinBoardHttpServer.java @@ -11,7 +11,7 @@ import javax.servlet.http.HttpServletResponse; import meerkat.bulletinboard.BulletinBoardServer; import meerkat.bulletinboard.sqlserver.SQLiteBulletinBoardServer; import meerkat.comm.CommunicationException; -import meerkat.protobuf.Voting.BulletinBoardMessage; +import meerkat.protobuf.BulletinBoardAPI.*; public class BulletinBoardHttpServer extends HttpServlet { diff --git a/bulletin-board-server/src/main/java/meerkat/bulletinboard/service/HelloProtoBuf.java b/bulletin-board-server/src/main/java/meerkat/bulletinboard/service/HelloProtoBuf.java index f848a47..a4d8012 100644 --- a/bulletin-board-server/src/main/java/meerkat/bulletinboard/service/HelloProtoBuf.java +++ b/bulletin-board-server/src/main/java/meerkat/bulletinboard/service/HelloProtoBuf.java @@ -3,8 +3,7 @@ package meerkat.bulletinboard.service; import com.google.protobuf.ByteString; import com.google.protobuf.Message; import meerkat.protobuf.Crypto; -import meerkat.protobuf.Voting; -import meerkat.protobuf.Voting.BulletinBoardMessage; +import meerkat.protobuf.BulletinBoardAPI.*; import java.util.Arrays; import java.util.List; @@ -16,7 +15,7 @@ public class HelloProtoBuf { public Message sayHello() { BulletinBoardMessage.Builder msg = BulletinBoardMessage.newBuilder(); - Voting.UnsignedBulletinBoardMessage.Builder unsigned = Voting.UnsignedBulletinBoardMessage.newBuilder(); + UnsignedBulletinBoardMessage.Builder unsigned = UnsignedBulletinBoardMessage.newBuilder(); unsigned.setData(ByteString.copyFromUtf8("Hello World!")); List tags = Arrays.asList("Greetings", "FirstPrograms"); unsigned.addAllTags(tags); diff --git a/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/BulletinBoardSQLServer.java b/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/BulletinBoardSQLServer.java index d91b545..b4045fb 100644 --- a/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/BulletinBoardSQLServer.java +++ b/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/BulletinBoardSQLServer.java @@ -3,10 +3,6 @@ package meerkat.bulletinboard.sqlserver; import java.util.Arrays; import java.util.List; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; - import com.google.protobuf.ProtocolStringList; import java.sql.Connection; @@ -16,14 +12,11 @@ import java.sql.SQLException; import java.sql.Statement; import meerkat.bulletinboard.BulletinBoardServer; -import meerkat.protobuf.Voting.MessageFilterList; import meerkat.comm.CommunicationException; +import meerkat.protobuf.BulletinBoardAPI.*; import meerkat.protobuf.Crypto.SignatureVerificationKey; -import meerkat.protobuf.Voting.BulletinBoardMessage; -import meerkat.protobuf.Voting.BulletinBoardMessageList; import meerkat.crypto.Digest; import meerkat.crypto.concrete.SHA256Digest; -import meerkat.protobuf.Voting.MessageID; public abstract class BulletinBoardSQLServer implements BulletinBoardServer{ @@ -69,10 +62,17 @@ public abstract class BulletinBoardSQLServer implements BulletinBoardServer{ */ protected abstract void insertNewTags(String[] tags) throws SQLException; + private BoolMsg boolToBoolMsg(boolean b){ + return BoolMsg.newBuilder() + .setValue(b) + .build(); + } + @Override - public boolean postMessage(BulletinBoardMessage msg) throws CommunicationException { + public BoolMsg postMessage(BulletinBoardMessage msg) throws CommunicationException { + if (!verifyMessage(msg)) { - return false; + return boolToBoolMsg(false); } PreparedStatement pstmt; @@ -130,7 +130,7 @@ public abstract class BulletinBoardSQLServer implements BulletinBoardServer{ throw new CommunicationException("Error Linking tags: " + e.getMessage()); } - return true; + return boolToBoolMsg(true); } @Override diff --git a/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/SQLiteBulletinBoardServer.java b/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/SQLiteBulletinBoardServer.java index a3782c1..6cc016b 100644 --- a/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/SQLiteBulletinBoardServer.java +++ b/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/SQLiteBulletinBoardServer.java @@ -4,9 +4,6 @@ import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Statement; -import java.util.HashMap; -import java.util.List; -import java.util.Map; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; @@ -16,20 +13,14 @@ import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import com.google.protobuf.Message; -import meerkat.protobuf.BulletinBoardServer; -import meerkat.protobuf.Bulletinboardserver; -import meerkat.protobuf.Voting.MessageFilterList; +import meerkat.protobuf.BulletinBoardAPI.*; import meerkat.rest.Constants; import meerkat.bulletinboard.sqlserver.BulletinBoardSQLServer; import meerkat.comm.CommunicationException; -import meerkat.protobuf.Voting.BulletinBoardMessage; -import meerkat.protobuf.Voting.BulletinBoardMessageList; -@Path("/SQLServer") +@Path("/sqlserver") public class SQLiteBulletinBoardServer extends BulletinBoardSQLServer { protected static final int TIMEOUT = 20; @@ -104,24 +95,15 @@ public class SQLiteBulletinBoardServer extends BulletinBoardSQLServer { } + @Path("postmessage") + @POST @Override - public boolean postMessage(BulletinBoardMessage msg) throws CommunicationException { + public BoolMsg postMessage(BulletinBoardMessage msg) throws CommunicationException { return super.postMessage(msg); } - + @Path("readmessages") @POST - @Consumes(Constants.MEDIATYPE_PROTOBUF) - @Produces(Constants.MEDIATYPE_PROTOBUF) - public Message doPostMessage(BulletinBoardMessage msg)throws CommunicationException { - boolean result = super.postMessage(msg); - - return BulletinBoardServer.Boolean.newBuilder() - .setValue(result) - .build(); - } - -// @GET @Consumes(Constants.MEDIATYPE_PROTOBUF) @Produces(Constants.MEDIATYPE_PROTOBUF) @Override diff --git a/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/HelloProtoWebApp.java b/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/HelloProtoWebApp.java index b144a5a..ca56c3d 100644 --- a/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/HelloProtoWebApp.java +++ b/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/HelloProtoWebApp.java @@ -3,10 +3,8 @@ package meerkat.bulletinboard.webapp; import com.google.protobuf.ByteString; import com.google.protobuf.Message; import meerkat.bulletinboard.service.HelloProtoBuf; -import meerkat.protobuf.Crypto.Signature; -import meerkat.protobuf.Crypto.SignatureType; -import meerkat.protobuf.Voting.BulletinBoardMessage; -import meerkat.protobuf.Voting.UnsignedBulletinBoardMessage; +import meerkat.protobuf.Crypto.*; +import meerkat.protobuf.BulletinBoardAPI.*; import meerkat.rest.Constants; import javax.annotation.PostConstruct; diff --git a/bulletin-board-server/src/test/java/meerkat/bulletinboard/HelloProtoIntegrationTest.java b/bulletin-board-server/src/test/java/meerkat/bulletinboard/HelloProtoIntegrationTest.java index 1bcb091..a34de1d 100644 --- a/bulletin-board-server/src/test/java/meerkat/bulletinboard/HelloProtoIntegrationTest.java +++ b/bulletin-board-server/src/test/java/meerkat/bulletinboard/HelloProtoIntegrationTest.java @@ -1,6 +1,6 @@ package meerkat.bulletinboard; -import meerkat.protobuf.Voting; +import meerkat.protobuf.BulletinBoardAPI.*; import meerkat.rest.Constants; import meerkat.rest.ProtobufMessageBodyReader; import meerkat.rest.ProtobufMessageBodyWriter; @@ -29,8 +29,8 @@ public class HelloProtoIntegrationTest { client.register(ProtobufMessageBodyWriter.class); WebTarget webTarget = client.target(BASE_URL).path(HELLO_URL); - Voting.BulletinBoardMessage response = webTarget.request(Constants.MEDIATYPE_PROTOBUF) - .get(Voting.BulletinBoardMessage.class); + BulletinBoardMessage response = webTarget.request(Constants.MEDIATYPE_PROTOBUF) + .get(BulletinBoardMessage.class); System.out.println(response.getMsg().getData()); diff --git a/bulletin-board-server/src/test/java/meerkat/bulletinboard/SQLiteServerIntegrationTest.java b/bulletin-board-server/src/test/java/meerkat/bulletinboard/SQLiteServerIntegrationTest.java index 6a6371d..2de886b 100644 --- a/bulletin-board-server/src/test/java/meerkat/bulletinboard/SQLiteServerIntegrationTest.java +++ b/bulletin-board-server/src/test/java/meerkat/bulletinboard/SQLiteServerIntegrationTest.java @@ -2,13 +2,12 @@ package meerkat.bulletinboard; import com.google.protobuf.ByteString; -import meerkat.protobuf.Crypto.Signature; -import meerkat.protobuf.Crypto.SignatureType; -import meerkat.protobuf.Voting.BulletinBoardMessage; -import meerkat.protobuf.Voting.UnsignedBulletinBoardMessage; +import meerkat.protobuf.Crypto.*; +import meerkat.protobuf.BulletinBoardAPI.*; import meerkat.rest.Constants; import meerkat.rest.ProtobufMessageBodyReader; import meerkat.rest.ProtobufMessageBodyWriter; + import org.junit.Before; import org.junit.Test; @@ -21,9 +20,9 @@ import javax.ws.rs.core.Response; public class SQLiteServerIntegrationTest { private static String PROP_GETTY_URL = "gretty.httpBaseURI"; - private static String DEFAULT_BASE_URL = "http://localhost:8081/"; + private static String DEFAULT_BASE_URL = "localhost:8082"; private static String BASE_URL = System.getProperty(PROP_GETTY_URL, DEFAULT_BASE_URL); - private static String SQL_SERVER_URL = "SQLServer"; + private static String SQL_SERVER_URL = "sqlserver/postmessage"; Client client; @@ -57,19 +56,13 @@ public class SQLiteServerIntegrationTest { .build()) .build(); -// SQLiteBulletinBoardServer bbs = new SQLiteBulletinBoardServer(); -// -// -// bbs.init(); -// -// bbs.postMessage(msg); -// response = Response.status(Status.OK).entity(bbs.testPrint()).build(); -// -// bbs.close(); - System.err.println("******** Testing: " + SQL_SERVER_URL); WebTarget webTarget = client.target(BASE_URL).path(SQL_SERVER_URL); response = webTarget.request(Constants.MEDIATYPE_PROTOBUF).post(Entity.entity(msg, Constants.MEDIATYPE_PROTOBUF)); + System.err.println(response); + BoolMsg bool = response.readEntity(BoolMsg.class); + assert bool.getValue(); + } } diff --git a/meerkat-common/src/main/java/Demo.java b/meerkat-common/src/main/java/Demo.java index 3b8e857..be79642 100644 --- a/meerkat-common/src/main/java/Demo.java +++ b/meerkat-common/src/main/java/Demo.java @@ -1,5 +1,5 @@ import com.google.protobuf.ByteString; -import static meerkat.protobuf.Voting.*; +import static meerkat.protobuf.BulletinBoardAPI.*; import java.io.IOException; /** diff --git a/meerkat-common/src/main/java/meerkat/bulletinboard/BulletinBoard.java b/meerkat-common/src/main/java/meerkat/bulletinboard/BulletinBoard.java index eb31c6d..0efd6a7 100644 --- a/meerkat-common/src/main/java/meerkat/bulletinboard/BulletinBoard.java +++ b/meerkat-common/src/main/java/meerkat/bulletinboard/BulletinBoard.java @@ -1,7 +1,7 @@ package meerkat.bulletinboard; import meerkat.comm.*; -import static meerkat.protobuf.Voting.*; +import static meerkat.protobuf.BulletinBoardAPI.*; import java.util.List; diff --git a/meerkat-common/src/main/java/meerkat/bulletinboard/BulletinBoardServer.java b/meerkat-common/src/main/java/meerkat/bulletinboard/BulletinBoardServer.java index f312ed8..d37a674 100644 --- a/meerkat-common/src/main/java/meerkat/bulletinboard/BulletinBoardServer.java +++ b/meerkat-common/src/main/java/meerkat/bulletinboard/BulletinBoardServer.java @@ -1,9 +1,7 @@ package meerkat.bulletinboard; import meerkat.comm.CommunicationException; -import meerkat.protobuf.Voting.BulletinBoardMessage; -import meerkat.protobuf.Voting.BulletinBoardMessageList; -import meerkat.protobuf.Voting.MessageFilterList; +import meerkat.protobuf.BulletinBoardAPI.*; /** * Created by Arbel on 07/11/15. @@ -24,10 +22,10 @@ public interface BulletinBoardServer{ /** * Post a message to bulletin board. * @param msg is the actual (signed) message - * @return TRUE if the message has been authenticated and FALSE otherwise. + * @return TRUE if the message has been authenticated and FALSE otherwise (in ProtoBuf form). * @throws CommunicationException on DB connection error. */ - public boolean postMessage(BulletinBoardMessage msg) throws CommunicationException; + public BoolMsg postMessage(BulletinBoardMessage msg) throws CommunicationException; /** * Read all messages posted matching the given filter. diff --git a/meerkat-common/src/main/java/meerkat/crypto/DigitalSignature.java b/meerkat-common/src/main/java/meerkat/crypto/DigitalSignature.java index 1abad8f..e0a9294 100644 --- a/meerkat-common/src/main/java/meerkat/crypto/DigitalSignature.java +++ b/meerkat-common/src/main/java/meerkat/crypto/DigitalSignature.java @@ -17,7 +17,7 @@ import static meerkat.protobuf.Crypto.*; /** * Created by talm on 25/10/15. * - * Sign and verifyarrays of messages + * Sign and verify arrays of messages */ public interface DigitalSignature { final public static String CERTIFICATE_ENCODING_X509 = "X.509"; diff --git a/meerkat-common/src/main/proto/meerkat/BulletinBoardAPI.proto b/meerkat-common/src/main/proto/meerkat/BulletinBoardAPI.proto new file mode 100644 index 0000000..fa64380 --- /dev/null +++ b/meerkat-common/src/main/proto/meerkat/BulletinBoardAPI.proto @@ -0,0 +1,65 @@ +syntax = "proto3"; + +package meerkat; + +option java_package = "meerkat.protobuf"; + +import 'meerkat/crypto.proto'; + +message BoolMsg { + bool value = 1; +} + + +message MessageID { + // The ID of a message for unique retrieval. + // Note that it is assumed that this ID is a function of the message itself. + bytes ID = 1; +} + +message UnsignedBulletinBoardMessage { + // Optional tags describing message + repeated string tags = 1; + + // The actual content of the message + bytes data = 2; +} + +message BulletinBoardMessage { + + UnsignedBulletinBoardMessage msg = 1; + + // Signature of message (and tags) + meerkat.Signature sig = 2; +} + +message BulletinBoardMessageList { + + repeated BulletinBoardMessage messages = 1; + +} + +enum FilterType { + ID = 0; // Match exact message ID + EXACT_ENTRY = 1; // Match exact entry number in database (chronological) + MAX_ENTRY = 2; // Find all entries in database up to specified entry number (chronological) + SIGNATURE = 3; // Find all entries in database that correspond to specific signature (signer) + TAG = 4; // Find all entries in database that have a specific tag + MAX_MESSAGES = 5; // Return at most some specified number of messages +} + +message MessageFilter { + + FilterType type = 1; + + // Concrete data input to filter + bytes filter = 2; +} + +message MessageFilterList { + + // Combination of filters. + // To be implemented using intersection ("AND") operations. + repeated MessageFilter filters = 1; + +} \ No newline at end of file diff --git a/meerkat-common/src/main/proto/meerkat/voting.proto b/meerkat-common/src/main/proto/meerkat/voting.proto index 34be8fb..beb4e0c 100644 --- a/meerkat-common/src/main/proto/meerkat/voting.proto +++ b/meerkat-common/src/main/proto/meerkat/voting.proto @@ -6,59 +6,6 @@ import 'meerkat/crypto.proto'; option java_package = "meerkat.protobuf"; -message MessageID { - // The ID of a message for unique retrieval. - // Note that it is assumed that this ID is a function of the message itself. - bytes ID = 1; -} - -message UnsignedBulletinBoardMessage { - // Optional tags describing message - repeated string tags = 1; - - // The actual content of the message - bytes data = 2; -} - -message BulletinBoardMessage { - - UnsignedBulletinBoardMessage msg = 1; - - // Signature of message (and tags) - meerkat.Signature sig = 2; -} - -message BulletinBoardMessageList { - - repeated BulletinBoardMessage messages = 1; - -} - -enum FilterType { - ID = 0; // Match exact message ID - EXACT_ENTRY = 1; // Match exact entry number in database (chronological) - MAX_ENTRY = 2; // Find all entries in database up to specified entry number (chronological) - SIGNATURE = 3; // Find all entries in database that correspond to specific signature (signer) - TAG = 4; // Find all entries in database that have a specific tag - MAX_MESSAGES = 5; // Return at most some specified number of messages -} - -message MessageFilter { - - FilterType type = 1; - - // Concrete data input to filter - bytes filter = 2; -} - -message MessageFilterList { - - // Combination of filters. - // To be implemented using intersection ("AND") operations. - repeated MessageFilter filters = 1; - -} - // A ballot question. This is an opaque // data type that is parsed by the UI to display // the question. diff --git a/meerkat-common/src/test/java/meerkat/crypto/concrete/TestECDSASignature.java b/meerkat-common/src/test/java/meerkat/crypto/concrete/TestECDSASignature.java index 4fbb35c..11c6b28 100644 --- a/meerkat-common/src/test/java/meerkat/crypto/concrete/TestECDSASignature.java +++ b/meerkat-common/src/test/java/meerkat/crypto/concrete/TestECDSASignature.java @@ -2,7 +2,7 @@ package meerkat.crypto.concrete; import com.google.protobuf.ByteString; import meerkat.protobuf.Crypto; -import meerkat.protobuf.Voting; +import meerkat.protobuf.Bulletinboardserver.*; import org.junit.Test; import java.io.ByteArrayInputStream; @@ -149,13 +149,13 @@ public class TestECDSASignature { signer.loadSigningCertificate(keyStore); - Voting.UnsignedBulletinBoardMessage.Builder unsignedMsgBuilder = Voting.UnsignedBulletinBoardMessage.newBuilder(); + UnsignedBulletinBoardMessage.Builder unsignedMsgBuilder = UnsignedBulletinBoardMessage.newBuilder(); unsignedMsgBuilder.setData(ByteString.copyFromUtf8(HELLO_WORLD)); unsignedMsgBuilder.addTags("Tag1"); unsignedMsgBuilder.addTags("Tag2"); unsignedMsgBuilder.addTags("Tag3"); - Voting.UnsignedBulletinBoardMessage usMsg = unsignedMsgBuilder.build(); + UnsignedBulletinBoardMessage usMsg = unsignedMsgBuilder.build(); signer.updateContent(usMsg); Crypto.Signature sig = signer.sign(); From a6afb748931d308bd81785ad8499d01fb1c3da23 Mon Sep 17 00:00:00 2001 From: Arbel Deutsch Peled Date: Fri, 20 Nov 2015 21:40:45 +0200 Subject: [PATCH 10/13] Added filters and DB reading functionality. Also added signer IDs and multiple signatures (on same message) to schema. --- bulletin-board-server/build.gradle | 6 +- .../bulletinboard/service/HelloProtoBuf.java | 2 +- .../sqlserver/BulletinBoardSQLServer.java | 93 +++++++-- .../sqlserver/SQLiteBulletinBoardServer.java | 178 +++++++++++++++++- .../webapp/HelloProtoWebApp.java | 2 +- .../SQLiteServerIntegrationTest.java | 121 +++++++++++- .../bulletinboard/BulletinBoardServer.java | 2 +- .../main/proto/meerkat/BulletinBoardAPI.proto | 28 ++- .../crypto/concrete/TestECDSASignature.java | 2 +- 9 files changed, 389 insertions(+), 45 deletions(-) diff --git a/bulletin-board-server/build.gradle b/bulletin-board-server/build.gradle index cfe4233..536673c 100644 --- a/bulletin-board-server/build.gradle +++ b/bulletin-board-server/build.gradle @@ -65,13 +65,17 @@ test { exclude '**/*IntegrationTest*' } +task debugIntegrationTest(type: Test){ + include '**/*IntegrationTest*' + debug = true +} task integrationTest(type: Test) { include '**/*IntegrationTest*' } gretty { - httpPort = 8082 + httpPort = 8081 contextPath = '/' integrationTestTask = 'integrationTest' loggingLevel = 'TRACE' diff --git a/bulletin-board-server/src/main/java/meerkat/bulletinboard/service/HelloProtoBuf.java b/bulletin-board-server/src/main/java/meerkat/bulletinboard/service/HelloProtoBuf.java index a4d8012..baa1d98 100644 --- a/bulletin-board-server/src/main/java/meerkat/bulletinboard/service/HelloProtoBuf.java +++ b/bulletin-board-server/src/main/java/meerkat/bulletinboard/service/HelloProtoBuf.java @@ -23,7 +23,7 @@ public class HelloProtoBuf { Crypto.Signature.Builder sig = Crypto.Signature.newBuilder(); sig.setData(ByteString.copyFromUtf8("deadbeef")); - msg.setSig(sig); + msg.addSig(sig); return msg.build(); } diff --git a/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/BulletinBoardSQLServer.java b/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/BulletinBoardSQLServer.java index b4045fb..9978cf5 100644 --- a/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/BulletinBoardSQLServer.java +++ b/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/BulletinBoardSQLServer.java @@ -14,6 +14,7 @@ import java.sql.Statement; import meerkat.bulletinboard.BulletinBoardServer; import meerkat.comm.CommunicationException; import meerkat.protobuf.BulletinBoardAPI.*; +import meerkat.protobuf.Crypto.Signature; import meerkat.protobuf.Crypto.SignatureVerificationKey; import meerkat.crypto.Digest; import meerkat.crypto.concrete.SHA256Digest; @@ -57,11 +58,16 @@ public abstract class BulletinBoardSQLServer implements BulletinBoardServer{ } /** - * This procedure makes sure that all tags in the given list have an entry in the tags list. - * @param tagIterator + * This procedure makes sure that all tags in the given list have an entry in the tags table. + * @param tags */ protected abstract void insertNewTags(String[] tags) throws SQLException; + /** + * This procedure is used to convert a boolean to a BoolMsg. + * @param b is the boolean to convert. + * @return a ProtoBuf message with boolean payload. + */ private BoolMsg boolToBoolMsg(boolean b){ return BoolMsg.newBuilder() .setValue(b) @@ -76,31 +82,59 @@ public abstract class BulletinBoardSQLServer implements BulletinBoardServer{ } PreparedStatement pstmt; + ResultSet rs; String sql; byte[] msgID; + long entryNum; ProtocolStringList tagList; String[] tags; + List signatureList; + Signature[] signatures; + + // Calculate message ID (depending only on the the unsigned message) + digest.reset(); - digest.update(msg); + digest.update(msg.getMsg()); msgID = digest.digest(); + // Add message to table if needed and store entry number of message. + try { - sql = "INSERT INTO MsgTable (MsgId, Msg, SignerId) VALUES(?,?,?)"; - pstmt = connection.prepareStatement(sql); - pstmt.setBytes(1, msgID); - pstmt.setBytes(2, msg.toByteArray()); - pstmt.setBytes(3, msg.getSig().getSignerId().toByteArray()); - pstmt.executeUpdate(); + sql = "SELECT EntryNum From MsgTable WHERE MsgId = ?"; + pstmt = connection.prepareStatement(sql); + pstmt.setBytes(1, msgID); + rs = pstmt.executeQuery(); + + if (rs.next()){ + + entryNum = rs.getLong(1); + + } else{ + + sql = "INSERT INTO MsgTable (MsgId, Msg) VALUES(?,?)"; + pstmt = connection.prepareStatement(sql); + pstmt.setBytes(1, msgID); + pstmt.setBytes(2, msg.toByteArray()); + pstmt.executeUpdate(); + + rs = pstmt.getGeneratedKeys(); + rs.next(); + entryNum = rs.getLong(1); + + } + pstmt.close(); } catch (SQLException e) { throw new CommunicationException("Error inserting into MsgTable: " + e.getMessage()); } + // Retrieve tags and store new ones in tag table. + try { tagList = msg.getMsg().getTagsList(); @@ -113,12 +147,15 @@ public abstract class BulletinBoardSQLServer implements BulletinBoardServer{ throw new CommunicationException(e.getMessage()); } + // Connect message to tags. + try{ - sql = "INSERT INTO MsgTagTable (TagId, MsgId) SELECT TagTable.TagId, ? AS MsgId FROM TagTable WHERE Tag = ?"; + sql = "INSERT OR IGNORE INTO MsgTagTable (TagId, EntryNum) SELECT TagTable.TagId, ? AS EntryNum FROM TagTable WHERE Tag = ?"; pstmt = connection.prepareStatement(sql); + pstmt.setLong(1, entryNum); + for (String tag : tags){ - pstmt.setBytes(1, msgID); pstmt.setString(2, tag); pstmt.addBatch(); } @@ -129,15 +166,37 @@ public abstract class BulletinBoardSQLServer implements BulletinBoardServer{ } catch (SQLException e) { throw new CommunicationException("Error Linking tags: " + e.getMessage()); } + + // Retrieve signatures. + + signatureList = msg.getSigList(); + signatures = new Signature[signatureList.size()]; + signatures = signatureList.toArray(signatures); + + // Connect message to signatures. + + try{ + sql = "INSERT OR IGNORE INTO SignatureTable (EntryNum, SignerId, Signature) VALUES (?,?,?)"; + pstmt = connection.prepareStatement(sql); + + pstmt.setLong(1, entryNum); + + for (Signature sig : signatures){ + + pstmt.setBytes(2, sig.getSignerId().toByteArray()); + pstmt.setBytes(3, sig.toByteArray()); + pstmt.addBatch(); + } + + pstmt.executeBatch(); + pstmt.close(); + + } catch (SQLException e) { + throw new CommunicationException("Error Linking tags: " + e.getMessage()); + } return boolToBoolMsg(true); } - - @Override - public BulletinBoardMessageList readMessages(MessageFilterList filterList) { - // TODO Auto-generated method stub - return null; - } public String testPrint(){ diff --git a/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/SQLiteBulletinBoardServer.java b/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/SQLiteBulletinBoardServer.java index 6cc016b..8be9a2d 100644 --- a/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/SQLiteBulletinBoardServer.java +++ b/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/SQLiteBulletinBoardServer.java @@ -2,8 +2,10 @@ package meerkat.bulletinboard.sqlserver; import java.sql.DriverManager; import java.sql.PreparedStatement; +import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; +import java.util.List; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; @@ -14,7 +16,10 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; +import com.google.protobuf.InvalidProtocolBufferException; + import meerkat.protobuf.BulletinBoardAPI.*; +import meerkat.protobuf.Crypto.Signature; import meerkat.rest.Constants; import meerkat.bulletinboard.sqlserver.BulletinBoardSQLServer; import meerkat.comm.CommunicationException; @@ -39,10 +44,14 @@ public class SQLiteBulletinBoardServer extends BulletinBoardSQLServer { connection = DriverManager.getConnection("jdbc:sqlite:local-instances/meerkat.db"); Statement statement = connection.createStatement(); statement.setQueryTimeout(TIMEOUT); - - statement.executeUpdate("CREATE TABLE IF NOT EXISTS MsgTable (EntryNum INTEGER PRIMARY KEY, MsgId BLOB UNIQUE, Msg BLOB, SignerId BLOB)"); + + statement.executeUpdate("CREATE TABLE IF NOT EXISTS MsgTable (EntryNum INTEGER PRIMARY KEY, MsgId BLOB UNIQUE, Msg BLOB)"); + statement.executeUpdate("CREATE TABLE IF NOT EXISTS TagTable (TagId INTEGER PRIMARY KEY, Tag varchar(50) UNIQUE)"); - statement.executeUpdate("CREATE TABLE IF NOT EXISTS MsgTagTable (MsgId BLOB, TagId INTEGER, FOREIGN KEY (MsgId) REFERENCES MsgTable(MsgId), FOREIGN KEY (TagId) REFERENCES TagTable(TagId))"); + statement.executeUpdate("CREATE TABLE IF NOT EXISTS MsgTagTable (EntryNum BLOB, TagId INTEGER, FOREIGN KEY (EntryNum) REFERENCES MsgTable(EntryNum), FOREIGN KEY (TagId) REFERENCES TagTable(TagId), UNIQUE (EntryNum, TagID))"); + + statement.executeUpdate("CREATE TABLE IF NOT EXISTS SignatureTable (EntryNum BLOB, SignerId BLOB, Signature BLOB UNIQUE, FOREIGN KEY (EntryNum) REFERENCES MsgTable(EntryNum))"); + statement.executeUpdate("CREATE INDEX IF NOT EXISTS SignerIndex ON SignatureTable(SignerId)"); statement.close(); @@ -107,8 +116,167 @@ public class SQLiteBulletinBoardServer extends BulletinBoardSQLServer { @Consumes(Constants.MEDIATYPE_PROTOBUF) @Produces(Constants.MEDIATYPE_PROTOBUF) @Override - public BulletinBoardMessageList readMessages(MessageFilterList filterList) { - return super.readMessages(filterList); + public BulletinBoardMessageList readMessages(MessageFilterList filterList) throws CommunicationException{ + + PreparedStatement pstmt; + ResultSet messages, signatures; + + long entryNum; + BulletinBoardMessageList.Builder resultListBuilder = BulletinBoardMessageList.newBuilder(); + BulletinBoardMessage.Builder messageBuilder; + + String sql; + String sqlSuffix = ""; + + List filters = filterList.getFilterList(); + int i; + + boolean tagsRequired = false; + boolean signaturesRequired = false; + + boolean isFirstFilter = true; + + // Check if Tag/Signature tables are required for filtering purposes. + + for (MessageFilter filter : filters){ + if (filter.getType() == FilterType.TAG){ + tagsRequired = true; + } else if (filter.getType() == FilterType.SIGNER_ID){ + signaturesRequired = true; + } + } + + sql = "SELECT MsgTable.EntryNum, MsgTable.Msg FROM MsgTable"; + + if (tagsRequired){ + sql += " INNER JOIN MsgTagTable ON MsgTable.EntryNum = MsgTagTable.EntryNum"; + sql += " INNER JOIN TagTable ON TagTable.TagId = MsgTagTable.TagId"; + } + + if (signaturesRequired){ + sql += " INNER JOIN SignatureTable ON SignatureTable.EntryNum = MsgTable.EntryNum"; + } + + // Add conditions. + + if (!filters.isEmpty()){ + sql += " WHERE"; + + for (MessageFilter filter : filters){ + + if (filter.getType().getNumber() != FilterType.MAX_MESSAGES_VALUE){ + if (isFirstFilter){ + isFirstFilter = false; + } else{ + sql += " AND"; + } + } + + switch (filter.getType().getNumber()){ + case FilterType.EXACT_ENTRY_VALUE: + sql += " MsgTable.EntryNum = ?"; + break; + case FilterType.MAX_ENTRY_VALUE: + sql += " MsgTable.EntryNum <= ?"; + break; + case FilterType.MAX_MESSAGES_VALUE: + sqlSuffix += " LIMIT = ?"; + break; + case FilterType.MSG_ID_VALUE: + sql += " MsgTableMsgId = ?"; + break; + case FilterType.SIGNER_ID_VALUE: + sql += " SignatureTable.SignerId = ?"; + break; + case FilterType.TAG_VALUE: + sql += " TagTable.Tag = ?"; + break; + } + } + + sql += sqlSuffix; + } + + // Make query. + + try { + pstmt = connection.prepareStatement(sql); + + // Specify values for filters. + + i = 1; + for (MessageFilter filter : filters){ + + switch (filter.getType().getNumber()){ + + case FilterType.EXACT_ENTRY_VALUE: // Go through. + case FilterType.MAX_ENTRY_VALUE: + pstmt.setLong(i, filter.getEntry()); + i++; + break; + + case FilterType.MSG_ID_VALUE: // Go through. + case FilterType.SIGNER_ID_VALUE: + pstmt.setBytes(i, filter.getId().toByteArray()); + i++; + break; + + case FilterType.TAG_VALUE: + pstmt.setString(i, filter.getTag()); + break; + + // The max-messages condition is applied as a suffix. Therefore, it is treated differently. + case FilterType.MAX_MESSAGES_VALUE: + pstmt.setLong(filters.size(), filter.getMaxMessages()); + break; + + } + } + + // Run query. + + messages = pstmt.executeQuery(); + + // Compile list of messages. + + sql = "SELECT Signature FROM SignatureTable WHERE EntryNum = ?"; + pstmt = connection.prepareStatement(sql); + + while (messages.next()){ + + // Get entry number and retrieve signatures. + + entryNum = messages.getLong(1); + pstmt.setLong(1, entryNum); + signatures = pstmt.executeQuery(); + + // Create message and append signatures. + + messageBuilder = BulletinBoardMessage.newBuilder() + .setEntryNum(entryNum) + .setMsg(UnsignedBulletinBoardMessage.parseFrom(messages.getBytes(2))); + + while (signatures.next()){ + messageBuilder.addSig(Signature.parseFrom(signatures.getBytes(1))); + } + + // Finalize message and add to message list. + + resultListBuilder.addMessage(messageBuilder.build()); + + } + + pstmt.close(); + + } catch (SQLException e){ + throw new CommunicationException("Error reading messages from DB: " + e.getMessage()); + } catch (InvalidProtocolBufferException e) { + throw new CommunicationException("Invalid data from DB: " + e.getMessage()); + } + + //Combine results and return. + + return resultListBuilder.build(); } @GET diff --git a/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/HelloProtoWebApp.java b/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/HelloProtoWebApp.java index ca56c3d..c0791c3 100644 --- a/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/HelloProtoWebApp.java +++ b/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/HelloProtoWebApp.java @@ -38,7 +38,7 @@ public class HelloProtoWebApp { .addTags("Signature") .addTags("Trustee") .setData(ByteString.copyFrom(b1)).build()) - .setSig(Signature.newBuilder() + .addSig(Signature.newBuilder() .setType(SignatureType.DSA) .setData(ByteString.copyFrom(b2)) .setSignerId(ByteString.copyFrom(b3)).build()) diff --git a/bulletin-board-server/src/test/java/meerkat/bulletinboard/SQLiteServerIntegrationTest.java b/bulletin-board-server/src/test/java/meerkat/bulletinboard/SQLiteServerIntegrationTest.java index 2de886b..558d52d 100644 --- a/bulletin-board-server/src/test/java/meerkat/bulletinboard/SQLiteServerIntegrationTest.java +++ b/bulletin-board-server/src/test/java/meerkat/bulletinboard/SQLiteServerIntegrationTest.java @@ -2,6 +2,8 @@ package meerkat.bulletinboard; import com.google.protobuf.ByteString; +import com.google.protobuf.TextFormat; + import meerkat.protobuf.Crypto.*; import meerkat.protobuf.BulletinBoardAPI.*; import meerkat.rest.Constants; @@ -20,17 +22,20 @@ import javax.ws.rs.core.Response; public class SQLiteServerIntegrationTest { private static String PROP_GETTY_URL = "gretty.httpBaseURI"; - private static String DEFAULT_BASE_URL = "localhost:8082"; + private static String DEFAULT_BASE_URL = "localhost:8081"; private static String BASE_URL = System.getProperty(PROP_GETTY_URL, DEFAULT_BASE_URL); - private static String SQL_SERVER_URL = "sqlserver/postmessage"; + private static String SQL_SERVER_POST = "sqlserver/postmessage"; + private static String SQL_SERVER_GET = "sqlserver/readmessages"; Client client; +// Connection connection; @Before public void setup() throws Exception { client = ClientBuilder.newClient(); client.register(ProtobufMessageBodyReader.class); client.register(ProtobufMessageBodyWriter.class); + } @Test @@ -38,31 +43,131 @@ public class SQLiteServerIntegrationTest { byte[] b1 = {(byte) 1, (byte) 2, (byte) 3, (byte) 4}; byte[] b2 = {(byte) 11, (byte) 12, (byte) 13, (byte) 14}; byte[] b3 = {(byte) 21, (byte) 22, (byte) 23, (byte) 24}; + byte[] b4 = {(byte) 4, (byte) 5, (byte) 100, (byte) -50, (byte) 0}; + WebTarget webTarget; Response response; - + BoolMsg bool; + BulletinBoardMessage msg; - + + MessageFilterList filterList; + BulletinBoardMessageList msgList; + +// try{ +// connection = DriverManager.getConnection("jdbc:sqlite:d:/arbel/projects/meerkat-java/bulletin-board-server/local-instances/meerkat.db"); +// } catch (SQLException e) { +// System.err.println(e.getMessage()); +// assert false; +// } + + // Test writing mechanism + + System.err.println("******** Testing: " + SQL_SERVER_POST); + webTarget = client.target(BASE_URL).path(SQL_SERVER_POST); + msg = BulletinBoardMessage.newBuilder() .setMsg(UnsignedBulletinBoardMessage.newBuilder() .addTags("Signature") .addTags("Trustee") .setData(ByteString.copyFrom(b1)) .build()) - .setSig(Signature.newBuilder() + .addSig(Signature.newBuilder() .setType(SignatureType.DSA) .setData(ByteString.copyFrom(b2)) .setSignerId(ByteString.copyFrom(b3)) .build()) + .addSig(Signature.newBuilder() + .setType(SignatureType.ECDSA) + .setData(ByteString.copyFrom(b3)) + .setSignerId(ByteString.copyFrom(b2)) + .build()) .build(); - System.err.println("******** Testing: " + SQL_SERVER_URL); - WebTarget webTarget = client.target(BASE_URL).path(SQL_SERVER_URL); response = webTarget.request(Constants.MEDIATYPE_PROTOBUF).post(Entity.entity(msg, Constants.MEDIATYPE_PROTOBUF)); System.err.println(response); - BoolMsg bool = response.readEntity(BoolMsg.class); + bool = response.readEntity(BoolMsg.class); assert bool.getValue(); + msg = BulletinBoardMessage.newBuilder() + .setMsg(UnsignedBulletinBoardMessage.newBuilder() + .addTags("Vote") + .addTags("Trustee") + .setData(ByteString.copyFrom(b4)) + .build()) + .addSig(Signature.newBuilder() + .setType(SignatureType.ECDSA) + .setData(ByteString.copyFrom(b4)) + .setSignerId(ByteString.copyFrom(b2)) + .build()) + .build(); + + response = webTarget.request(Constants.MEDIATYPE_PROTOBUF).post(Entity.entity(msg, Constants.MEDIATYPE_PROTOBUF)); + System.err.println(response); + bool = response.readEntity(BoolMsg.class); + assert bool.getValue(); + + // Test reading mechanism + + System.err.println("******** Testing: " + SQL_SERVER_GET); + webTarget = client.target(BASE_URL).path(SQL_SERVER_GET); + + filterList = MessageFilterList.newBuilder() + .addFilter( + MessageFilter.newBuilder() + .setType(FilterType.TAG) + .setTag("Vote") + .build() + ) + .build(); + +// String sql = "SELECT MsgTable.EntryNum, MsgTable.Msg FROM MsgTable INNER JOIN SignatureTable ON SignatureTable.EntryNum = MsgTable.EntryNum WHERE SignatureTable.SignerId = ?"; +// PreparedStatement pstmt = connection.prepareStatement(sql); +// int i=1; +// for (MessageFilter filter : filterList.getFilterList()){ +// +// switch (filter.getType().getNumber()){ +// +// case FilterType.EXACT_ENTRY_VALUE: // Go through. +// case FilterType.MAX_ENTRY_VALUE: +// pstmt.setLong(i, filter.getEntry()); +// i++; +// break; +// +// case FilterType.MSG_ID_VALUE: // Go through. +// case FilterType.SIGNER_ID_VALUE: +// pstmt.setBytes(i, filter.getId().toByteArray()); +// i++; +// break; +// +// case FilterType.TAG_VALUE: +// pstmt.setString(i, filter.getTag()); +// break; +// +// // The max-messages condition is applied as a suffix. Therefore, it is treated differently. +// case FilterType.MAX_MESSAGES_VALUE: +// pstmt.setLong(filterList.getFilterList().size(), filter.getMaxMessages()); +// break; +// +// } +// } +// ResultSet rs = pstmt.executeQuery(); +// +// i = 0; +// while (rs.next()){ +// i++; +// assert rs.getBytes(2) +// } +// System.err.println("Local DB size = " + i); +// pstmt.close(); + + response = webTarget.request(Constants.MEDIATYPE_PROTOBUF).post(Entity.entity(filterList, Constants.MEDIATYPE_PROTOBUF)); + System.err.println(response); + msgList = response.readEntity(BulletinBoardMessageList.class); + System.err.println("List size: " + msgList.getMessageCount()); + System.err.println("This is the list:"); + System.err.println(TextFormat.printToString(msgList)); + assert msgList.getMessageCount() == 1; } } diff --git a/meerkat-common/src/main/java/meerkat/bulletinboard/BulletinBoardServer.java b/meerkat-common/src/main/java/meerkat/bulletinboard/BulletinBoardServer.java index d37a674..fe19d6e 100644 --- a/meerkat-common/src/main/java/meerkat/bulletinboard/BulletinBoardServer.java +++ b/meerkat-common/src/main/java/meerkat/bulletinboard/BulletinBoardServer.java @@ -32,7 +32,7 @@ public interface BulletinBoardServer{ * @param filter return only messages that match the filter (empty list means no filtering). * @return */ - BulletinBoardMessageList readMessages(MessageFilterList filterList); + BulletinBoardMessageList readMessages(MessageFilterList filterList) throws CommunicationException; /** * This method closes the connection to the DB. diff --git a/meerkat-common/src/main/proto/meerkat/BulletinBoardAPI.proto b/meerkat-common/src/main/proto/meerkat/BulletinBoardAPI.proto index fa64380..986fcb8 100644 --- a/meerkat-common/src/main/proto/meerkat/BulletinBoardAPI.proto +++ b/meerkat-common/src/main/proto/meerkat/BulletinBoardAPI.proto @@ -26,24 +26,28 @@ message UnsignedBulletinBoardMessage { } message BulletinBoardMessage { + + // Serial entry number of message in database + int64 entryNum = 1; + + // Unsigned raw data of message + UnsignedBulletinBoardMessage msg = 2; - UnsignedBulletinBoardMessage msg = 1; - - // Signature of message (and tags) - meerkat.Signature sig = 2; + // Signature of message (and tags), excluding the entry number. + repeated meerkat.Signature sig = 3; } message BulletinBoardMessageList { - repeated BulletinBoardMessage messages = 1; + repeated BulletinBoardMessage message = 1; } enum FilterType { - ID = 0; // Match exact message ID + MSG_ID = 0; // Match exact message ID EXACT_ENTRY = 1; // Match exact entry number in database (chronological) MAX_ENTRY = 2; // Find all entries in database up to specified entry number (chronological) - SIGNATURE = 3; // Find all entries in database that correspond to specific signature (signer) + SIGNER_ID = 3; // Find all entries in database that correspond to specific signature (signer) TAG = 4; // Find all entries in database that have a specific tag MAX_MESSAGES = 5; // Return at most some specified number of messages } @@ -52,14 +56,18 @@ message MessageFilter { FilterType type = 1; - // Concrete data input to filter - bytes filter = 2; + oneof filter{ + bytes id = 2; + int64 entry = 3; + string tag = 4; + int64 maxMessages = 5; + } } message MessageFilterList { // Combination of filters. // To be implemented using intersection ("AND") operations. - repeated MessageFilter filters = 1; + repeated MessageFilter filter = 1; } \ No newline at end of file diff --git a/meerkat-common/src/test/java/meerkat/crypto/concrete/TestECDSASignature.java b/meerkat-common/src/test/java/meerkat/crypto/concrete/TestECDSASignature.java index 11c6b28..8d9a880 100644 --- a/meerkat-common/src/test/java/meerkat/crypto/concrete/TestECDSASignature.java +++ b/meerkat-common/src/test/java/meerkat/crypto/concrete/TestECDSASignature.java @@ -2,7 +2,7 @@ package meerkat.crypto.concrete; import com.google.protobuf.ByteString; import meerkat.protobuf.Crypto; -import meerkat.protobuf.Bulletinboardserver.*; +import meerkat.protobuf.BulletinBoardAPI.*; import org.junit.Test; import java.io.ByteArrayInputStream; From c68eba84d2f27c30131c7c4665750ee860848b9b Mon Sep 17 00:00:00 2001 From: Arbel Deutsch Peled Date: Fri, 20 Nov 2015 21:59:45 +0200 Subject: [PATCH 11/13] Refactored into WebApp and Server --- .../sqlserver/SQLiteBulletinBoardServer.java | 28 +-------- .../webapp/BulletinBoardWebApp.java | 63 +++++++++++++++++++ 2 files changed, 64 insertions(+), 27 deletions(-) create mode 100644 bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/BulletinBoardWebApp.java diff --git a/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/SQLiteBulletinBoardServer.java b/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/SQLiteBulletinBoardServer.java index 8be9a2d..abc87a2 100644 --- a/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/SQLiteBulletinBoardServer.java +++ b/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/SQLiteBulletinBoardServer.java @@ -7,25 +7,13 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.List; -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - import com.google.protobuf.InvalidProtocolBufferException; import meerkat.protobuf.BulletinBoardAPI.*; import meerkat.protobuf.Crypto.Signature; -import meerkat.rest.Constants; import meerkat.bulletinboard.sqlserver.BulletinBoardSQLServer; import meerkat.comm.CommunicationException; - -@Path("/sqlserver") public class SQLiteBulletinBoardServer extends BulletinBoardSQLServer { protected static final int TIMEOUT = 20; @@ -35,7 +23,7 @@ public class SQLiteBulletinBoardServer extends BulletinBoardSQLServer { * 1. The database connection * 2. The database tables (if they do not yet exist). */ - @PostConstruct + @Override public void init() throws CommunicationException { @@ -65,7 +53,6 @@ public class SQLiteBulletinBoardServer extends BulletinBoardSQLServer { } - @PreDestroy public void close() throws CommunicationException{ try{ @@ -78,7 +65,6 @@ public class SQLiteBulletinBoardServer extends BulletinBoardSQLServer { } - @Override protected void insertNewTags(String[] tags) throws SQLException { @@ -104,17 +90,11 @@ public class SQLiteBulletinBoardServer extends BulletinBoardSQLServer { } - @Path("postmessage") - @POST @Override public BoolMsg postMessage(BulletinBoardMessage msg) throws CommunicationException { return super.postMessage(msg); } - @Path("readmessages") - @POST - @Consumes(Constants.MEDIATYPE_PROTOBUF) - @Produces(Constants.MEDIATYPE_PROTOBUF) @Override public BulletinBoardMessageList readMessages(MessageFilterList filterList) throws CommunicationException{ @@ -278,11 +258,5 @@ public class SQLiteBulletinBoardServer extends BulletinBoardSQLServer { return resultListBuilder.build(); } - - @GET - @Produces(MediaType.TEXT_PLAIN) - public String test() { - return "Hello World"; - } } diff --git a/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/BulletinBoardWebApp.java b/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/BulletinBoardWebApp.java new file mode 100644 index 0000000..ed162e1 --- /dev/null +++ b/bulletin-board-server/src/main/java/meerkat/bulletinboard/webapp/BulletinBoardWebApp.java @@ -0,0 +1,63 @@ +package meerkat.bulletinboard.webapp; + +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import meerkat.bulletinboard.BulletinBoardServer; +import meerkat.bulletinboard.sqlserver.SQLiteBulletinBoardServer; +import meerkat.comm.CommunicationException; +import meerkat.protobuf.BulletinBoardAPI.BoolMsg; +import meerkat.protobuf.BulletinBoardAPI.BulletinBoardMessage; +import meerkat.protobuf.BulletinBoardAPI.BulletinBoardMessageList; +import meerkat.protobuf.BulletinBoardAPI.MessageFilterList; +import meerkat.rest.Constants; + +@Path("/sqlserver") +public class BulletinBoardWebApp implements BulletinBoardServer{ + + BulletinBoardServer bulletinBoard; + + @PostConstruct + @Override + public void init() throws CommunicationException { + bulletinBoard = new SQLiteBulletinBoardServer(); + bulletinBoard.init(); + } + + @Path("postmessage") + @POST + @Consumes(Constants.MEDIATYPE_PROTOBUF) + @Produces(Constants.MEDIATYPE_PROTOBUF) + @Override + public BoolMsg postMessage(BulletinBoardMessage msg) throws CommunicationException { + return bulletinBoard.postMessage(msg); + } + + @Path("readmessages") + @POST + @Consumes(Constants.MEDIATYPE_PROTOBUF) + @Produces(Constants.MEDIATYPE_PROTOBUF) + @Override + public BulletinBoardMessageList readMessages(MessageFilterList filterList) throws CommunicationException { + return bulletinBoard.readMessages(filterList); + } + + @Override + @PreDestroy + public void close() throws CommunicationException { + bulletinBoard.close(); + } + + @GET + @Produces(MediaType.TEXT_PLAIN) + public String test() { + return "This BulletinBoard is up and running!\n Please consult the API documents to perform queries."; + } + +} From d3c8e150bd98c1c7d1661397c87635ceca44e00a Mon Sep 17 00:00:00 2001 From: Tal Moran Date: Sun, 22 Nov 2015 14:05:28 +0200 Subject: [PATCH 12/13] Added more signature examples --- .../resources/certs/signed-messages/random1.bin | Bin 0 -> 3801 bytes .../signed-messages/random1.bin.user1.sha256sig | Bin 0 -> 70 bytes .../signed-messages/random1.bin.user2.sha256sig | Bin 0 -> 71 bytes .../resources/certs/signed-messages/random2.bin | Bin 0 -> 2931 bytes .../signed-messages/random2.bin.user1.sha256sig | Bin 0 -> 71 bytes .../signed-messages/random2.bin.user2.sha256sig | Bin 0 -> 71 bytes .../resources/certs/signed-messages/random3.bin | Bin 0 -> 2384 bytes .../signed-messages/random3.bin.user1.sha256sig | Bin 0 -> 72 bytes .../signed-messages/random3.bin.user2.sha256sig | 1 + 9 files changed, 1 insertion(+) create mode 100644 meerkat-common/src/test/resources/certs/signed-messages/random1.bin create mode 100644 meerkat-common/src/test/resources/certs/signed-messages/random1.bin.user1.sha256sig create mode 100644 meerkat-common/src/test/resources/certs/signed-messages/random1.bin.user2.sha256sig create mode 100644 meerkat-common/src/test/resources/certs/signed-messages/random2.bin create mode 100644 meerkat-common/src/test/resources/certs/signed-messages/random2.bin.user1.sha256sig create mode 100644 meerkat-common/src/test/resources/certs/signed-messages/random2.bin.user2.sha256sig create mode 100644 meerkat-common/src/test/resources/certs/signed-messages/random3.bin create mode 100644 meerkat-common/src/test/resources/certs/signed-messages/random3.bin.user1.sha256sig create mode 100644 meerkat-common/src/test/resources/certs/signed-messages/random3.bin.user2.sha256sig diff --git a/meerkat-common/src/test/resources/certs/signed-messages/random1.bin b/meerkat-common/src/test/resources/certs/signed-messages/random1.bin new file mode 100644 index 0000000000000000000000000000000000000000..e4e56dff3e1fa3e657025415266fcdeebc527f59 GIT binary patch literal 3801 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 Pbs+3{=I)8{V+)iDYpsr< literal 0 HcmV?d00001 diff --git a/meerkat-common/src/test/resources/certs/signed-messages/random1.bin.user1.sha256sig b/meerkat-common/src/test/resources/certs/signed-messages/random1.bin.user1.sha256sig new file mode 100644 index 0000000000000000000000000000000000000000..33ba6a8b86c6b51f4f8fdd55796af1c7e5c1804d GIT binary patch literal 70 zcmV-M0J;A#L;@fO7Ji3rZdY!81*$gi)C04pBZsV{y4Aazd;+Db*` cY57ZH-t7%%&HM1b5P+gRq|KIpbh<+)_$IL+-~a#s literal 0 HcmV?d00001 diff --git a/meerkat-common/src/test/resources/certs/signed-messages/random1.bin.user2.sha256sig b/meerkat-common/src/test/resources/certs/signed-messages/random1.bin.user2.sha256sig new file mode 100644 index 0000000000000000000000000000000000000000..ca8ebf7f86a79d6dd16828dd9b8523b54eb908eb GIT binary patch literal 71 zcmV-N0J#4!MFJoL=9I+%f73F9FG=;$LP@&-sZDOKX7otwQCpYm_Jw5vApn+m@CWiM dy~{5ovdvDh*7WHR@x0Lt_k~krss{$PALW@~BB1~P literal 0 HcmV?d00001 diff --git a/meerkat-common/src/test/resources/certs/signed-messages/random2.bin b/meerkat-common/src/test/resources/certs/signed-messages/random2.bin new file mode 100644 index 0000000000000000000000000000000000000000..91aae8210b47a2b4518cd86ba0ec8609a199ede0 GIT binary patch literal 2931 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 literal 0 HcmV?d00001 diff --git a/meerkat-common/src/test/resources/certs/signed-messages/random2.bin.user1.sha256sig b/meerkat-common/src/test/resources/certs/signed-messages/random2.bin.user1.sha256sig new file mode 100644 index 0000000000000000000000000000000000000000..e1eac6e23685e6f4428160631c42f21f75f01cf4 GIT binary patch literal 71 zcmV-N0J#4!MFJpHRoWlM(iMmb{^5v%jm@+^Oaarz?sZ3>*iTQB7*<` literal 0 HcmV?d00001 diff --git a/meerkat-common/src/test/resources/certs/signed-messages/random2.bin.user2.sha256sig b/meerkat-common/src/test/resources/certs/signed-messages/random2.bin.user2.sha256sig new file mode 100644 index 0000000000000000000000000000000000000000..973b3b02ef08b4d5149f07e43962df4a258963a3 GIT binary patch literal 71 zcmV-N0J#4!MFJrJg50Ze+S6h#9E`W9bSF5LaVB>1mflxg;>a}@LiHbt0w6dMZ???4 d2IBTk+Kr%Liti|0N0jq~ksMy!X{U+a5PE!#A)x>O literal 0 HcmV?d00001 diff --git a/meerkat-common/src/test/resources/certs/signed-messages/random3.bin b/meerkat-common/src/test/resources/certs/signed-messages/random3.bin new file mode 100644 index 0000000000000000000000000000000000000000..a0afb9522bb18522818c8189ee58c4e2ff4b4036 GIT binary patch literal 2384 zcmV-W39t5E>z)d_ONDld+n!{^mLZ+JpAx3XBB#eH;j1g??F)V7R`6%7h<4Md1P|=D zs%Hq}kk)KT?)6@};aJl3L8Z{m8EgOd3MfvM29`LN8R`*ftD9tt*WD3!K<_sN{?kHN zv8_#G!*f|KUw7;k-m!j4<#bFWu~zMU?yFw(humMoa#<01z>P+Fg>BoE)iCGfimnt* z`YW`(JJUR~)-Oj7(y4zp59TC@U+8%V(2V|6Svh>g5aQS;KLT|{!)XP=#sMo{U0E1z zm^*IQOMn*T_17dSGq}@7aL!I=|5p9vhzZv@d97+5{`qK%2jOu2=Z$C^bIQB5L=ab5 zto)ybf|xpDGSQGRb%h|Ha9PDW-~5YjU^I*I-^lND0FW08N@E)8!3bq@nb)Zx|IuDv zl~RNhJLiu%AOs{becbQTexRpo#)%F`{!krKByJfzi2GG25V}>L>xDtDuo3xScPlo$ zM~_VT4Ke8c=f#KCaW7`j?rB)U!Slju55eAw3yGdPxVE2tdFSr-?*&q$m&>j67&b}b z1zq`aUotYX*#{VjG_b?t_Z{cAes`Fu-taR-D=u|$oCef`@!*buryqjIfU1u8cg_}t zIwhDo9@1~sp{;f=M~wyV!Zje>kQ~KHFG1Z=aM_SW>T#rB(jk47At(5B;r32ksXuDM0^Ap2XgMFz1f;9=93I$7=S05mQlucwYF|ZQ(x&fJ~Q1ZLS$Juz7yz8#EnS- z#D(loRP}SGF_rbvdTQsV4&^HntJ`tP%{w#kYL_v;G$;VBe>3n(P&w9F;XSNUt`wYG zwic;&e0KZ^MC_loV)jKtHqQ?}@d5}D#Y=MVeF$D6D8{(?NW&|y?YAtLO%EhEzLVz~ z2*WMRljueGu=xaL48`-yJ*@(d=*u#mcWxZ%wx=`^H~vR&F>CAk{@B^BXU9k@Vyiko z{x1^!GACW_LNFK}HTk3{=`+D&nf zdr|AOaGGCWc<&-fjN|XZT;&tJiFD7#ux;cX+Lr?xL-{tXxg3N1e91^J_w~3@#RMx{ zPn`uPV`gje^pIo)5!aZAshn{BNL4pOdlg7WA`QM&1&`GDp%jXIpb1M)>=7&mTdBWz zZ^Ie`8szT_UpRby|F(HZ&*!07E;A)H*5FPQZ)f+-(=D=BjUDJ-A7uaKtdF>VfCJd%VHthIo)m>o7-zuA%!9;+gzN;pK;D_7zF)-=SSVa}8^ccq)2 zeWE9b(!ScztFrP)XB9xscsTLUz zDg7|E+a&J&G5mak!x_5muvET#`_H&e-EQcAE<`a~##dBPkZtjS&!JXL+_!ImRO?OZ z$Nha0sTwC##i28o*znkn8t}tWlE;Pse3Z)7_|ag#NDapxm|nXbN;%e0pPF=<>1EfH zl7jY}K(jI2|N3y4E>O)xHOMKxzcoPpv39DOXCznd_QvkSM%5ebiKzzPOa&g1q{L{} zYd1O`sB5t?>8W;K)kt3RaqoM+GmVn<^-_$=LS^uEzDT}0$GiE~s^LG`CnyqJ?-Dac6QU{aSBQh7% zX=C!R?n&$6Fve0arve>??uR?*uNJ_;2;$)OlJw@CblMI$%@DXpQfKD+e2 zoQD_|31AK&q}L7eGIB*^zUq*@(5xNiO2?TOAZmy0i@^6kwyiKMoVnaAP+ta7ZBgC) zHYIWU*Yk|<1eLhHI8Np*)YiGGv%H z7NQiL!FVsqrws~jz>-$0YVprV>Mxg%0Tw>O>ANjqzHbwjqqc4h7uBAOcbuqZ6T*Sp z$VXqfV5~_XuE|`bzZ#(%4t{iTzlzHxnSw20NqZ>kG$x?RN3Kp@V5>YiTu25%?lNx* zK5o+?oR$>PN@NLi{cpvecxF1sUB0^ED_DQ>O0chmFx3k`jPdeWqbG7iUzMzAhB8vt z$}6|O3Y=@Avqz(SaM(h0Kv zll~VLK29l1HBVAefe5PzW2mi&WHI0;-*z!mq2d8&gm_Lyn&{3k8_Rpt8YugpLDL#E zW^vzx+PTABRS?7=uZp$1olxq+~34v6~B*7A{<0)>AhkF%_6y1nL4y^qO^7m(ahfRK@O3|YXWe-{4eKi z*t?zT6#z$*nVW;glT=ZIaIN05oPRKS{nJ73Rm!*nak3V+^_j%>UCF$|;b-fftt9G=%PN92l*U#$^`bME*Jud>#cF&VoC}6^gZWhU8yA&boCgmQb^zKh zYbI&UD3ffZ)#LwzfK06yqfhXKlFaifWv%Oo5iwNxoSq&$UWi~WH8DG z1!smABuRSZrAnXPKDM$Q;V^(IFliv3%g?@oy}uwUH2bNbJ*=0zSV|2K){;NdRY zDAo4>qQxYUq_MMN+vfQj^w27aQ8`8lz&xv==_J)Vriu|Nkf{3eH(fvHWga+$nIJL? z)0ny?p=k5;eeYN^mO1k9>CAs+uvx=u4)y&jG;Ki~`dn%^GTf4k!J7zjLA%iy{ox8g CxxRn^ literal 0 HcmV?d00001 diff --git a/meerkat-common/src/test/resources/certs/signed-messages/random3.bin.user1.sha256sig b/meerkat-common/src/test/resources/certs/signed-messages/random3.bin.user1.sha256sig new file mode 100644 index 0000000000000000000000000000000000000000..7c87d33e14f7ffc19866934f2bb3401792f8ab1e GIT binary patch literal 72 zcmXqTV^U=3J=bNu*>GaTzdI%|^4l~*HZND5WG~^};&^gr=7Ov%Uw}#uDkWJs>Q*l; c@BFedorU{j_aO!MdAd#EoRvO`f+nk?06$3`SpWb4 literal 0 HcmV?d00001 diff --git a/meerkat-common/src/test/resources/certs/signed-messages/random3.bin.user2.sha256sig b/meerkat-common/src/test/resources/certs/signed-messages/random3.bin.user2.sha256sig new file mode 100644 index 0000000..d6d3656 --- /dev/null +++ b/meerkat-common/src/test/resources/certs/signed-messages/random3.bin.user2.sha256sig @@ -0,0 +1 @@ +0D r=¥|n“Ò2ɪ‰!S»®[gCŸ$ä°Ž/ Ê”(Âò½ ^esüHLŸ½o,oV®”§ce²p0(èXÆ]&@ \ No newline at end of file From 8200f08da0cf24de21bb918cb51f70a494a5cf1a Mon Sep 17 00:00:00 2001 From: Tal Moran Date: Sun, 22 Nov 2015 15:31:51 +0200 Subject: [PATCH 13/13] Add configuration for test dependencies between subprojects --- build.gradle-template | 15 +++++++++++++++ bulletin-board-server/build.gradle | 3 +++ meerkat-common/build.gradle | 17 +++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/build.gradle-template b/build.gradle-template index 14cb9dd..60ec7c9 100644 --- a/build.gradle-template +++ b/build.gradle-template @@ -57,6 +57,21 @@ dependencies { /*==== You probably don't have to edit below this line =======*/ +// Setup test configuration that can appear as a dependency in +// other subprojects +configurations { + testOutput.extendsFrom (testCompile) +} + +task testJar(type: Jar, dependsOn: testClasses) { + classifier = 'tests' + from sourceSets.test.output +} + +artifacts { + testOutput testJar +} + // The run task added by the application plugin // is also of type JavaExec. tasks.withType(JavaExec) { diff --git a/bulletin-board-server/build.gradle b/bulletin-board-server/build.gradle index 536673c..2bf9d56 100644 --- a/bulletin-board-server/build.gradle +++ b/bulletin-board-server/build.gradle @@ -55,6 +55,9 @@ dependencies { // Google protobufs compile 'com.google.protobuf:protobuf-java:3.+' + // Depend on test resources from meerkat-common + testCompile project(path: ':meerkat-common', configuration: 'testOutput') + testCompile 'junit:junit:4.+' runtime 'org.codehaus.groovy:groovy:2.4.+' diff --git a/meerkat-common/build.gradle b/meerkat-common/build.gradle index 236bd82..d464a31 100644 --- a/meerkat-common/build.gradle +++ b/meerkat-common/build.gradle @@ -58,6 +58,23 @@ dependencies { /*==== You probably don't have to edit below this line =======*/ +// Setup test configuration that can appear as a dependency in +// other subprojects +configurations { + testOutput.extendsFrom (testCompile) +} + +task testJar(type: Jar, dependsOn: testClasses) { + classifier = 'tests' + from sourceSets.test.output +} + +artifacts { + testOutput testJar +} + + + // The run task added by the application plugin // is also of type JavaExec. tasks.withType(JavaExec) {