|
From: Pelle B. <pe...@us...> - 2004-03-30 00:00:05
|
Update of /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/passphraseagents In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22709/src/java/org/neuclear/commons/crypto/passphraseagents Modified Files: GuiDialogAgent.java InteractiveAgent.java Log Message: InteractiveAgent now has a new method which allows signers to ask for a passphrase without specifying alias. The agents are passed a reference to the Signer, which they can use to browse aliases as well as create new key pairs. The intention is to encapsulate most of the key management functionality within the InteractiveAgent. Index: GuiDialogAgent.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/passphraseagents/GuiDialogAgent.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** GuiDialogAgent.java 19 Jan 2004 17:53:14 -0000 1.7 --- GuiDialogAgent.java 29 Mar 2004 23:48:32 -0000 1.8 *************** *** 1,4 **** --- 1,6 ---- package org.neuclear.commons.crypto.passphraseagents; + import org.neuclear.commons.crypto.signers.Signer; + import java.awt.*; import java.awt.event.ActionEvent; *************** *** 29,32 **** --- 31,40 ---- $Id$ $Log$ + Revision 1.8 2004/03/29 23:48:32 pelle + InteractiveAgent now has a new method which allows signers to ask for a passphrase without specifying alias. + The agents are passed a reference to the Signer, which they can use to browse aliases as well as create new key pairs. + + The intention is to encapsulate most of the key management functionality within the InteractiveAgent. + Revision 1.7 2004/01/19 17:53:14 pelle Various clean ups *************** *** 94,98 **** public final class GuiDialogAgent implements InteractiveAgent { public GuiDialogAgent() { ! cache=new HashMap(); frame = new Frame("Please Enter Passphrase..."); --- 102,106 ---- public final class GuiDialogAgent implements InteractiveAgent { public GuiDialogAgent() { ! cache = new HashMap(); frame = new Frame("Please Enter Passphrase..."); *************** *** 138,144 **** panel.add(buttons, BorderLayout.SOUTH); ! remember=new Checkbox("remember passphrase",false); buttons.add(remember); ! remember.addItemListener(new ItemListener(){ public void itemStateChanged(ItemEvent itemEvent) { if (!remember.getState()) --- 146,152 ---- panel.add(buttons, BorderLayout.SOUTH); ! remember = new Checkbox("remember passphrase", false); buttons.add(remember); ! remember.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent itemEvent) { if (!remember.getState()) *************** *** 155,159 **** synchronized (passphrase) { passphrase.setText(""); ! isCancel=true; passphrase.notifyAll(); } --- 163,167 ---- synchronized (passphrase) { passphrase.setText(""); ! isCancel = true; passphrase.notifyAll(); } *************** *** 165,169 **** public void actionPerformed(final ActionEvent actionEvent) { synchronized (passphrase) { ! isCancel=false; passphrase.notifyAll(); } --- 173,177 ---- public void actionPerformed(final ActionEvent actionEvent) { synchronized (passphrase) { ! isCancel = false; passphrase.notifyAll(); } *************** *** 174,184 **** passphrase.addActionListener(action); } public char[] getPassPhrase(final String name) throws UserCancellationException { ! return getPassPhrase(name,false); } /** * Asks for the passphrase. * @param name * @param incorrect true indicates the user entered an incorrect passphrase and should reenter it. --- 182,207 ---- passphrase.addActionListener(action); + createNew = new Button("New Identity"); + createNew.setVisible(false); + createNew.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + + } + + }); + buttons.add(createNew); + aliasList = new List(); + aliasList.setVisible(false); + text.add(aliasList); + } public char[] getPassPhrase(final String name) throws UserCancellationException { ! return getPassPhrase(name, false); } + /** * Asks for the passphrase. + * * @param name * @param incorrect true indicates the user entered an incorrect passphrase and should reenter it. *************** *** 186,190 **** * @throws UserCancellationException */ ! public synchronized char[] getPassPhrase(final String name,boolean incorrect) throws UserCancellationException { synchronized (passphrase) {//We dont want multiple agents popping up at the same time if (cache.containsKey(name)) --- 209,213 ---- * @throws UserCancellationException */ ! public synchronized char[] getPassPhrase(final String name, boolean incorrect) throws UserCancellationException { synchronized (passphrase) {//We dont want multiple agents popping up at the same time if (cache.containsKey(name)) *************** *** 192,199 **** else passphrase.setText(""); ! isCancel=true; if (incorrect) System.err.println("Incorrect passphrase"); incorrectLabel.setVisible(incorrect); nameLabel.setText(name); --- 215,223 ---- else passphrase.setText(""); ! isCancel = true; if (incorrect) System.err.println("Incorrect passphrase"); incorrectLabel.setVisible(incorrect); + nameLabel.setVisible(true); nameLabel.setText(name); *************** *** 206,214 **** } frame.setVisible(false); ! if(isCancel) throw new UserCancellationException(name); final String phrase = passphrase.getText(); ! if(remember.getState()) ! cache.put(name,phrase); passphrase.setText(""); return phrase.toCharArray(); --- 230,238 ---- } frame.setVisible(false); ! if (isCancel) throw new UserCancellationException(name); final String phrase = passphrase.getText(); ! if (remember.getState()) ! cache.put(name, phrase); passphrase.setText(""); return phrase.toCharArray(); *************** *** 220,226 **** try { System.out.println("Getting passphrase... " + new String(dia.getPassPhrase("neu://pelle@test"))); ! System.out.println("Getting passphrase... " + new String(dia.getPassPhrase("neu://pelle@test",true))); } catch (UserCancellationException e) { ! System.out.print("User Cancellation by: "+e.getName()); } --- 244,250 ---- try { System.out.println("Getting passphrase... " + new String(dia.getPassPhrase("neu://pelle@test"))); ! System.out.println("Getting passphrase... " + new String(dia.getPassPhrase("neu://pelle@test", true))); } catch (UserCancellationException e) { ! System.out.print("User Cancellation by: " + e.getName()); } *************** *** 228,231 **** --- 252,269 ---- } + /** + * The User is asked to pick a name by the PassPhraseAgent. The PassPhraseAgent can query the given signer for + * a list of included aliases or even create a new keypair. + * + * @return + * @throws UserCancellationException + */ + public char[] getPassPhrase(Signer signer) throws UserCancellationException { + nameLabel.setVisible(false); + createNew.setVisible(true); + aliasList.setVisible(true); + return new char[0]; + } + private final TextField passphrase; private final Button ok; *************** *** 233,240 **** private final Label nameLabel; private final Label incorrectLabel; private final Frame frame; private final Map cache; private Image img; ! private boolean isCancel=true; --- 271,280 ---- private final Label nameLabel; private final Label incorrectLabel; + private final List aliasList; + private final Button createNew; private final Frame frame; private final Map cache; private Image img; ! private boolean isCancel = true; Index: InteractiveAgent.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/passphraseagents/InteractiveAgent.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** InteractiveAgent.java 19 Dec 2003 18:02:53 -0000 1.3 --- InteractiveAgent.java 29 Mar 2004 23:48:32 -0000 1.4 *************** *** 1,4 **** --- 1,6 ---- package org.neuclear.commons.crypto.passphraseagents; + import org.neuclear.commons.crypto.signers.Signer; + /* NeuClear Distributed Transaction Clearing Platform *************** *** 21,24 **** --- 23,32 ---- $Id$ $Log$ + Revision 1.4 2004/03/29 23:48:32 pelle + InteractiveAgent now has a new method which allows signers to ask for a passphrase without specifying alias. + The agents are passed a reference to the Signer, which they can use to browse aliases as well as create new key pairs. + + The intention is to encapsulate most of the key management functionality within the InteractiveAgent. + Revision 1.3 2003/12/19 18:02:53 pelle Revamped a lot of exception handling throughout the framework, it has been simplified in most places: *************** *** 50,53 **** --- 58,70 ---- */ public interface InteractiveAgent extends PassPhraseAgent { + /** + * The User is asked to pick a name by the PassPhraseAgent. The PassPhraseAgent can query the given signer for + * a list of included aliases or even create a new keypair. + * + * @return + * @throws UserCancellationException + */ + char[] getPassPhrase(final Signer signer) throws UserCancellationException; + } |