Slight change to Message API

Bulletin_Board_Server_phase_1
Arbel Deutsch Peled 2015-11-22 12:22:21 +02:00
parent c68eba84d2
commit 03f1c3d483
9 changed files with 17 additions and 16 deletions

View File

@ -18,7 +18,7 @@ public class HelloProtoBuf {
UnsignedBulletinBoardMessage.Builder unsigned = UnsignedBulletinBoardMessage.newBuilder(); UnsignedBulletinBoardMessage.Builder unsigned = UnsignedBulletinBoardMessage.newBuilder();
unsigned.setData(ByteString.copyFromUtf8("Hello World!")); unsigned.setData(ByteString.copyFromUtf8("Hello World!"));
List<String> tags = Arrays.asList("Greetings", "FirstPrograms"); List<String> tags = Arrays.asList("Greetings", "FirstPrograms");
unsigned.addAllTags(tags); unsigned.addAllTag(tags);
msg.setMsg(unsigned); msg.setMsg(unsigned);
Crypto.Signature.Builder sig = Crypto.Signature.newBuilder(); Crypto.Signature.Builder sig = Crypto.Signature.newBuilder();

View File

@ -137,7 +137,7 @@ public abstract class BulletinBoardSQLServer implements BulletinBoardServer{
try { try {
tagList = msg.getMsg().getTagsList(); tagList = msg.getMsg().getTagList();
tags = new String[tagList.size()]; tags = new String[tagList.size()];
tags = tagList.toArray(tags); tags = tagList.toArray(tags);

View File

@ -35,8 +35,8 @@ public class HelloProtoWebApp {
} else { } else {
msg = BulletinBoardMessage.newBuilder() msg = BulletinBoardMessage.newBuilder()
.setMsg(UnsignedBulletinBoardMessage.newBuilder() .setMsg(UnsignedBulletinBoardMessage.newBuilder()
.addTags("Signature") .addTag("Signature")
.addTags("Trustee") .addTag("Trustee")
.setData(ByteString.copyFrom(b1)).build()) .setData(ByteString.copyFrom(b1)).build())
.addSig(Signature.newBuilder() .addSig(Signature.newBuilder()
.setType(SignatureType.DSA) .setType(SignatureType.DSA)

View File

@ -35,8 +35,8 @@ public class HelloProtoIntegrationTest {
System.out.println(response.getMsg().getData()); System.out.println(response.getMsg().getData());
assertThat(response.getMsg().getData().toStringUtf8(), is("Hello World!")); assertThat(response.getMsg().getData().toStringUtf8(), is("Hello World!"));
assertThat(response.getMsg().getTagsCount(), is(2)); assertThat(response.getMsg().getTagCount(), is(2));
assertThat(response.getMsg().getTags(0), is("Greetings")); assertThat(response.getMsg().getTag(0), is("Greetings"));
assertThat(response.getMsg().getTags(1), is("FirstPrograms")); assertThat(response.getMsg().getTag(1), is("FirstPrograms"));
} }
} }

View File

@ -68,8 +68,8 @@ public class SQLiteServerIntegrationTest {
msg = BulletinBoardMessage.newBuilder() msg = BulletinBoardMessage.newBuilder()
.setMsg(UnsignedBulletinBoardMessage.newBuilder() .setMsg(UnsignedBulletinBoardMessage.newBuilder()
.addTags("Signature") .addTag("Signature")
.addTags("Trustee") .addTag("Trustee")
.setData(ByteString.copyFrom(b1)) .setData(ByteString.copyFrom(b1))
.build()) .build())
.addSig(Signature.newBuilder() .addSig(Signature.newBuilder()
@ -91,8 +91,8 @@ public class SQLiteServerIntegrationTest {
msg = BulletinBoardMessage.newBuilder() msg = BulletinBoardMessage.newBuilder()
.setMsg(UnsignedBulletinBoardMessage.newBuilder() .setMsg(UnsignedBulletinBoardMessage.newBuilder()
.addTags("Vote") .addTag("Vote")
.addTags("Trustee") .addTag("Trustee")
.setData(ByteString.copyFrom(b4)) .setData(ByteString.copyFrom(b4))
.build()) .build())
.addSig(Signature.newBuilder() .addSig(Signature.newBuilder()

View File

@ -12,7 +12,7 @@ public class Demo {
BulletinBoardMessage msg; BulletinBoardMessage msg;
UnsignedBulletinBoardMessage msgContents = UnsignedBulletinBoardMessage.newBuilder() UnsignedBulletinBoardMessage msgContents = UnsignedBulletinBoardMessage.newBuilder()
.addTags("test") .addTag("test")
.setData(ByteString.copyFromUtf8("some data")) .setData(ByteString.copyFromUtf8("some data"))
.build(); .build();

View File

@ -52,6 +52,7 @@ public interface DigitalSignature {
/** /**
* Sign the content that was added. * Sign the content that was added.
* Reset the DigitalSignature and make it available to sign a new message using the same key.
* @return * @return
* @throws SignatureException * @throws SignatureException
*/ */

View File

@ -19,7 +19,7 @@ message MessageID {
message UnsignedBulletinBoardMessage { message UnsignedBulletinBoardMessage {
// Optional tags describing message // Optional tags describing message
repeated string tags = 1; repeated string tag = 1;
// The actual content of the message // The actual content of the message
bytes data = 2; bytes data = 2;

View File

@ -151,9 +151,9 @@ public class TestECDSASignature {
UnsignedBulletinBoardMessage.Builder unsignedMsgBuilder = UnsignedBulletinBoardMessage.newBuilder(); UnsignedBulletinBoardMessage.Builder unsignedMsgBuilder = UnsignedBulletinBoardMessage.newBuilder();
unsignedMsgBuilder.setData(ByteString.copyFromUtf8(HELLO_WORLD)); unsignedMsgBuilder.setData(ByteString.copyFromUtf8(HELLO_WORLD));
unsignedMsgBuilder.addTags("Tag1"); unsignedMsgBuilder.addTag("Tag1");
unsignedMsgBuilder.addTags("Tag2"); unsignedMsgBuilder.addTag("Tag2");
unsignedMsgBuilder.addTags("Tag3"); unsignedMsgBuilder.addTag("Tag3");
UnsignedBulletinBoardMessage usMsg = unsignedMsgBuilder.build(); UnsignedBulletinBoardMessage usMsg = unsignedMsgBuilder.build();