@Test public void testValidateProperBlogComment() throws IOException, GeneralSecurityException { String comment = "This is a blog comment"; MessageId pOriginalId = new MessageId(getRandomId()); MessageId currentId = new MessageId(getRandomId()); byte[] sigBytes = getRandomBytes(42); BdfList m = BdfList.of(COMMENT.getInt(), comment, pOriginalId, currentId, sigBytes); BdfList signed = BdfList.of(blog.getId(), message.getTimestamp(), comment, pOriginalId, currentId); expectCrypto(blog, SIGNING_LABEL_COMMENT, signed, sigBytes); BdfDictionary result = validator.validateMessage(message, group, m).getDictionary(); assertEquals(comment, result.getString(KEY_COMMENT)); assertEquals(authorList, result.getList(KEY_AUTHOR)); assertEquals(pOriginalId.getBytes(), result.getRaw(KEY_ORIGINAL_PARENT_MSG_ID)); assertEquals(currentId.getBytes(), result.getRaw(KEY_PARENT_MSG_ID)); assertFalse(result.getBoolean(KEY_READ)); context.assertIsSatisfied(); }
@Override protected BdfMessageContext validateMessage(Message m, Group g, BdfList body) throws InvalidMessageException, FormatException { BdfMessageContext c; int type = body.getLong(0).intValue(); body.remove(0); switch (MessageType.valueOf(type)) { case POST: c = validatePost(m, g, body); addMessageMetadata(c, m.getTimestamp()); break; case COMMENT: c = validateComment(m, g, body); addMessageMetadata(c, m.getTimestamp()); break; case WRAPPED_POST: c = validateWrappedPost(body); break; case WRAPPED_COMMENT: c = validateWrappedComment(body); break; default: throw new InvalidMessageException("Unknown Message Type"); } c.getDictionary().put(KEY_TYPE, type); return c; }
BlogPostValidator extends BdfMessageValidator { @Override protected BdfMessageContext validateMessage(Message m, Group g, BdfList body) throws InvalidMessageException, FormatException { BdfMessageContext c; int type = body.getLong(0).intValue(); body.remove(0); switch (MessageType.valueOf(type)) { case POST: c = validatePost(m, g, body); addMessageMetadata(c, m.getTimestamp()); break; case COMMENT: c = validateComment(m, g, body); addMessageMetadata(c, m.getTimestamp()); break; case WRAPPED_POST: c = validateWrappedPost(body); break; case WRAPPED_COMMENT: c = validateWrappedComment(body); break; default: throw new InvalidMessageException("Unknown Message Type"); } c.getDictionary().put(KEY_TYPE, type); return c; } }
BlogPostValidator extends BdfMessageValidator { @Override protected BdfMessageContext validateMessage(Message m, Group g, BdfList body) throws InvalidMessageException, FormatException { BdfMessageContext c; int type = body.getLong(0).intValue(); body.remove(0); switch (MessageType.valueOf(type)) { case POST: c = validatePost(m, g, body); addMessageMetadata(c, m.getTimestamp()); break; case COMMENT: c = validateComment(m, g, body); addMessageMetadata(c, m.getTimestamp()); break; case WRAPPED_POST: c = validateWrappedPost(body); break; case WRAPPED_COMMENT: c = validateWrappedComment(body); break; default: throw new InvalidMessageException("Unknown Message Type"); } c.getDictionary().put(KEY_TYPE, type); return c; } BlogPostValidator(GroupFactory groupFactory, MessageFactory messageFactory,
			BlogFactory blogFactory, ClientHelper clientHelper,
			MetadataEncoder metadataEncoder, Clock clock); }
BlogPostValidator extends BdfMessageValidator { @Override protected BdfMessageContext validateMessage(Message m, Group g, BdfList body) throws InvalidMessageException, FormatException { BdfMessageContext c; int type = body.getLong(0).intValue(); body.remove(0); switch (MessageType.valueOf(type)) { case POST: c = validatePost(m, g, body); addMessageMetadata(c, m.getTimestamp()); break; case COMMENT: c = validateComment(m, g, body); addMessageMetadata(c, m.getTimestamp()); break; case WRAPPED_POST: c = validateWrappedPost(body); break; case WRAPPED_COMMENT: c = validateWrappedComment(body); break; default: throw new InvalidMessageException("Unknown Message Type"); } c.getDictionary().put(KEY_TYPE, type); return c; } BlogPostValidator(GroupFactory groupFactory, MessageFactory messageFactory,
			BlogFactory blogFactory, ClientHelper clientHelper,
			MetadataEncoder metadataEncoder, Clock clock);  }
BlogPostValidator extends BdfMessageValidator { @Override protected BdfMessageContext validateMessage(Message m, Group g, BdfList body) throws InvalidMessageException, FormatException { BdfMessageContext c; int type = body.getLong(0).intValue(); body.remove(0); switch (MessageType.valueOf(type)) { case POST: c = validatePost(m, g, body); addMessageMetadata(c, m.getTimestamp()); break; case COMMENT: c = validateComment(m, g, body); addMessageMetadata(c, m.getTimestamp()); break; case WRAPPED_POST: c = validateWrappedPost(body); break; case WRAPPED_COMMENT: c = validateWrappedComment(body); break; default: throw new InvalidMessageException("Unknown Message Type"); } c.getDictionary().put(KEY_TYPE, type); return c; } BlogPostValidator(GroupFactory groupFactory, MessageFactory messageFactory,
			BlogFactory blogFactory, ClientHelper clientHelper,
			MetadataEncoder metadataEncoder, Clock clock);   }