/*
 * Copyright 2018 Scytl Secure Electronic Voting SA
 *
 * All rights reserved
 *
 * See our extended copyright notice in *file 'Copyright.txt' which is part of this source code package
 */
package com.scytl.products.ov.ei.services.domain.model.vote;

import com.scytl.products.ov.commons.beans.domain.model.receipt.Receipt;
import com.scytl.products.ov.commons.beans.domain.model.vote.Vote;
import com.scytl.products.ov.commons.beans.exceptions.ApplicationException;
import com.scytl.products.ov.commons.beans.exceptions.ResourceNotFoundException;
import com.scytl.products.ov.commons.beans.validation.CryptographicOperationException;

/**
 *
 */
public interface ReceiptFactory {

    /**
     * Receives a vote as parameter and generates a Receipt. The receipt is
     * generated by taking the hashcode of the vote.
     *
     * @param vote
     *            - the vote over which the receipt will be generated.
     * @param authToken
     *            - the authentication token.
     * @return The receipt of the vote.
     * @throws ApplicationException
     *             if validation of fields of a vote fails.
     * @throws CryptographicOperationException
     */
    Receipt generate(Vote vote, String authToken) throws ApplicationException, CryptographicOperationException;

    /**
     * Signs the receipt.
     * 
     * @param vote
     *            - the vote.
     * @param receipt
     *            - the receipt to be signed.
     * @return the signature of receipt.
     * @throws ResourceNotFoundException
     * @throws CryptographicOperationException
     */
    String sign(Receipt receipt, Vote vote) throws CryptographicOperationException, ResourceNotFoundException;

}
