ch.openchvote.inspectionclient.plain.PublicData Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of inspection-client Show documentation
Show all versions of inspection-client Show documentation
This module implements the 'verification client' party of the CHVote protocol.
The newest version!
/*
* Copyright (C) 2024 Berner Fachhochschule https://e-voting.bfh.ch
*
* - This program is free software: you can redistribute it and/or modify -
* - it under the terms of the GNU Affero General Public License as published by -
* - the Free Software Foundation, either version 3 of the License, or -
* - (at your option) any later version. -
* - -
* - This program is distributed in the hope that it will be useful, -
* - but WITHOUT ANY WARRANTY; without even the implied warranty of -
* - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -
* - GNU General Public License for more details. -
* - -
* - You should have received a copy of the GNU Affero General Public License -
* - along with this program. If not, see . -
*/
package ch.openchvote.inspectionclient.plain;
import ch.openchvote.framework.party.EventData;
import ch.openchvote.algorithms.protocols.common.model.EventSetup;
import ch.openchvote.algorithms.protocols.plain.model.VotingParametersPlain;
import ch.openchvote.protocol.protocols.plain.content.requestresponse.response.RAI1;
import ch.openchvote.protocol.protocols.plain.content.requestresponse.response.REI1;
import ch.openchvote.protocol.protocols.plain.content.userinterface.input.UVI1;
import ch.openchvote.utilities.sequence.ByteArray;
import ch.openchvote.utilities.tuples.Sextuple;
import ch.openchvote.utilities.tuples.Tuple;
/**
* Instances of this class represent the inspection client's public data. The class inherits from the generic {@link Tuple}
* subclass, that matches with the number of {@link EventData.Data} and {@link EventData.DataMap} objects to store.
* Convenience methods for accessing the fields with names as specified by the CHVote protocol are provided.
*/
@SuppressWarnings("MissingJavadoc")
public final class PublicData extends Sextuple<
// the administrator's id
EventData.Data, // AD
// voter index
EventData.Data, // v
// event setup and voting parameters
EventData.Data, // ES
EventData.Data, // VP_v
// inspection code
EventData.DataMap, // bold_i
EventData.Data> // IC
implements EventData {
public PublicData() {
this(new Data<>(), new Data<>(), new Data<>(), new Data<>(), new DataMap<>(), new Data<>());
}
// private constructor for initializing all fields
private PublicData(Data AD, Data v, Data ES, Data VP_v, DataMap bold_i, Data IC) {
super(AD, v, ES, VP_v, bold_i, IC);
}
// private copy constructor
@SuppressWarnings("unused")
private PublicData(PublicData publicData) {
this(publicData.get_AD(), publicData.get_v(), publicData.get_ES(), publicData.get_VP_v(), publicData.get_bold_i(), publicData.get_IC());
}
public Data get_AD() {
return this.getFirst();
}
public Data get_v() {
return this.getSecond();
}
public Data get_ES() {
return this.getThird();
}
public Data get_VP_v() {
return this.getFourth();
}
public DataMap get_bold_i() {
return this.getFifth();
}
public Data get_IC() {
return this.getSixth();
}
/**
* Calling this method stores the given content of type {@link RAI1} into the inspection client's public data.
*
* @param content The given content
*/
public void setContent(RAI1 content) {
this.get_ES().set(content.get_ES());
this.get_VP_v().set(content.get_VP());
}
/**
* Calling this method stores the given content of type {@link REI1} into the inspection client's public data.
*
* @param index The index of the received content
* @param content The given content
*/
public void setContent(int index, REI1 content) {
this.get_bold_i().set(index, content.get_I());
}
/**
* Calling this method stores the given content of type {@link UVI1} into the inspection client's public data.
*
* @param content The given content
*/
public void setContent(UVI1 content) {
this.get_AD().set(content.get_AD());
this.get_v().set(content.get_v());
}
}