org.iids.aos.kernel.ac
Class TOCSerialiser

java.lang.Object
  extended by org.iids.aos.kernel.ac.TOCSerialiser

public class TOCSerialiser
extends java.lang.Object

This class serialises a TOC in accordance with the AOS kernel's encoding rules. It makes use of the XDR definitions of the TOC and the TOC entry.

Author:
Patrick Verkaik

Field Summary
static int SERIALISED_ENTRY_SIZE
          The number of additional bytes required for serialising a TOC entry.
static int SERIALISED_OVERHEAD
          The number of bytes required for serialising a TOC of 0 entries.
 
Constructor Summary
TOCSerialiser()
          Constructs a TOCSerialiser with zero entries.
 
Method Summary
 void addNonSpecialTOCEntry(TOCEntry entry, byte[] digest)
          Adds a TOC entry to the current set of TOC entries.
 void addSpecialTOCEntry(TOCEntry entry)
           
 void done(boolean sign, java.security.PrivateKey privateKey)
          Called when all TOC entries have been added.
 byte[] getSerialised()
          Returns the buffer holding serialised TOC.
 int getSerialisedLength()
          Returns the length of the serialised TOC.
 byte[] getSignature()
          Returns the signature over the TOC.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SERIALISED_OVERHEAD

public static final int SERIALISED_OVERHEAD
The number of bytes required for serialising a TOC of 0 entries.


SERIALISED_ENTRY_SIZE

public static final int SERIALISED_ENTRY_SIZE
The number of additional bytes required for serialising a TOC entry.

Constructor Detail

TOCSerialiser

public TOCSerialiser()
Constructs a TOCSerialiser with zero entries.

Method Detail

addNonSpecialTOCEntry

public void addNonSpecialTOCEntry(TOCEntry entry,
                                  byte[] digest)
Adds a TOC entry to the current set of TOC entries. Each parameter is a field in the new TOC entry, and is defined by the XDR description.


addSpecialTOCEntry

public void addSpecialTOCEntry(TOCEntry entry)

done

public void done(boolean sign,
                 java.security.PrivateKey privateKey)
          throws java.io.IOException
Called when all TOC entries have been added. Signs the whole of the serialised TOC and makes the serialised TOC and its signature available for retrieval through getSerialised() and getSignature().

Parameters:
sign - whether to sign or not (performance measurements)
privateKey - the private key to use for signing
Throws:
java.io.IOException - if a serialisation error occurred

getSerialised

public byte[] getSerialised()
Returns the buffer holding serialised TOC. NOTE: may be larger than getSerialisedLength().


getSerialisedLength

public int getSerialisedLength()
Returns the length of the serialised TOC.


getSignature

public byte[] getSignature()
Returns the signature over the TOC.



Copyright © 2003, 2004 IIDS Group. All Rights Reserved.