public void actionPerformed(ActionEvent e) { swingSchema.setKeyStore(null); CFBamSwingMainJFrame mainJFrame = null; { Container cont = getParent(); while ((cont != null) && (!(cont instanceof CFBamSwingMainJFrame))) { cont = cont.getParent(); } if (cont != null) { mainJFrame = (CFBamSwingMainJFrame) cont; mainJFrame.exitApplication(); } } }
public void actionPerformed(ActionEvent e) { final String S_ProcName = "actionPerformed"; CFBamSwingMainJFrame mainJFrame = null; { Container cont = getParent(); while ((cont != null) && (!(cont instanceof CFBamSwingMainJFrame))) { cont = cont.getParent(); } if (cont != null) { mainJFrame = (CFBamSwingMainJFrame) cont; } } char pw[] = textKeystorePassword.getPassword(); String keystorePassword; if (pw != null) { keystorePassword = new String(pw); } else { keystorePassword = null; } CFBamClientConfigurationFile configFile = swingSchema.getClientConfigurationFile(); String keystoreFileName = configFile.getKeyStore(); boolean exitApp = false; boolean exitForm = false; boolean creatingKeystore = false; KeyStore keyStore = null; File keystoreFile = new File(keystoreFileName); if (!keystoreFile.exists()) { int userOption = JOptionPane.NO_OPTION; try { userOption = JOptionPane.showOptionDialog( null, "Would you like to create the keystore \"" + keystoreFileName + "\"?\n" + "Selecting No will exit the application so you can edit the client configuration file and restart.", "Create Keystore?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); } catch (HeadlessException x) { throw CFLib.getDefaultExceptionFactory() .newRuntimeException( getClass(), S_ProcName, "Caught HeadlessException -- " + x.getMessage(), x); } if (userOption == JOptionPane.YES_OPTION) { creatingKeystore = true; JInternalFrame nextForm = swingSchema.newCreateKeystoreJInternalFrame(); getDesktopPane().add(nextForm); nextForm.setVisible(true); nextForm.show(); Container cont = getParent(); while ((cont != null) && (!(cont instanceof JInternalFrame))) { cont = cont.getParent(); } if (cont != null) { JInternalFrame frame = (JInternalFrame) cont; try { frame.setClosed(true); } catch (Exception x) { } } } else { exitApp = true; } } else if (!keystoreFile.isFile()) { JOptionPane.showMessageDialog( null, "The referenced JCEKS keystore \"" + keystoreFileName + "\" is not a file.", "Error", JOptionPane.ERROR_MESSAGE, null); exitApp = true; } else if (!keystoreFile.canRead()) { JOptionPane.showMessageDialog( null, "Permission denied attempting to access JCEKS keystore \"" + keystoreFileName + "\".", "Error", JOptionPane.ERROR_MESSAGE, null); exitApp = true; } if ((!exitApp) && (!creatingKeystore)) { try { keyStore = KeyStore.getInstance("jceks"); char[] caPassword = keystorePassword.toCharArray(); FileInputStream input = new FileInputStream(keystoreFileName); keyStore.load(input, caPassword); input.close(); swingSchema.setKeyStore(keyStore); exitForm = true; } catch (CertificateException x) { keyStore = null; JOptionPane.showMessageDialog( null, "Could not open keystore due to CertificateException -- " + x.getMessage(), "Error", JOptionPane.ERROR_MESSAGE, null); exitApp = true; } catch (IOException x) { keyStore = null; JOptionPane.showMessageDialog( null, "Could not open keystore due to IOException -- " + x.getMessage(), "Error", JOptionPane.ERROR_MESSAGE, null); } catch (KeyStoreException x) { keyStore = null; JOptionPane.showMessageDialog( null, "Could not open keystore due to KeyStoreException -- " + x.getMessage(), "Error", JOptionPane.ERROR_MESSAGE, null); exitApp = true; } catch (NoSuchAlgorithmException x) { keyStore = null; JOptionPane.showMessageDialog( null, "Could not open keystore due to NoSuchAlgorithmException -- " + x.getMessage(), "Error", JOptionPane.ERROR_MESSAGE, null); exitApp = true; } } if (exitApp) { swingSchema.setKeyStore(null); mainJFrame.exitApplication(); } else if (exitForm) { JInternalFrame nextForm = swingSchema.newOpenDeviceKeyJInternalFrame(); getDesktopPane().add(nextForm); nextForm.setVisible(true); nextForm.show(); Container cont = getParent(); while ((cont != null) && (!(cont instanceof JInternalFrame))) { cont = cont.getParent(); } if (cont != null) { JInternalFrame frame = (JInternalFrame) cont; try { frame.setClosed(true); } catch (Exception x) { } } } }