/*
* Runner.java
*
* Created on July 5, 2003, 7:30 AM
*/
package tk.teutoburgo.otp4u.gui;
import java.io.*;
import tk.teutoburgo.otp4u.application.OTP4U;
/**
*
* @author Karl Dinwiddie
*/
public class Runner
implements Runnable {
public static final short DO_ENCRYPT = 0;
public static final short DO_DECRYPT = 1, GENERATE=2, GK4K0=3,
PUBLIC=4, RANDOM=5, MIX=6, SEPARATE=7;
private RunListener runListener;
public static OTP4U otp4u = new OTP4U(OTP4U.GUI_TRUE);
private int nextAction;
/** Creates a new instance of Runner */
public Runner(RunListener newRunListener) {
runListener = newRunListener;
}
return messages.toString();
}
public void setNextAction(short action) {
nextAction = action;
}
public void run() {
synchronized(this) {
try {
runListener.log("Using configuration file:" + runListener.getConfigFile().getCanonicalPath());
OTP4U.setConfigFile(runListener.getConfigFile());
switch (nextAction) {
case DO_ENCRYPT:
otp4u.doEncryption(runListener.getTargetFile().getCanonicalPath());
runListener.log("Encryption completed.");
break;
case DO_DECRYPT:
otp4u.doDecryption(runListener.getTargetFile().getCanonicalPath());
runListener.log("Decryption completed.");
break;
case GENERATE:
otp4u.generateEntropyFile();
runListener.log("Entropy source generated.");
break;
case GK4K0:
otp4u.generateK4K0File();
runListener.log("K4K0 generated.");
break;
case PUBLIC:
otp4u.writePublicKey();
runListener.log("Public key generated.");
break;
case RANDOM:
otp4u.writeRandomKey();
runListener.log("Random key generated.");
break;
case MIX:
otp4u.mixGUI(runListener.getTargetFile().getCanonicalPath());
runListener.log("Mixed key generated.");
break;
case SEPARATE:
otp4u.separate();
runListener.log("Key and ciphertext.dat files generated.");
break;
}
runListener.handleThrowable(t);
}
System.
out.
println("notifyall");
notifyAll();
}
}
public interface RunListener {
public File getConfigFile
();
public File getTargetFile
();
}
}