|
From: Pelle B. <pe...@us...> - 2004-04-15 15:34:50
|
Update of /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/signers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10493/src/java/org/neuclear/commons/crypto/signers Modified Files: DefaultSigner.java Log Message: Got rid of the looping InvalidPassphraseException in DefaultSigner. Added initial focus for all dialogs. Index: DefaultSigner.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/signers/DefaultSigner.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** DefaultSigner.java 14 Apr 2004 00:10:52 -0000 1.9 --- DefaultSigner.java 15 Apr 2004 15:34:41 -0000 1.10 *************** *** 34,37 **** --- 34,41 ---- $Id$ $Log$ + Revision 1.10 2004/04/15 15:34:41 pelle + Got rid of the looping InvalidPassphraseException in DefaultSigner. + Added initial focus for all dialogs. + Revision 1.9 2004/04/14 00:10:52 pelle Added a MessageLabel for handling errors, validation and info *************** *** 90,94 **** */ public final class DefaultSigner implements BrowsableSigner { ! public DefaultSigner(final InteractiveAgent agent) throws UserCancellationException, InvalidPassphraseException { prefs = Preferences.userNodeForPackage(DefaultSigner.class); this.agent = agent; --- 94,98 ---- */ public final class DefaultSigner implements BrowsableSigner { ! public DefaultSigner(final InteractiveAgent agent) throws UserCancellationException { prefs = Preferences.userNodeForPackage(DefaultSigner.class); this.agent = agent; *************** *** 97,109 **** if (file.exists() && file.length() == 0) file.delete(); // Delete empty file - InputStream is = null; - if (file.exists()) { - passphrase = agent.getPassPhrase(filename); - try { - is = new FileInputStream(file); - } catch (FileNotFoundException e) { - throw new LowLevelException(e); - } - } try { prefs.flush(); --- 101,104 ---- *************** *** 111,127 **** e.printStackTrace(); } ! if (passphrase != null) ! signer = loadSigner(is, agent); ! else ! signer = new JCESigner(filename, is, "jks", "SUN", agent); ! ! } ! private JCESigner loadSigner(InputStream is, final InteractiveAgent agent) throws InvalidPassphraseException { try { ! return new JCESigner(filename, is, "jks", "SUN", agent, passphrase); } catch (InvalidPassphraseException e) { ! return loadSigner(is, agent); } } --- 106,130 ---- e.printStackTrace(); } ! signer = loadSigner(file, agent, false); } ! private JCESigner loadSigner(final File file, final InteractiveAgent agent, final boolean wrong) throws UserCancellationException { try { ! if (file.exists() && file.length() > 0) { ! passphrase = agent.getPassPhrase(filename, wrong); ! try { ! InputStream is = new FileInputStream(file); ! return new JCESigner(filename, is, "jks", "SUN", agent, passphrase); ! } catch (FileNotFoundException e) { // Lets just return an empty signer then ! // throw new LowLevelException(e); ! } ! } } catch (InvalidPassphraseException e) { ! return loadSigner(file, agent, true); ! } ! try { ! return new JCESigner(filename, null, "jks", "SUN", agent); ! } catch (InvalidPassphraseException e) { ! throw new LowLevelException(e); } } |