Update of /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/passphraseagents
In directory sc8-pr-cvs1:/tmp/cvs-serv31489/src/java/org/neuclear/commons/crypto/passphraseagents
Modified Files:
AskAtStartupAgent.java CommandLineAgent.java
GuiDialogAgent.java PassPhraseAgent.java
Added Files:
UserCancelsException.java
Log Message:
Work done on the SigningServlet. The two phase web model is now only an option.
Allowing much quicker signing, using the GuiDialogueAgent.
The screen has also been cleaned up and displays the xml to be signed.
The GuiDialogueAgent now optionally remembers passphrases and has a checkbox to support this.
The PassPhraseAgent's now have a UserCancelsException, which allows the agent to tell the application if the user specifically
cancels the signing process.
--- NEW FILE: UserCancelsException.java ---
package org.neuclear.commons.crypto.passphraseagents;
import org.neuclear.commons.crypto.CryptoException;
/*
NeuClear Distributed Transaction Clearing Platform
(C) 2003 Pelle Braendgaard
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: UserCancelsException.java,v 1.1 2003/12/16 23:16:40 pelle Exp $
$Log: UserCancelsException.java,v $
Revision 1.1 2003/12/16 23:16:40 pelle
Work done on the SigningServlet. The two phase web model is now only an option.
Allowing much quicker signing, using the GuiDialogueAgent.
The screen has also been cleaned up and displays the xml to be signed.
The GuiDialogueAgent now optionally remembers passphrases and has a checkbox to support this.
The PassPhraseAgent's now have a UserCancelsException, which allows the agent to tell the application if the user specifically
cancels the signing process.
*/
/**
* User: pelleb
* Date: Dec 16, 2003
* Time: 4:28:58 PM
*/
public class UserCancelsException extends CryptoException {
public UserCancelsException(String name) {
super("Cancellation by: "+name);
this.name=name;
}
public String getName() {
return name;
}
private final String name;
}
Index: AskAtStartupAgent.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/passphraseagents/AskAtStartupAgent.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** AskAtStartupAgent.java 21 Nov 2003 04:43:41 -0000 1.2
--- AskAtStartupAgent.java 16 Dec 2003 23:16:40 -0000 1.3
***************
*** 21,24 ****
--- 21,32 ----
$Id$
$Log$
+ Revision 1.3 2003/12/16 23:16:40 pelle
+ Work done on the SigningServlet. The two phase web model is now only an option.
+ Allowing much quicker signing, using the GuiDialogueAgent.
+ The screen has also been cleaned up and displays the xml to be signed.
+ The GuiDialogueAgent now optionally remembers passphrases and has a checkbox to support this.
+ The PassPhraseAgent's now have a UserCancelsException, which allows the agent to tell the application if the user specifically
+ cancels the signing process.
+
Revision 1.2 2003/11/21 04:43:41 pelle
EncryptedFileStore now works. It uses the PBECipher with DES3 afair.
***************
*** 41,45 ****
*/
public final class AskAtStartupAgent implements PassPhraseAgent {
! public AskAtStartupAgent(final InteractiveAgent agent, final String name) {
this.name = name;
this.passphrase = agent.getPassPhrase(name);
--- 49,53 ----
*/
public final class AskAtStartupAgent implements PassPhraseAgent {
! public AskAtStartupAgent(final InteractiveAgent agent, final String name) throws UserCancelsException {
this.name = name;
this.passphrase = agent.getPassPhrase(name);
Index: CommandLineAgent.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/passphraseagents/CommandLineAgent.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** CommandLineAgent.java 21 Nov 2003 04:43:41 -0000 1.3
--- CommandLineAgent.java 16 Dec 2003 23:16:40 -0000 1.4
***************
*** 25,28 ****
--- 25,36 ----
$Id$
$Log$
+ Revision 1.4 2003/12/16 23:16:40 pelle
+ Work done on the SigningServlet. The two phase web model is now only an option.
+ Allowing much quicker signing, using the GuiDialogueAgent.
+ The screen has also been cleaned up and displays the xml to be signed.
+ The GuiDialogueAgent now optionally remembers passphrases and has a checkbox to support this.
+ The PassPhraseAgent's now have a UserCancelsException, which allows the agent to tell the application if the user specifically
+ cancels the signing process.
+
Revision 1.3 2003/11/21 04:43:41 pelle
EncryptedFileStore now works. It uses the PBECipher with DES3 afair.
***************
*** 74,79 ****
public static void main(final String[] args) {
final PassPhraseAgent dia = new CommandLineAgent();
! System.out.println("Getting passphrase... " + new String(dia.getPassPhrase("neu://pelle@test")));
! System.out.println("Getting passphrase... " + new String(dia.getPassPhrase("neu://pelle@test")));
System.exit(0);
--- 82,91 ----
public static void main(final String[] args) {
final PassPhraseAgent dia = new CommandLineAgent();
! 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")));
! } catch (UserCancelsException e) {
! e.printStackTrace();
! }
System.exit(0);
Index: GuiDialogAgent.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/passphraseagents/GuiDialogAgent.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** GuiDialogAgent.java 14 Dec 2003 20:52:54 -0000 1.3
--- GuiDialogAgent.java 16 Dec 2003 23:16:40 -0000 1.4
***************
*** 4,7 ****
--- 4,11 ----
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+ import java.awt.event.ItemListener;
+ import java.awt.event.ItemEvent;
+ import java.util.Map;
+ import java.util.HashMap;
/*
***************
*** 25,28 ****
--- 29,40 ----
$Id$
$Log$
+ Revision 1.4 2003/12/16 23:16:40 pelle
+ Work done on the SigningServlet. The two phase web model is now only an option.
+ Allowing much quicker signing, using the GuiDialogueAgent.
+ The screen has also been cleaned up and displays the xml to be signed.
+ The GuiDialogueAgent now optionally remembers passphrases and has a checkbox to support this.
+ The PassPhraseAgent's now have a UserCancelsException, which allows the agent to tell the application if the user specifically
+ cancels the signing process.
+
Revision 1.3 2003/12/14 20:52:54 pelle
Added ServletPassPhraseAgent which uses ThreadLocal to transfer the passphrase to the signer.
***************
*** 73,76 ****
--- 85,89 ----
public final class GuiDialogAgent implements InteractiveAgent {
public GuiDialogAgent() {
+ cache=new HashMap();
frame = new Frame("Please Enter Passphrase...");
***************
*** 111,114 ****
--- 124,137 ----
final Panel buttons = new Panel(new FlowLayout());
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())
+ cache.clear();
+ }
+
+ });
ok = new Button("Sign");
buttons.add(ok);
***************
*** 119,122 ****
--- 142,146 ----
synchronized (passphrase) {
passphrase.setText("");
+ isCancel=true;
passphrase.notifyAll();
}
***************
*** 128,131 ****
--- 152,156 ----
public void actionPerformed(final ActionEvent actionEvent) {
synchronized (passphrase) {
+ isCancel=false;
passphrase.notifyAll();
}
***************
*** 138,144 ****
}
! public char[] getPassPhrase(final String name) {
synchronized (passphrase) {//We dont want multiple agents popping up at the same time
! passphrase.setText("");
nameLabel.setText(name);
frame.pack();
--- 163,173 ----
}
! public synchronized char[] getPassPhrase(final String name) throws UserCancelsException {
synchronized (passphrase) {//We dont want multiple agents popping up at the same time
! if (cache.containsKey(name))
! passphrase.setText((String) cache.get(name));
! else
! passphrase.setText("");
! isCancel=true;
nameLabel.setText(name);
frame.pack();
***************
*** 150,154 ****
--- 179,187 ----
}
frame.setVisible(false);
+ if(isCancel)
+ throw new UserCancelsException(name);
final String phrase = passphrase.getText();
+ if(remember.getState())
+ cache.put(name,phrase);
passphrase.setText("");
return phrase.toCharArray();
***************
*** 158,163 ****
public static void main(final String[] args) {
final PassPhraseAgent dia = new GuiDialogAgent();
! System.out.println("Getting passphrase... " + new String(dia.getPassPhrase("neu://pelle@test")));
! System.out.println("Getting passphrase... " + new String(dia.getPassPhrase("neu://pelle@test")));
System.exit(0);
--- 191,200 ----
public static void main(final String[] args) {
final PassPhraseAgent dia = new GuiDialogAgent();
! 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")));
! } catch (UserCancelsException e) {
! System.out.print("User Cancellation by: "+e.getName());
! }
System.exit(0);
***************
*** 166,172 ****
--- 203,212 ----
private final TextField passphrase;
private final Button ok;
+ private final Checkbox remember;
private final Label nameLabel;
private final Frame frame;
+ private final Map cache;
private Image img;
+ private boolean isCancel=true;
Index: PassPhraseAgent.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/passphraseagents/PassPhraseAgent.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** PassPhraseAgent.java 11 Nov 2003 21:17:46 -0000 1.1
--- PassPhraseAgent.java 16 Dec 2003 23:16:40 -0000 1.2
***************
*** 22,25 ****
--- 22,33 ----
$Id$
$Log$
+ Revision 1.2 2003/12/16 23:16:40 pelle
+ Work done on the SigningServlet. The two phase web model is now only an option.
+ Allowing much quicker signing, using the GuiDialogueAgent.
+ The screen has also been cleaned up and displays the xml to be signed.
+ The GuiDialogueAgent now optionally remembers passphrases and has a checkbox to support this.
+ The PassPhraseAgent's now have a UserCancelsException, which allows the agent to tell the application if the user specifically
+ cancels the signing process.
+
Revision 1.1 2003/11/11 21:17:46 pelle
Further vital reshuffling.
***************
*** 55,58 ****
* @return
*/
! char[] getPassPhrase(String name);
}
--- 63,66 ----
* @return
*/
! char[] getPassPhrase(String name) throws UserCancelsException;
}
|