ePOST API

rice.post.storage
Class StorageService

java.lang.Object
  extended by rice.post.storage.StorageService

public class StorageService
extends java.lang.Object

This class represents a service which stores data in PAST. This class supports two types of data: content-hash blocks and private-key signed blocks. This class will automatically format and store data, as well as retrieve and verify the stored data.

Version:
$Id: StorageService.java 2852 2005-12-16 16:04:27Z jstewart $

Field Summary
static int MAX_CONTENT_HASH_SIZE
           
protected  long timeoutInterval
          The default timeout period of objects (3 weeks)
 
Constructor Summary
StorageService(Endpoint endpoint, PostEntityAddress address, Past immutablePast, Past mutablePast, IdFactory factory, java.security.KeyPair keyPair, long timeoutInterval)
          Contructs a StorageService given a PAST to run on top of.
 
Method Summary
 void backupLogs(PostLog log, Log[] logs, Continuation command)
          This method backs up all of the provided logs by inserting them into the immutable store with appropriate version numbers.
 Id getRandomNodeId()
           
protected  long getTimeout()
          Internal method which returns what the timeout should be for an object inserted now.
 byte[][] partition(byte[] array)
          Method which partitions a serialized object into acceptable size arrays - currently, it just splits the array into a bunch of arrays of size MAX_CONTENT_HASH_SIZE or less.
static void recoverLogs(Id location, long timestamp, java.security.KeyPair keyPair, Past immutablePast, Past mutablePast, Continuation command, Environment env, Logger logger)
          This method performs an emergency recovery of the logs by reinserting them into the provided PAST store.
 void refreshContentHash(ContentHashReference[] references, Continuation command)
          This method "refreshes" a list of ContentHashReferences, which ensures that all of the referenced objects are not collected by the underlying store.
 void refreshSecure(SecureReference[] references, Continuation command)
          This method "refreshes" a list of SecureReferences, which ensures that all of the referenced objects are not collected by the underlying store.
 void retrieveAllSigned(SignedReference reference, Continuation command)
          This method retrieves a previously-stored block from PAST which was signed using the private key.
 void retrieveAndVerifySigned(SignedReference reference, Continuation command)
          This method retrieves a previously-stored private-key signed block from PAST.
 void retrieveAndVerifySigned(SignedReference reference, java.security.PublicKey publicKey, Continuation command)
          This method retrieves a previously-stored block from PAST which was signed using the private key matching the given public key.
 void retrieveContentHash(ContentHashReference reference, Continuation command)
          This method retrieves a given PostDataReference object from the network.
 void retrieveContentHashEntry(Id location, byte[] key, Continuation command)
          This method retrieves a single content hash entry and verifies it.
 void retrieveSecure(SecureReference reference, Continuation command)
          This method retrieves a given SecureReference object from the network.
 void retrieveSigned(SignedReference reference, Continuation command)
          This method retrieves a previously-stored block from PAST which was signed using the private key.
 void setAggregate(PostLog log, Continuation command)
          Method which sets the aggregate head, if we are using a Aggregation as the immutable past store.
 void storeContentHash(PostData data, Continuation command)
          Stores a PostData in the PAST storage system, in encrypted state, and returns a pointer and key to the data object.
 void storeContentHashEntry(byte[] plainText, Continuation command)
          Performs the actual content hashing and insertion of a single content has block.
 void storeSecure(PostData data, Continuation command)
          Stores a PostData in the PAST storage system, in encrypted state, and returns a pointer and key to the data object.
 void storeSigned(PostData data, Id location, Continuation command)
          Stores a PostData in the PAST store by signing the content and storing it at a well-known location.
protected static void storeSigned(PostData data, Id location, long time, long expiration, java.security.KeyPair keyPair, Past past, Continuation command)
          Stores a PostData in the PAST store by signing the content and storing it at a well-known location.
 boolean verifySigned(PostData data, java.security.PublicKey key)
          This method verifies a signed block of data with the given public key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_CONTENT_HASH_SIZE

public static int MAX_CONTENT_HASH_SIZE

timeoutInterval

protected long timeoutInterval
The default timeout period of objects (3 weeks)

Constructor Detail

StorageService

public StorageService(Endpoint endpoint,
                      PostEntityAddress address,
                      Past immutablePast,
                      Past mutablePast,
                      IdFactory factory,
                      java.security.KeyPair keyPair,
                      long timeoutInterval)
Contructs a StorageService given a PAST to run on top of.

Parameters:
past - The PAST service to use.
credentials - Credentials to use to store data.
keyPair - The keypair to sign/verify data with
Method Detail

getRandomNodeId

public Id getRandomNodeId()

getTimeout

protected long getTimeout()
Internal method which returns what the timeout should be for an object inserted now. Basically, does environment.getTimeSource().currentTimeMillis() + timeoutInterval.

Returns:
The default timeout period for an object inserted now

storeContentHash

public void storeContentHash(PostData data,
                             Continuation command)
Stores a PostData in the PAST storage system, in encrypted state, and returns a pointer and key to the data object. This first encrypts the PostData using it's hash value as the key, and then stores the ciphertext at the value of the hash of the ciphertext. Once the data has been stored, the command.receiveResult() method will be called with a ContentHashReference as the argument.

Parameters:
data - The data to store.
command - The command to run once the store has completed.

partition

public byte[][] partition(byte[] array)
Method which partitions a serialized object into acceptable size arrays - currently, it just splits the array into a bunch of arrays of size MAX_CONTENT_HASH_SIZE or less.

Parameters:
array - the array
Returns:
Splitted shaat

storeContentHashEntry

public void storeContentHashEntry(byte[] plainText,
                                  Continuation command)
Performs the actual content hashing and insertion of a single content has block. Returns an array containing the Id and byte[] key of the inserted object.

Parameters:
data - The data to store.
command - The command to run once the store has completed.

retrieveContentHash

public void retrieveContentHash(ContentHashReference reference,
                                Continuation command)
This method retrieves a given PostDataReference object from the network. This method also performs the verification checks and decryption necessary. Once the data has been stored, the command.receiveResult() method will be called with a PostData as the argument.

Parameters:
reference - The reference to the PostDataObject
command - The command to run once the store has completed.

retrieveContentHashEntry

public void retrieveContentHashEntry(Id location,
                                     byte[] key,
                                     Continuation command)
This method retrieves a single content hash entry and verifies it. The byte[] data is returned to the caller

Parameters:
reference - The reference to the PostDataObject
command - The command to run once the store has completed.

refreshContentHash

public void refreshContentHash(ContentHashReference[] references,
                               Continuation command)
This method "refreshes" a list of ContentHashReferences, which ensures that all of the referenced objects are not collected by the underlying store. This method should be invoked upon objects which the user is interested in, but the user did not create (i.e. The parts of an email the user has recevied).

Parameters:
references - The references to refresh
command - The command to run once done

backupLogs

public void backupLogs(PostLog log,
                       Log[] logs,
                       Continuation command)
This method backs up all of the provided logs by inserting them into the immutable store with appropriate version numbers.

Parameters:
references - The references to refresh
command - The command to run once done

recoverLogs

public static void recoverLogs(Id location,
                               long timestamp,
                               java.security.KeyPair keyPair,
                               Past immutablePast,
                               Past mutablePast,
                               Continuation command,
                               Environment env,
                               Logger logger)
This method performs an emergency recovery of the logs by reinserting them into the provided PAST store.


setAggregate

public void setAggregate(PostLog log,
                         Continuation command)
Method which sets the aggregate head, if we are using a Aggregation as the immutable past store.

Parameters:
log - The log to set the aggregate in

storeSigned

public void storeSigned(PostData data,
                        Id location,
                        Continuation command)
Stores a PostData in the PAST store by signing the content and storing it at a well-known location. This method also includes a timestamp, which dates this update. Once the data has been stored, the command.receiveResult() method will be called with a SignedReference as the argument.

Parameters:
data - The data to store
location - The location where to store the data
command - The command to run once the store has completed.

storeSigned

protected static void storeSigned(PostData data,
                                  Id location,
                                  long time,
                                  long expiration,
                                  java.security.KeyPair keyPair,
                                  Past past,
                                  Continuation command)
Stores a PostData in the PAST store by signing the content and storing it at a well-known location. This method also includes a timestamp, which dates this update. Once the data has been stored, the command.receiveResult() method will be called with a SignedReference as the argument. Calling this method does not verify the signed contents after storage. If you need verification you will have to call retrieveAndVerifySigned yourself.

Parameters:
data - The data to store
location - The location where to store the data
command - The command to run once the store has completed.

retrieveAndVerifySigned

public void retrieveAndVerifySigned(SignedReference reference,
                                    Continuation command)
This method retrieves a previously-stored private-key signed block from PAST. This method also does all necessary verification checks and fetches the content from multiple locations in order to prevent version-rollback attacks. Once the data has been stored, the command.receiveResult() method will be called with a PostData as the argument.

Parameters:
location - The location of the data
command - The command to run once the store has completed.

retrieveAndVerifySigned

public void retrieveAndVerifySigned(SignedReference reference,
                                    java.security.PublicKey publicKey,
                                    Continuation command)
This method retrieves a previously-stored block from PAST which was signed using the private key matching the given public key. This method also does all necessary verification checks and fetches the content from multiple locations in order to prevent version-rollback attacks. Once the data has been stored, the command.receiveResult() method will be called with a PostData as the argument.

Parameters:
location - The location of the data
publicKey - The public key matching the private key used to sign the data
command - The command to run once the store has completed.

retrieveSigned

public void retrieveSigned(SignedReference reference,
                           Continuation command)
This method retrieves a previously-stored block from PAST which was signed using the private key. THIS METHOD EXPLICITLY DOES NOT PERFORM ANY VERIFICATION CHECKS ON THE DATA. YOU MUST CALL verifySigned() IN ORDER TO VERIFY THE DATA. This is provided for the case where the cooresponding key is located in the data. Once the data has been stored, the command.receiveResult() method will be called with a PostData as the argument.

Parameters:
location - The location of the data
command - The command to run once the store has completed.

retrieveAllSigned

public void retrieveAllSigned(SignedReference reference,
                              Continuation command)
This method retrieves a previously-stored block from PAST which was signed using the private key. THIS METHOD EXPLICITLY DOES NOT PERFORM ANY VERIFICATION CHECKS ON THE DATA. YOU MUST CALL verifySigned() IN ORDER TO VERIFY THE DATA. This is provided for the case where the cooresponding key is located in the data. Once the data has been stored, the command.receiveResult() method will be called with an array of PostData and Exceptions as the argument.

Parameters:
location - The location of the data
command - The command to run once the store has completed.

verifySigned

public boolean verifySigned(PostData data,
                            java.security.PublicKey key)
This method verifies a signed block of data with the given public key.

Parameters:
data - The data
key - The public key to verify the data against
Returns:
Whether the key matches the data

storeSecure

public void storeSecure(PostData data,
                        Continuation command)
Stores a PostData in the PAST storage system, in encrypted state, and returns a pointer and key to the data object. This method first generates a random key, uses this key to encrypt the data, and then stored the data under the key of it's content-hash. Once the data has been stored, the command.receiveResult() method will be called with a SecureReference as the argument.

Parameters:
data - The data to store.
command - The command to run once the store has completed.

retrieveSecure

public void retrieveSecure(SecureReference reference,
                           Continuation command)
This method retrieves a given SecureReference object from the network. This method also performs the verification checks and decryption necessary. Once the data has been stored, the command.receiveResult() method will be called with a PostData as the argument.

Parameters:
reference - The reference to the PostDataObject
command - The command to run once the store has completed.

refreshSecure

public void refreshSecure(SecureReference[] references,
                          Continuation command)
This method "refreshes" a list of SecureReferences, which ensures that all of the referenced objects are not collected by the underlying store. This method should be invoked upon objects which the user is interested in, but the user did not create (i.e. The parts of an email the user has recevied).

Parameters:
references - The references to refresh
command - The command to run once done

ePOST API

Copyright © 2001-2005 - Rice Pastry.