Class KeyGenerator.ToFileThread

java.lang.Object
  |
  +--KeyGenerator.ToFileThread
All Implemented Interfaces:
java.lang.Runnable
Enclosing class:
KeyGenerator

public class KeyGenerator.ToFileThread
extends java.lang.Object
implements java.lang.Runnable

This inner class can be used by programs wich wants a progessbars, or wants to run the process as a thread The Thread version must be used like this: KeyGenerator outerClass = new KeyGenerator(); KeyGenerator.ToFileThread keyGenerator = null; keyGenerator = outerClass. new ToFileThread(); keyGenerator.toFile(fileName, keyLength); Thread generateKey = new Thread(keyGenerator); generateKey.start(); Then the program may access the percentComplete field


Field Summary
 int percentComplete
          Percent complete, for use with progressbars/etc..
 
Constructor Summary
KeyGenerator.ToFileThread()
          Initializes the KeyGenerator using SUN's SHA1PRNG algorithm
KeyGenerator.ToFileThread(java.lang.String algorithm, java.lang.String provider)
          Initializes the KeyGenerator using specified provider and algorithm
 
Method Summary
 void run()
          This method will be run by Thread.start() and takes care of the actual key generating proces
 void toFile(java.io.File file, int keyLength)
          This method sets the filename and keylength and MUST be called before Thread.start()
 void toFile(java.lang.String fileName, int keyLength)
          This method sets the filename and keylength and MUST be called before Thread.start()
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

percentComplete

public int percentComplete
Percent complete, for use with progressbars/etc..
Constructor Detail

KeyGenerator.ToFileThread

public KeyGenerator.ToFileThread()
                          throws java.security.NoSuchAlgorithmException,
                                 java.security.NoSuchProviderException
Initializes the KeyGenerator using SUN's SHA1PRNG algorithm
Parameters:
none -  
Throws:
java.security.NoSuchAlgorithmException - If algorithm is not found
java.security.NoSuchProviderException - If the provieder is not found

KeyGenerator.ToFileThread

public KeyGenerator.ToFileThread(java.lang.String algorithm,
                                 java.lang.String provider)
                          throws java.security.NoSuchAlgorithmException,
                                 java.security.NoSuchProviderException
Initializes the KeyGenerator using specified provider and algorithm
Parameters:
algorithm - The name of tha algorithm to use
provider - The name of the provider who provides the algorithm
Throws:
java.security.NoSuchAlgorithmException - If algorithm is not found
java.security.NoSuchProviderException - If the provieder is not found
Method Detail

toFile

public void toFile(java.lang.String fileName,
                   int keyLength)
            throws java.io.IOException,
                   java.io.FileNotFoundException
This method sets the filename and keylength and MUST be called before Thread.start()
Parameters:
fileName - file to write key to
keyLength - number of bytes to write
Shows - if the method was successful

toFile

public void toFile(java.io.File file,
                   int keyLength)
            throws java.io.IOException,
                   java.io.FileNotFoundException
This method sets the filename and keylength and MUST be called before Thread.start()
Parameters:
file - file to write key to
keyLength - number of bytes to write
Shows - if the method was successful

run

public void run()
This method will be run by Thread.start() and takes care of the actual key generating proces
Specified by:
run in interface java.lang.Runnable