me.edwards.des.demo
Class Submitter

java.lang.Object
  extended by me.edwards.des.demo.Submitter

public class Submitter
extends java.lang.Object

This class allows local Nodes to function without an Election Application. This class is purely used for demonstration purposes.

It handles submitting Ballots to a local Node for demonstration purposes.

Created on: Dec 30, 2015 at 2:01:45 PM

Author:
Matthew Edwards

Field Summary
private static java.util.HashMap<java.lang.String,java.security.interfaces.ECPublicKey> keys
           
 
Constructor Summary
Submitter()
           
 
Method Summary
static void generateDatabase(java.lang.String file, int users)
          Generates a database of key pairs for demonstration purposes.
static java.security.interfaces.ECPublicKey getKey(java.lang.String uuid)
          Returns the corresponding ECDSA Public Key for the specified UUID.
static void loadDatabase(java.lang.String file)
          Loads the "public.data" database located in the specified directory and loads it for demonstration purposes.
static void submit(java.lang.String file, Node node, java.lang.String[][] voteList, int duration)
          Submits Ballots to a local Node for demonstration purposes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

keys

private static final java.util.HashMap<java.lang.String,java.security.interfaces.ECPublicKey> keys
Constructor Detail

Submitter

public Submitter()
Method Detail

generateDatabase

public static void generateDatabase(java.lang.String file,
                                    int users)
                             throws java.io.IOException
Generates a database of key pairs for demonstration purposes. Two databases are created. "private.data" is created for the private keys and "public.data" is created for the public keys.

Parameters:
file - Directory in which to create databases
users - Number of users to generate data for
Throws:
java.io.IOException - Thrown if an IOException occurs during file writing

loadDatabase

public static void loadDatabase(java.lang.String file)
                         throws java.io.IOException
Loads the "public.data" database located in the specified directory and loads it for demonstration purposes. The keys stored in the database will be used to authenticate Ballots.

Parameters:
file - Directory in which to load the "public.data" database file
Throws:
java.io.IOException - Thrown if an IOException occurs during file reading

submit

public static void submit(java.lang.String file,
                          Node node,
                          java.lang.String[][] voteList,
                          int duration)
                   throws java.io.IOException
Submits Ballots to a local Node for demonstration purposes.

Parameters:
file - Directory in which to load the "private.data" database file
node - Local Node to submit Ballots to
voteList - An array representing a list of Vote IDs, each containing list of possible Votes for that Vote ID
duration - The total amount of time to be taken, in milliseconds
Throws:
java.io.IOException - Thrown if an IOException occurs during file reading

getKey

public static java.security.interfaces.ECPublicKey getKey(java.lang.String uuid)
Returns the corresponding ECDSA Public Key for the specified UUID.

Parameters:
uuid - UUID of the Ballot
Returns:
If the UUID exists, the ECDSA Public Key is returned, otherwise null is returned.