diff --git a/bramble-api/src/main/java/org/briarproject/bramble/api/client/ClientHelper.java b/bramble-api/src/main/java/org/briarproject/bramble/api/client/ClientHelper.java index 814136f4f0a0e535b0a38367bf46c83189820c1c..dff1799e7e8259ecedcbd0a6d9f86e57d736073d 100644 --- a/bramble-api/src/main/java/org/briarproject/bramble/api/client/ClientHelper.java +++ b/bramble-api/src/main/java/org/briarproject/bramble/api/client/ClientHelper.java @@ -94,6 +94,8 @@ public interface ClientHelper { BdfList toList(Message m) throws FormatException; + BdfList toList(Author a); + byte[] sign(String label, BdfList toSign, byte[] privateKey) throws FormatException, GeneralSecurityException; diff --git a/bramble-core/src/main/java/org/briarproject/bramble/client/ClientHelperImpl.java b/bramble-core/src/main/java/org/briarproject/bramble/client/ClientHelperImpl.java index 2af115819e1f9a4f345dfc14fcd7215b3c4439b1..4ced8b3f76991e73d5394ebc599a1dde309c1456 100644 --- a/bramble-core/src/main/java/org/briarproject/bramble/client/ClientHelperImpl.java +++ b/bramble-core/src/main/java/org/briarproject/bramble/client/ClientHelperImpl.java @@ -351,6 +351,11 @@ class ClientHelperImpl implements ClientHelper { raw.length - MESSAGE_HEADER_LENGTH); } + @Override + public BdfList toList(Author a) { + return BdfList.of(a.getFormatVersion(), a.getName(), a.getPublicKey()); + } + @Override public byte[] sign(String label, BdfList toSign, byte[] privateKey) throws FormatException, GeneralSecurityException { diff --git a/bramble-core/src/test/java/org/briarproject/bramble/client/ClientHelperImplTest.java b/bramble-core/src/test/java/org/briarproject/bramble/client/ClientHelperImplTest.java index 4ffe9e5326ed8496864c22644604f3b7b5f55b5e..0d54281a807d0cc5415a4ff8f7c6b38309ba4277 100644 --- a/bramble-core/src/test/java/org/briarproject/bramble/client/ClientHelperImplTest.java +++ b/bramble-core/src/test/java/org/briarproject/bramble/client/ClientHelperImplTest.java @@ -331,6 +331,18 @@ public class ClientHelperImplTest extends BrambleTestCase { } } + @Test + public void testParsesAndEncodesAuthor() throws Exception { + context.checking(new Expectations() {{ + oneOf(authorFactory).createAuthor(author.getFormatVersion(), + author.getName(), author.getPublicKey()); + will(returnValue(author)); + }}); + + BdfList authorList = clientHelper.toList(author); + assertEquals(author, clientHelper.parseAndValidateAuthor(authorList)); + } + @Test public void testAcceptsValidAuthor() throws Exception { BdfList authorList = BdfList.of(