From 03f1c3d4836bc0da022d0d8d01eac8a2fff1ce93 Mon Sep 17 00:00:00 2001 From: Arbel Deutsch Peled Date: Sun, 22 Nov 2015 12:22:21 +0200 Subject: [PATCH] Slight change to Message API --- .../java/meerkat/bulletinboard/service/HelloProtoBuf.java | 2 +- .../bulletinboard/sqlserver/BulletinBoardSQLServer.java | 2 +- .../meerkat/bulletinboard/webapp/HelloProtoWebApp.java | 4 ++-- .../meerkat/bulletinboard/HelloProtoIntegrationTest.java | 6 +++--- .../bulletinboard/SQLiteServerIntegrationTest.java | 8 ++++---- meerkat-common/src/main/java/Demo.java | 2 +- .../src/main/java/meerkat/crypto/DigitalSignature.java | 1 + .../src/main/proto/meerkat/BulletinBoardAPI.proto | 2 +- .../meerkat/crypto/concrete/TestECDSASignature.java | 6 +++--- 9 files changed, 17 insertions(+), 16 deletions(-) rename meerkat-common/src/test/{java => }/meerkat/crypto/concrete/TestECDSASignature.java (97%) 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 baa1d98..772e7dd 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 @@ -18,7 +18,7 @@ public class HelloProtoBuf { UnsignedBulletinBoardMessage.Builder unsigned = UnsignedBulletinBoardMessage.newBuilder(); unsigned.setData(ByteString.copyFromUtf8("Hello World!")); List tags = Arrays.asList("Greetings", "FirstPrograms"); - unsigned.addAllTags(tags); + unsigned.addAllTag(tags); msg.setMsg(unsigned); Crypto.Signature.Builder sig = Crypto.Signature.newBuilder(); 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 9978cf5..e121da2 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 @@ -137,7 +137,7 @@ public abstract class BulletinBoardSQLServer implements BulletinBoardServer{ try { - tagList = msg.getMsg().getTagsList(); + tagList = msg.getMsg().getTagList(); tags = new String[tagList.size()]; tags = tagList.toArray(tags); 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 c0791c3..bf748c5 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 @@ -35,8 +35,8 @@ public class HelloProtoWebApp { } else { msg = BulletinBoardMessage.newBuilder() .setMsg(UnsignedBulletinBoardMessage.newBuilder() - .addTags("Signature") - .addTags("Trustee") + .addTag("Signature") + .addTag("Trustee") .setData(ByteString.copyFrom(b1)).build()) .addSig(Signature.newBuilder() .setType(SignatureType.DSA) 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 a34de1d..c7b16df 100644 --- a/bulletin-board-server/src/test/java/meerkat/bulletinboard/HelloProtoIntegrationTest.java +++ b/bulletin-board-server/src/test/java/meerkat/bulletinboard/HelloProtoIntegrationTest.java @@ -35,8 +35,8 @@ public class HelloProtoIntegrationTest { System.out.println(response.getMsg().getData()); assertThat(response.getMsg().getData().toStringUtf8(), is("Hello World!")); - assertThat(response.getMsg().getTagsCount(), is(2)); - assertThat(response.getMsg().getTags(0), is("Greetings")); - assertThat(response.getMsg().getTags(1), is("FirstPrograms")); + assertThat(response.getMsg().getTagCount(), is(2)); + assertThat(response.getMsg().getTag(0), is("Greetings")); + assertThat(response.getMsg().getTag(1), is("FirstPrograms")); } } 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 558d52d..e090529 100644 --- a/bulletin-board-server/src/test/java/meerkat/bulletinboard/SQLiteServerIntegrationTest.java +++ b/bulletin-board-server/src/test/java/meerkat/bulletinboard/SQLiteServerIntegrationTest.java @@ -68,8 +68,8 @@ public class SQLiteServerIntegrationTest { msg = BulletinBoardMessage.newBuilder() .setMsg(UnsignedBulletinBoardMessage.newBuilder() - .addTags("Signature") - .addTags("Trustee") + .addTag("Signature") + .addTag("Trustee") .setData(ByteString.copyFrom(b1)) .build()) .addSig(Signature.newBuilder() @@ -91,8 +91,8 @@ public class SQLiteServerIntegrationTest { msg = BulletinBoardMessage.newBuilder() .setMsg(UnsignedBulletinBoardMessage.newBuilder() - .addTags("Vote") - .addTags("Trustee") + .addTag("Vote") + .addTag("Trustee") .setData(ByteString.copyFrom(b4)) .build()) .addSig(Signature.newBuilder() diff --git a/meerkat-common/src/main/java/Demo.java b/meerkat-common/src/main/java/Demo.java index be79642..130adcc 100644 --- a/meerkat-common/src/main/java/Demo.java +++ b/meerkat-common/src/main/java/Demo.java @@ -12,7 +12,7 @@ public class Demo { BulletinBoardMessage msg; UnsignedBulletinBoardMessage msgContents = UnsignedBulletinBoardMessage.newBuilder() - .addTags("test") + .addTag("test") .setData(ByteString.copyFromUtf8("some data")) .build(); diff --git a/meerkat-common/src/main/java/meerkat/crypto/DigitalSignature.java b/meerkat-common/src/main/java/meerkat/crypto/DigitalSignature.java index e0a9294..f13a886 100644 --- a/meerkat-common/src/main/java/meerkat/crypto/DigitalSignature.java +++ b/meerkat-common/src/main/java/meerkat/crypto/DigitalSignature.java @@ -52,6 +52,7 @@ public interface DigitalSignature { /** * Sign the content that was added. + * Reset the DigitalSignature and make it available to sign a new message using the same key. * @return * @throws SignatureException */ diff --git a/meerkat-common/src/main/proto/meerkat/BulletinBoardAPI.proto b/meerkat-common/src/main/proto/meerkat/BulletinBoardAPI.proto index 986fcb8..28fc948 100644 --- a/meerkat-common/src/main/proto/meerkat/BulletinBoardAPI.proto +++ b/meerkat-common/src/main/proto/meerkat/BulletinBoardAPI.proto @@ -19,7 +19,7 @@ message MessageID { message UnsignedBulletinBoardMessage { // Optional tags describing message - repeated string tags = 1; + repeated string tag = 1; // The actual content of the message bytes data = 2; diff --git a/meerkat-common/src/test/java/meerkat/crypto/concrete/TestECDSASignature.java b/meerkat-common/src/test/meerkat/crypto/concrete/TestECDSASignature.java similarity index 97% rename from meerkat-common/src/test/java/meerkat/crypto/concrete/TestECDSASignature.java rename to meerkat-common/src/test/meerkat/crypto/concrete/TestECDSASignature.java index 8d9a880..4230e6e 100644 --- a/meerkat-common/src/test/java/meerkat/crypto/concrete/TestECDSASignature.java +++ b/meerkat-common/src/test/meerkat/crypto/concrete/TestECDSASignature.java @@ -151,9 +151,9 @@ public class TestECDSASignature { UnsignedBulletinBoardMessage.Builder unsignedMsgBuilder = UnsignedBulletinBoardMessage.newBuilder(); unsignedMsgBuilder.setData(ByteString.copyFromUtf8(HELLO_WORLD)); - unsignedMsgBuilder.addTags("Tag1"); - unsignedMsgBuilder.addTags("Tag2"); - unsignedMsgBuilder.addTags("Tag3"); + unsignedMsgBuilder.addTag("Tag1"); + unsignedMsgBuilder.addTag("Tag2"); + unsignedMsgBuilder.addTag("Tag3"); UnsignedBulletinBoardMessage usMsg = unsignedMsgBuilder.build();