DigiStamp.com

dgs.tlkt.demo
Class CreateTimeStamp

java.lang.Object
  extended bydgs.tlkt.demo.CreateTimeStamp

public class CreateTimeStamp
extends java.lang.Object

Time stamping the contents of a file and save the new time stamp to disk. Internet communication to the DigiStamp server is performed as part of the processing.

This source code is include with the SecureTime toolkit distribution.

Given a file name, the process performs:

  1. calculate SHA-1 hash of the contents
  2. Construct a time stamp request
  3. Internet communcation to the time stamp server
  4. Verify the time stamp signature
  5. Verify the certficate trust
  6. writes the time stamp to disk


Field Summary
 java.io.PrintStream myOut
          where should the output go.
 boolean verbose
          detailed output ?
 
Constructor Summary
CreateTimeStamp(boolean verbose, java.io.PrintStream myOut)
          Create a processing instance.
 
Method Summary
 boolean compareResponse(CMSTsToken cms, TsRequest tsr)
          Did we get the expected data in the time stamp server response?
 boolean createTSofFile(java.lang.String fileToTimestamp, java.lang.String outFileName)
          This method demonstrates time stamping the contents of a file.
static void main(java.lang.String[] args)
          Execute the demo from a command line.
 boolean runDemo(java.lang.String fileToTimestamp, java.lang.String outFileName)
          A demostration of time stamp the content of a file.
 void setupConfig(java.lang.String account, java.lang.String pswd)
          Set your Internet communications preferences.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myOut

public java.io.PrintStream myOut
where should the output go. Default is "System.out".


verbose

public boolean verbose
detailed output ? default = false

Constructor Detail

CreateTimeStamp

public CreateTimeStamp(boolean verbose,
                       java.io.PrintStream myOut)
Create a processing instance.

See Also:
main(String[]), createTSofFile(String,String)
Method Detail

compareResponse

public boolean compareResponse(CMSTsToken cms,
                               TsRequest tsr)
Did we get the expected data in the time stamp server response?

Parameters:
cms - dgs.tlkt.CMSTsToken
Returns:
boolean

createTSofFile

public boolean createTSofFile(java.lang.String fileToTimestamp,
                              java.lang.String outFileName)
                       throws ExceptionDgs,
                              java.security.NoSuchAlgorithmException,
                              java.io.IOException,
                              java.lang.InterruptedException
This method demonstrates time stamping the contents of a file. The process is to create a time stamp request, communication with the Internet time stamp server and verify the accuracy of the response.

The configuration of Internet communications should have already been performed (@link #setupConfig(String, String))

Parameters:
fileToTimestamp - java.lang.String
outFileName - java.lang.String
Throws:
ExceptionDgs
java.security.NoSuchAlgorithmException
java.io.IOException
java.lang.InterruptedException

main

public static void main(java.lang.String[] args)
Execute the demo from a command line. Enter:
  1. account number
  2. password
  3. input file name that will be time stamped
  4. (optional) output file name of the time stamp

See Also:
for details

runDemo

public boolean runDemo(java.lang.String fileToTimestamp,
                       java.lang.String outFileName)
                throws java.security.cert.CertificateEncodingException,
                       java.security.GeneralSecurityException,
                       ExceptionDgs,
                       java.security.NoSuchAlgorithmException,
                       java.io.IOException,
                       java.lang.InterruptedException
A demostration of time stamp the content of a file. The configuration of Internet communications should have already been performed

Parameters:
fileToTimestamp - input file that will be time stamped
outFileName - output file for the time stamp
Throws:
java.security.cert.CertificateEncodingException
java.security.GeneralSecurityException
ExceptionDgs
java.security.NoSuchAlgorithmException
java.io.IOException
java.lang.InterruptedException
See Also:
setupConfig(String, String)

setupConfig

public void setupConfig(java.lang.String account,
                        java.lang.String pswd)
Set your Internet communications preferences. Determines which time stamp server to access, the failover policy and account information. You should only need to do this once for 1 or more time stamp requests. Load the configuration from a file. Passing null causes to attempt to use the default file name (dgsToolkit.ini). Or, you can specify a different file name that has your configuration. If no file is found, then will be using the defaults. An example configuration file with these values:
 
  
   
   	 listOfServers.0 = tsatest1
   	 listOfServers.1 = tsatest2
   	 
   
  
 
With the above values, then all other configurations items use the defaults. Please see the Javadoc for the class DgsConfig to review the defaults.

Parameters:
account - - your account number at DigiStamp
pswd - - your account password

Copyright 2000-2010 DigiStamp, Inc.