Validate revoke messages

This commit is contained in:
ameba23
2021-08-30 12:19:37 +02:00
parent 8605ead547
commit 0c4ad98839
2 changed files with 12 additions and 1 deletions

View File

@@ -297,7 +297,7 @@ public class RemoteWipeManagerImpl extends ConversationClientImpl
public void wipe(Transaction txn, Contact contact)
throws DbException, FormatException {
// Check that we have a SETUP message from contact
// Check that we have wiper status
if (!amWiper(txn, contact.getId())) throw new DbException();
Group group = getContactGroup(contact);

View File

@@ -17,6 +17,7 @@ import javax.annotation.concurrent.Immutable;
import javax.inject.Inject;
import static org.briarproject.bramble.util.ValidationUtils.checkSize;
import static org.briarproject.briar.api.remotewipe.MessageType.REVOKE;
import static org.briarproject.briar.api.remotewipe.MessageType.SETUP;
import static org.briarproject.briar.api.remotewipe.MessageType.WIPE;
import static org.briarproject.briar.socialbackup.SocialBackupConstants.MSG_KEY_LOCAL;
@@ -40,6 +41,7 @@ class RemoteWipeValidator extends BdfMessageValidator {
.fromValue(body.getLong(0).intValue());
if (type == SETUP) return validateSetupMessage(body);
else if (type == WIPE) return validateWipeMessage(body);
else if (type == REVOKE) return validateRevokeMessage(body);
else throw new AssertionError();
}
@@ -60,4 +62,13 @@ class RemoteWipeValidator extends BdfMessageValidator {
new BdfEntry(MSG_KEY_LOCAL, false));
return new BdfMessageContext(meta);
}
private BdfMessageContext validateRevokeMessage(BdfList body)
throws FormatException {
checkSize(body, 1);
BdfDictionary meta = BdfDictionary.of(
new BdfEntry(MSG_KEY_MESSAGE_TYPE, REVOKE.getValue()),
new BdfEntry(MSG_KEY_LOCAL, false));
return new BdfMessageContext(meta);
}
}