@Test(expected = FormatException.class) public void testRejectsAuthorWithTooLongName() throws Exception { BdfList invalidAuthor = BdfList.of( author.getFormatVersion(), getRandomString(MAX_AUTHOR_NAME_LENGTH + 1), author.getPublicKey() ); clientHelper.parseAndValidateAuthor(invalidAuthor); }
@Override public Author parseAndValidateAuthor(BdfList author) throws FormatException { checkSize(author, 3); int formatVersion = author.getLong(0).intValue(); if (formatVersion != FORMAT_VERSION) throw new FormatException(); String name = author.getString(1); checkLength(name, 1, MAX_AUTHOR_NAME_LENGTH); byte[] publicKey = author.getRaw(2); checkLength(publicKey, 1, MAX_PUBLIC_KEY_LENGTH); return authorFactory.createAuthor(formatVersion, name, publicKey); }
ClientHelperImpl implements ClientHelper { @Override public Author parseAndValidateAuthor(BdfList author) throws FormatException { checkSize(author, 3); int formatVersion = author.getLong(0).intValue(); if (formatVersion != FORMAT_VERSION) throw new FormatException(); String name = author.getString(1); checkLength(name, 1, MAX_AUTHOR_NAME_LENGTH); byte[] publicKey = author.getRaw(2); checkLength(publicKey, 1, MAX_PUBLIC_KEY_LENGTH); return authorFactory.createAuthor(formatVersion, name, publicKey); } }
ClientHelperImpl implements ClientHelper { @Override public Author parseAndValidateAuthor(BdfList author) throws FormatException { checkSize(author, 3); int formatVersion = author.getLong(0).intValue(); if (formatVersion != FORMAT_VERSION) throw new FormatException(); String name = author.getString(1); checkLength(name, 1, MAX_AUTHOR_NAME_LENGTH); byte[] publicKey = author.getRaw(2); checkLength(publicKey, 1, MAX_PUBLIC_KEY_LENGTH); return authorFactory.createAuthor(formatVersion, name, publicKey); } @Inject  ClientHelperImpl(DatabaseComponent db, MessageFactory messageFactory,
			BdfReaderFactory bdfReaderFactory,
			BdfWriterFactory bdfWriterFactory, MetadataParser metadataParser,
			MetadataEncoder metadataEncoder, CryptoComponent crypto,
			AuthorFactory authorFactory); }
ClientHelperImpl implements ClientHelper { @Override public Author parseAndValidateAuthor(BdfList author) throws FormatException { checkSize(author, 3); int formatVersion = author.getLong(0).intValue(); if (formatVersion != FORMAT_VERSION) throw new FormatException(); String name = author.getString(1); checkLength(name, 1, MAX_AUTHOR_NAME_LENGTH); byte[] publicKey = author.getRaw(2); checkLength(publicKey, 1, MAX_PUBLIC_KEY_LENGTH); return authorFactory.createAuthor(formatVersion, name, publicKey); } @Inject  ClientHelperImpl(DatabaseComponent db, MessageFactory messageFactory,
			BdfReaderFactory bdfReaderFactory,
			BdfWriterFactory bdfWriterFactory, MetadataParser metadataParser,
			MetadataEncoder metadataEncoder, CryptoComponent crypto,
			AuthorFactory authorFactory); @Override void addLocalMessage(Message m, BdfDictionary metadata,
			boolean shared); @Override void addLocalMessage(Transaction txn, Message m,
			BdfDictionary metadata, boolean shared); @Override Message createMessage(GroupId g, long timestamp, BdfList body); @Override Message createMessageForStoringMetadata(GroupId g); @Override Message getMessage(MessageId m); @Override Message getMessage(Transaction txn, MessageId m); @Override BdfList getMessageAsList(MessageId m); @Override BdfList getMessageAsList(Transaction txn, MessageId m); @Override BdfDictionary getGroupMetadataAsDictionary(GroupId g); @Override BdfDictionary getGroupMetadataAsDictionary(Transaction txn,
			GroupId g); @Override BdfDictionary getMessageMetadataAsDictionary(MessageId m); @Override BdfDictionary getMessageMetadataAsDictionary(Transaction txn,
			MessageId m); @Override Map<MessageId, BdfDictionary> getMessageMetadataAsDictionary(
			GroupId g); @Override Map<MessageId, BdfDictionary> getMessageMetadataAsDictionary(
			Transaction txn, GroupId g); @Override Map<MessageId, BdfDictionary> getMessageMetadataAsDictionary(
			GroupId g, BdfDictionary query); @Override Map<MessageId, BdfDictionary> getMessageMetadataAsDictionary(
			Transaction txn, GroupId g, BdfDictionary query); @Override void mergeGroupMetadata(GroupId g, BdfDictionary metadata); @Override void mergeGroupMetadata(Transaction txn, GroupId g,
			BdfDictionary metadata); @Override void mergeMessageMetadata(MessageId m, BdfDictionary metadata); @Override void mergeMessageMetadata(Transaction txn, MessageId m,
			BdfDictionary metadata); @Override byte[] toByteArray(BdfDictionary dictionary); @Override byte[] toByteArray(BdfList list); @Override BdfDictionary toDictionary(byte[] b, int off, int len); @Override BdfDictionary toDictionary(TransportProperties transportProperties); @Override BdfDictionary toDictionary(
			Map<TransportId, TransportProperties> map); @Override BdfList toList(byte[] b, int off, int len); @Override BdfList toList(byte[] b); @Override BdfList toList(Message m); @Override BdfList toList(Author a); @Override byte[] sign(String label, BdfList toSign, byte[] privateKey); @Override void verifySignature(byte[] signature, String label, BdfList signed,
			byte[] publicKey); @Override Author parseAndValidateAuthor(BdfList author); @Override TransportProperties parseAndValidateTransportProperties(
			BdfDictionary properties); @Override Map<TransportId, TransportProperties> parseAndValidateTransportPropertiesMap(
			BdfDictionary properties); }
ClientHelperImpl implements ClientHelper { @Override public Author parseAndValidateAuthor(BdfList author) throws FormatException { checkSize(author, 3); int formatVersion = author.getLong(0).intValue(); if (formatVersion != FORMAT_VERSION) throw new FormatException(); String name = author.getString(1); checkLength(name, 1, MAX_AUTHOR_NAME_LENGTH); byte[] publicKey = author.getRaw(2); checkLength(publicKey, 1, MAX_PUBLIC_KEY_LENGTH); return authorFactory.createAuthor(formatVersion, name, publicKey); } @Inject  ClientHelperImpl(DatabaseComponent db, MessageFactory messageFactory,
			BdfReaderFactory bdfReaderFactory,
			BdfWriterFactory bdfWriterFactory, MetadataParser metadataParser,
			MetadataEncoder metadataEncoder, CryptoComponent crypto,
			AuthorFactory authorFactory); @Override void addLocalMessage(Message m, BdfDictionary metadata,
			boolean shared); @Override void addLocalMessage(Transaction txn, Message m,
			BdfDictionary metadata, boolean shared); @Override Message createMessage(GroupId g, long timestamp, BdfList body); @Override Message createMessageForStoringMetadata(GroupId g); @Override Message getMessage(MessageId m); @Override Message getMessage(Transaction txn, MessageId m); @Override BdfList getMessageAsList(MessageId m); @Override BdfList getMessageAsList(Transaction txn, MessageId m); @Override BdfDictionary getGroupMetadataAsDictionary(GroupId g); @Override BdfDictionary getGroupMetadataAsDictionary(Transaction txn,
			GroupId g); @Override BdfDictionary getMessageMetadataAsDictionary(MessageId m); @Override BdfDictionary getMessageMetadataAsDictionary(Transaction txn,
			MessageId m); @Override Map<MessageId, BdfDictionary> getMessageMetadataAsDictionary(
			GroupId g); @Override Map<MessageId, BdfDictionary> getMessageMetadataAsDictionary(
			Transaction txn, GroupId g); @Override Map<MessageId, BdfDictionary> getMessageMetadataAsDictionary(
			GroupId g, BdfDictionary query); @Override Map<MessageId, BdfDictionary> getMessageMetadataAsDictionary(
			Transaction txn, GroupId g, BdfDictionary query); @Override void mergeGroupMetadata(GroupId g, BdfDictionary metadata); @Override void mergeGroupMetadata(Transaction txn, GroupId g,
			BdfDictionary metadata); @Override void mergeMessageMetadata(MessageId m, BdfDictionary metadata); @Override void mergeMessageMetadata(Transaction txn, MessageId m,
			BdfDictionary metadata); @Override byte[] toByteArray(BdfDictionary dictionary); @Override byte[] toByteArray(BdfList list); @Override BdfDictionary toDictionary(byte[] b, int off, int len); @Override BdfDictionary toDictionary(TransportProperties transportProperties); @Override BdfDictionary toDictionary(
			Map<TransportId, TransportProperties> map); @Override BdfList toList(byte[] b, int off, int len); @Override BdfList toList(byte[] b); @Override BdfList toList(Message m); @Override BdfList toList(Author a); @Override byte[] sign(String label, BdfList toSign, byte[] privateKey); @Override void verifySignature(byte[] signature, String label, BdfList signed,
			byte[] publicKey); @Override Author parseAndValidateAuthor(BdfList author); @Override TransportProperties parseAndValidateTransportProperties(
			BdfDictionary properties); @Override Map<TransportId, TransportProperties> parseAndValidateTransportPropertiesMap(
			BdfDictionary properties);  }