|
From: Pelle B. <pe...@us...> - 2004-04-02 23:16:57
|
Update of /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/keyresolvers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4251/src/java/org/neuclear/commons/crypto/keyresolvers Modified Files: KeyResolverFactory.java PublicKeyCache.java Log Message: Got TransferOrder and Builder working with their test cases. Working on TransferReceipt which is the first embedded receipt. This is causing some problems at the moment. Index: KeyResolverFactory.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/keyresolvers/KeyResolverFactory.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** KeyResolverFactory.java 19 Feb 2004 15:29:09 -0000 1.3 --- KeyResolverFactory.java 2 Apr 2004 23:04:44 -0000 1.4 *************** *** 23,26 **** --- 23,30 ---- $Id$ $Log$ + Revision 1.4 2004/04/02 23:04:44 pelle + Got TransferOrder and Builder working with their test cases. + Working on TransferReceipt which is the first embedded receipt. This is causing some problems at the moment. + Revision 1.3 2004/02/19 15:29:09 pelle Various cleanups and corrections *************** *** 67,71 **** } ! public final static String DEFAULT = "org.neuclear.commons.crypto.keyresolvers.NullResolver"; private static KeyResolver instance; } --- 71,75 ---- } ! public final static String DEFAULT = "org.neuclear.commons.crypto.keyresolvers.PublicKeyCache"; private static KeyResolver instance; } Index: PublicKeyCache.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/keyresolvers/PublicKeyCache.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PublicKeyCache.java 1 Apr 2004 23:16:36 -0000 1.1 --- PublicKeyCache.java 2 Apr 2004 23:04:44 -0000 1.2 *************** *** 1,10 **** package org.neuclear.commons.crypto.keyresolvers; import org.neuclear.commons.crypto.CryptoTools; - import java.lang.ref.WeakReference; import java.security.PublicKey; - import java.util.HashMap; - import java.util.Map; /** --- 1,8 ---- package org.neuclear.commons.crypto.keyresolvers; + import org.neuclear.commons.Cache; import org.neuclear.commons.crypto.CryptoTools; import java.security.PublicKey; /** *************** *** 15,37 **** * To change this template use Options | File Templates. */ ! public class PublicKeyCache implements KeyResolver { ! - private PublicKeyCache() { - this.cache = new HashMap(); - } public final PublicKey resolve(String name) { ! final WeakReference ref = (WeakReference) cache.get(name); ! if (ref == null) ! return null; ! return (PublicKey) ref.get(); } ! public final void cache(final PublicKey pub) { final String keyid = CryptoTools.encodeBase32(CryptoTools.digest(pub.getEncoded())); ! if (!cache.containsKey(keyid) || ((WeakReference) cache.get(keyid)).isEnqueued()) { ! cache.put(keyid, new WeakReference(pub)); ! } } --- 13,26 ---- * To change this template use Options | File Templates. */ ! public class PublicKeyCache extends Cache implements KeyResolver { public final PublicKey resolve(String name) { ! return (PublicKey) lookup(name); } ! public final PublicKey cache(final PublicKey pub) { final String keyid = CryptoTools.encodeBase32(CryptoTools.digest(pub.getEncoded())); ! return (PublicKey) cache(keyid, pub); } *************** *** 50,54 **** } - private final Map cache; private static PublicKeyCache instance; } --- 39,42 ---- |