Add the channel identifier to the PlaintextBallot, so it is now printed by the output device
parent
853a6b5684
commit
b1a033da5e
|
@ -60,9 +60,9 @@ message BallotAnswer {
|
|||
}
|
||||
|
||||
message PlaintextBallot {
|
||||
uint64 serialNumber = 1; // Ballot serial number
|
||||
|
||||
repeated BallotAnswer answers = 2;
|
||||
uint64 serial_number = 1; // Ballot serial number
|
||||
bytes channel_identifier = 2;
|
||||
repeated BallotAnswer answers = 3;
|
||||
}
|
||||
|
||||
message EncryptedBallot {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package meerkat.voting.output;
|
||||
|
||||
import com.google.protobuf.BoolValue;
|
||||
import com.google.protobuf.ByteString;
|
||||
import meerkat.protobuf.PollingStation.ScannedData;
|
||||
import meerkat.protobuf.Voting.SignedEncryptedBallot;
|
||||
import meerkat.rest.Constants;
|
||||
|
@ -10,10 +11,7 @@ import meerkat.voting.output.outputcommands.*;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.ws.rs.client.Client;
|
||||
import javax.ws.rs.client.ClientBuilder;
|
||||
import javax.ws.rs.client.Entity;
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.client.*;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -25,6 +23,7 @@ import static meerkat.pollingstation.PollingStationConstants.POLLING_STATION_WEB
|
|||
public class NetworkVirtualPrinter extends AsyncRunnableOutputDevice {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(NetworkVirtualPrinter.class);
|
||||
private ByteString channelIdentifier;
|
||||
private SignedEncryptedBallot signedEncryptedBallot;
|
||||
private final WebTarget successfulPrintTarget;
|
||||
|
||||
|
@ -35,6 +34,7 @@ public class NetworkVirtualPrinter extends AsyncRunnableOutputDevice {
|
|||
client.register(ProtobufMessageBodyReader.class);
|
||||
client.register(ProtobufMessageBodyWriter.class);
|
||||
successfulPrintTarget = client.target(address).path(POLLING_STATION_WEB_SCANNER_SCAN_PATH);
|
||||
resetState();
|
||||
}
|
||||
|
||||
|
||||
|
@ -46,6 +46,7 @@ public class NetworkVirtualPrinter extends AsyncRunnableOutputDevice {
|
|||
*/
|
||||
public void doCommitToBallot(CommitOutputCommand command) {
|
||||
logger.debug("entered method doCommitToBallot");
|
||||
channelIdentifier = command.getChannelIdentifierByteString();
|
||||
signedEncryptedBallot = command.getSignedEncryptedBallot();
|
||||
command.getCallback().onSuccess(null);
|
||||
}
|
||||
|
@ -57,7 +58,7 @@ public class NetworkVirtualPrinter extends AsyncRunnableOutputDevice {
|
|||
*/
|
||||
public void doAudit(AuditOutputCommand command) {
|
||||
logger.debug("entered method doAudit");
|
||||
signedEncryptedBallot = null;
|
||||
resetState();
|
||||
command.getCallback().onSuccess(null);
|
||||
}
|
||||
|
||||
|
@ -69,7 +70,7 @@ public class NetworkVirtualPrinter extends AsyncRunnableOutputDevice {
|
|||
public void doCastBallot(CastOutputCommand command) {
|
||||
logger.debug("entered method doCastBallot");
|
||||
ScannedData scannedData = ScannedData.newBuilder()
|
||||
.setChannel(null) //TODO: fill the details for the channel to be able to send here
|
||||
.setChannel(channelIdentifier)
|
||||
.setSignedEncryptedBallot(this.signedEncryptedBallot)
|
||||
.build();
|
||||
|
||||
|
@ -77,6 +78,8 @@ public class NetworkVirtualPrinter extends AsyncRunnableOutputDevice {
|
|||
BoolValue b = response.readEntity(BoolValue.class);
|
||||
response.close();
|
||||
|
||||
resetState();
|
||||
|
||||
if (b.getValue()) {
|
||||
command.getCallback().onSuccess(null);
|
||||
}
|
||||
|
@ -92,8 +95,14 @@ public class NetworkVirtualPrinter extends AsyncRunnableOutputDevice {
|
|||
*/
|
||||
public void doCancel(CancelOutputCommand command) {
|
||||
logger.debug("entered method doCancel");
|
||||
signedEncryptedBallot = null;
|
||||
resetState();
|
||||
command.getCallback().onSuccess(null);
|
||||
}
|
||||
|
||||
|
||||
private void resetState() {
|
||||
channelIdentifier = null;
|
||||
signedEncryptedBallot = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,7 +29,10 @@ public class SystemConsoleOutputDevice extends AsyncRunnableOutputDevice {
|
|||
logger.debug("entered method doCommitToBallot");
|
||||
PlaintextBallot plaintextBallot = command.getPlaintext();
|
||||
long plaintextSerialNumber = plaintextBallot.getSerialNumber();
|
||||
System.out.println("Commitment of Ballot #" + plaintextSerialNumber + " (plaintext):");
|
||||
System.out.println("Commitment of Ballot #" + plaintextSerialNumber);
|
||||
System.out.println("(channel): ");
|
||||
System.out.println(bytesToString(command.getChannelIdentifierByteString()));
|
||||
System.out.println("(plaintext): ");
|
||||
System.out.println(plaintextBallot);
|
||||
SignedEncryptedBallot signedEncryptedBallot = command.getSignedEncryptedBallot();
|
||||
long encryptedSerialNumber = signedEncryptedBallot.getEncryptedBallot().getSerialNumber();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package meerkat.voting.output.outputcommands;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import meerkat.protobuf.Voting.*;
|
||||
import meerkat.voting.controller.callbacks.ControllerCallback;
|
||||
|
||||
|
@ -19,6 +20,10 @@ public class CommitOutputCommand extends OutputCommand<Void> {
|
|||
this.signedEncryptedBallot = signedEncryptedBallot;
|
||||
}
|
||||
|
||||
public ByteString getChannelIdentifierByteString() {
|
||||
return plaintextBallot.getChannelIdentifier();
|
||||
}
|
||||
|
||||
public PlaintextBallot getPlaintext() {
|
||||
return plaintextBallot;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue