ePOST API

rice.post.storage
Class SignedData

java.lang.Object
  extended by rice.post.storage.SignedData
All Implemented Interfaces:
java.io.Serializable, GCPastContent, PastContent

public class SignedData
extends java.lang.Object

This class is used internally by the storage package to store data that is signed.

Version:
$Id: SignedData.java 2326 2005-03-14 23:04:14Z amislove $
See Also:
Serialized Form

Field Summary
protected  byte[] data
           
protected  Id location
           
static long NO_VERSION
           
protected  byte[] signature
           
protected  byte[] timestamp
           
 
Constructor Summary
SignedData(Id location, byte[] data, byte[] timestamp)
          Builds a SignedData for a byte array given a timestamp.
 
Method Summary
 PastContent checkInsert(Id id, PastContent existingContent)
          Checks if a insert operation should be allowed.
 boolean equals(java.lang.Object o)
          Force subclasses to override equals
 byte[] getData()
          Returns the internal array of data
 byte[] getDataAndTimestamp()
           
 GCPastContentHandle getHandle(GCPast local, long expiration)
          Produces a handle for this content object.
 PastContentHandle getHandle(Past local)
          Produces a handle for this content object.
 Id getId()
          Returns the location of this data
 GCPastMetadata getMetadata(long expiration)
          Returns the metadata which should be stored with this object.
 byte[] getSignature()
           
 byte[] getTimestamp()
          Returns the internal timestamp of this version
 long getVersion()
          Returns the version number of this object
 boolean isMutable()
          States if this content object is mutable.
protected  void setSignature(byte[] sig)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

timestamp

protected transient byte[] timestamp

signature

protected transient byte[] signature

NO_VERSION

public static final long NO_VERSION
See Also:
Constant Field Values

data

protected transient byte[] data

location

protected Id location
Constructor Detail

SignedData

public SignedData(Id location,
                  byte[] data,
                  byte[] timestamp)
Builds a SignedData for a byte array given a timestamp. The signature is the hash of the timestamp appended to the byte array, signed with the user's private key.

Parameters:
data - The data to store
time - The timestamp
credentials - Credentials of the data
Method Detail

getTimestamp

public byte[] getTimestamp()
Returns the internal timestamp of this version

Returns:
The timestamp when the data was stored

getDataAndTimestamp

public byte[] getDataAndTimestamp()
Returns:
The data and timestamp appended

getSignature

public byte[] getSignature()
Returns:
The signature to verify the data and timestamp

setSignature

protected void setSignature(byte[] sig)

equals

public boolean equals(java.lang.Object o)
Force subclasses to override equals

Returns:
Whether this and o are equal

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

checkInsert

public PastContent checkInsert(Id id,
                               PastContent existingContent)
                        throws PastException
Checks if a insert operation should be allowed. Invoked when a Past node receives an insert request and it is a replica root for the id; invoked on the object to be inserted. This method determines the effect of an insert operation on an object that already exists: it computes the new value of the stored object, as a function of the new and the existing object.

Parameters:
id - the key identifying the object
newObj - the new object to be stored
existingObj - the existing object stored on this node (null if no object associated with id is stored on this node)
Returns:
null, if the operation is not allowed; else, the new object to be stored on the local node.
Throws:
PastException

isMutable

public boolean isMutable()
States if this content object is mutable. Mutable objects are not subject to dynamic caching in Past.

Returns:
true if this object is mutable, else false

getVersion

public long getVersion()
Returns the version number of this object

Specified by:
getVersion in interface GCPastContent
Returns:
The version number

getMetadata

public GCPastMetadata getMetadata(long expiration)
Returns the metadata which should be stored with this object. Allows applications to add arbitrary items into the object's metadata.

Specified by:
getMetadata in interface GCPastContent
Parameters:
The - local GCPast service which the content is on.
Returns:
the handle

getId

public Id getId()
Returns the location of this data

Specified by:
getId in interface PastContent
Returns:
The location of this data.

getData

public byte[] getData()
Returns the internal array of data

Returns:
The byte array of actual data.

getHandle

public PastContentHandle getHandle(Past local)
Produces a handle for this content object. The handle is retrieved and returned to the client as a result of the Past.lookupHandles() method.

Specified by:
getHandle in interface PastContent
Parameters:
The - local Past service which the content is on.
Returns:
the handle

getHandle

public GCPastContentHandle getHandle(GCPast local,
                                     long expiration)
Produces a handle for this content object. The handle is retrieved and returned to the client as a result of the Past.lookupHandles() method.

Specified by:
getHandle in interface GCPastContent
Parameters:
The - local Past service which the content is on.
Returns:
the handle

ePOST API

Copyright © 2001-2005 - Rice Pastry.