[Webfunds-commits] java/webfunds/client/contracts/wizard SignContractWizardPanel.java ContractEdit.java ContractFile.java FinishEnd.java FinishSig.java KeyContract.java KeyServer.java KeyTop.java WizardPanel.java KeyPanel.java
Edwin Woudt
edwin@cypherpunks.ai
Mon, 28 Aug 2000 09:02:33 -0400 (AST)
edwin 00/08/28 09:02:33
Modified: webfunds/client/contracts/wizard ContractEdit.java
ContractFile.java FinishEnd.java FinishSig.java
KeyContract.java KeyServer.java KeyTop.java
WizardPanel.java
Added: webfunds/client/contracts/wizard
SignContractWizardPanel.java
Removed: webfunds/client/contracts/wizard KeyPanel.java
Log:
Cosmetical changes:
- Remove KeyPanel as it had no function anymore.
- Split methods that are specific to the sign contract wizard out of
WizardPanel into SignContractWizardPanel and let all panels extend
from the second one.
- Rename loadString method to loadStringFromFile.
- Remove some debugging code.
- Remove commented out code.
- Fix JavaDoc comments to proper JavaDoc format (one short descriptive,
followed by a blank line and then zero or more paragraphs enclosed
within <p> and </p>.
Revision Changes Path
1.4 +3 -3 java/webfunds/client/contracts/wizard/ContractEdit.java
Index: ContractEdit.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/contracts/wizard/ContractEdit.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ContractEdit.java 2000/08/21 08:24:20 1.3
+++ ContractEdit.java 2000/08/28 13:02:31 1.4
@@ -1,5 +1,5 @@
/*
- * $Id: ContractEdit.java,v 1.3 2000/08/21 08:24:20 edwin Exp $
+ * $Id: ContractEdit.java,v 1.4 2000/08/28 13:02:31 edwin Exp $
*
* Copyright (c) Systemics Inc 2000 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -16,10 +16,10 @@
* Panel that allows the user to do final adjustments to the panel.
*
* @author Edwin Woudt <edwin@webfunds.org>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
-public class ContractEdit extends WizardPanel {
+public class ContractEdit extends SignContractWizardPanel {
public JEditorPane editor;
1.6 +4 -12 java/webfunds/client/contracts/wizard/ContractFile.java
Index: ContractFile.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/contracts/wizard/ContractFile.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ContractFile.java 2000/08/28 03:03:16 1.5
+++ ContractFile.java 2000/08/28 13:02:31 1.6
@@ -1,5 +1,5 @@
/*
- * $Id: ContractFile.java,v 1.5 2000/08/28 03:03:16 iang Exp $
+ * $Id: ContractFile.java,v 1.6 2000/08/28 13:02:31 edwin Exp $
*
* Copyright (c) Systemics Inc 2000 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -27,10 +27,10 @@
* Panel that asks for the filename of the contract.
*
* @author Edwin Woudt <edwin@webfunds.org>
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*/
-public class ContractFile extends WizardPanel
+public class ContractFile extends SignContractWizardPanel
implements ActionListener {
JTextField txtFile;
@@ -168,11 +168,10 @@
return true;
}
- String s = loadString(filename);
+ String s = loadStringFromFile(filename);
if (s == null)
return false;
-System.err.println("got string " + s.length() + " getting ini");
IniFileReader ini;
try {
ini = new IniFileReader(s.getBytes());
@@ -208,7 +207,6 @@
String topKey = checkTopLevelKey(aKey);
if (topKey != null)
{
-System.err.println("setting String topKey " + topKey.length());
data.setTopLevelKey(topKey);
}
@@ -217,7 +215,6 @@
String conKey = checkPublicContractKey(aKey, topKey);
if (conKey != null)
{
-System.err.println("setting String conKey " + conKey.length());
data.setPublicContractKey(conKey);
}
@@ -226,12 +223,10 @@
String opKey = checkOperatorKey(aKey);
if (opKey != null)
{
-System.err.println("setting opKey " + opKey.length());
data.setOperatorKey(opKey);
}
}
-else System.err.println("no keys found");
String base;
try {
@@ -241,14 +236,11 @@
return false;
}
-System.err.println("got base " + base.length());
data.setUnsignedContract(base);
data.setContractFilename(txtFile.getText());
return true;
- // JOptionPane.showMessageDialog(this, "Error opening file: "+s,
- // "Error", JOptionPane.ERROR_MESSAGE);
}
1.4 +3 -3 java/webfunds/client/contracts/wizard/FinishEnd.java
Index: FinishEnd.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/contracts/wizard/FinishEnd.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FinishEnd.java 2000/08/21 08:24:20 1.3
+++ FinishEnd.java 2000/08/28 13:02:31 1.4
@@ -1,5 +1,5 @@
/*
- * $Id: FinishEnd.java,v 1.3 2000/08/21 08:24:20 edwin Exp $
+ * $Id: FinishEnd.java,v 1.4 2000/08/28 13:02:31 edwin Exp $
*
* Copyright (c) Systemics Inc 2000 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -19,10 +19,10 @@
* Final 'congratulations' panel.
*
* @author Edwin Woudt <edwin@webfunds.org>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
-public class FinishEnd extends WizardPanel {
+public class FinishEnd extends SignContractWizardPanel {
WizardData data;
1.10 +3 -22 java/webfunds/client/contracts/wizard/FinishSig.java
Index: FinishSig.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/contracts/wizard/FinishSig.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- FinishSig.java 2000/08/28 03:03:16 1.9
+++ FinishSig.java 2000/08/28 13:02:32 1.10
@@ -1,5 +1,5 @@
/*
- * $Id: FinishSig.java,v 1.9 2000/08/28 03:03:16 iang Exp $
+ * $Id: FinishSig.java,v 1.10 2000/08/28 13:02:32 edwin Exp $
*
* Copyright (c) Systemics Inc 2000 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -37,10 +37,10 @@
* Panel that does the actual signing.
*
* @author Edwin Woudt <edwin@webfunds.org>
- * @version $Revision: 1.9 $
+ * @version $Revision: 1.10 $
*/
-public class FinishSig extends WizardPanel
+public class FinishSig extends SignContractWizardPanel
implements ActionListener {
JTextField txtFile, txtFileUnsigned, txtPass;
@@ -315,25 +315,6 @@
public boolean next() {
byte[] signedBytes;
-
- // test for validness of signed contract output file
- // hmm... creates file in advance for what purpose?
-/*
- String n = txtFile.getText();
- File f = new File(n);
- if (f.exists()) {
- if (!confirm("File "+n+" already exists! Overwrite?")) return false;
- } else {
- try {
- FileOutputStream fos = new FileOutputStream(f);
- fos.write(0);
- fos.close();
- } catch (IOException ioe) {
- error("Could not create output file"+n+".", ioe);
- return false;
- }
- }
-*/
// parse the armoured key
PGPArmoury akey;
1.9 +6 -43 java/webfunds/client/contracts/wizard/KeyContract.java
Index: KeyContract.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/contracts/wizard/KeyContract.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- KeyContract.java 2000/08/28 03:03:16 1.8
+++ KeyContract.java 2000/08/28 13:02:32 1.9
@@ -1,5 +1,5 @@
/*
- * $Id: KeyContract.java,v 1.8 2000/08/28 03:03:16 iang Exp $
+ * $Id: KeyContract.java,v 1.9 2000/08/28 13:02:32 edwin Exp $
*
* Copyright (c) Systemics Inc 2000 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -32,10 +32,10 @@
* Panel that asks for the contract key
*
* @author Edwin Woudt <edwin@webfunds.org>
- * @version $Revision: 1.8 $
+ * @version $Revision: 1.9 $
*/
-public class KeyContract extends KeyPanel
+public class KeyContract extends SignContractWizardPanel
implements ActionListener {
JTextField txtFile;
@@ -321,7 +321,7 @@
if (fileName.length() != 0) // got a name, try for a key
{
- String s = loadString(fileName);
+ String s = loadStringFromFile(fileName, "contract public key");
if (s == null)
return false;
@@ -350,54 +350,17 @@
}
-
-/*
-System.err.println("CONTRACT -----------\n" + KeyUtil.publicKeyToString(contractKey));
- final String tag = Contract.USERID_CONTRACT;
- PGPPublicKey stripped = null;
- try {
- PGPPublicKey Xstripped = KeyUtil.stripAndVerifyKey(contractKey,
- tag,
- topLevelKey);
- stripped = KeyUtil.stripAndVerifyKey(Xstripped,
- tag,
- topLevelKey);
-System.err.println("ok, so double stripping worked!");
-String am = KeyUtil.publicKeyToString(stripped);
-PGPPublicKey unam;
-unam = KeyUtil.publicKeyFromString(am);
-Xstripped = KeyUtil.stripAndVerifyKey(unam,
- tag,
- topLevelKey);
-} catch (ArmouredKeyException ex) { error("test: " + ex); return false;
-
- } catch (StripKeyException ex) {
- error("Contract key: " + ex);
- return false;
- }
-
- String contractKeyAsString = KeyUtil.publicKeyToString(stripped);
-System.err.println("\n\nCONTRACT +++++++++++\n" + contractKeyAsString);
-
- if (contractKeyAsString != null) {
- data.setPublicContractKey(contractKeyAsString);
- } else {
- return false;
- }
-*/
-
-
fileName = txtFile2.getText();
// have we already got it? perhaps from another run.
existing = data.getSecretContractKey();
-System.err.println("got " + fileName + " and got ex " + existing.length());
if (fileName.length() == 0 && existing.length() > 0)
return true;
/*
* This one is a bit different.
*/
- String secretString = loadString(fileName, "contract secret key");
+ String secretString = loadStringFromFile(fileName,
+ "contract secret key");
if (secretString == null)
return false;
1.9 +4 -4 java/webfunds/client/contracts/wizard/KeyServer.java
Index: KeyServer.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/contracts/wizard/KeyServer.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- KeyServer.java 2000/08/28 03:03:16 1.8
+++ KeyServer.java 2000/08/28 13:02:32 1.9
@@ -1,5 +1,5 @@
/*
- * $Id: KeyServer.java,v 1.8 2000/08/28 03:03:16 iang Exp $
+ * $Id: KeyServer.java,v 1.9 2000/08/28 13:02:32 edwin Exp $
*
* Copyright (c) Systemics Inc 2000 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -26,10 +26,10 @@
* Panel that asks for the [operator] certification key
*
* @author Edwin Woudt <edwin@webfunds.org>
- * @version $Revision: 1.8 $
+ * @version $Revision: 1.9 $
*/
-public class KeyServer extends KeyPanel
+public class KeyServer extends SignContractWizardPanel
implements ActionListener {
JTextField txtFile;
@@ -165,7 +165,7 @@
if (fileName.length() == 0 && existing.length() > 0)
return true;
- String s = loadString(fileName);
+ String s = loadStringFromFile(fileName);
if (s == null)
return false;
1.9 +4 -5 java/webfunds/client/contracts/wizard/KeyTop.java
Index: KeyTop.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/contracts/wizard/KeyTop.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- KeyTop.java 2000/08/28 03:03:16 1.8
+++ KeyTop.java 2000/08/28 13:02:32 1.9
@@ -1,5 +1,5 @@
/*
- * $Id: KeyTop.java,v 1.8 2000/08/28 03:03:16 iang Exp $
+ * $Id: KeyTop.java,v 1.9 2000/08/28 13:02:32 edwin Exp $
*
* Copyright (c) Systemics Inc 2000 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -22,10 +22,10 @@
* Panel that asks for the toplevel certification key
*
* @author Edwin Woudt <edwin@webfunds.org>
- * @version $Revision: 1.8 $
+ * @version $Revision: 1.9 $
*/
-public class KeyTop extends KeyPanel
+public class KeyTop extends SignContractWizardPanel
implements ActionListener {
JTextField txtFile;
@@ -231,11 +231,10 @@
String fileName = txtFile.getText();
// have we already got it?
String existing = data.getTopLevelKey();
-System.err.println("got " + fileName + " and " + existing.length());
if (fileName.length() == 0 && existing.length() > 0)
return true;
- String s = loadString(fileName);
+ String s = loadStringFromFile(fileName);
if (s == null)
return false;
1.7 +7 -140 java/webfunds/client/contracts/wizard/WizardPanel.java
Index: WizardPanel.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/contracts/wizard/WizardPanel.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- WizardPanel.java 2000/08/28 03:21:53 1.6
+++ WizardPanel.java 2000/08/28 13:02:32 1.7
@@ -1,5 +1,5 @@
/*
- * $Id: WizardPanel.java,v 1.6 2000/08/28 03:21:53 iang Exp $
+ * $Id: WizardPanel.java,v 1.7 2000/08/28 13:02:32 edwin Exp $
*
* Copyright (c) Systemics Inc 2000 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -27,7 +27,7 @@
* Abstract superclass for all panels in a wizard.
*
* @author Edwin Woudt <edwin@webfunds.org>
- * @version $Revision: 1.6 $
+ * @version $Revision: 1.7 $
*/
public abstract class WizardPanel extends JPanel {
@@ -53,14 +53,10 @@
public abstract boolean next();
/**
- * Convenience method that displays a User error message and prints the
- * exception on the console.
+ * Convenience method that displays a User error message.
*
* @param message a descriptive message that will be displayed in the popup
* box.
- * @param e the exception corresponding to this error, will be displayed
- * on the console. If no exception is available, then a 'null' can
- * be provided.
*/
protected void error(String message) {
System.err.println("ERROR: "+message);
@@ -69,9 +65,10 @@
}
/**
- * Convenience method that displays an error message and prints the
- * exception on the console. Use where exceptions and stack traces
- * are called for, and the error is unexpected. Is noisier than above.
+ * Convenience method that displays an error message and exception.
+ *
+ * <p>Use where exceptions and stack traces are called for, and the error is
+ * unexpected. Is noisier than above.</p>
*
* @param message a descriptive message that will be displayed in the popup
* box.
@@ -100,135 +97,5 @@
return (result == JOptionPane.YES_OPTION);
}
-
- /**
- * Take a string and return a better string for saving,
- * if the string represents a good armoured OPERATOR key.
- * @param s an armoured key read in from somewhere
- * @return the re-armoured key, filtered for contract goodness
- */
- protected String checkOperatorKey(String s) {
-
- PGPPublicKey key;
- try {
- key = KeyUtil.checkArmouredPublicKey(s,
- Contract.USERID_OPERATOR,
- null);
- } catch (StripKeyException ex) {
- error(ex.getMessage());
- return null;
- } catch (ArmouredKeyException ex) {
- error(ex.getMessage());
- return null;
- }
-
- return KeyUtil.publicKeyToString(key);
- }
-
- /**
- * Take a string and return a better string for saving,
- * if the string represents a good armoured TOP LEVEL key.
- * @param s an armoured key read in from somewhere
- * @return the re-armoured key, filtered for contract goodness
- */
- protected String checkTopLevelKey(String s) {
-
- PGPPublicKey key;
- try {
- key = KeyUtil.checkArmouredPublicKey(s,
- Contract.USERID_TOP_LEVEL,
- null);
- } catch (StripKeyException ex) {
- error(ex.toString());
- return null;
- } catch (ArmouredKeyException ex) {
- error(ex.toString());
- return null;
- }
-
- return KeyUtil.publicKeyToString(key);
- }
-
- /**
- * Take a string and return a better string for saving,
- * if the string represents a good armoured CONTRACT key.
- * @param s an armoured key read in from somewhere
- * @param top an armoured certification key previously prepared
- * @return the re-armoured key, filtered for contract goodness
- */
- protected String checkPublicContractKey(String s, String top) {
-
- // first, recover the top key
- PGPPublicKey topKey;
- try {
- topKey = KeyUtil.checkArmouredPublicKey(top,
- Contract.USERID_TOP_LEVEL,
- null);
- } catch (StripKeyException ex) {
- error("certification key error (cannot check contract key): " + ex);
- return null;
- } catch (ArmouredKeyException ex) {
- error("certification key error (cannot check contract key): " + ex);
- return null;
- }
-
- PGPPublicKey key;
- try {
- key = KeyUtil.checkArmouredPublicKey(s,
- Contract.USERID_CONTRACT,
- topKey);
- } catch (StripKeyException ex) {
- error(ex.toString());
- return null;
- } catch (ArmouredKeyException ex) {
- error(ex.toString());
- return null;
- }
- return KeyUtil.publicKeyToString(key);
- }
-
- /**
- * Load a string from a filename and return it.
- * Prints out a suitable error message if bad.
- */
- protected String loadString(String filename) {
-
- return loadString(filename, "");
- }
-
- /**
- * Load a string from a filename and return it.
- * Prints out a suitable error message if bad.
- */
- protected String loadString(String filename, String name) {
-
- if (filename.equals("")) {
- error("Please specify a " + name + " filename");
- return null;
- }
-
- // read file
- String s;
- try {
- File f = new File(filename);
- FileInputStream fis = new FileInputStream(f);
- DataInputStream dis = new DataInputStream(fis);
-
- byte[] contr = new byte[fis.available()];
- dis.readFully(contr);
-
- s = new String(contr,"ISO8859-1");
- } catch (IOException ioe) {
- if (ioe instanceof FileNotFoundException) {
- error("Error opening file " + filename + ": File not found");
- } else {
- error("Error opening file " + filename + ": ", ioe);
- }
- return null;
- }
-
- return s;
- }
-
}
1.1 java/webfunds/client/contracts/wizard/SignContractWizardPanel.java
Index: SignContractWizardPanel.java
===================================================================
/*
* $Id: SignContractWizardPanel.java,v 1.1 2000/08/28 13:02:32 edwin Exp $
*
* Copyright (c) Systemics Inc 2000 on behalf of
* the WebFunds Development Team. All Rights Reserved.
*/
package webfunds.client.contracts.wizard;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import javax.swing.*;
import cryptix.openpgp.PGPPublicKey;
import webfunds.ricardian.StripKeyException;
import webfunds.ricardian.ArmouredKeyException;
import webfunds.ricardian.Contract;
import webfunds.ricardian.KeyUtil;
/**
* Abstract superclass for panels containing methods that are specific to the
* sign contract wizard.
*
* @author Edwin Woudt <edwin@webfunds.org>
* @version $Revision: 1.1 $
*/
public abstract class SignContractWizardPanel extends WizardPanel {
/**
* Check and strip an OPERATOR key.
*
* <p>This method checks if the given key passes the criteria for an
* operater key. If it does, all superfluous signatures and userids are
* filtered out and the stripped key is returned. If it is not a valid
* key an error message is displayed and null is returned.</p>
*
* @param s an armoured key read in from somewhere.
* @return the re-armoured key, filtered for contract goodness,
* null if the checks fail.
*/
protected String checkOperatorKey(String s) {
PGPPublicKey key;
try {
key = KeyUtil.checkArmouredPublicKey(s,
Contract.USERID_OPERATOR,
null);
} catch (StripKeyException ex) {
error(ex.getMessage());
return null;
} catch (ArmouredKeyException ex) {
error(ex.getMessage());
return null;
}
return KeyUtil.publicKeyToString(key);
}
/**
* Check and strip a TOP LEVEL key.
*
* <p>This method checks if the given key passes the criteria for a
* top level key. If it does, all superfluous signatures and userids are
* filtered out and the stripped key is returned. If it is not a valid
* key an error message is displayed and null is returned.</p>
*
* @param s an armoured key read in from somewhere.
* @return the re-armoured key, filtered for contract goodness,
* null if the checks fail.
*/
protected String checkTopLevelKey(String s) {
PGPPublicKey key;
try {
key = KeyUtil.checkArmouredPublicKey(s,
Contract.USERID_TOP_LEVEL,
null);
} catch (StripKeyException ex) {
error(ex.toString());
return null;
} catch (ArmouredKeyException ex) {
error(ex.toString());
return null;
}
return KeyUtil.publicKeyToString(key);
}
/**
* Check and strip a CONTRACT key.
*
* <p>This method checks if the given key passes the criteria for a
* contract key. If it does, all superfluous signatures and userids are
* filtered out and the stripped key is returned. If it is not a valid
* key an error message is displayed and null is returned.</p>
*
* @param s an armoured key read in from somewhere.
* @param top an armoured key, representing the top level key that signs
* this key.
* @return the re-armoured key, filtered for contract goodness,
* null if the checks fail.
*/
protected String checkPublicContractKey(String s, String top) {
// first, recover the top key
PGPPublicKey topKey;
try {
topKey = KeyUtil.checkArmouredPublicKey(top,
Contract.USERID_TOP_LEVEL,
null);
} catch (StripKeyException ex) {
error("certification key error (cannot check contract key): " + ex);
return null;
} catch (ArmouredKeyException ex) {
error("certification key error (cannot check contract key): " + ex);
return null;
}
PGPPublicKey key;
try {
key = KeyUtil.checkArmouredPublicKey(s,
Contract.USERID_CONTRACT,
topKey);
} catch (StripKeyException ex) {
error(ex.toString());
return null;
} catch (ArmouredKeyException ex) {
error(ex.toString());
return null;
}
return KeyUtil.publicKeyToString(key);
}
/**
* Load a string from a filename and return it.
*
* <p>If reading fails it displays a suitable error message and returns
* null.</p>
*/
protected String loadStringFromFile(String filename) {
return loadStringFromFile(filename, "");
}
/**
* Load a string from a filename and return it.
*
* <p>If reading fails it displays a suitable error message and returns
* null.</p>
*/
protected String loadStringFromFile(String filename, String name) {
if (filename.equals("")) {
error("Please specify a " + name + " filename");
return null;
}
// read file
String s;
try {
File f = new File(filename);
FileInputStream fis = new FileInputStream(f);
DataInputStream dis = new DataInputStream(fis);
byte[] contr = new byte[fis.available()];
dis.readFully(contr);
s = new String(contr,"ISO8859-1");
} catch (IOException ioe) {
if (ioe instanceof FileNotFoundException) {
error("Error opening file " + filename + ": File not found");
} else {
error("Error opening file " + filename + ": ", ioe);
}
return null;
}
return s;
}
}