View Javadoc

1   /**
2      This file is part of GoldenGate Project (named also GoldenGate or GG).
3   
4      Copyright 2009, Frederic Bregier, and individual contributors by the @author
5      tags. See the COPYRIGHT.txt in the distribution for a full listing of
6      individual contributors.
7   
8      All GoldenGate Project is free software: you can redistribute it and/or 
9      modify it under the terms of the GNU General Public License as published 
10     by the Free Software Foundation, either version 3 of the License, or
11     (at your option) any later version.
12  
13     GoldenGate is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17  
18     You should have received a copy of the GNU General Public License
19     along with GoldenGate .  If not, see <http://www.gnu.org/licenses/>.
20   */
21  package goldengate.uip;
22  import goldengate.common.crypto.Blowfish;
23  import goldengate.common.crypto.Des;
24  import goldengate.common.exception.CryptoException;
25  
26  import java.awt.event.ActionEvent;
27  import java.awt.event.FocusAdapter;
28  import java.awt.event.FocusEvent;
29  import java.awt.event.WindowAdapter;
30  import java.awt.event.WindowEvent;
31  import java.io.File;
32  import java.io.IOException;
33  
34  import javax.swing.*;
35  import javax.swing.border.BevelBorder;
36  import javax.swing.filechooser.FileNameExtensionFilter;
37  
38  /**
39   * GUI for GoldenGate Password Management for GoldenGate products.
40   *
41  * This code was edited or generated using CloudGarden's Jigloo
42  * SWT/Swing GUI Builder, which is free for non-commercial
43  * use. If Jigloo is being used commercially (ie, by a corporation,
44  * company or business for any purpose whatever) then you
45  * should purchase a license for each developer using Jigloo.
46  * Please visit www.cloudgarden.com for details.
47  * Use of Jigloo implies acceptance of these licensing terms.
48  * A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
49  * THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
50  * LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
51  */
52  public class GgUiPassword extends javax.swing.JFrame {
53  
54      /**
55       * 
56       */
57      private static final long serialVersionUID = -4276191288898099362L;
58      private JMenuItem helpMenuItem;
59      private JMenu jMenu5;
60      private AbstractAction saveAsKeyAction;
61      private AbstractAction saveKeyAction;
62      private AbstractAction newKeyAction;
63      private AbstractAction openKeyAction;
64      private AbstractAction loadPswdAction;
65      private AbstractAction exitAction;
66      private JPanel jPanel1;
67      private JTextField jTextFieldPasswordFile;
68      private JPasswordField jPasswordField;
69      private JTextField jPasswordFieldTxt;
70      private JTextField jTextFieldCryptedPassword;
71      private JTextField jTextFieldKeyFile;
72      private JMenuItem savePasswordMenuItem;
73      private AbstractAction helpAction;
74      private AbstractAction savePaswdAction;
75      private JMenuItem loadPasswordMenuItem;
76      private JMenu jMenuPassword;
77      private JMenuItem exitMenuItem;
78      private JSeparator jSeparator2;
79      private JMenuItem saveAsMenuItem;
80      private JMenuItem saveMenuItem;
81      private JMenuItem openFileMenuItem;
82      private JMenuItem newFileMenuItem;
83      private JMenu jMenu3;
84      private JMenuBar jMenuBar1;
85  
86      private JFileChooser chooserKeyFile;
87      private FileNameExtensionFilter filterKey;
88      private JFileChooser chooserPwdFile;
89      private FileNameExtensionFilter filterPwdKey;
90  
91      private AbstractAction closeHelpAction;
92      private JTextPane jTextPaneHelp;
93      private JButton jButtonHelp;
94      private JDialog jDialogHelp;
95      private GgPassword ggPassword;
96      boolean passwordModified = false;
97  
98      /**
99      * Auto-generated main method to display this JFrame
100     */
101     public static void main(String[] args) {
102         if (! GgPassword.loadOptions(args)) {
103             // Bad options
104             System.exit(2);
105         }
106         SwingUtilities.invokeLater(new Runnable() {
107             public void run() {
108                 GgUiPassword inst = new GgUiPassword();
109                 inst.setLocationRelativeTo(null);
110                 inst.setVisible(true);
111             }
112         });
113     }
114 
115     public GgUiPassword() {
116         super();
117 
118         chooserKeyFile = new JFileChooser();
119         filterKey = new FileNameExtensionFilter(
120                 "DES or Blowfish Key ("+Des.EXTENSION+", "+Blowfish.EXTENSION+")",
121                 Des.EXTENSION, Blowfish.EXTENSION);
122         chooserKeyFile.setFileFilter(filterKey);
123         chooserKeyFile.setFileSelectionMode(JFileChooser.FILES_ONLY);
124 
125         chooserPwdFile = new JFileChooser();
126         filterPwdKey = new FileNameExtensionFilter(
127                 "GoldenGate Password Files ("+GgPassword.GGPEXTENSION+")",
128                 GgPassword.GGPEXTENSION);
129         chooserPwdFile.setFileFilter(filterPwdKey);
130         chooserPwdFile.setFileSelectionMode(JFileChooser.FILES_ONLY);
131 
132         try {
133             ggPassword = new GgPassword();
134         } catch (Exception e) {
135             // TODO Auto-generated catch block
136             e.printStackTrace();
137             System.exit(3);
138         }
139 
140         initGUI();
141         initFromGgPassword();
142     }
143 
144     private void initFromGgPassword() {
145         File keyFile = ggPassword.getKeyFile();
146         if (keyFile != null) {
147             jTextFieldKeyFile.setText(keyFile.getAbsolutePath());
148             enableMenuWithKey();
149         }
150         File pFile = ggPassword.getPasswordFile();
151         if (pFile != null) {
152             jTextFieldPasswordFile.setText(pFile.getAbsolutePath());
153         }
154         String clpwd = ggPassword.getClearPassword();
155         if (clpwd != null) {
156             setUncryptedPassword(clpwd);
157             clpwd = ggPassword.getCryptedPassword();
158             jTextFieldCryptedPassword.setText(clpwd);
159         }
160     }
161 
162     private void initGUI() {
163         try {
164             GroupLayout thisLayout = new GroupLayout((JComponent)getContentPane());
165             getContentPane().setLayout(thisLayout);
166             this.addWindowListener(new WindowAdapter() {
167                 public void windowClosing(WindowEvent evt) {
168                     if (passwordModified) {
169                         getSavePaswdAction().actionPerformed(null);
170                     }
171                     System.exit(1);
172                 }
173                 public void windowClosed(WindowEvent evt) {
174                     if (passwordModified) {
175                         getSavePaswdAction().actionPerformed(null);
176                     }
177                     System.exit(1);
178                 }
179             });
180             this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
181             this.setTitle("GoldenGate Password GUI");
182             this.setLocale(new java.util.Locale("en", "GB"));
183             {
184                 jTextFieldKeyFile = new JTextField();
185                 jTextFieldKeyFile.setText("Key File");
186                 jTextFieldKeyFile.setEditable(false);
187                 jTextFieldKeyFile.setBorder(BorderFactory.createCompoundBorder(
188                         BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0,0,0)),
189                         BorderFactory.createCompoundBorder(
190                                 null,
191                                 null)));
192             }
193             {
194                 jPanel1 = new JPanel();
195                 GroupLayout jPanel1Layout = new GroupLayout((JComponent)jPanel1);
196                 jPanel1.setLayout(jPanel1Layout);
197                 jPanel1.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
198                 {
199                     jTextFieldPasswordFile = new JTextField();
200                     jTextFieldPasswordFile.setText("Password File");
201                     jTextFieldPasswordFile.setEditable(false);
202                     jTextFieldPasswordFile.setBorder(BorderFactory.createCompoundBorder(
203                             BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0,0,0)),
204                             BorderFactory.createCompoundBorder(
205                                     null,
206                                     null)));
207                 }
208                 {
209                     if (GgPassword.clearPasswordView) {
210                         jPasswordFieldTxt = new JTextField();
211                         jPasswordFieldTxt.addFocusListener(new FocusAdapter() {
212                             public void focusLost(FocusEvent evt) {
213                                 String paswd = new String(jPasswordFieldTxt.getText());
214                                 if (! paswd.equals(ggPassword.getClearPassword())) {
215                                     try {
216                                         ggPassword.setClearPassword(new String(paswd));
217                                     } catch (Exception e) {
218                                         // TODO Auto-generated catch block
219                                         e.printStackTrace();
220                                     }
221                                     jTextFieldCryptedPassword.setText(ggPassword.getCryptedPassword());
222                                     passwordModified = true;
223                                 }
224                             }
225                         });
226                     } else {
227                         jPasswordField = new JPasswordField();
228                         jPasswordField.addFocusListener(new FocusAdapter() {
229                             public void focusLost(FocusEvent evt) {
230                                 String paswd = new String(jPasswordField.getPassword());
231                                 if (! paswd.equals(ggPassword.getClearPassword())) {
232                                     try {
233                                         ggPassword.setClearPassword(new String(paswd));
234                                     } catch (Exception e) {
235                                         // TODO Auto-generated catch block
236                                         e.printStackTrace();
237                                     }
238                                     jTextFieldCryptedPassword.setText(ggPassword.getCryptedPassword());
239                                     passwordModified = true;
240                                 }
241                             }
242                         });
243                     }
244                 }
245                 {
246                     jTextFieldCryptedPassword = new JTextField();
247                     jTextFieldCryptedPassword.addFocusListener(new FocusAdapter() {
248                         public void focusLost(FocusEvent evt) {
249                             String paswd = jTextFieldCryptedPassword.getText();
250                             if (! paswd.equals(ggPassword.getCryptedPassword())) {
251                                 try {
252                                     ggPassword.setCryptedPassword(paswd);
253                                 } catch (Exception e1) {
254                                     // TODO Auto-generated catch block
255                                     e1.printStackTrace();
256                                 }
257                                 setUncryptedPassword(ggPassword.getClearPassword());
258                                 jTextFieldCryptedPassword.setText(ggPassword.getCryptedPassword());
259                                 passwordModified = true;
260                             }
261                         }
262                     }
263                     );
264                 }
265                 if (GgPassword.clearPasswordView) {
266                     jPanel1Layout.setHorizontalGroup(jPanel1Layout.createSequentialGroup()
267                             .addContainerGap()
268                             .addGroup(jPanel1Layout.createParallelGroup()
269                                 .addGroup(jPanel1Layout.createSequentialGroup()
270                                     .addComponent(jTextFieldPasswordFile, GroupLayout.PREFERRED_SIZE, 340, GroupLayout.PREFERRED_SIZE)
271                                     .addGap(0, 0, Short.MAX_VALUE))
272                                 .addComponent(jPasswordFieldTxt, GroupLayout.Alignment.LEADING, 0, 341, Short.MAX_VALUE)
273                                 .addComponent(jTextFieldCryptedPassword, GroupLayout.Alignment.LEADING, 0, 338, Short.MAX_VALUE))
274                             .addContainerGap());
275                         jPanel1Layout.setVerticalGroup(jPanel1Layout.createSequentialGroup()
276                             .addContainerGap()
277                             .addComponent(jTextFieldPasswordFile, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE)
278                             .addGap(18)
279                             .addComponent(jPasswordFieldTxt, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE)
280                             .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 1, Short.MAX_VALUE)
281                             .addComponent(jTextFieldCryptedPassword, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE)
282                             .addContainerGap());
283                 } else {
284                     jPanel1Layout.setHorizontalGroup(jPanel1Layout.createSequentialGroup()
285                             .addContainerGap()
286                             .addGroup(jPanel1Layout.createParallelGroup()
287                                 .addGroup(jPanel1Layout.createSequentialGroup()
288                                     .addComponent(jTextFieldPasswordFile, GroupLayout.PREFERRED_SIZE, 340, GroupLayout.PREFERRED_SIZE)
289                                     .addGap(0, 0, Short.MAX_VALUE))
290                                 .addComponent(jPasswordField, GroupLayout.Alignment.LEADING, 0, 341, Short.MAX_VALUE)
291                                 .addComponent(jTextFieldCryptedPassword, GroupLayout.Alignment.LEADING, 0, 338, Short.MAX_VALUE))
292                             .addContainerGap());
293                         jPanel1Layout.setVerticalGroup(jPanel1Layout.createSequentialGroup()
294                             .addContainerGap()
295                             .addComponent(jTextFieldPasswordFile, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE)
296                             .addGap(18)
297                             .addComponent(jPasswordField, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE)
298                             .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 1, Short.MAX_VALUE)
299                             .addComponent(jTextFieldCryptedPassword, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE)
300                             .addContainerGap());
301                 }
302             }
303             thisLayout.setVerticalGroup(thisLayout.createSequentialGroup()
304                 .addContainerGap()
305                 .addComponent(jTextFieldKeyFile, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE)
306                 .addGap(21)
307                 .addComponent(jPanel1, GroupLayout.PREFERRED_SIZE, 143, GroupLayout.PREFERRED_SIZE)
308                 .addContainerGap(31, Short.MAX_VALUE));
309             thisLayout.setHorizontalGroup(thisLayout.createSequentialGroup()
310                 .addContainerGap()
311                 .addGroup(thisLayout.createParallelGroup()
312                     .addComponent(jPanel1, GroupLayout.Alignment.LEADING, 0, 366, Short.MAX_VALUE)
313                     .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
314                         .addGap(7)
315                         .addComponent(jTextFieldKeyFile, 0, 353, Short.MAX_VALUE)
316                         .addGap(6)))
317                 .addGap(6));
318             setSize(400, 300);
319             {
320                 jMenuBar1 = new JMenuBar();
321                 setJMenuBar(jMenuBar1);
322                 {
323                     jMenu3 = new JMenu();
324                     jMenuBar1.add(jMenu3);
325                     jMenu3.setText("File");
326                     {
327                         openFileMenuItem = new JMenuItem();
328                         jMenu3.add(openFileMenuItem);
329                         openFileMenuItem.setText("Open Key");
330                         openFileMenuItem.setAction(getOpenKeyAction());
331                     }
332                     {
333                         newFileMenuItem = new JMenuItem();
334                         jMenu3.add(newFileMenuItem);
335                         newFileMenuItem.setText("New Key");
336                         newFileMenuItem.setAction(getNewKeyAction());
337                     }
338                     {
339                         saveMenuItem = new JMenuItem();
340                         jMenu3.add(saveMenuItem);
341                         saveMenuItem.setText("Save Key");
342                         saveMenuItem.setAction(getSaveKeyAction());
343                         saveMenuItem.setEnabled(false);
344                     }
345                     {
346                         saveAsMenuItem = new JMenuItem();
347                         jMenu3.add(saveAsMenuItem);
348                         saveAsMenuItem.setText("Save Key As ...");
349                         saveAsMenuItem.setAction(getSaveAsKeyAction());
350                         saveAsMenuItem.setEnabled(false);
351                     }
352                     {
353                         jSeparator2 = new JSeparator();
354                         jMenu3.add(jSeparator2);
355                     }
356                     {
357                         exitMenuItem = new JMenuItem();
358                         jMenu3.add(exitMenuItem);
359                         exitMenuItem.setText("Exit");
360                         exitMenuItem.setAction(getExitAction());
361                     }
362                 }
363                 {
364                     jMenuPassword = new JMenu();
365                     jMenuBar1.add(jMenuPassword);
366                     jMenuPassword.setText("Password");
367                     jMenuPassword.setEnabled(false);
368                     {
369                         loadPasswordMenuItem = new JMenuItem();
370                         jMenuPassword.add(loadPasswordMenuItem);
371                         loadPasswordMenuItem.setText("Load");
372                         loadPasswordMenuItem.setAction(getLoadPswdAction());
373                     }
374                     {
375                         savePasswordMenuItem = new JMenuItem();
376                         jMenuPassword.add(savePasswordMenuItem);
377                         savePasswordMenuItem.setText("Save");
378                         savePasswordMenuItem.setAction(getSavePaswdAction());
379                     }
380                 }
381                 {
382                     jMenu5 = new JMenu();
383                     jMenuBar1.add(jMenu5);
384                     jMenu5.setText("Help");
385                     {
386                         helpMenuItem = new JMenuItem();
387                         jMenu5.add(helpMenuItem);
388                         helpMenuItem.setText("Help");
389                         helpMenuItem.setAction(getHelpAction());
390                     }
391                 }
392             }
393         } catch (Exception e) {
394             e.printStackTrace();
395         }
396     }
397 
398     private AbstractAction getExitAction() {
399         if(exitAction == null) {
400             exitAction = new AbstractAction("Exit", null) {
401                 /**
402                  * 
403                  */
404                 private static final long serialVersionUID = 7484447837851868127L;
405 
406                 public void actionPerformed(ActionEvent evt) {
407                     //TODO FIXME Add control on exit (save)
408                     if (passwordModified) {
409                         getSavePaswdAction().actionPerformed(evt);
410                     }
411                     System.exit(1);
412                 }
413             };
414         }
415         return exitAction;
416     }
417 
418     private String getUncryptedPassword() {
419         if (GgPassword.clearPasswordView) {
420             return jPasswordFieldTxt.getText();
421         } else {
422             return new String(jPasswordField.getPassword());
423         }
424     }
425 
426     private void setUncryptedPassword(String passwd) {
427         if (GgPassword.clearPasswordView) {
428             jPasswordFieldTxt.setText(passwd);
429         } else {
430             jPasswordField.setText(passwd);
431         }
432     }
433 
434     private void updateCryptedPassword() {
435         try {
436             ggPassword.setClearPassword(getUncryptedPassword());
437         } catch (Exception e) {
438             // TODO Auto-generated catch block
439             e.printStackTrace();
440         }
441         jTextFieldCryptedPassword.setText(ggPassword.getCryptedPassword());
442         passwordModified = true;
443     }
444 
445     private void enableMenuWithKey() {
446         saveAsMenuItem.setEnabled(true);
447         saveMenuItem.setEnabled(true);
448         jMenuPassword.setEnabled(true);
449     }
450     private AbstractAction getOpenKeyAction() {
451         if(openKeyAction == null) {
452             openKeyAction = new AbstractAction("Open Key", null) {
453                 /**
454                  * 
455                  */
456                 private static final long serialVersionUID = -3840578648343599999L;
457 
458                 public void actionPerformed(ActionEvent evt) {
459                     jTextFieldPasswordFile.setText("");
460                     jTextFieldCryptedPassword.setText("");
461                     chooserKeyFile.setDialogType(JFileChooser.OPEN_DIALOG);
462                     int response = chooserKeyFile.showOpenDialog(rootPane);
463                     if (response == JFileChooser.APPROVE_OPTION) {
464                         File file = chooserKeyFile.getSelectedFile();
465                         jTextFieldKeyFile.setText(file.getAbsolutePath());
466                         try {
467                             ggPassword.loadKey(file);
468                             updateCryptedPassword();
469                             enableMenuWithKey();
470                         } catch (CryptoException e) {
471                             // TODO Auto-generated catch block
472                             e.printStackTrace();
473                         }
474                     }
475                 }
476             };
477         }
478         return openKeyAction;
479     }
480 
481     private AbstractAction getNewKeyAction() {
482         if(newKeyAction == null) {
483             newKeyAction = new AbstractAction("New Key", null) {
484                 /**
485                  * 
486                  */
487                 private static final long serialVersionUID = 10107370851157816L;
488 
489                 public void actionPerformed(ActionEvent evt) {
490                     try {
491                         ggPassword.createNewKey();
492                     } catch (Exception e) {
493                         // TODO Auto-generated catch block
494                         e.printStackTrace();
495                     }
496                     updateCryptedPassword();
497                     enableMenuWithKey();
498                 }
499             };
500         }
501         return newKeyAction;
502     }
503 
504     private AbstractAction getSaveKeyAction() {
505         if(saveKeyAction == null) {
506             saveKeyAction = new AbstractAction("Save Key", null) {
507                 /**
508                  * 
509                  */
510                 private static final long serialVersionUID = 4400661431842092244L;
511 
512                 public void actionPerformed(ActionEvent evt) {
513                     try {
514                         ggPassword.saveKey(null);
515                     } catch (CryptoException e) {
516                         // TODO Auto-generated catch block
517                         e.printStackTrace();
518                     }
519                     passwordModified = false;
520                 }
521             };
522         }
523         return saveKeyAction;
524     }
525 
526     private AbstractAction getSaveAsKeyAction() {
527         if(saveAsKeyAction == null) {
528             saveAsKeyAction = new AbstractAction("Save Key As...", null) {
529                 /**
530                  * 
531                  */
532                 private static final long serialVersionUID = 565842888109816432L;
533 
534                 public void actionPerformed(ActionEvent evt) {
535                     chooserKeyFile.setDialogType(JFileChooser.SAVE_DIALOG);
536                     int response = chooserKeyFile.showSaveDialog(rootPane);
537                     if (response == JFileChooser.APPROVE_OPTION) {
538                         File file = chooserKeyFile.getSelectedFile();
539                         if (! filterKey.accept(file)) {
540                             if (GgPassword.desModel) {
541                                 file = new File(file.getAbsoluteFile()+"."+Des.EXTENSION);
542                             } else {
543                                 file = new File(file.getAbsoluteFile()+"."+Blowfish.EXTENSION);
544                             }
545                         }
546                         jTextFieldKeyFile.setText(file.getAbsolutePath());
547                         try {
548                             ggPassword.saveKey(file);
549                         } catch (CryptoException e) {
550                             // TODO Auto-generated catch block
551                             e.printStackTrace();
552                         }
553                         passwordModified = false;
554                     }
555                 }
556             };
557         }
558         return saveAsKeyAction;
559     }
560 
561     private AbstractAction getLoadPswdAction() {
562         if(loadPswdAction == null) {
563             loadPswdAction = new AbstractAction("Load", null) {
564                 /**
565                  * 
566                  */
567                 private static final long serialVersionUID = -3100726446117809610L;
568 
569                 public void actionPerformed(ActionEvent evt) {
570                     chooserPwdFile.setDialogType(JFileChooser.OPEN_DIALOG);
571                     int response = chooserPwdFile.showOpenDialog(rootPane);
572                     if (response == JFileChooser.APPROVE_OPTION) {
573                         File file = chooserPwdFile.getSelectedFile();
574                         jTextFieldPasswordFile.setText(file.getAbsolutePath());
575                         ggPassword.setPasswordFile(file);
576                         try {
577                             ggPassword.loadPasswordFile();
578                         } catch (CryptoException e) {
579                             // TODO Auto-generated catch block
580                             e.printStackTrace();
581                         } catch (Exception e) {
582                             // TODO Auto-generated catch block
583                             e.printStackTrace();
584                         }
585                         setUncryptedPassword(ggPassword.getClearPassword());
586                         jTextFieldCryptedPassword.setText(ggPassword.getCryptedPassword());
587                         passwordModified = false;
588                     }
589                 }
590             };
591         }
592         return loadPswdAction;
593     }
594 
595     private AbstractAction getSavePaswdAction() {
596         if(savePaswdAction == null) {
597            savePaswdAction = new AbstractAction("Save", null) {
598                 /**
599              * 
600              */
601             private static final long serialVersionUID = -5712120697650940845L;
602 
603                 public void actionPerformed(ActionEvent evt) {
604                     chooserPwdFile.setDialogType(JFileChooser.SAVE_DIALOG);
605                     int response = chooserPwdFile.showSaveDialog(rootPane);
606                     if (response == JFileChooser.APPROVE_OPTION) {
607                         File file = chooserPwdFile.getSelectedFile();
608                         if (! filterPwdKey.accept(file)) {
609                             file = new File(file.getAbsoluteFile()+"."+GgPassword.GGPEXTENSION);
610                         }
611                         jTextFieldPasswordFile.setText(file.getAbsolutePath());
612                         ggPassword.setPasswordFile(file);
613                         try {
614                             ggPassword.savePasswordFile();
615                         } catch (IOException e) {
616                             // TODO Auto-generated catch block
617                             e.printStackTrace();
618                         }
619                         passwordModified = false;
620                     }
621                 }
622             };
623         }
624         return savePaswdAction;
625     }
626 
627     private AbstractAction getHelpAction() {
628         if(helpAction == null) {
629             helpAction = new AbstractAction("Help", null) {
630                 /**
631                  * 
632                  */
633                 private static final long serialVersionUID = -8528091873190483826L;
634 
635                 public void actionPerformed(ActionEvent evt) {
636                     getJDialogHelp().setVisible(true);
637                 }
638             };
639         }
640         return helpAction;
641     }
642 
643     private JDialog getJDialogHelp() {
644         if(jDialogHelp == null) {
645             jDialogHelp = new JDialog(this);
646             GroupLayout jDialogHelpLayout = new GroupLayout((JComponent)jDialogHelp.getContentPane());
647             jDialogHelp.setLayout(jDialogHelpLayout);
648             jDialogHelp.getContentPane().setBackground(new java.awt.Color(255,255,255));
649             jDialogHelp.setPreferredSize(new java.awt.Dimension(670, 479));
650             jDialogHelp.setSize(670, 479);
651             jDialogHelpLayout.setHorizontalGroup(jDialogHelpLayout.createSequentialGroup()
652                 .addContainerGap(27, 27)
653                 .addGroup(jDialogHelpLayout.createParallelGroup()
654                     .addComponent(getJTextPaneHelp(), GroupLayout.Alignment.LEADING, 0, 604, Short.MAX_VALUE)
655                     .addGroup(GroupLayout.Alignment.LEADING, jDialogHelpLayout.createSequentialGroup()
656                         .addGap(254)
657                         .addComponent(getJButtonHelp(), GroupLayout.PREFERRED_SIZE, 111, GroupLayout.PREFERRED_SIZE)
658                         .addGap(0, 239, Short.MAX_VALUE)))
659                 .addContainerGap(23, 23));
660             jDialogHelpLayout.setVerticalGroup(jDialogHelpLayout.createSequentialGroup()
661                 .addContainerGap()
662                 .addComponent(getJTextPaneHelp(), 0, 395, Short.MAX_VALUE)
663                 .addComponent(getJButtonHelp(), GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
664                 .addContainerGap());
665         }
666         return jDialogHelp;
667     }
668 
669     private JButton getJButtonHelp() {
670         if(jButtonHelp == null) {
671             jButtonHelp = new JButton();
672             jButtonHelp.setText("OK");
673             jButtonHelp.setAction(getCloseHelpAction());
674         }
675         return jButtonHelp;
676     }
677 
678     private JTextPane getJTextPaneHelp() {
679         if(jTextPaneHelp == null) {
680             jTextPaneHelp = new JTextPane();
681             jTextPaneHelp.setText("                                            "+
682                     "                            GoldenGate GUI Password Tool\r\n\r\n"+
683                     "A) Key for crypto support\r\n\r\n"+
684                     "* First you need to open a Key File (Open) or to create a "+
685                     "New Key File (New Key) and to save it (Save Key As...)\r\n"+
686                     "* You can at any moment save the Key File to a new "+
687                     "Key File (Save Key As...)\r\n\r\n"+
688                     "B) Password with Crypto Key\r\n"+
689                     "* Then you need to get a Password:\r\n"+
690                     "1) Enter a password in the Password field\r\n"+
691                     "2) Load a password from a Password file (compatible with "+
692                     "the current Key) (Load)\r\n"+
693                     "* Then you need to save this password (encrypted) to "+
694                     "a File (Save)\r\n\r\n"+
695                     "C) "+GgPassword.HELPOPTIONS);
696             jTextPaneHelp.setEditable(false);
697             jTextPaneHelp.setBackground(new java.awt.Color(255,255,255));
698         }
699         return jTextPaneHelp;
700     }
701 
702     private AbstractAction getCloseHelpAction() {
703         if(closeHelpAction == null) {
704             closeHelpAction = new AbstractAction("Close", null) {
705                 /**
706                  * 
707                  */
708                 private static final long serialVersionUID = -2310092372166868386L;
709 
710                 public void actionPerformed(ActionEvent evt) {
711                     getJDialogHelp().dispose();
712                 }
713             };
714         }
715         return closeHelpAction;
716     }
717 
718 }