Source Code Cross Referenced for EncryptBugDBPropTool.java in  » Test-Coverage » salome-tmf » salomeTMF_plug » bugzilla » tools » encrypt_prop » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Test Coverage » salome tmf » salomeTMF_plug.bugzilla.tools.encrypt_prop 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * SalomeTMF is a Test Management Framework
003:         * Copyright (C) 2005 France Telecom R&D
004:         *
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation; either
008:         * version 2 of the License, or (at your option) any later version.
009:         *
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013:         * Lesser General Public License for more details.
014:         *
015:         * You should have received a copy of the GNU Lesser General Public
016:         * License along with this library; if not, write to the Free Software
017:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018:         *
019:         * @author Fayçal SOUGRATI, Vincent Pautret, Marche Mikael
020:         *
021:         * Contact: mikael.marche@rd.francetelecom.com
022:         */
023:
024:        package salomeTMF_plug.bugzilla.tools.encrypt_prop;
025:
026:        import java.io.DataOutputStream;
027:        import java.io.File;
028:        import java.io.FileOutputStream;
029:        import java.io.InputStream;
030:        import java.io.OutputStream;
031:        import java.net.URL;
032:        import java.util.Properties;
033:
034:        import javax.swing.JFileChooser;
035:        import javax.swing.JOptionPane;
036:        import javax.swing.filechooser.FileFilter;
037:
038:        /**
039:         *
040:         * @author  capg2710
041:         */
042:        public class EncryptBugDBPropTool extends javax.swing.JFrame {
043:
044:            File propFile = null;
045:            File keyFile = null;
046:            Properties prop = new Properties();
047:            boolean keyFileExists = true;
048:            URL urlDir = null;
049:
050:            /** Creates new form EncryptDBPropTool */
051:            public EncryptBugDBPropTool() {
052:                initComponents();
053:            }
054:
055:            /** This method is called from within the constructor to
056:             * initialize the form.
057:             * WARNING: Do NOT modify this code. The content of this method is
058:             * always regenerated by the Form Editor.
059:             */
060:            private void initComponents() {//GEN-BEGIN:initComponents
061:                propsFilePanel = new javax.swing.JPanel();
062:                propFileLabel = new javax.swing.JLabel();
063:                propFileField = new javax.swing.JTextField();
064:                chooseFileButton = new javax.swing.JButton();
065:                jLabel7 = new javax.swing.JLabel();
066:                bugzillaField = new javax.swing.JTextField();
067:                jPanel9 = new javax.swing.JPanel();
068:                jdbcDriverLabel = new javax.swing.JLabel();
069:                jdbcDriverField = new javax.swing.JTextField();
070:                jPanel1 = new javax.swing.JPanel();
071:                jLabel3 = new javax.swing.JLabel();
072:                jLabel1 = new javax.swing.JLabel();
073:                jLabel6 = new javax.swing.JLabel();
074:                jLabel2 = new javax.swing.JLabel();
075:                databaseURLField = new javax.swing.JTextField();
076:                jPanel2 = new javax.swing.JPanel();
077:                jLabel4 = new javax.swing.JLabel();
078:                jLabel5 = new javax.swing.JLabel();
079:                dbUserLabel = new javax.swing.JLabel();
080:                dbUserField = new javax.swing.JTextField();
081:                jPanel3 = new javax.swing.JPanel();
082:                userPwdLabel = new javax.swing.JLabel();
083:                userPwdField = new javax.swing.JTextField();
084:                jPanel8 = new javax.swing.JPanel();
085:                jLabel8 = new javax.swing.JLabel();
086:                urlBugField = new javax.swing.JTextField();
087:                jPanel10 = new javax.swing.JPanel();
088:                jLabel9 = new javax.swing.JLabel();
089:                jLabel10 = new javax.swing.JLabel();
090:                jLabel11 = new javax.swing.JLabel();
091:                jScrollPane1 = new javax.swing.JScrollPane();
092:                osTextPane = new javax.swing.JTextPane();
093:                jPanel11 = new javax.swing.JPanel();
094:                jLabel12 = new javax.swing.JLabel();
095:                jScrollPane2 = new javax.swing.JScrollPane();
096:                prioritiesTextPane = new javax.swing.JTextPane();
097:                jPanel12 = new javax.swing.JPanel();
098:                jLabel13 = new javax.swing.JLabel();
099:                jScrollPane3 = new javax.swing.JScrollPane();
100:                platformsTextPane = new javax.swing.JTextPane();
101:                jPanel13 = new javax.swing.JPanel();
102:                jLabel14 = new javax.swing.JLabel();
103:                jScrollPane4 = new javax.swing.JScrollPane();
104:                severitiesTextPane = new javax.swing.JTextPane();
105:                jPanel14 = new javax.swing.JPanel();
106:                buttonsPanel = new javax.swing.JPanel();
107:                jPanel4 = new javax.swing.JPanel();
108:                encryptButton = new javax.swing.JButton();
109:                cancelButton = new javax.swing.JButton();
110:                jPanel5 = new javax.swing.JPanel();
111:                jPanel6 = new javax.swing.JPanel();
112:                jPanel7 = new javax.swing.JPanel();
113:
114:                setTitle("Encrypt Bugzilla Database properties tool");
115:                setLocationRelativeTo(this );
116:                addWindowListener(new java.awt.event.WindowAdapter() {
117:                    public void windowClosing(java.awt.event.WindowEvent evt) {
118:                        exitForm(evt);
119:                    }
120:                });
121:
122:                propsFilePanel.setLayout(new java.awt.GridLayout(11, 3, 3, 3));
123:
124:                propsFilePanel.setMinimumSize(new java.awt.Dimension(400, 300));
125:                propsFilePanel
126:                        .setPreferredSize(new java.awt.Dimension(800, 400));
127:                propFileLabel
128:                        .setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
129:                propFileLabel.setText("Bugzilla properties file :");
130:                propsFilePanel.add(propFileLabel);
131:
132:                propFileField.setEditable(false);
133:                propsFilePanel.add(propFileField);
134:
135:                chooseFileButton
136:                        .setIcon(new javax.swing.ImageIcon(
137:                                getClass()
138:                                        .getResource(
139:                                                "/salomeTMF_plug/bugzilla/resources/img/openFile.gif")));
140:                chooseFileButton.setText("Open a file...");
141:                chooseFileButton
142:                        .addActionListener(new java.awt.event.ActionListener() {
143:                            public void actionPerformed(
144:                                    java.awt.event.ActionEvent evt) {
145:                                chooseFilePerformed(evt);
146:                            }
147:                        });
148:
149:                propsFilePanel.add(chooseFileButton);
150:
151:                jLabel7
152:                        .setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
153:                jLabel7.setText("Bugzilla :");
154:                propsFilePanel.add(jLabel7);
155:
156:                propsFilePanel.add(bugzillaField);
157:
158:                propsFilePanel.add(jPanel9);
159:
160:                jdbcDriverLabel
161:                        .setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
162:                jdbcDriverLabel.setText("JDBC driver :");
163:                propsFilePanel.add(jdbcDriverLabel);
164:
165:                propsFilePanel.add(jdbcDriverField);
166:
167:                jPanel1.setLayout(new java.awt.BorderLayout());
168:
169:                jLabel3.setText("com.mysql.jdbc.Driver");
170:                jPanel1.add(jLabel3, java.awt.BorderLayout.WEST);
171:
172:                jLabel1.setText("Exemple :");
173:                jPanel1.add(jLabel1, java.awt.BorderLayout.NORTH);
174:
175:                jPanel1.add(jLabel6, java.awt.BorderLayout.SOUTH);
176:
177:                propsFilePanel.add(jPanel1);
178:
179:                jLabel2
180:                        .setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
181:                jLabel2.setText("Bugzilla database URL :");
182:                propsFilePanel.add(jLabel2);
183:
184:                propsFilePanel.add(databaseURLField);
185:
186:                jPanel2.setLayout(new java.awt.BorderLayout());
187:
188:                jLabel4.setText("jdbc\\:mysql\\://L-AT5568/DB");
189:                jPanel2.add(jLabel4, java.awt.BorderLayout.CENTER);
190:
191:                jLabel5.setText("Exemple : ");
192:                jPanel2.add(jLabel5, java.awt.BorderLayout.NORTH);
193:
194:                propsFilePanel.add(jPanel2);
195:
196:                dbUserLabel
197:                        .setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
198:                dbUserLabel.setText("Bugzilla database user :");
199:                propsFilePanel.add(dbUserLabel);
200:
201:                propsFilePanel.add(dbUserField);
202:
203:                propsFilePanel.add(jPanel3);
204:
205:                userPwdLabel
206:                        .setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
207:                userPwdLabel.setText("Bugzilla user password :");
208:                propsFilePanel.add(userPwdLabel);
209:
210:                propsFilePanel.add(userPwdField);
211:
212:                propsFilePanel.add(jPanel8);
213:
214:                jLabel8
215:                        .setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
216:                jLabel8.setText("Bugzilla web page :");
217:                propsFilePanel.add(jLabel8);
218:
219:                urlBugField
220:                        .addActionListener(new java.awt.event.ActionListener() {
221:                            public void actionPerformed(
222:                                    java.awt.event.ActionEvent evt) {
223:                                urlBugFieldActionPerformed(evt);
224:                            }
225:                        });
226:
227:                propsFilePanel.add(urlBugField);
228:
229:                jPanel10.setLayout(new java.awt.BorderLayout());
230:
231:                jLabel9.setText("http://lat4630/bugzilla");
232:                jPanel10.add(jLabel9, java.awt.BorderLayout.CENTER);
233:
234:                jLabel10.setText("Exemple :");
235:                jPanel10.add(jLabel10, java.awt.BorderLayout.NORTH);
236:
237:                propsFilePanel.add(jPanel10);
238:
239:                jLabel11
240:                        .setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
241:                jLabel11.setText("OS list :");
242:                propsFilePanel.add(jLabel11);
243:
244:                jScrollPane1.setViewportView(osTextPane);
245:
246:                propsFilePanel.add(jScrollPane1);
247:
248:                propsFilePanel.add(jPanel11);
249:
250:                jLabel12
251:                        .setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
252:                jLabel12.setText("Priorities list :");
253:                propsFilePanel.add(jLabel12);
254:
255:                jScrollPane2.setViewportView(prioritiesTextPane);
256:
257:                propsFilePanel.add(jScrollPane2);
258:
259:                propsFilePanel.add(jPanel12);
260:
261:                jLabel13
262:                        .setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
263:                jLabel13.setText("Platforms list : ");
264:                propsFilePanel.add(jLabel13);
265:
266:                jScrollPane3.setViewportView(platformsTextPane);
267:
268:                propsFilePanel.add(jScrollPane3);
269:
270:                propsFilePanel.add(jPanel13);
271:
272:                jLabel14
273:                        .setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
274:                jLabel14.setText("Bug severities list :");
275:                propsFilePanel.add(jLabel14);
276:
277:                jScrollPane4.setViewportView(severitiesTextPane);
278:
279:                propsFilePanel.add(jScrollPane4);
280:
281:                propsFilePanel.add(jPanel14);
282:
283:                getContentPane().add(propsFilePanel,
284:                        java.awt.BorderLayout.CENTER);
285:
286:                buttonsPanel.setLayout(new java.awt.BorderLayout());
287:
288:                encryptButton
289:                        .setFont(new java.awt.Font("MS Sans Serif", 1, 14));
290:                encryptButton.setForeground(new java.awt.Color(0, 153, 0));
291:                encryptButton
292:                        .setIcon(new javax.swing.ImageIcon(
293:                                getClass()
294:                                        .getResource(
295:                                                "/salomeTMF_plug/bugzilla/resources/img/encrypt.gif")));
296:                encryptButton.setText("Encrypt");
297:                encryptButton
298:                        .addActionListener(new java.awt.event.ActionListener() {
299:                            public void actionPerformed(
300:                                    java.awt.event.ActionEvent evt) {
301:                                encryptPerformed(evt);
302:                            }
303:                        });
304:
305:                jPanel4.add(encryptButton);
306:
307:                cancelButton.setFont(new java.awt.Font("MS Sans Serif", 0, 12));
308:                cancelButton.setForeground(new java.awt.Color(255, 0, 0));
309:                cancelButton.setText("Cancel");
310:                cancelButton.setMinimumSize(new java.awt.Dimension(121, 41));
311:                cancelButton.setPreferredSize(new java.awt.Dimension(121, 41));
312:                cancelButton
313:                        .addActionListener(new java.awt.event.ActionListener() {
314:                            public void actionPerformed(
315:                                    java.awt.event.ActionEvent evt) {
316:                                cancelPerformed(evt);
317:                            }
318:                        });
319:
320:                jPanel4.add(cancelButton);
321:
322:                buttonsPanel.add(jPanel4, java.awt.BorderLayout.CENTER);
323:
324:                getContentPane().add(buttonsPanel, java.awt.BorderLayout.SOUTH);
325:
326:                getContentPane().add(jPanel5, java.awt.BorderLayout.NORTH);
327:
328:                getContentPane().add(jPanel6, java.awt.BorderLayout.EAST);
329:
330:                getContentPane().add(jPanel7, java.awt.BorderLayout.WEST);
331:
332:                // Default values
333:                bugzillaField.setText("on");
334:                jdbcDriverField.setText("com.mysql.jdbc.Driver");
335:                osTextPane
336:                        .setText("All, Windows 3.1, Windows 95, Windows 98, Windows ME, "
337:                                + "Windows 2000, Windows NT, Windows XP, Mac System 7, Mac System 7.5, "
338:                                + "Mac System 7.6.1, Mac System 8.0, Mac System 8.5, Mac System 8.6, "
339:                                + "Mac System 9.x, MacOS X, Linux, BSDI, FreeBSD, NetBSD, OpenBSD, AIX, "
340:                                + "BeOS, HP-UX, IRIX, Neutrino, OpenVMS, OS/2, OSF/1, Solaris, SunOS, other");
341:                prioritiesTextPane.setText("P1, P2, P3, P4, P5");
342:                platformsTextPane
343:                        .setText("All, DEC, HP, Macintosh, PC, SGI, Sun, Other");
344:                severitiesTextPane
345:                        .setText("blocker, critical, major, normal, minor, trivial, enhancement");
346:
347:                pack();
348:            }//GEN-END:initComponents
349:
350:            private void urlBugFieldActionPerformed(
351:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_urlBugFieldActionPerformed
352:                // TODO add your handling code here:
353:            }//GEN-LAST:event_urlBugFieldActionPerformed
354:
355:            private void encryptPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_encryptPerformed
356:                prop.setProperty("Bugzilla", bugzillaField.getText());
357:                prop.setProperty("DriverJDBC", jdbcDriverField.getText());
358:                prop.setProperty("URLDB_BugZilla", databaseURLField.getText());
359:                prop.setProperty("User_BugZilla", dbUserField.getText());
360:                prop.setProperty("URLHTTP_BugZilla", urlBugField.getText());
361:
362:                prop.setProperty("OS", osTextPane.getText());
363:                prop.setProperty("Priorities", prioritiesTextPane.getText());
364:                prop.setProperty("Plateforms", platformsTextPane.getText());
365:                prop.setProperty("Severities", severitiesTextPane.getText());
366:
367:                String clearKey = userPwdField.getText();
368:                // TODO add your handling code here:
369:                // Cas ou le fichier properties existe
370:                if (!propFileField.getText().equals("")) {
371:                    // Cas ou la clé de cryptage existe
372:                    if (keyFileExists) {
373:                        try {
374:                            MD5paswd.readkey(keyFile);
375:                        } catch (Exception e1) {
376:                            e1.printStackTrace();
377:                            JOptionPane.showMessageDialog(this ,
378:                                    "Problème lecture de la clé de cryptage",
379:                                    "Erreur...", JOptionPane.ERROR_MESSAGE);
380:                        }
381:                        /*}
382:                        // Cas ou cette clé n'existe pas
383:                        else {
384:                            try {
385:                                MD5paswd.writekey(urlDir.getPath());
386:                                keyFileExists = true;
387:                                MD5paswd.readkey(urlDir);
388:                            } catch (Exception e1) {
389:                                e1.printStackTrace();
390:                                JOptionPane.showMessageDialog(this,
391:                                "Problème d'écriture de la clé de cryptage",
392:                                "Erreur...",
393:                                JOptionPane.ERROR_MESSAGE);
394:                            }
395:                            
396:                        }*/
397:
398:                        String cryptedKey = MD5paswd.encrypString(clearKey);
399:                        prop.setProperty("Password", cryptedKey);
400:                    }
401:
402:                    try {
403:                        OutputStream os = new DataOutputStream(
404:                                new FileOutputStream(propFile));
405:                        prop.store(os, "");
406:                        JOptionPane.showMessageDialog(this ,
407:                                "Le fichier properties a bien été enregistré",
408:                                "Info...", JOptionPane.INFORMATION_MESSAGE);
409:                    } catch (Exception e2) {
410:                        e2.printStackTrace();
411:                        JOptionPane
412:                                .showMessageDialog(
413:                                        this ,
414:                                        "Problème d'ecriture dans le fichier properties",
415:                                        "Erreur...", JOptionPane.ERROR_MESSAGE);
416:                    }
417:                }
418:                // Cas ou le fichier properties n'existe pas
419:                else {
420:                    Object[] options = { "Oui", "Non" };
421:                    int choice = JOptionPane
422:                            .showOptionDialog(
423:                                    this ,
424:                                    "Voulez-vous indiquer l'emplacement du fichier clé afin de pouvoir\n"
425:                                            + "encrypter le mot de passe? (sinon le mot de passe sera enregistré en clair)",
426:                                    "Attention !", JOptionPane.YES_NO_OPTION,
427:                                    JOptionPane.QUESTION_MESSAGE, null,
428:                                    options, options[1]);
429:
430:                    if (choice == JOptionPane.YES_OPTION) {
431:                        JFileChooser fileChooserForKey = new JFileChooser();
432:                        fileChooserForKey.setApproveButtonText("Valider");
433:                        int val = fileChooserForKey
434:                                .showOpenDialog(EncryptBugDBPropTool.this );
435:                        if (val == JFileChooser.APPROVE_OPTION) {
436:                            try {
437:                                keyFile = fileChooserForKey.getSelectedFile();
438:                                MD5paswd.readkey(keyFile);
439:                                String cryptedKey = MD5paswd
440:                                        .encrypString(clearKey);
441:                                prop.setProperty("Password", cryptedKey);
442:                            } catch (Exception e3) {
443:                                e3.printStackTrace();
444:                                JOptionPane
445:                                        .showMessageDialog(
446:                                                this ,
447:                                                "Problème lors de l'ouverture du fichier clé!",
448:                                                "Avertissement...",
449:                                                JOptionPane.WARNING_MESSAGE);
450:                            }
451:
452:                        } else {
453:                            keyFileExists = false;
454:                            prop.setProperty("Password", clearKey);
455:                        }
456:                    } else {
457:                        keyFileExists = false;
458:                        prop.setProperty("Password", clearKey);
459:                    }
460:
461:                    JOptionPane
462:                            .showMessageDialog(
463:                                    this ,
464:                                    "Vous devez choisir un emplacement ou le fichier 'CfgBugzilla.properties' sera cree.",
465:                                    "Info...", JOptionPane.INFORMATION_MESSAGE);
466:
467:                    JFileChooser fileChooser = new JFileChooser();
468:                    fileChooser.setApproveButtonText("Valider");
469:                    fileChooser
470:                            .setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
471:                    int returnVal = fileChooser
472:                            .showOpenDialog(EncryptBugDBPropTool.this );
473:                    if (returnVal == JFileChooser.APPROVE_OPTION) {
474:
475:                        try {
476:                            propFile = new File(fileChooser.getSelectedFile()
477:                                    .getPath()
478:                                    + java.io.File.separator
479:                                    + "CfgBugzilla.properties");
480:                            OutputStream os = new DataOutputStream(
481:                                    new FileOutputStream(propFile));
482:                            prop.store(os, "");
483:
484:                        } catch (Exception e2) {
485:                            e2.printStackTrace();
486:                            JOptionPane
487:                                    .showMessageDialog(
488:                                            this ,
489:                                            "Problème d'ecriture dans le fichier properties",
490:                                            "Erreur...",
491:                                            JOptionPane.ERROR_MESSAGE);
492:                        }
493:                        JOptionPane.showMessageDialog(this ,
494:                                "Le fichier properties a bien ete enregistre",
495:                                "Info...", JOptionPane.INFORMATION_MESSAGE);
496:                        propFileField.setText(propFile.getAbsolutePath());
497:                    }
498:                }
499:            }//GEN-LAST:event_encryptPerformed
500:
501:            private void cancelPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelPerformed
502:                // TODO add your handling code here:
503:                this .dispose();
504:            }//GEN-LAST:event_cancelPerformed
505:
506:            private void chooseFilePerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chooseFilePerformed
507:                // TODO add your handling code here:
508:                JFileChooser fileChooser = new JFileChooser();
509:                fileChooser.setApproveButtonText("Valider");
510:                FileFilter[] fileFilterTab = fileChooser
511:                        .getChoosableFileFilters();
512:                for (int i = 0; i < fileFilterTab.length; i++) {
513:                    fileChooser.removeChoosableFileFilter(fileFilterTab[i]);
514:                }
515:                fileChooser.addChoosableFileFilter(new PropsFileFilter(
516:                        "Fichier Properties [*.properties]", ".properties"));
517:                int returnVal = fileChooser
518:                        .showOpenDialog(EncryptBugDBPropTool.this );
519:                if (returnVal == JFileChooser.APPROVE_OPTION) {
520:                    propFile = fileChooser.getSelectedFile();
521:                    propFileField.setText(propFile.getAbsolutePath());
522:                    URL urlFile = null;
523:
524:                    try {
525:                        urlFile = propFile.toURL();
526:                        InputStream in = urlFile.openStream();
527:                        prop.load(in);
528:                        in.close();
529:                    } catch (Exception e1) {
530:                        e1.printStackTrace();
531:                        JOptionPane.showMessageDialog(this ,
532:                                "Problème d'ouverture du fichier properties",
533:                                "Erreur...", JOptionPane.ERROR_MESSAGE);
534:                    }
535:
536:                    bugzillaField.setText(prop.getProperty("Bugzilla"));
537:                    jdbcDriverField.setText(prop.getProperty("DriverJDBC"));
538:                    databaseURLField
539:                            .setText(prop.getProperty("URLDB_BugZilla"));
540:                    dbUserField.setText(prop.getProperty("User_BugZilla"));
541:                    urlBugField.setText(prop.getProperty("URLHTTP_BugZilla"));
542:                    String cryptedPwd = prop.getProperty("Password");
543:
544:                    osTextPane.setText(prop.getProperty("OS"));
545:                    prioritiesTextPane.setText(prop.getProperty("Priorities"));
546:                    platformsTextPane.setText(prop.getProperty("Plateforms"));
547:                    severitiesTextPane.setText(prop.getProperty("Severities"));
548:
549:                    Object[] options = { "Oui", "Non" };
550:                    int choice = JOptionPane.showOptionDialog(this ,
551:                            "Voulez-vous indiquer l'emplacement du fichier clé afin de pouvoir\n"
552:                                    + "decrypter le mot de passe?",
553:                            "Attention !", JOptionPane.YES_NO_OPTION,
554:                            JOptionPane.QUESTION_MESSAGE, null, options,
555:                            options[1]);
556:
557:                    if (choice == JOptionPane.YES_OPTION) {
558:                        JFileChooser fileChooserForKey = new JFileChooser();
559:                        fileChooserForKey.setApproveButtonText("Valider");
560:                        int val = fileChooserForKey
561:                                .showOpenDialog(EncryptBugDBPropTool.this );
562:                        if (val == JFileChooser.APPROVE_OPTION) {
563:                            try {
564:                                keyFile = fileChooserForKey.getSelectedFile();
565:                                keyFileExists = true;
566:                                MD5paswd.readkey(keyFile);
567:                                String pwd = MD5paswd.decryptString(cryptedPwd);
568:                                userPwdField.setText(pwd);
569:                            } catch (Exception e3) {
570:                                e3.printStackTrace();
571:                                JOptionPane
572:                                        .showMessageDialog(
573:                                                this ,
574:                                                "Problème lors de l'ouverture du fichier clé!",
575:                                                "Avertissement...",
576:                                                JOptionPane.WARNING_MESSAGE);
577:                            }
578:
579:                        } else {
580:                            keyFileExists = false;
581:                            userPwdField.setText("");
582:                            userPwdField.setEnabled(false);
583:                        }
584:                    } else {
585:                        keyFileExists = false;
586:                        userPwdField.setText("");
587:                        userPwdField.setEnabled(false);
588:                    }
589:                }
590:            }//GEN-LAST:event_chooseFilePerformed
591:
592:            /** Exit the Application */
593:            private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
594:                System.exit(0);
595:            }//GEN-LAST:event_exitForm
596:
597:            /**
598:             * @param args the command line arguments
599:             */
600:            public static void main(String args[]) {
601:                new EncryptBugDBPropTool().show();
602:            }
603:
604:            // Variables declaration - do not modify//GEN-BEGIN:variables
605:            private javax.swing.JTextField bugzillaField;
606:            private javax.swing.JPanel buttonsPanel;
607:            private javax.swing.JButton cancelButton;
608:            private javax.swing.JButton chooseFileButton;
609:            private javax.swing.JTextField databaseURLField;
610:            private javax.swing.JTextField dbUserField;
611:            private javax.swing.JLabel dbUserLabel;
612:            private javax.swing.JButton encryptButton;
613:            private javax.swing.JLabel jLabel1;
614:            private javax.swing.JLabel jLabel10;
615:            private javax.swing.JLabel jLabel11;
616:            private javax.swing.JLabel jLabel12;
617:            private javax.swing.JLabel jLabel13;
618:            private javax.swing.JLabel jLabel14;
619:            private javax.swing.JLabel jLabel2;
620:            private javax.swing.JLabel jLabel3;
621:            private javax.swing.JLabel jLabel4;
622:            private javax.swing.JLabel jLabel5;
623:            private javax.swing.JLabel jLabel6;
624:            private javax.swing.JLabel jLabel7;
625:            private javax.swing.JLabel jLabel8;
626:            private javax.swing.JLabel jLabel9;
627:            private javax.swing.JPanel jPanel1;
628:            private javax.swing.JPanel jPanel10;
629:            private javax.swing.JPanel jPanel11;
630:            private javax.swing.JPanel jPanel12;
631:            private javax.swing.JPanel jPanel13;
632:            private javax.swing.JPanel jPanel14;
633:            private javax.swing.JPanel jPanel2;
634:            private javax.swing.JPanel jPanel3;
635:            private javax.swing.JPanel jPanel4;
636:            private javax.swing.JPanel jPanel5;
637:            private javax.swing.JPanel jPanel6;
638:            private javax.swing.JPanel jPanel7;
639:            private javax.swing.JPanel jPanel8;
640:            private javax.swing.JPanel jPanel9;
641:            private javax.swing.JScrollPane jScrollPane1;
642:            private javax.swing.JScrollPane jScrollPane2;
643:            private javax.swing.JScrollPane jScrollPane3;
644:            private javax.swing.JScrollPane jScrollPane4;
645:            private javax.swing.JTextField jdbcDriverField;
646:            private javax.swing.JLabel jdbcDriverLabel;
647:            private javax.swing.JTextPane osTextPane;
648:            private javax.swing.JTextPane platformsTextPane;
649:            private javax.swing.JTextPane prioritiesTextPane;
650:            private javax.swing.JTextField propFileField;
651:            private javax.swing.JLabel propFileLabel;
652:            private javax.swing.JPanel propsFilePanel;
653:            private javax.swing.JTextPane severitiesTextPane;
654:            private javax.swing.JTextField urlBugField;
655:            private javax.swing.JTextField userPwdField;
656:            private javax.swing.JLabel userPwdLabel;
657:            // End of variables declaration//GEN-END:variables
658:
659:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.