: Class DBase

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## Free
Class DBase

    java.lang.Object
      |
      +--Free.DBase

public class DBase
extends java.lang.Object

DBase creates databases, tables and interacts with these through JDBC and SQL. Implementation of the databases is with Hypersonic SQL which is written totally in Java. The logic for calculating totals is also performed in this class.

Version:
  1.8 27 October 2001
Author:
  Jason Kitcat

Field Summary
`protected static java.lang.String` | `cryptword`

Constructor Summary
`DBase()`

Method Summary
`protected static int` | `authKeyCheck(java.lang.String key2)` This method retrieves stored `AuthKeys` (encrypted with secret key 1) decrypts them and then compares with the decrypted `AuthKey` delivered with the vote (originally encrypted with secret key 2).
`protected static void` | `calcResult()` analyses the totals to create the final results for the vote.
`protected static java.lang.String` | `decrypt(java.lang.String data)` Decrypts data pulled from the database returning normal strings.
`protected static void` | `doSQL(java.lang.String sqlCommand)` executes the SQL command sent as a parameter and returns the result to DB Console.
`protected static java.util.Vector` | `getTotals()` analyses votes to create data for total packets.
`protected static void` | `importKeys()` Imports keys from the `ERServer`, decrypts them and then inserts them into `AuthKeys` table.
`protected static void` | `init()` initialises the Hypersonic SQL database.
`protected static boolean` | `isSafe(java.lang.String input)` checks String input to make sure it only contains safe characters.
`protected static boolean` | `removeKey(java.lang.String akey)` Removes key from database once used for security + vote confirmation
`protected static void` | `storeTotal(Packet total_input)` adds a total entry to the database.
`protected static void` | `storeVote(java.lang.String data)` adds a vote entry to the database.
`protected static void` | `verCheck(int ERtotal)` Checks the number of votes registered against what ERServer reported.

Methods inherited from class java.lang.Object
`, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### cryptword

    protected static java.lang.String cryptword

Constructor Detail

### DBase

    public DBase()

Method Detail

### init

    protected static void init()

  initialises the Hypersonic SQL database.

### decrypt

    protected static java.lang.String decrypt(java.lang.String data)
                                       throws java.lang.Exception

  Decrypts data pulled from the database returning normal strings.
  Parameters:
    `data` - The encrypted string

### isSafe

    protected static boolean isSafe(java.lang.String input)
                             throws java.lang.Exception

  checks String input to make sure it only contains safe characters. It's not pretty but regular expression packages tried all were far too slow.
  Parameters:
    `input` - The String to check

### storeVote

    protected static void storeVote(java.lang.String data)
                             throws java.lang.Exception

  adds a vote entry to the database.
  Parameters:
    `data` - The string representing the party to insert

### storeTotal

    protected static void storeTotal(Packet total_input)
                              throws java.lang.Exception

  adds a total entry to the database.
  Parameters:
    `data` - The string representing the total data to inser

### calcResult

    protected static void calcResult()
                              throws java.lang.Exception

  analyses the totals to create the final results for the vote.

### getTotals

    protected static java.util.Vector getTotals()
                                         throws java.lang.Exception

  analyses votes to create data for total packets.

### removeKey

    protected static boolean removeKey(java.lang.String akey)

  Removes key from database once used for security + vote confirmation
  Parameters:
    `akey` - The key to remove

### authKeyCheck

    protected static int authKeyCheck(java.lang.String key2)
                               throws java.lang.Exception

  This method retrieves stored `AuthKeys` (encrypted with secret key 1) decrypts them and then compares with the decrypted `AuthKey` delivered with the vote (originally encrypted with secret key 2). If a match is found then the AuthKey encrypted with secret key 1 is sent to the ERServer. On confirmation it is removed from the database here. This impacts performance - it could have been simply done as a SELECT statement if the keys weren't stored encrypted, however I feel this is a necessary security precaution especially when the security of the database is not known in our db independent setup. Note that since 1.5 all db data is encrypted. Thus keys are twice encrypted.
  Parameters:
    `data` - The string representing the party to insert

### importKeys

    protected static void importKeys()
                              throws java.lang.Exception

  Imports keys from the `ERServer`, decrypts them and then inserts them into `AuthKeys` table.

### verCheck

    protected static void verCheck(int ERtotal)
                            throws java.lang.Exception

  Checks the number of votes registered against what ERServer reported.
  Parameters:
    `ERtotal` - What the ERServer returned

### doSQL

    protected static void doSQL(java.lang.String sqlCommand)

  executes the SQL command sent as a parameter and returns the result to DB Console.
  Parameters:
    `sqlCommand` - A string containing SQL

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD