|
From: <pe...@us...> - 2003-12-19 00:31:19
|
Update of /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/passphraseagents
In directory sc8-pr-cvs1:/tmp/cvs-serv18953/src/java/org/neuclear/commons/crypto/passphraseagents
Modified Files:
AskAtStartupAgent.java GuiDialogAgent.java
InteractiveAgent.java PassPhraseAgent.java
ServletPassPhraseAgent.java
Added Files:
ConsoleAgent.java
Removed Files:
CommandLineAgent.java UserCancelsException.java
Log Message:
Lots of usability changes through out all the passphrase agents and end user tools.
--- NEW FILE: ConsoleAgent.java ---
package org.neuclear.commons.crypto.passphraseagents;
import org.neuclear.commons.Utility;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map;
import java.util.HashMap;
/*
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: ConsoleAgent.java,v 1.1 2003/12/19 00:31:15 pelle Exp $
$Log: ConsoleAgent.java,v $
Revision 1.1 2003/12/19 00:31:15 pelle
Lots of usability changes through out all the passphrase agents and end user tools.
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 UserCancellationException, 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.
Otherwise You will Finaliate.
Anything that can be final has been made final throughout everyting. We've used IDEA's Inspector tool to find all instance of variables that could be final.
This should hopefully make everything more stable (and secure).
Revision 1.2 2003/11/19 14:37:37 pelle
ConsoleAgent now masks the passphrase input using the JLine library which is now a dependency.
And the beginnings of a KeyGeneratorApplet
Revision 1.1 2003/11/11 21:17:46 pelle
Further vital reshuffling.
org.neudist.crypto.* and org.neudist.utils.* have been moved to respective areas under org.neuclear.commons
org.neuclear.signers.* as well as org.neuclear.passphraseagents have been moved under org.neuclear.commons.crypto as well.
Did a bit of work on the Canonicalizer and changed a few other minor bits.
Revision 1.2 2003/10/31 23:58:53 pelle
The IdentityCreator now fully works with the new Signer architecture.
Revision 1.1 2003/10/29 21:16:27 pelle
Refactored the whole signing process. Now we have an interface called Signer which is the old SignerStore.
To use it you pass a byte array and an alias. The sign method then returns the signature.
If a Signer needs a passphrase it uses a PassPhraseAgent to present a dialogue box, read it from a command line etc.
This new Signer pattern allows us to use secure signing hardware such as N-Cipher in the future for server applications as well
as SmartCards for end user applications.
*/
/**
* User: pelleb
* Date: Oct 29, 2003
* Time: 11:53:29 AM
*/
public final class ConsoleAgent implements InteractiveAgent {
public ConsoleAgent() {
this.cache = new HashMap();
}
public char[] getPassPhrase(String name) throws UserCancellationException {
return getPassPhrase(name,false); //To change body of implemented methods use Options | File Templates.
}
public final synchronized char[] getPassPhrase(final String name, boolean incorrect) throws UserCancellationException {
if (!incorrect&&cache.containsKey(name))
return ((String)cache.get(name)).toCharArray();
final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
if (incorrect)
System.out.println("entered passphrase was incorrect please try again");
System.out.println("Please enter passphrase for: " + name+" ('q' to quit)");
System.out.print(": ");
try {
final String line = new jline.ConsoleReader().readLine(new Character((char)'*'));
if (line.equals("q"))
throw new UserCancellationException(name);
if (firstrun) {
System.out.println("Do you wish to remember your entered passphrases for this sesson?");
if(Utility.getAffirmative(false)) {
remember=true;
}
firstrun=false;
}
if (remember)
cache.put(name,line);
return line.toCharArray();
} catch (IOException e) {
System.err.println("Couldnt read line. Returning empty passphrase");
return "".toCharArray();
}
}
private final Map cache;
private boolean remember=false;
private boolean firstrun=true;
public static void main(final String[] args) {
final InteractiveAgent dia = new ConsoleAgent();
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")));
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.println("user cancelled");
}
System.exit(0);
}
}
Index: AskAtStartupAgent.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/passphraseagents/AskAtStartupAgent.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** AskAtStartupAgent.java 16 Dec 2003 23:16:40 -0000 1.3
--- AskAtStartupAgent.java 19 Dec 2003 00:31:15 -0000 1.4
***************
*** 21,24 ****
--- 21,27 ----
$Id$
$Log$
+ Revision 1.4 2003/12/19 00:31:15 pelle
+ Lots of usability changes through out all the passphrase agents and end user tools.
+
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.
***************
*** 26,30 ****
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.
--- 29,33 ----
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 UserCancellationException, which allows the agent to tell the application if the user specifically
cancels the signing process.
***************
*** 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);
--- 52,56 ----
*/
public final class AskAtStartupAgent implements PassPhraseAgent {
! public AskAtStartupAgent(final InteractiveAgent agent, final String name) throws UserCancellationException {
this.name = name;
this.passphrase = agent.getPassPhrase(name);
Index: GuiDialogAgent.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/passphraseagents/GuiDialogAgent.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** GuiDialogAgent.java 16 Dec 2003 23:16:40 -0000 1.4
--- GuiDialogAgent.java 19 Dec 2003 00:31:15 -0000 1.5
***************
*** 29,32 ****
--- 29,35 ----
$Id$
$Log$
+ Revision 1.5 2003/12/19 00:31:15 pelle
+ Lots of usability changes through out all the passphrase agents and end user tools.
+
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.
***************
*** 34,38 ****
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.
--- 37,41 ----
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 UserCancellationException, which allows the agent to tell the application if the user specifically
cancels the signing process.
***************
*** 117,122 ****
nameLabel = new Label();
nameLabel.setForeground(Color.blue);
-
text.add(nameLabel);
passphrase = new TextField();
passphrase.setEchoChar('*');
--- 120,128 ----
nameLabel = new Label();
nameLabel.setForeground(Color.blue);
text.add(nameLabel);
+ incorrectLabel = new Label();
+ incorrectLabel.setForeground(Color.red);
+ incorrectLabel.setVisible(false);
+ text.add(incorrectLabel);
passphrase = new TextField();
passphrase.setEchoChar('*');
***************
*** 163,167 ****
}
! 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))
--- 169,183 ----
}
! 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.
! * @return
! * @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))
***************
*** 170,173 ****
--- 186,191 ----
passphrase.setText("");
isCancel=true;
+ incorrectLabel.setVisible(true);
+
nameLabel.setText(name);
frame.pack();
***************
*** 180,184 ****
frame.setVisible(false);
if(isCancel)
! throw new UserCancelsException(name);
final String phrase = passphrase.getText();
if(remember.getState())
--- 198,202 ----
frame.setVisible(false);
if(isCancel)
! throw new UserCancellationException(name);
final String phrase = passphrase.getText();
if(remember.getState())
***************
*** 190,198 ****
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());
}
--- 208,216 ----
public static void main(final String[] args) {
! final InteractiveAgent 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",true)));
! } catch (UserCancellationException e) {
System.out.print("User Cancellation by: "+e.getName());
}
***************
*** 205,208 ****
--- 223,227 ----
private final Checkbox remember;
private final Label nameLabel;
+ private final Label incorrectLabel;
private final Frame frame;
private final Map cache;
Index: InteractiveAgent.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/passphraseagents/InteractiveAgent.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** InteractiveAgent.java 11 Nov 2003 21:17:46 -0000 1.1
--- InteractiveAgent.java 19 Dec 2003 00:31:15 -0000 1.2
***************
*** 21,24 ****
--- 21,27 ----
$Id$
$Log$
+ Revision 1.2 2003/12/19 00:31:15 pelle
+ Lots of usability changes through out all the passphrase agents and end user tools.
+
Revision 1.1 2003/11/11 21:17:46 pelle
Further vital reshuffling.
***************
*** 39,41 ****
--- 42,46 ----
*/
public interface InteractiveAgent extends PassPhraseAgent {
+ char[] getPassPhrase(String name,boolean incorrect) throws UserCancellationException;
+
}
Index: PassPhraseAgent.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/passphraseagents/PassPhraseAgent.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** PassPhraseAgent.java 16 Dec 2003 23:16:40 -0000 1.2
--- PassPhraseAgent.java 19 Dec 2003 00:31:15 -0000 1.3
***************
*** 22,25 ****
--- 22,28 ----
$Id$
$Log$
+ Revision 1.3 2003/12/19 00:31:15 pelle
+ Lots of usability changes through out all the passphrase agents and end user tools.
+
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.
***************
*** 27,31 ****
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.
--- 30,34 ----
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 UserCancellationException, which allows the agent to tell the application if the user specifically
cancels the signing process.
***************
*** 63,66 ****
* @return
*/
! char[] getPassPhrase(String name) throws UserCancelsException;
}
--- 66,69 ----
* @return
*/
! char[] getPassPhrase(String name) throws UserCancellationException;
}
Index: ServletPassPhraseAgent.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/passphraseagents/ServletPassPhraseAgent.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ServletPassPhraseAgent.java 14 Dec 2003 20:52:54 -0000 1.1
--- ServletPassPhraseAgent.java 19 Dec 2003 00:31:15 -0000 1.2
***************
*** 41,43 ****
--- 41,47 ----
set(null);
}
+
+ public char[] getPassPhrase(String name, boolean incorrect) throws UserCancellationException {
+ return getPassPhrase(name);
+ }
}
--- CommandLineAgent.java DELETED ---
--- UserCancelsException.java DELETED ---
|