issrg.SAWS
Class LogFileWriter

java.lang.Object
  extended byissrg.SAWS.LogFileWriter

public class LogFileWriter
extends java.lang.Object

Author:
W.Xu

Field Summary
 byte[] accumulatedHash
           
 int currentRecordWriteCount
           
 byte[] finalSignature
           
 
Constructor Summary
LogFileWriter()
          This method is the constructor of LogFileWriter.
LogFileWriter(java.lang.String root, java.lang.String cLogFilename, java.security.PublicKey vt, java.security.PublicKey sawsEncPK, java.security.PrivateKey sawsSignPIK, byte[] ba, java.lang.String sAlgName, byte[] secureBytes, java.util.Map UserIDPKMap)
          This method is the constructor of LogFileWriter.
 
Method Summary
 void createLastFileRecord(java.lang.String lastFilename, byte[] lastAccHash, byte[] lastSignature)
          This method is to generate the record body of a last log file record.
 void createSAWSRecord(byte[] messageBlock, byte recordType, byte encryptionFlag)
          This method is to create a SAWS Record .
 void createSAWSRecord(byte[] messageBlock, byte recordType, byte userID, byte encryptionFlag)
          This method is to create a SAWS Record .
 void createSAWSRecord(byte[] messageBlock, byte recordType, byte userID, byte encryptionFlag, java.security.PublicKey encryptionPublicKey)
          This method is to create a SAWS Record .
 void finalizeLogFile()
          This method is called to finalize the log file, i.e. write the accumulated hash and the signature to the log file.
 byte[] getAccHash()
          This method is to get the final accumualted hash
 int getCurrentRecordWriteCount()
          This method is to get the current writing record number in the current log file
 byte[] getSignature()
          This method is to get the final signature
 int prepareNewLog()
          This method creates a new log file, prepares this file for adding new log records to it in the future.
 int repairLog(java.lang.String logRoot, java.lang.String logFilename, byte[] secureRandomB, logReadingException e)
          This method is to repair a log file.
 void setDebugLevel(int debugLevel)
           
 void writeSignatureRecord()
          This method is called to write a signature record to the log file after initialisation is finished.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentRecordWriteCount

public int currentRecordWriteCount

accumulatedHash

public byte[] accumulatedHash

finalSignature

public byte[] finalSignature
Constructor Detail

LogFileWriter

public LogFileWriter()
This method is the constructor of LogFileWriter.


LogFileWriter

public LogFileWriter(java.lang.String root,
                     java.lang.String cLogFilename,
                     java.security.PublicKey vt,
                     java.security.PublicKey sawsEncPK,
                     java.security.PrivateKey sawsSignPIK,
                     byte[] ba,
                     java.lang.String sAlgName,
                     byte[] secureBytes,
                     java.util.Map UserIDPKMap)
This method is the constructor of LogFileWriter.

Parameters:
root - String is the log root
cLogFilename - is the log file name to be written
vt - is the SAWS VT public key
sawsEncPK - is the SAWS encryption public key
sawsSignPIK - is the SAWS signing private key
ba - is the binary array of the SAWS signing public key certificate to be written into the log file
sAlgName - is the signing algorithem name
secureBytes - is the secure random number used for secure hashing
Method Detail

setDebugLevel

public void setDebugLevel(int debugLevel)

getSignature

public byte[] getSignature()
This method is to get the final signature


getAccHash

public byte[] getAccHash()
This method is to get the final accumualted hash


getCurrentRecordWriteCount

public int getCurrentRecordWriteCount()
This method is to get the current writing record number in the current log file


prepareNewLog

public int prepareNewLog()
This method creates a new log file, prepares this file for adding new log records to it in the future.


createLastFileRecord

public void createLastFileRecord(java.lang.String lastFilename,
                                 byte[] lastAccHash,
                                 byte[] lastSignature)
This method is to generate the record body of a last log file record.

Parameters:
lastFilename - the file name of the previous log file
lastAccHash - the accumulated hash of the previous log file
lastSignature - the signature of the previous log file
Returns:
byte[] the block of the lastFileRecord

createSAWSRecord

public void createSAWSRecord(byte[] messageBlock,
                             byte recordType,
                             byte encryptionFlag)
This method is to create a SAWS Record . It is a simplied invoke method of the following method.

Returns:
bytes of the record body.

createSAWSRecord

public void createSAWSRecord(byte[] messageBlock,
                             byte recordType,
                             byte userID,
                             byte encryptionFlag)
This method is to create a SAWS Record . It is a simplied invoke method of the following method.

Returns:
bytes of the record body.

createSAWSRecord

public void createSAWSRecord(byte[] messageBlock,
                             byte recordType,
                             byte userID,
                             byte encryptionFlag,
                             java.security.PublicKey encryptionPublicKey)
This method is to create a SAWS Record .

Parameters:
messageBlock - log data block (here it is the secret random number to be wrapped into a record.
recordType - record type
userID - user ID
encryptionFlag - encryption flag to indicate the encryption requirement.
encryptionPublicKey - the encryption public key used for assymmetric encryption. This could be the VT enc public key, or the SAWS enc public key
Returns:
bytes of the record body.

repairLog

public int repairLog(java.lang.String logRoot,
                     java.lang.String logFilename,
                     byte[] secureRandomB,
                     logReadingException e)
This method is to repair a log file. Its main input is logReadingException e.

Parameters:
logRoot - the log root
logFilename - the log filename to be repaired.
secureRandomB - byte[] is the secure random bytes for this log file
Returns:
int. 0 for success, -1 for failure.

finalizeLogFile

public void finalizeLogFile()
This method is called to finalize the log file, i.e. write the accumulated hash and the signature to the log file.


writeSignatureRecord

public void writeSignatureRecord()
This method is called to write a signature record to the log file after initialisation is finished.