|
From: <pe...@us...> - 2003-12-22 13:45:28
|
Update of /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/passphraseagents
In directory sc8-pr-cvs1:/tmp/cvs-serv14605/src/java/org/neuclear/commons/crypto/passphraseagents
Modified Files:
AskAtStartupAgent.java
Log Message:
Added a naive benchmarking tool.
Fixed a bug in AskAtStartupAgent
Index: AskAtStartupAgent.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/passphraseagents/AskAtStartupAgent.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** AskAtStartupAgent.java 19 Dec 2003 18:02:53 -0000 1.5
--- AskAtStartupAgent.java 22 Dec 2003 13:45:25 -0000 1.6
***************
*** 3,6 ****
--- 3,9 ----
import org.neuclear.commons.LowLevelException;
+ import java.util.Map;
+ import java.util.HashMap;
+
/*
NeuClear Distributed Transaction Clearing Platform
***************
*** 23,26 ****
--- 26,33 ----
$Id$
$Log$
+ Revision 1.6 2003/12/22 13:45:25 pelle
+ Added a naive benchmarking tool.
+ Fixed a bug in AskAtStartupAgent
+
Revision 1.5 2003/12/19 18:02:53 pelle
Revamped a lot of exception handling throughout the framework, it has been simplified in most places:
***************
*** 57,69 ****
/**
! * User: pelleb
! * Date: Oct 30, 2003
! * Time: 5:09:36 PM
*/
public final class AskAtStartupAgent implements PassPhraseAgent {
public AskAtStartupAgent(final InteractiveAgent agent, final String name) throws UserCancellationException {
- this.name = name;
this.agent=agent;
! this.passphrase = agent.getPassPhrase(name);
}
--- 64,76 ----
/**
! * AskAtStartupAgent encapsulates another passphraseagent, but caches each request.
! * It is given an initial argument, which it asks at startup, thus not requiring it to ask the admin
! * for the passphrase at alls.
*/
public final class AskAtStartupAgent implements PassPhraseAgent {
public AskAtStartupAgent(final InteractiveAgent agent, final String name) throws UserCancellationException {
this.agent=agent;
! cache=new HashMap();
! getPassPhrase(name);
}
***************
*** 74,96 ****
* @return
*/
! public final char[] getPassPhrase(final String name) {
! if (name.equals(this.name))
return passphrase;
! else
! return new char[0];
}
public char[] getPassPhrase(String name, boolean incorrect) throws UserCancellationException {
if (incorrect) {
! if (name.equals(this.name))
! passphrase=agent.getPassPhrase(name);
! else
! throw new LowLevelException(getClass().getName()+"\nCan not provide passphrase for: "+name);
! }
return getPassPhrase(name);
}
! private final String name;
! private char[] passphrase;
private final PassPhraseAgent agent;
--- 81,104 ----
* @return
*/
! public final char[] getPassPhrase(final String name) throws UserCancellationException {
! if (cache.containsKey(name))
! return (char[]) cache.get(name);
! else {
! char passphrase[] =agent.getPassPhrase(name);
! cache.put(name,passphrase);
return passphrase;
! }
}
public char[] getPassPhrase(String name, boolean incorrect) throws UserCancellationException {
if (incorrect) {
! char passphrase[] =agent.getPassPhrase(name,incorrect);
! cache.put(name,passphrase);
! return passphrase;
! }
return getPassPhrase(name);
}
! private final Map cache;
private final PassPhraseAgent agent;
|