Class VoteProcessor

java.lang.Object
  extended byVoteProcessor

public class VoteProcessor
extends java.lang.Object

This is the most important class. This class processes the votes and uses other classes to do this. It sets status codes and if an error occurs the status code is sent to Errorhander class that will handle the error.

Please refer to the doProcessing method to see how the program works.

Version:
1
Author:
Alexander Scheidl
See Also:
doProcessing(), Errorhandler.pushError(int)

Field Summary
private  boolean calculatevotes
          indicates whether the main- and sub vote process has to be processed
private  RSAToString crypter
          generate a RSAToString as a null object (used for decryption of votes)
private  RSAToString crypterhashserver
          generate a RSAToString as a null object (used for server signature checking of votes)
private  RSAToString crypterhashverifier
          generate a RSAToString as a null object (used for verifier signature checking of votes)
private  Errorhandler error
          generate an error handler as a null object.
private  GUI gui
          generate a GUI class for graphical user interface as a null object.
private  boolean hasverifier
          indicates whether a signature check with a verifier key is needed or not
if true a verifier key is set and a verifier key checking is needed
private  boolean invalidallchosen
          indicates whether an invalid all option was choosen (true) or not (false)
private  boolean invalidmainchosen
          indicates whether an invalid main option was choosen (true) or not (false)
private  KeyReader key
          generate a KeyReader as null object
private  Optionprocessor Option
          generate an Optionprocessor for creating and handling options.
private  Output out
          generate an Output class for writing votes into a csv file without signature strings
private  boolean outfile
          indicates status of writting an output file without signature string
if true a file is written
private  boolean outfilesign
          indicates status of writing an output file with signature string
if true a file is written
private  Output outsign
          generate an Output class for writing votes into a csv file with signature strings
private  int signaturestatus
          intialize signature status, every vote gets its own status (see 'see also')
private  int status
          status codes of program (used for error handling)
private  VoteReader vote
          generate a VoteReader as null object
 int votecounts
          shows the number of votes that are processed
 
Constructor Summary
VoteProcessor(GUI gui)
          This constructor is used by the GUI class constructor so that the current GUI is 'connected' to VoteProcessor.
 
Method Summary
 boolean checkKeyFile()
          This method checks if key file is ok, if not an errorstatus is sent to Errorhandler.
 boolean CheckOptionfile()
          This method checks if option file is ok and starts parsing, if not an errorstatus is send to Errorhandler.
private  boolean checkPanager(java.lang.String id, Option[] mainoption, Option[] suboption, Vote[] vote)
          check if subvote meets panager requirements.
private  boolean checkSign(java.lang.String vtrvote, java.lang.String[] sign)
          This method checks the signature with help of the String.equals() method.
 boolean CheckVoteFile()
          This method checks if vote file is ok and starts parsing, if not an errorstatus is send to Errorhandler.
 void doCalculation(boolean b)
          this method sets boolean status whether the program calculate votes or not
private  int doCheckSigning(java.lang.String vote, java.lang.String token)
          This method calculates the signature status of one vote.
private  java.lang.String doDecryption(java.lang.String s)
          This method is used to decrypt a given String.
 void doProcessing()
          This is the main processing method.
private  void doTransferInternToExternVoteCounter(Option[] intern, Option[] extern)
          This method transfers intern to extern Option array (=vote counter).
 int getContestIdentifier(java.lang.String vote)
          This method captures the ContestIdentifier from a given vote string .
 Errorhandler getErrorhandler()
          Getter class for error object
 KeyReader getKeyReader()
          Getter method for KeyReader class
private  Vote[] getMainVotes(java.lang.String vote)
          This method captures from one decrypted vote String the id and values of the voted main options.
 Optionprocessor getOptions()
          Getter class for options
private  java.lang.String[] getServerSign(java.lang.String token)
          This method retrieves "VTokenRequest" and "VTokenResponseServer" string from a token.
 int getSignatureStatus()
          Getter method for signaturestatus of one(!!!)
 int getStatus()
          Getter method for status code of program (error codes)
private  Vote[] getSubVotes(java.lang.String vote)
          This method captures from one decrypted vote String the id and values of the voted sub options.
private  java.lang.String[] getVerifierSign(java.lang.String token)
          This method retrieves "VTokenRequest" and "VFTokenResponse" string from a vote token.
 java.lang.String getVFTokenResponse(java.lang.String token)
          This method captures the "VFTokenResponse" content from a token String.
 VoteReader getVoteReader()
          Getter class for votes
 java.lang.String getVTokenRequest(java.lang.String token)
          This method captures the "VTokenRequest" content from a token String .
 java.lang.String getVTokenResponseServer(java.lang.String token)
          This method captures the "VTokenResponseServer" content from a token String.
 java.lang.String getVtrFromVote(java.lang.String vote)
          This method captures the "VTR" content from a vote String.
private  Option[] makeLocalVoteCounter(Option[] global)
          This method makes the local option counter = local Option[] array.
 void makeOutfile(boolean b)
          indicates whether an Outfile is written or not
 void makeSignOutfile(boolean b)
          indicates whether an Outfile with signature status is written or not
 void resetAllOutputfileerrors()
          this method resets all error coming from Outputfiles
 void setKeys(java.lang.String s)
          This method sets a new KeyReader class for reading keys
 void setOptions(java.lang.String s)
          This method sets a new Optionprocessor class
 void setSignatureStatus(int n)
          This method is used to set the signature status of one(!!!)
 void setStatus(int status)
          set status codes of program - if an error the corresponding status code will be handled in the Errorhandler Class.
 void setVerifier(boolean b)
          method checks if a verifier for signature checking is needed
 void setVotes(java.lang.String s)
          This method sets a new VoteReader for parsing votes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

error

private Errorhandler error
generate an error handler as a null object.
by call of the constructor this variable (field) will be initialised

See Also:
Errorhandler, Go to Code

gui

private GUI gui
generate a GUI class for graphical user interface as a null object.
by call of the constructor this variable (field) will be initialised

See Also:
GUI, Go to Code

Option

private Optionprocessor Option
generate an Optionprocessor for creating and handling options.
main and sub option arrays will be created as array with 0 elements

See Also:
Optionprocessor, Go to Code

key

private KeyReader key
generate a KeyReader as null object

See Also:
Go to Code

vote

private VoteReader vote
generate a VoteReader as null object

See Also:
Go to Code

crypterhashserver

private RSAToString crypterhashserver
generate a RSAToString as a null object (used for server signature checking of votes)

See Also:
Go to Code

crypterhashverifier

private RSAToString crypterhashverifier
generate a RSAToString as a null object (used for verifier signature checking of votes)

See Also:
Go to Code

crypter

private RSAToString crypter
generate a RSAToString as a null object (used for decryption of votes)

See Also:
Go to Code

out

private Output out
generate an Output class for writing votes into a csv file without signature strings

See Also:
Go to Code

outsign

private Output outsign
generate an Output class for writing votes into a csv file with signature strings

See Also:
Go to Code

status

private int status
status codes of program (used for error handling)

See Also:
Go to Code

signaturestatus

private int signaturestatus
intialize signature status, every vote gets its own status (see 'see also')

See Also:
doCheckSigning(String,String), Go to Code

votecounts

public int votecounts
shows the number of votes that are processed

See Also:
Go to Code

calculatevotes

private boolean calculatevotes
indicates whether the main- and sub vote process has to be processed

See Also:
doCalculation(boolean), Go to Code

outfile

private boolean outfile
indicates status of writting an output file without signature string
if true a file is written

See Also:
Go to Code

outfilesign

private boolean outfilesign
indicates status of writing an output file with signature string
if true a file is written

See Also:
Go to Code

hasverifier

private boolean hasverifier
indicates whether a signature check with a verifier key is needed or not
if true a verifier key is set and a verifier key checking is needed

See Also:
Go to Code

invalidmainchosen

private boolean invalidmainchosen
indicates whether an invalid main option was choosen (true) or not (false)

See Also:
Go to Code

invalidallchosen

private boolean invalidallchosen
indicates whether an invalid all option was choosen (true) or not (false)

See Also:
Go to Code
Constructor Detail

VoteProcessor

public VoteProcessor(GUI gui)
This constructor is used by the GUI class constructor so that the current GUI is 'connected' to VoteProcessor.

EPC Main_process 13: This constructor sets also the Errorhandler with the current GUI so that Errorhandler can interact with GUI (-> error dialogs).
Also all needed error counters will be created with the init of a new Errorhandler

See Also:
GUI, Errorhandler, Go to Code
Method Detail

doProcessing

public void doProcessing()
This is the main processing method.

It consists of 3 loops:
.) mainloop: goes through vote file, sets main and sub votes and does decryption and signature checks for every vote. (EPC Main_process)
.) mainvoteloop: goes through main votes (getting from mainloop) and deso checkings (EPC Vote_process)
.) subvoteloop: goes through sub votes (getting from mainloop) and does checkings (EPC Vote_process)

errors from loops will be covered by a status code (see programstatus codes) to Errorhandler via the Errorhandler.pushError(int) method. The Errorhandler class sets the errors so that in this method the errors will be checked (Errorhandler.getBreakMainLoop(); Errorhandler.getMainVoteError();Errorhandler.getSubVoteError()) and if set the matching loops are broken.

You can read through it or you can view the corresponding epc and click on the link below to view the process description. EPC Links:


EPC Main_process 15:First temp storage variable for votestring, vtoken and sub/main options in the doProcessing() method are created. Then the votecounts variable is set to 0 which should secure that votes are from beginning processed. - Note at this stage a votestring (captured with VoteReader.setVoteStream() method contains the VToken and the encrypted Vote String.

After that all errors and values (possibly from former runs) are reseted with help of Optionprocessor.resetMainoptionValues(), Optionprocessor.resetSuboptionValues(), Errorhandler#resetErrorFromDoProcessing(), Errorhandler.resetCounters(), resetAllOutputfileerrors() and the both invalid indicators (boolean invalidallchosen and invalidmainchosen) are set to false.

The GUI.jProgressBar1 which is the graphical indicator of process progress will be set with min (=0) and max value with the javax#swing#JProgressBar#setMinimum(int) and javax#swing#JProgressBar#setMaximum(int) (=max. amount of votes, getting from VoteReader.getNumberOfVotes() method)

Thereafter if outfiles are set (boolean outfile, outfilesign) - see EPC Main_process 2 - the corresponding header are written into preselected files with the Output.writeStartLine(String, int, int , boolean) method. If an error occurs (I/O Exceptions) errors are sent to Errorhandler via the Errorhandler.pushError(int)
Go to Code

EPC Main_process 16: First mainloop captures one vote and increases the control variable (votecounts) that symbolizes one vote at the end of current loop by one until the max is reached via the method. Also the GUI.jProgressBar1 is updated via the javax#swing#JProgressBar#setValue() with current value of the votecounts variable and the ProgressBars graphical component (GUI appearence) is updated via the javax#swing#JProgressBar#paint() method.
So at the begin of every loop a check will be done if loop has to be broken (via the Errorhandler.getBreakMainLoop()). Also all errors coming from last inning of loop are reseted with Errorhandler.resetErrorsFromDoProcessing() and invalidallchosen and invalidmainchosen. Finally it will be found out if main and sub options have to be processed or if none are read with the Errorhandler.getNoSubOptionStatus() and Errorhandler.getNoMainOptionStatus(). Please note, it is absolutely necessary that main options are set, if not, program can't calculate votes. CheckOptionfile()
Go to Code

EPC Main_process 17:Thereafter the decryption of one votestring will be done and temporary saved as a string with the doDecryption(String) that captures one Vote with the VoteReader.getAVote(int) method. Also the Vtoken String is set with the VoteReader.getAVToken(int) method (token string contains tags for signature checking).
Go to Code

EPC Main_process 18:After decryption the next step is to capture voted main options from the votestring. This is done via the getMainVotes(java.lang.String) method. The voted options are saved in a Vote[] array for later processing.
Go to Code

EPC Main_process 19:If voted main options are extracted it will be checked if main options from option file are loaded. If not, and main options are voted, an error is sent to Errorhandler via the Errorhandler.pushError(int) method. Please note as a consequence of this, program aborts.
Go to Code

EPC Main_process 20:After main vote extraction voted sub options from the votestring will be captured. This is done via the getSubVotes(java.lang.String) method. The voted options are saved in a Vote[] array for later processing.
Go to Code

EPC Main_process 21:If voted sub options are extracted it will be checked if sub options from option file are loaded. If not and sub options are voted, an error is sent to Errorhandler via the Errorhandler.pushError(int) method. Please note as a consequence of this, program aborts.
Go to Code

EPC Main_process 22:After vote array setting it will be checked if loop can continue or if serious errors are set so that loop must break. If not, process continues to see if export for csv file without signature status has put an Output.error. This will be checked with the Errorhandler.getOutfileError() and if an error is found the outfile is set false. This is important because if an outfile is set loop must continue even if a signature error is set to secure making a csv file, see which vote has an signature error and set program status adequate.
Go to Code

EPC Main_process 23:The chain continues to see if exported file with signature status has put an Output.error. This will be checked with the Errorhandler.getOutfileErrorSign() and if an error is found the outfilesign is set false. This is important because if an outfile is set loop must continue even if a signature error is set to secure making a csv file, see which vote has an signature error and set program status adequate.
Go to Code

EPC Main_process 24:Then the signatures are checked via the doCheckSigning(String, String) method. First String is the token from vote string and the second from Vtoken String.
Go to Code

EPC Main_process 25:After determination of signature status the code is set with the setSignatureStatus(int).
Go to Code

EPC Main_process 26:If signature status getSignatureStatus() != 0, that means that an problem with the signature has occured (for status codes refer to EPC Chain) the calculated error status according to former set errors from exporting votes the errorstatus will be reported to Errorhandler with the Errorhandler.pushError(int) method. Please note if no files for exporting are prebooked program aborts with an error message, if outfile(s) are set program continues but does not do a calculation. Please refer to Errorhandler and see status codes: 6.. no output is set; 61.. output is set.
Go to Code

EPC Main_process 27:When signature checking is done the ContestID, in other words the election id, will be inspected. Therefore it is necessary to check the contest id from option file (Optionprocessor.getContestIdentifier()) with that from vote (getContestIdentifier(String)). If both are not equal an error is pushed Errorhandler.pushError(int). Also it is important to distinguish between the situation if an outfile is set or not, because if one is set (regardless of with/without signature) process must continue but no calculation may be shown.
Go to Code

EPC Main_process 28:After ContestID is inspected it will be checked if an export file without signature status has been set to be exported. (see outfile)
Go to Code

EPC Main_process 29:If EPC Main_process 28 is true preselected file will be filled with voted options (2 calls one for main and one for sub options) without signature status with Output.writefile(String,Vote[],int,String,String,String,String,boolean,int) method. If an error occurs it will be sent to Errorhandler Errorhandler.pushError(int).
Go to Code

EPC Main_process 30:Then it must be checked if a calculation of votes is set (see GUI.voteresult(java.awt.event.ActionEvent)) or if an export of votes with signature status is set (see outfilesign)
Go to Code

EPC Main_process 31:It will be checked if an export file with signature status has been set to be exported. (see outfilesign)
Go to Code

EPC Main_process 32:If EPC Main_process 31 is true preselected file will be filled with voted options (2 calls one for main and one for sub options) with signature status string (getVtrFromVote(String), getVTokenRequest(String), getVFTokenResponse(String), getVTokenResponseServer(String)) with Output.writefile(String,Vote[],int,String,String,String,String,boolean,int) method. If an error occurs it will be sent to Errorhandler Errorhandler.pushError(int).
Go to Code

EPC Main_process 33:After that it must be checked if no errors are set Errorhandler.getBreakMainLoop() and calculation of votes is set (see GUI.voteresult(java.awt.event.ActionEvent) )
Go to Code

EPC Main_process 34:Start EPC Vote_process
Go to Code

EPC Main_process 35:At the end of one inning for mainloop is reached and control variable (votecounts) is increased by one so that the next vote can be analysed.
Go to Code

EPC Vote_process 1.: If votes must be calculated - this depends on two factors: errors may avoid calculations (checked with the Errorhandler.getNoMainVoteLoop()) or the GUI setting is not to calculate - (boolean calculatevotes) the mainvoteloop will be started.
Go to Code

EPC Vote_process 2.:First a local counter for voted options of one vote are created with the makeLocalVoteCounter(Option[]) method. This is necessary because first options of one vote are evaluated and then error checked. If no errors found counter will be transfered to "extern" counter so that an overall result is possible. If errors are found corresponding error counters will be increased. This will be done by the Errorhandler.pushError(int) method in Errorhandler.
Go to Code

EPC Vote_process 3.:The mainvoteloop captures one voted main option (done by 'for' loop)
Go to Code

EPC Vote_process 4.:It will be checked if this main option is also in option file with the OptionUtilities.containsId(java.lang.String, Option[]) method, if not errors are sent to Errorhandler via the Errorhandler.pushError(int) method
Go to Code

EPC Vote_process 5.:If check form EPC Vote_process 4 fails, the corresponding errorcounter is increased. This will be done in the Errorhandler Class, so the error is send via Errorhandler.pushError(int)
Go to Code

EPC Vote_process 6.:If EPC Vote_process 4 succeeds it will be checked if voted option is a strike out (means its value < 0) with the Vote.getNumber() method.
Go to Code

EPC Vote_process 12.1:If voted option is a strike out, local vote counter for strike outs is increased by one with the Option.increaseCancellationby1() method. The right option is found in the local counter array with the Option#Utilities#serachOptionId(String,Option[],int) method.
Go to Code

EPC Vote_process 7.:If voted option isn't an strike out it will be checked if voted option has an invalid status (all/main) with the OptionUtilities.getInvalidStatusOfChosenOption(int, Option[]).
Go to Code

EPC Vote_process 12.2:If voted option has not an invalid status, it will be found in local counter array with the OptionUtilities.serachOptionId(java.lang.String, Option[], int) method and will be increased by voted value with the Option.increaseValueby(int) method.
Go to Code

EPC Vote_process 8.:If voted option has an invalid status it will be checked if an invalid option was already chosen. This is not allowed because election system allows only to choose one invalid status option per vote. So if one is chosen (checked with the boolean variables invalidallchosen, invalidmainchosen) an error to Errorhandler is sent Errorhandler.pushError(int).
Go to Code

EPC Vote_process 9,10.:The correspondending boolean is set true invalidallchosen -statuscode 2, invalidmainchosen - statuscode 1 and status is pushed to Errorhandler with the Errorhandler.pushError(int) method. Note if the invalidallchosen status is set program stops processing of this vote and goes to next vote.
Go to Code

EPC Vote_process 11:The corresponding option in extern (!) counter array is increased. The right option will be found in extern counter array with the OptionUtilities.serachOptionId(java.lang.String, Option[], int) method and will be increased by voted value with the Option.increaseValueby(int) method. (Why extern counter? - because program can abort processing vote at this stage and so intern counter can not be transfered to extern counter). Please note if an option with invalid status is strike out all other options are counted because electors volition is to strike out invalid status of a vote. At the end it will be checked if Errorhandler has set a mainvoteloop or even the whole mainloop break via the Errorhandler.getMainVoteError() and Errorhandler.getBreakMainLoop() methods. (For more details refer to programstatus codes)
Go to Code

EPC Vote_process 13:Finally of the mainvoteloop checks with the vote are done:
.) check permissible votes for main options (Optionprocessor.getmaxVotes_main() must be larger than OptionUtilities.getSum(Option[])) status code: 831
.) check number of votes that may be cumulated in a main option (Optionprocessor.getmaxCumVotes_main() must be larger than OptionUtilities.searchvaluebyid(java.lang.String, Option[])) status code: 832
.) check number of main options that may be struck out (Optionprocessor.getMainCancellation() must be larger than OptionUtilities.getCancellationsSum(Option[])) status code: 833
Go to Code

EPC Vote_process 14:If one of these checks fails the corresponding status code is sent to Errorhandler with the Errorhandler.pushError(int) method that handles further actions like increasing error counters.
Go to Code

EPC Vote_process 15:If all voted main options are processed or errors broke loop the sub voted options are processed with the subvoteloop.
Go to Code

EPC Vote_process 16:If sub votes must be calculated - this depends on two factors: errors may be avoid calculations or no sub votes are choosen the setting is not to calculate (checked with the Errorhandler#getNoSubVoteLoop())- the subvoteloop will be started.
Go to Code

EPC Vote_process 17:Like the mainvoteloop first a local counter for voted sub options are created with the makeLocalVoteCounter(Option[]) method.
Go to Code

EPC Vote_process 18:The subvoteloop captures one voted main option (done by 'for' loop)
Go to Code

EPC Vote_process 19:It will be checked if voted sub option is also in option file with the OptionUtilities.containsId(java.lang.String, Option[]) method.
Go to Code

EPC Vote_process 20.:If check from EPC Vote_process 19 fails, the corresponding errorcounter is increased. This will be done in the Errorhandler Class, so the error is send via Errorhandler.pushError(int)
Go to Code

EPC Vote_process 21:It will be checked if panager is allowed or not (Optionprocessor.getPanagerStatus().
Go to Code

EPC Vote_process 22:If panager is not allowed the voted sub options must match a voted main option. This is checked with the checkPanager(java.lang.String, Option[], Option[], Vote[]) method.
Go to Code

EPC Vote_process 23:If check from EPC Vote_process 22 fails an error is sent to Errorhandler via the Errorhandler.pushError(int) method.
Go to Code

EPC Vote_process 24:Thereafter it will be checked if voted option is a strike out (means its value < 0) with the Vote.getNumber() method. If so, local vote counter for strike outs is increased by one with the Option.increaseCancellationby1() method. The right option is found in local counter array with the OptionUtilities.serachOptionId(java.lang.String, Option[], int) method. If its not a strike out the local option counter will be increased by the Option.increaseValueby(int) method.
Go to Code

EPC Vote_process 25:At the end of the subvoteloop checks like that for main options are done:
.) check permissible votes for sub options (Optionprocessor.getmaxVotes_sub() must be larger than OptionUtilities.getSum(Option[])) status code: 741
.) check number of votes that may be cumulated in a sub option (Optionprocessor.getmaxCumVotes_sub() must be larger than OptionUtilities.searchvaluebyid(java.lang.String, Option[])) status code: 742
.) check number of sub options that may be struck out (Optionprocessor.getSubCancellation() must be larger than OptionUtilities.getCancellationsSum(Option[])) status code: 743
Go to Code

EPC Vote_process 26:If one of the checks from EPC Vote_process 25 fails the corresponding status code is sent to Errorhandler with the Errorhandler.pushError(int) method and handles further actions like increasing error counters or setting loop breaks.
Go to Code

EPC Vote_process 27:If all voted sub options are processed or errors broke loop the process continues to EPC Vote_process 28.
Go to Code

EPC Vote_process 28:If subvoteloop are done it will be checked if errors from processing of the sub options are set (Errorhandler.getSubVoteError() or if no sub options from option file are set (Errorhandler.getNoSubOptionStatus() and Errorhandler.getNoSubvoteLoop().
Go to Code

EPC Vote_process 29:If none from EPC Vote_process 28 are set the intern counter for sub options is transferd to extern counter for sub options with the doTransferInternToExternVoteCounter(Option[], Option[]) method.
Go to Code

EPC Vote_process 30:If checks for sub votes are done it will be checked if errors from processing of the main options are set (Errorhandler.getMainVoteError() and Errorhandler.getNoMainVoteLoop()).
Go to Code

EPC Vote_process 31:If none errors from EPC Vote_process 30 are set the intern counter for main options is transfered to extern counter for main options with the doTransferInternToExternVoteCounter(Option[], Option[]) method.
At this stage the EPC Vote_process ends and goes back to EPC Main_process.
Go to Code


doCalculation

public void doCalculation(boolean b)
this method sets boolean status whether the program calculate votes or not

Parameters:
b - boolean if true votes are calculated, else not
See Also:
calculatevotes, Errorhandler.setShowTable(boolean), Go to Code

resetAllOutputfileerrors

public void resetAllOutputfileerrors()
this method resets all error coming from Outputfiles

See Also:
Output.resetError(), Errorhandler#OutputfileError(), Go to Code

makeOutfile

public void makeOutfile(boolean b)
indicates whether an Outfile is written or not

Parameters:
b - if ture an outfile is written, else not
See Also:
outfile, Go to Code

makeSignOutfile

public void makeSignOutfile(boolean b)
indicates whether an Outfile with signature status is written or not

Parameters:
b - if ture an outfile is written, else not
See Also:
outfilesign, Go to Code

setVerifier

public void setVerifier(boolean b)
method checks if a verifier for signature checking is needed

Parameters:
b - if true a verifier is needed
See Also:
Go to Code

setStatus

public void setStatus(int status)
set status codes of program - if an error the corresponding status code will be handled in the Errorhandler Class.

Parameters:
status - int code of the program
See Also:
programstatus codes, status, Errorhandler, Go to Code

setOptions

public void setOptions(java.lang.String s)
This method sets a new Optionprocessor class

Parameters:
s - String with the link to option file
See Also:
Optionprocessor, Go to Code

setVotes

public void setVotes(java.lang.String s)
This method sets a new VoteReader for parsing votes

Parameters:
s - String with the link to votes file
See Also:
VoteReader, Go to Code

setKeys

public void setKeys(java.lang.String s)
This method sets a new KeyReader class for reading keys

Parameters:
s - String with the link to file
See Also:
KeyReader, Go to Code

getStatus

public int getStatus()
Getter method for status code of program (error codes)

Returns:
status code of program
See Also:
status, Go to Code

getKeyReader

public KeyReader getKeyReader()
Getter method for KeyReader class

Returns:
key KeyReader
See Also:
key, KeyReader, Go to Code

getVoteReader

public VoteReader getVoteReader()
Getter class for votes

Returns:
vote VoteReader with the current VoteReader object
See Also:
vote, VoteReader, Go to Code

getOptions

public Optionprocessor getOptions()
Getter class for options

Returns:
Option Options from Optionprocessor
See Also:
Option, Optionprocessor, Go to Code

getErrorhandler

public Errorhandler getErrorhandler()
Getter class for error object

Returns:
error Errorhandler
See Also:
error, Errorhandler, Go to Code

CheckOptionfile

public boolean CheckOptionfile()
This method checks if option file is ok and starts parsing, if not an errorstatus is send to Errorhandler.

First this method resets all errors from former read options with the resetSubAndMainOptionStatus() method. Arter that the method checks if an option file is read. If read, main options will be set with the setMainOptions() method. Then these main options will be checked if at least a main option is set (with getNoMainOptionsError()). Afterwards sub options will be set with the the setSubOptions() method and will also be checked for errors with the getNoSubOptionsError(). At last the parameters for options are set with the setparam() method and checked for errors with the getParamError() method. In this section it will also be verified if an additional verifier for signature checking is required or not.

Please note that all errors will be covered by Errorhandler class with the pushError() method.

Errorcodes:

Returns:
true if file is ok, false if not
See Also:
Optionprocessor.setMainOptions(), Optionprocessor.getNoMainOptionsError(), Optionprocessor.setSubOptions(), Optionprocessor.getNoSubOptionsError(), Optionprocessor.setparam(), Optionprocessor.getParamError(), Optionprocessor.getVerifierStatus(), Errorhandler.pushError(int), Go to Code

CheckVoteFile

public boolean CheckVoteFile()
This method checks if vote file is ok and starts parsing, if not an errorstatus is send to Errorhandler.

First it will be checked if a vote file is read with the isReadOk() method. If read the method sets the vote stream with the setVoteStream() method. Thereafter it will be checked if at least one vote is set with the getNoVoteError().

Please note that all errors will be covered to Errorhandler class with the pushError() method.

Errorcodes:

Returns:
true if vote (ballot) file is ok, false if not
See Also:
VoteReader.isReadOk(), VoteReader.setVoteStream(), VoteReader.getNoVoteError(), Errorhandler.pushError(int), Go to Code

checkKeyFile

public boolean checkKeyFile()
This method checks if key file is ok, if not an errorstatus is sent to Errorhandler.

First it will be checked if a key file is read with the isReadOk() method. If read the method sets the different Keys with the setEncryptionKey(), setServerKey(), setVerifierKey() method. Thereafter it will be checked if an error with one of these keys exists. An error with the setVerifierKey() will only be sent if an verifier key is needed. This fact will be checked by the boolean hasverifier.

Please note that all errors will be covered to Errorhandler class with the pushError() method.

Errorcodes:

Returns:
true if keys are ok, false if not
See Also:
KeyReader.isReadOk(), KeyReader.setEncryptionKey(), KeyReader.getEncryptionKeyErrorStatus(), KeyReader.setServerKey(), KeyReader.getServerKeyErrorStatus(), KeyReader.setVerifierKey(), KeyReader.getVerifierErrorStatus(), hasverifier, Errorhandler.pushError(int), Go to Code

checkPanager

private boolean checkPanager(java.lang.String id,
                             Option[] mainoption,
                             Option[] suboption,
                             Vote[] vote)
check if subvote meets panager requirements.
First this method determines the array postions of sub- and the corresponding main option (id of main option = foreign key of the sub option) with help of the searchOptionId() method. If no main option is found - that means that the foreign key of sub option is false - false is returned.

If foreign key is found it will be checked whether the corresponding main option of sub option (foreign key = main option id) is chosen. This will be done with help of the containsVoteIdAndGiveValueBack() method. If all checks are ok, true is returned else false.

Parameters:
id - String with the voted sub option id
mainoption - Option[] array to be checked if it contains a matching foreign key
suboption - Option[] array with sub options
vote - Vote[] array for checking the vote
Returns:
true if it meets requirements, false if not
See Also:
OptionUtilities.serachOptionId(String, Option[], int), OptionUtilities.containsVoteIdAndGiveValueBack(String,Vote[]), Option.foreign_key, Go to Code

makeLocalVoteCounter

private Option[] makeLocalVoteCounter(Option[] global)
This method makes the local option counter = local Option[] array.
Method loops the global option array and copies id and mames to an new local counter with 0 values.

Parameters:
global - Option[] with the global Option array to be copied
Returns:
local Option[] with the copied option with values set to 0
See Also:
Option, Go to Code

doTransferInternToExternVoteCounter

private void doTransferInternToExternVoteCounter(Option[] intern,
                                                 Option[] extern)
This method transfers intern to extern Option array (=vote counter).
The intern counter will be looped and values will be transfered to extern counter by normal value setting methods.

Parameters:
intern - Option[] the lokal Option counter
extern - Option[] the extern Option counter
See Also:
Option.setValueKum(String), Option.setValueVote(String), Option.setCancellation(String), Go to Code

getMainVotes

private Vote[] getMainVotes(java.lang.String vote)
This method captures from one decrypted vote String the id and values of the voted main options.

A vote String contains "v" elements that are representing the voted main options. Within these elements an "i" and "val" tag symbolising the voted main option id ("i") and the voted value "val" which could be a positive number (possibly a cumulation) or a strike out represented by a -1.

First a XmlParser object with "v" will be created with an amount of 150 appearences. That means one vote can contain a max. of 150 votes. The real amount of votes will be identified by th getNumOfElements() method. So a Vote[] array with this amount will be established and filled with values captured from an loop of "v" elements. Within these "v" elements XmlParser objects with "i" and "val" will be created and put in a Vote[] array element by setId(i.getString()) and setNumber(val.getString()) methods. So the getString() method captures "i" and "val" elements from XmlParser objects and the set methods put values into the array element. At the end of the loop the Vote[] array is returned.

Parameters:
vote - a vote String
Returns:
array with main votes
See Also:
XmlParser, XmlParser.getNumOfElements(), XmlParser.getString(int), Vote.setId(String), Vote.setNumber(String), Go to Code

getSubVotes

private Vote[] getSubVotes(java.lang.String vote)
This method captures from one decrypted vote String the id and values of the voted sub options.

A vote String contains "s" elements that are representing the voted sub options. Within these elements an "i" and "val" tag symbolising the voted sub option id ("i") and the voted value "val" which could be a positive number (possibly a cumulation) or a strike out represented by a -1.

First a XmlParser object with "s" will be created with an amount of 150 appearences. That means one vote can contain a max. of 150 votes. The real amount of votes will be identified by th getNumOfElements() method. So an Vote[] array with this amount will be established and filled with values captured from an loop of "s" elements. Within these "v" elements XmlParser objects with "i" and "val" will be created and put in a Vote[] array element by setId(i.getString()) and setNumber(val.getString()) methods. So the getString() method captures "i" and "val" elements from XmlParser objects and the set methods put values into the array element. At the end of the loop the Vote[] array is returned.

Parameters:
vote - a vote String
Returns:
array with sub votes
See Also:
XmlParser, XmlParser.getNumOfElements(), XmlParser.getString(int), Vote.setId(String), Vote.setNumber(String), Go to Code

doDecryption

private java.lang.String doDecryption(java.lang.String s)
This method is used to decrypt a given String.

Votes are in blocks encrypted. This encryption blocks are designated by a tag for robust processing.

First the crypter object is set with the decryption key by the getEncodeRSA() method So this method creates an XmlParser Object that contains all < Block > elements for a vote (inital assampution of 150 block elements for one vote). Real amount of block elements are captured from the getNumOfElements() method.

After that the block elements are looped and decrypted via the decode method and finally appended to an StringBuffer which is at the end of loop converted into a string.

If an error occurs during decryption the current program status code is sent to Errorhandler via the pushError(int) method. The Errorhandler class takes the error handling. A decryption error is an fatal error so that program will stop processing.

Following errors could occur (and will be catched):
  • no Block elements are set
  • NullPointerException -> if no tags to process
  • NumberFormatException -> if block tag contains no hex number
  • ArithmeticException -> if problems with the biginteger calculation occurs
  • RsaException -> see RSA class for more details

Parameters:
s - the String to be decrypted
Returns:
decrypted String
See Also:
RSAToString.doDecryption(String), KeyReader.getEncodeRSA(), XmlParser, XmlParser.getNumOfElements(), StringBuffer, Errorhandler.pushError(int), Go to Code

getContestIdentifier

public int getContestIdentifier(java.lang.String vote)
This method captures the ContestIdentifier from a given vote string .
This is useful because ContestIdentifier from Vote must be identical to that captured from option file.

A XmlParser objected is generated that will search the string parameter for an "id" tag. If found the String will be converted into an int (see Integer wrapper class) and returned.

Parameters:
vote - String which should contain the id tag
Returns:
int with the contest id, if not found 0 is returned
See Also:
XmlParser, Integer.valueOf(String), Integer.intValue(), Go to Code

getSignatureStatus

public int getSignatureStatus()
Getter method for signaturestatus of one(!!!) vote

Returns:
signaturestatus of a vote
See Also:
Go to Code

setSignatureStatus

public void setSignatureStatus(int n)
This method is used to set the signature status of one(!!!) vote

Parameters:
n - int with the signature status number
See Also:
signaturestatus, doCheckSigning(String,String), Go to Code

getVtrFromVote

public java.lang.String getVtrFromVote(java.lang.String vote)
This method captures the "VTR" content from a vote String.
"VTR" from "Vote" Tag and "VTokenRequest" from "Token" Tag must be identical else files seem to be corruped. A XmlParser objected is generated that will search the string parameter for an "VTR" tag. If found String will be returned, if not an error String is returned so that by comparison of "VTR" and VTokenRequest from token an error occurs (please refer to checkSign() method for more details).

Parameters:
vote - String
Returns:
vtr String
See Also:
#XmlParser, checkSign(String, String[]), Go to Code

getVTokenRequest

public java.lang.String getVTokenRequest(java.lang.String token)
This method captures the "VTokenRequest" content from a token String .
A XmlParser objected is generated that will search the string parameter for a "VTokenRequest" tag. If found String will be returned, if not an error String is returned.

Parameters:
token - String
Returns:
request String
See Also:
#XmlParser, Go to Code

getVTokenResponseServer

public java.lang.String getVTokenResponseServer(java.lang.String token)
This method captures the "VTokenResponseServer" content from a token String.
A XmlParser objected is generated that will search the string parameter for a "VTokenResponseServer" tag. If found String will be returned, if not an empty String is returned.

Parameters:
token - String
Returns:
response String
See Also:
#XmlParser, Go to Code

getVFTokenResponse

public java.lang.String getVFTokenResponse(java.lang.String token)
This method captures the "VFTokenResponse" content from a token String.
A XmlParser objected is generated that will search the string parameter for a "VFTokenResponse" tag. If found String will be returned, if not an empty String will be returned.

Parameters:
token - String
Returns:
response String
See Also:
#XmlParser, Go to Code

getServerSign

private java.lang.String[] getServerSign(java.lang.String token)
This method retrieves "VTokenRequest" and "VTokenResponseServer" string from a token.
Both tag elements are needed for checking server Signature. A specific token string contains at least 2 elements "VTokenRequest" and "VTokenResponseServer". First tag contains the hex string as plaintext, second contain "Block" tags which must be decoded with the public key from server (= Blind Signature Element from Server). If done this element must be equal to "VTokenRequest" and "VTR" from vote see getVtrFromVote(String). For more details to signature checking please refer to doCheckSigning(String,String).

First the method creates a String[] array for the two tag elements with inital values of "vtrs" and "ss". So if an error during element capturing occurs these two Strings are given back. So later in program process if elements are compared with that from vote an error occurs. Then 2 XmlParser objects (one for "VTokenRequest" and the other for "VTokenResponseServer") are generated. After that RSACryptString object is set with the Server Key by the getServerRSA() method.

Afterwards this method creates an XmParser Object which contains all Block elements from "VTokenResponseServer" (inital assampution of 150 Block elements for one tag). Real amount of block elements are captured from the getNumOfElements() method. After that the Block elements are looped and "sign checked" via the checkSign() method and finally appended to a StringBuffer which is at the end of loop converted into a string and put into the String array. The "VTokenRequest" tag will also be put into the array.

Errors will be catched and sent to Errorhandler via the pushError() method.

Parameters:
token - String of a vote
Returns:
String[] String[0] VTokenRequest content, String[1] VTokenResponseServer content
See Also:
XmlParser, XmlParser.getNumOfElements(), getVtrFromVote(String), doCheckSigning(String,String), RSAToString.doVerify(String), Errorhandler.pushError(int), Go to Code

getVerifierSign

private java.lang.String[] getVerifierSign(java.lang.String token)
This method retrieves "VTokenRequest" and "VFTokenResponse" string from a vote token.
Both tag elements are needed for checking verifier signature. A specific token string contains at least 2 elements "VTokenRequest" and "VTokenResponseServer" and in this case an addditional verifier element "VFTokenResponse". First tag contains the hex string as plaintext, third contain "Block" tags which must be decoded with the public key from verifier (= blind signature element from server). If done this element must be equal to "VTokenRequest" and "VTR" from vote see getVtrFromVote(String). For more details to signature checking please refer to doCheckSigning(String,String). Please note the second element VTokenResponseServer is handled in getServerSign()method

First the method creates a String[] array for the two tag elements with inital values of "vtrv" and "vs". So if an error during element capturing occurs this two Strings are given back. So later in program process if elements are compared with that from vote an error occurs. Then 2 XmlParser objects (one for "VTokenRequest" and the other for "VFTokenResponse") are generated. After that RSAToString object is set with the Server Key by the getServerRSA() method.

Afterwards this method creates an XmParser Object which contains all Block elements from "VFTokenResponse" (inital assampution of 150 Block elements for one tag). Real amount of block elements are captured from the getNumOfElements() method. After that the Block elements are looped and "sign checked" via the checkSign() method > and finally appended to a StringBuffer which is at the end of loop converted into a string and put into the String array. The "VTokenRequest" tag will also be put into array.

Errors will be catched and sent to Errorhandler via the pushError() method.

Parameters:
token - String of a vote
Returns:
String[] String[0] VTokenRequest content, String[1] VFTokenResponse content
See Also:
XmlParser, XmlParser.getNumOfElements(), getVtrFromVote(String), doCheckSigning(String,String), RSAToString.doVerify(String), Errorhandler.pushError(int), Go to Code

checkSign

private boolean checkSign(java.lang.String vtrvote,
                          java.lang.String[] sign)
This method checks the signature with help of the String.equals() method.
Following assumption must be met to assure a correct signature checking:



First method checks equality of "VTR" and "VTokenRequest". If false check fails otherwise an additional check of sameness with "VTR" (because of the first check it don't cares wheter to use the VTR or VTokenRequest Tag) and the Blind Signature Element "VTokenResponseServer from Server or/and if needed "VFTokenResponse" (Blind Signature Element from Verifier) is done.

Parameters:
vtrvote - String with vtr tag element from vote String
sign - String[0] VTokenRequest content, String[1] VTokenResponse/Server content
Returns:
true if signature is ok and false if not
See Also:
String.equals(Object), Go to Code

doCheckSigning

private int doCheckSigning(java.lang.String vote,
                           java.lang.String token)
This method calculates the signature status of one vote.
First it will be checked if there is a verfier needed hasverifier. If so there will be two booleans created with signature checks of server and verifier, else only one boolean with server signature checking will be created.
The boolean will be determined by the checkSign method. The needed tags from the both parameters vote and token String will be extracted by the getVtrFromVote(vote) and getServerSign(token)/getVerifierSign(token) and insert in the checkSign methods.

Following status codes are possible:

Parameters:
vote - String with vote of one person
token - String with token of one person
Returns:
int Status 0.. no errors, 1.. server has error verifier not set or true, 2.. verifier has an error server not set or true, 3.. both have an error
See Also:
hasverifier, getVtrFromVote(String), getVerifierSign(String), getServerSign(String), checkSign(String, String[]), Go to Code