|
From: Pelle B. <pe...@us...> - 2004-04-13 00:04:02
|
Update of /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/signers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21842/src/java/org/neuclear/commons/crypto/signers Modified Files: DefaultSigner.java JCESigner.java Log Message: implemented the queue and improved the DefaultSigner Index: JCESigner.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/signers/JCESigner.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** JCESigner.java 9 Apr 2004 22:56:45 -0000 1.21 --- JCESigner.java 12 Apr 2004 23:50:08 -0000 1.22 *************** *** 2,5 **** --- 2,8 ---- * $Id$ * $Log$ + * Revision 1.22 2004/04/12 23:50:08 pelle + * implemented the queue and improved the DefaultSigner + * * Revision 1.21 2004/04/09 22:56:45 pelle * SwingAgent now manages key creation as well through the NewAliasDialog. *************** *** 173,176 **** --- 176,180 ---- import org.neuclear.commons.crypto.CryptoException; import org.neuclear.commons.crypto.CryptoTools; + import org.neuclear.commons.crypto.passphraseagents.AlwaysTheSamePassphraseAgent; import org.neuclear.commons.crypto.passphraseagents.InteractiveAgent; import org.neuclear.commons.crypto.passphraseagents.PassPhraseAgent; *************** *** 273,300 **** } ! /** ! * @param provider ! * @param type ! * @param in ! * @param agent ! * @param name ! * @return ! * @throws InvalidPassphraseException ! * @throws UserCancellationException ! */ ! private static KeyStore loadKeyStore(final String provider, final String type, final InputStream in, final PassPhraseAgent agent, final String name) throws InvalidPassphraseException, UserCancellationException { ! // System.out.println("Loading JCESigner: "+name); ! return loadKeyStore(provider, type, in, agent.getPassPhrase("Keystore password for: " + name)); } ! /** ! * @param provider ! * @param type ! * @param in ! * @param passphrase ! * @return ! * @throws InvalidPassphraseException ! */ ! private static KeyStore loadKeyStore(final String provider, final String type, final InputStream in, final char[] passphrase) throws InvalidPassphraseException { // System.out.println("Loading JCESigner using passphrase: "+new String(passphrase)); try { --- 277,289 ---- } ! private static KeyStore loadKeyStore(final String provider, final String type, final InputStream in, final char[] passphrase) throws InvalidPassphraseException { ! try { ! return loadKeyStore(provider, type, in, new AlwaysTheSamePassphraseAgent(passphrase), "keystore"); ! } catch (UserCancellationException e) { ! throw new LowLevelException(e); ! } } ! private static KeyStore loadKeyStore(final String provider, final String type, final InputStream in, final PassPhraseAgent agent, final String name) throws InvalidPassphraseException, UserCancellationException { // System.out.println("Loading JCESigner using passphrase: "+new String(passphrase)); try { *************** *** 304,308 **** else ki = KeyStore.getInstance(type, provider); ! ki.load(in, passphrase); return ki; } catch (KeyStoreException e) { --- 293,300 ---- else ki = KeyStore.getInstance(type, provider); ! if (in != null) ! ki.load(in, agent.getPassPhrase("Keystore password for: " + name)); ! else ! ki.load(null, null); return ki; } catch (KeyStoreException e) { Index: DefaultSigner.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/signers/DefaultSigner.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** DefaultSigner.java 12 Apr 2004 15:37:01 -0000 1.6 --- DefaultSigner.java 12 Apr 2004 23:50:07 -0000 1.7 *************** *** 9,12 **** --- 9,13 ---- import java.security.PublicKey; import java.util.Iterator; + import java.util.prefs.Preferences; /* *************** *** 30,33 **** --- 31,37 ---- $Id$ $Log$ + Revision 1.7 2004/04/12 23:50:07 pelle + implemented the queue and improved the DefaultSigner + Revision 1.6 2004/04/12 15:37:01 pelle Refactored DefaultSigner to delegate to a JCESigner and not inherit. *************** *** 75,79 **** public final class DefaultSigner implements BrowsableSigner { public DefaultSigner(final PassPhraseAgent agent) throws UserCancellationException, InvalidPassphraseException { ! signer = new JCESigner(CryptoTools.DEFAULT_KEYSTORE, "jks", "SUN", agent); } --- 79,85 ---- public final class DefaultSigner implements BrowsableSigner { public DefaultSigner(final PassPhraseAgent agent) throws UserCancellationException, InvalidPassphraseException { ! Preferences prefs = Preferences.userNodeForPackage(DefaultSigner.class); ! final String filename = prefs.get("KEYSTORE", CryptoTools.DEFAULT_KEYSTORE); ! signer = new JCESigner(filename, "jks", "SUN", agent); } |