All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ch.openchvote.printingauthority.writein.PublicData Maven / Gradle / Ivy

There is a newer version: 2.1
Show 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.printingauthority.writein;

import ch.openchvote.framework.party.EventData;
import ch.openchvote.algorithms.protocols.common.model.EventSetup;
import ch.openchvote.algorithms.protocols.writein.model.ElectionParametersWriteIn;
import ch.openchvote.protocol.protocols.writein.content.message.MAP1;
import ch.openchvote.utilities.tuples.Pair;
import ch.openchvote.utilities.tuples.Tuple;

/**
 * Instances of this class represent the printing authority'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 Pair<
        // event setup and election parameters
        EventData.Data, // ES
        EventData.Data> // EP
        implements EventData {

    public PublicData() {
        this(new Data<>(), new Data<>());
    }

    // private constructor for initializing all fields
    private PublicData(Data ES, Data EP) {
        super(ES, EP);
    }

    // private copy constructor
    @SuppressWarnings("unused")
    private PublicData(PublicData publicData) {
        this(publicData.get_ES(), publicData.get_EP());
    }

    public Data get_ES() {
        return this.getFirst();
    }

    public Data get_EP() {
        return this.getSecond();
    }

    /**
     * Calling this method stores the given content of type {@link MAP1} into the printing authority's secret data.
     *
     * @param content The given content
     */
    public void setContent(MAP1 content) {
        this.get_ES().set(content.get_ES());
        this.get_EP().set(content.get_EP());
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy