mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 14:19:53 +01:00
Validate revoke messages
This commit is contained in:
@@ -297,7 +297,7 @@ public class RemoteWipeManagerImpl extends ConversationClientImpl
|
|||||||
|
|
||||||
public void wipe(Transaction txn, Contact contact)
|
public void wipe(Transaction txn, Contact contact)
|
||||||
throws DbException, FormatException {
|
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();
|
if (!amWiper(txn, contact.getId())) throw new DbException();
|
||||||
|
|
||||||
Group group = getContactGroup(contact);
|
Group group = getContactGroup(contact);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import javax.annotation.concurrent.Immutable;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import static org.briarproject.bramble.util.ValidationUtils.checkSize;
|
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.SETUP;
|
||||||
import static org.briarproject.briar.api.remotewipe.MessageType.WIPE;
|
import static org.briarproject.briar.api.remotewipe.MessageType.WIPE;
|
||||||
import static org.briarproject.briar.socialbackup.SocialBackupConstants.MSG_KEY_LOCAL;
|
import static org.briarproject.briar.socialbackup.SocialBackupConstants.MSG_KEY_LOCAL;
|
||||||
@@ -40,6 +41,7 @@ class RemoteWipeValidator extends BdfMessageValidator {
|
|||||||
.fromValue(body.getLong(0).intValue());
|
.fromValue(body.getLong(0).intValue());
|
||||||
if (type == SETUP) return validateSetupMessage(body);
|
if (type == SETUP) return validateSetupMessage(body);
|
||||||
else if (type == WIPE) return validateWipeMessage(body);
|
else if (type == WIPE) return validateWipeMessage(body);
|
||||||
|
else if (type == REVOKE) return validateRevokeMessage(body);
|
||||||
else throw new AssertionError();
|
else throw new AssertionError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,4 +62,13 @@ class RemoteWipeValidator extends BdfMessageValidator {
|
|||||||
new BdfEntry(MSG_KEY_LOCAL, false));
|
new BdfEntry(MSG_KEY_LOCAL, false));
|
||||||
return new BdfMessageContext(meta);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user