org.tranche.flatfile
Class NonceMap

java.lang.Object
  extended by org.tranche.flatfile.NonceMap

public class NonceMap
extends java.lang.Object

An abstraction to track nonces on the server-side. It will also ensure that the same nonce isn't being used twice during operation of the server.

Author:
Bryan Smith - bryanesmith@gmail.com, Jayson Falkner - jfalkner@umich.edu, James "Augie" Hill - augman85@gmail.com

Field Summary
static int DEFAULT_MAX_NONCES
          Default maximum number of nonces to store in memory.
static int NONCE_BYTES
          Size of nonce in bytes
 
Constructor Summary
NonceMap(FlatFileTrancheServer trancheServer)
           
NonceMap(RoutingTrancheServer trancheServer)
           
 
Method Summary
 boolean contains(byte[] nonce)
          Check to see whether the nonce bytes are valid.
 int getMaximumSize()
          Get maximum size of NonceMap.
 byte[] newNonce()
          Create a new nonce.
 void remove(byte[] nonce)
          Remove nonce from collection of valid nonces.
 void setMaximumSize(int maxSize, java.security.cert.X509Certificate cert, java.security.PrivateKey key)
          Sets the maximum size in the Configuration for the FlatFileTrancheServer.
 int size()
          Total number of nonces currently in collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NONCE_BYTES

public static final int NONCE_BYTES
Size of nonce in bytes

See Also:
Constant Field Values

DEFAULT_MAX_NONCES

public static final int DEFAULT_MAX_NONCES

Default maximum number of nonces to store in memory.

See Also:
Constant Field Values
Constructor Detail

NonceMap

public NonceMap(FlatFileTrancheServer trancheServer)

NonceMap

public NonceMap(RoutingTrancheServer trancheServer)
Method Detail

contains

public boolean contains(byte[] nonce)

Check to see whether the nonce bytes are valid.

Parameters:
nonce - the nonce bytes
Returns:
true if the hash map contains the nonce bytes; false otherwise

newNonce

public byte[] newNonce()

Create a new nonce.

Returns:
nonce bytes

getMaximumSize

public int getMaximumSize()

Get maximum size of NonceMap. Note this is always up to date because checks FlatFileTrancheServer's configuration, so don't call too often.

There's an private version of this method, getMethodSizeInternal, that uses a cached version to save time.

Returns:

setMaximumSize

public void setMaximumSize(int maxSize,
                           java.security.cert.X509Certificate cert,
                           java.security.PrivateKey key)
                    throws java.lang.Exception

Sets the maximum size in the Configuration for the FlatFileTrancheServer.

Parameters:
maxSize -
cert -
key -
Throws:
java.lang.Exception

remove

public void remove(byte[] nonce)

Remove nonce from collection of valid nonces.

Parameters:
nonce - the nonce bytes to remove from the collection

size

public int size()

Total number of nonces currently in collection.

Returns:


This code is free for use both commercially and non-commercially as stated in the project's license