Source Code Cross Referenced for KeystorePanel.java in  » IDE-Netbeans » web.core » org » netbeans » modules » websvc » wsitconf » ui » service » subpanels » 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 » IDE Netbeans » web.core » org.netbeans.modules.websvc.wsitconf.ui.service.subpanels 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 2006 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        package org.netbeans.modules.websvc.wsitconf.ui.service.subpanels;
043:
044:        import java.io.IOException;
045:        import org.netbeans.modules.websvc.wsitconf.ui.StoreFileFilter;
046:        import org.netbeans.modules.websvc.wsitconf.util.Util;
047:        import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.ProprietarySecurityPolicyModelHelper;
048:        import org.netbeans.modules.xml.multiview.ui.SectionVisualTheme;
049:        import org.netbeans.modules.xml.wsdl.model.WSDLComponent;
050:        import org.openide.DialogDisplayer;
051:        import org.openide.NotifyDescriptor;
052:        import org.openide.filesystems.FileUtil;
053:        import org.openide.util.NbBundle;
054:        import javax.swing.*;
055:        import java.io.File;
056:        import java.util.Iterator;
057:        import java.util.List;
058:        import java.util.Set;
059:        import org.netbeans.api.project.Project;
060:        import org.netbeans.modules.websvc.wsitconf.ui.ClassDialog;
061:
062:        /**
063:         *
064:         * @author Martin Grebac
065:         */
066:        public class KeystorePanel extends JPanel {
067:
068:            public static final String PKCS12 = "PKCS12"; //NOI18N
069:            public static final String JKS = "JKS"; //NOI18N
070:
071:            public static final String DEFAULT_PASSWORD = "changeit"; //NOI18N
072:            public static final String DEFAULT_PASSWORD2 = "adminadmin"; //NOI18N
073:
074:            private WSDLComponent comp;
075:
076:            private boolean jsr109 = false;
077:            private Project project = null;
078:
079:            private boolean client;
080:            private String keystoreType = JKS;
081:
082:            private boolean inSync = false;
083:
084:            public KeystorePanel(WSDLComponent comp, Project p, boolean jsr109,
085:                    boolean client) {
086:                super ();
087:                this .comp = comp;
088:                this .jsr109 = jsr109;
089:                this .project = p;
090:                this .client = client;
091:
092:                initComponents();
093:
094:                keyAliasCombo.setBackground(SectionVisualTheme
095:                        .getDocumentBackgroundColor());
096:                keyAliasLabel.setBackground(SectionVisualTheme
097:                        .getDocumentBackgroundColor());
098:                keyPasswordLabel.setBackground(SectionVisualTheme
099:                        .getDocumentBackgroundColor());
100:                keyPasswordField.setBackground(SectionVisualTheme
101:                        .getDocumentBackgroundColor());
102:                keystoreLocationLabel.setBackground(SectionVisualTheme
103:                        .getDocumentBackgroundColor());
104:                keystoreLocationTextField.setBackground(SectionVisualTheme
105:                        .getDocumentBackgroundColor());
106:                keystorePasswordLabel.setBackground(SectionVisualTheme
107:                        .getDocumentBackgroundColor());
108:                keystorePasswordField.setBackground(SectionVisualTheme
109:                        .getDocumentBackgroundColor());
110:                aliasSelectorLbl.setBackground(SectionVisualTheme
111:                        .getDocumentBackgroundColor());
112:                aliasSelectorField.setBackground(SectionVisualTheme
113:                        .getDocumentBackgroundColor());
114:
115:                sync();
116:            }
117:
118:            private String getKeystoreAlias() {
119:                return (String) this .keyAliasCombo.getSelectedItem();
120:            }
121:
122:            private void setKeystoreAlias(String alias) {
123:                this .keyAliasCombo.setSelectedItem(alias);
124:            }
125:
126:            private String getKeyPassword() {
127:                return String.valueOf(this .keyPasswordField.getPassword());
128:            }
129:
130:            private void setKeyPassword(String password) {
131:                this .keyPasswordField.setText(password);
132:            }
133:
134:            private String getSelector() {
135:                String path = this .aliasSelectorField.getText();
136:                if ("".equals(path) || (path == null)) { //NOI18N
137:                    return null;
138:                }
139:                return path;
140:            }
141:
142:            private void setSelector(String selector) {
143:                this .aliasSelectorField.setText(selector);
144:            }
145:
146:            private char[] getCharKeystorePassword() {
147:                return keystorePasswordField.getPassword();
148:            }
149:
150:            private String getKeystorePassword() {
151:                return String.valueOf(this .keystorePasswordField.getPassword());
152:            }
153:
154:            private void setKeystorePassword(String password) {
155:                this .keystorePasswordField.setText(password);
156:            }
157:
158:            private void setKeystorePath(String path) {
159:                this .keystoreLocationTextField.setText(path);
160:            }
161:
162:            private String getKeystorePath() {
163:                String path = this .keystoreLocationTextField.getText();
164:                if ("".equals(path) || (path == null)) { //NOI18N
165:                    return null;
166:                }
167:                return path;
168:            }
169:
170:            private void setKeystoreType(String type) {
171:                this .keystoreType = type;
172:            }
173:
174:            String keyStoreLocation = null;
175:            String ksType = null;
176:            String keyStorePassword = null;
177:            String keyStoreAlias = null;
178:            String keyPassword = null;
179:            String aliasSelector = null;
180:
181:            public void sync() {
182:                inSync = true;
183:
184:                keyStoreLocation = ProprietarySecurityPolicyModelHelper
185:                        .getStoreLocation(comp, false);
186:                if (keyStoreLocation != null) {
187:                    setKeystorePath(keyStoreLocation);
188:                } else if (jsr109) {
189:                    setKeystorePath(Util.getStoreLocation(project, false,
190:                            client));
191:                }
192:
193:                ksType = ProprietarySecurityPolicyModelHelper.getStoreType(
194:                        comp, false);
195:                if (ksType != null) {
196:                    setKeystoreType(ksType);
197:                }
198:
199:                keyStorePassword = ProprietarySecurityPolicyModelHelper
200:                        .getStorePassword(comp, false);
201:                if (keyStorePassword != null) {
202:                    setKeystorePassword(keyStorePassword);
203:                    reloadAliases();
204:                } else if (jsr109) {
205:                    setKeystorePassword(keyStorePassword = DEFAULT_PASSWORD);
206:                    if (!reloadAliases()) {
207:                        String adminPassword = Util.getPassword(project);
208:                        setKeystorePassword(keyStorePassword = adminPassword);
209:                    }
210:                    if (!reloadAliases()) {
211:                        setKeystorePassword(keyStorePassword = "");
212:                    }
213:                }
214:
215:                keyStoreAlias = ProprietarySecurityPolicyModelHelper
216:                        .getStoreAlias(comp, false);
217:                setKeystoreAlias(keyStoreAlias);
218:
219:                keyPassword = ProprietarySecurityPolicyModelHelper
220:                        .getKeyPassword(comp);
221:                if (keyPassword != null) {
222:                    setKeyPassword(keyPassword);
223:                }
224:
225:                aliasSelector = ProprietarySecurityPolicyModelHelper
226:                        .getAliasSelector(comp);
227:                if (aliasSelector != null) {
228:                    setSelector(aliasSelector);
229:                }
230:
231:                enableDisable();
232:
233:                inSync = false;
234:            }
235:
236:            private void enableDisable() {
237:                //        boolean gf = Util.isGlassfish(project);
238:                //        keyPasswordField.setEnabled(!gf);
239:                //        keyPasswordLabel.setEnabled(!gf);
240:            }
241:
242:            public void storeState() {
243:                String keystoreAlias = getKeystoreAlias();
244:                //ProprietarySecurityPolicyModelHelper pmh = ProprietarySecurityPolicyModelHelper.getInstance(cfgVersion);
245:                if ((keystoreAlias == null) || (keystoreAlias.length() == 0)) {
246:                    ProprietarySecurityPolicyModelHelper.setKeyStoreAlias(comp,
247:                            null, client);
248:                } else {
249:                    ProprietarySecurityPolicyModelHelper.setKeyStoreAlias(comp,
250:                            keystoreAlias, client);
251:                }
252:                // do not store anything else if GF is target server
253:                String keyPasswd = getKeyPassword();
254:                String keyStorePasswd = getKeystorePassword();
255:                String keyStoreLoc = getKeystorePath();
256:
257:                //        if (!Util.isGlassfish(project) || 
258:                //            ((keyPasswd != null) && (!keyPasswd.equals(this.keyPassword))) || 
259:                //            ((keyStorePasswd != null) && (!keyStorePasswd.equals(this.keyStorePassword))) || 
260:                //            ((keyStoreLoc != null) && (!keyStoreLoc.equals(this.keyStoreLocation)))
261:                //            ) {
262:                if ((keyPasswd == null) || (keyPasswd.length() == 0)) {
263:                    ProprietarySecurityPolicyModelHelper.setKeyPassword(comp,
264:                            null, client);
265:                } else {
266:                    ProprietarySecurityPolicyModelHelper.setKeyPassword(comp,
267:                            keyPasswd, client);
268:                }
269:                if ((keyStorePasswd == null) || (keyStorePasswd.length() == 0)) {
270:                    ProprietarySecurityPolicyModelHelper.setStorePassword(comp,
271:                            null, false, client);
272:                } else {
273:                    ProprietarySecurityPolicyModelHelper.setStorePassword(comp,
274:                            keyStorePasswd, false, client);
275:                }
276:                ProprietarySecurityPolicyModelHelper.setStoreType(comp,
277:                        keystoreType, false, client);
278:                ProprietarySecurityPolicyModelHelper.setStoreLocation(comp,
279:                        keyStoreLoc, false, client);
280:                //        }
281:
282:                String selector = getSelector();
283:                if (selector != null) {
284:                    ProprietarySecurityPolicyModelHelper.setAliasSelector(comp,
285:                            selector, false);
286:                }
287:
288:            }
289:
290:            /** This method is called from within the constructor to
291:             * initialize the form.
292:             * WARNING: Do NOT modify this code. The content of this method is
293:             * always regenerated by the Form Editor.
294:             */
295:            // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
296:            private void initComponents() {
297:
298:                keystoreLocationLabel = new javax.swing.JLabel();
299:                keystorePasswordLabel = new javax.swing.JLabel();
300:                keystoreLocationTextField = new javax.swing.JTextField();
301:                keystoreLocationButton = new javax.swing.JButton();
302:                keyAliasLabel = new javax.swing.JLabel();
303:                keyPasswordLabel = new javax.swing.JLabel();
304:                keyAliasCombo = new javax.swing.JComboBox();
305:                keystorePasswordField = new javax.swing.JPasswordField();
306:                keyPasswordField = new javax.swing.JPasswordField();
307:                loadkeysButton = new javax.swing.JButton();
308:                aliasSelectorLbl = new javax.swing.JLabel();
309:                aliasSelectorField = new javax.swing.JTextField();
310:                aliasSelectorButton = new javax.swing.JButton();
311:
312:                org.openide.awt.Mnemonics.setLocalizedText(
313:                        keystoreLocationLabel, org.openide.util.NbBundle
314:                                .getMessage(KeystorePanel.class,
315:                                        "LBL_KeyStorePanel_LocationLabel")); // NOI18N
316:
317:                org.openide.awt.Mnemonics.setLocalizedText(
318:                        keystorePasswordLabel, org.openide.util.NbBundle
319:                                .getMessage(KeystorePanel.class,
320:                                        "LBL_StorePanel_StorePassword")); // NOI18N
321:
322:                org.openide.awt.Mnemonics.setLocalizedText(
323:                        keystoreLocationButton, org.openide.util.NbBundle
324:                                .getMessage(KeystorePanel.class,
325:                                        "LBL_KeystorePanel_Browse")); // NOI18N
326:                keystoreLocationButton
327:                        .addActionListener(new java.awt.event.ActionListener() {
328:                            public void actionPerformed(
329:                                    java.awt.event.ActionEvent evt) {
330:                                keystoreLocationButtonActionPerformed(evt);
331:                            }
332:                        });
333:
334:                org.openide.awt.Mnemonics.setLocalizedText(keyAliasLabel,
335:                        org.openide.util.NbBundle.getMessage(
336:                                KeystorePanel.class,
337:                                "LBL_KeyStorePanel_KeyAliasLabel")); // NOI18N
338:
339:                org.openide.awt.Mnemonics.setLocalizedText(keyPasswordLabel,
340:                        org.openide.util.NbBundle.getMessage(
341:                                KeystorePanel.class,
342:                                "LBL_Keystore_KeyPasswordLabel")); // NOI18N
343:
344:                keyAliasCombo.setEditable(true);
345:
346:                org.openide.awt.Mnemonics.setLocalizedText(loadkeysButton,
347:                        org.openide.util.NbBundle.getMessage(
348:                                KeystorePanel.class, "LBL_LoadKeys")); // NOI18N
349:                loadkeysButton
350:                        .addActionListener(new java.awt.event.ActionListener() {
351:                            public void actionPerformed(
352:                                    java.awt.event.ActionEvent evt) {
353:                                loadkeysButtonActionPerformed(evt);
354:                            }
355:                        });
356:
357:                org.openide.awt.Mnemonics.setLocalizedText(aliasSelectorLbl,
358:                        org.openide.util.NbBundle.getMessage(
359:                                KeystorePanel.class,
360:                                "LBL_Keystore_KeySelectorLabel")); // NOI18N
361:
362:                org.openide.awt.Mnemonics.setLocalizedText(aliasSelectorButton,
363:                        org.openide.util.NbBundle
364:                                .getMessage(KeystorePanel.class,
365:                                        "LBL_KeystorePanel_Browse")); // NOI18N
366:                aliasSelectorButton
367:                        .addActionListener(new java.awt.event.ActionListener() {
368:                            public void actionPerformed(
369:                                    java.awt.event.ActionEvent evt) {
370:                                aliasSelectorButtonActionPerformed(evt);
371:                            }
372:                        });
373:
374:                org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
375:                        this );
376:                this .setLayout(layout);
377:                layout
378:                        .setHorizontalGroup(layout
379:                                .createParallelGroup(
380:                                        org.jdesktop.layout.GroupLayout.LEADING)
381:                                .add(
382:                                        layout
383:                                                .createSequentialGroup()
384:                                                .addContainerGap()
385:                                                .add(
386:                                                        layout
387:                                                                .createParallelGroup(
388:                                                                        org.jdesktop.layout.GroupLayout.LEADING)
389:                                                                .add(
390:                                                                        keystoreLocationLabel)
391:                                                                .add(
392:                                                                        keystorePasswordLabel)
393:                                                                .add(
394:                                                                        keyAliasLabel)
395:                                                                .add(
396:                                                                        keyPasswordLabel)
397:                                                                .add(
398:                                                                        aliasSelectorLbl))
399:                                                .addPreferredGap(
400:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
401:                                                .add(
402:                                                        layout
403:                                                                .createParallelGroup(
404:                                                                        org.jdesktop.layout.GroupLayout.LEADING)
405:                                                                .add(
406:                                                                        org.jdesktop.layout.GroupLayout.TRAILING,
407:                                                                        layout
408:                                                                                .createSequentialGroup()
409:                                                                                .add(
410:                                                                                        keystoreLocationTextField,
411:                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
412:                                                                                        257,
413:                                                                                        Short.MAX_VALUE)
414:                                                                                .addPreferredGap(
415:                                                                                        org.jdesktop.layout.LayoutStyle.RELATED)
416:                                                                                .add(
417:                                                                                        keystoreLocationButton)
418:                                                                                .addPreferredGap(
419:                                                                                        org.jdesktop.layout.LayoutStyle.RELATED))
420:                                                                .add(
421:                                                                        org.jdesktop.layout.GroupLayout.TRAILING,
422:                                                                        layout
423:                                                                                .createSequentialGroup()
424:                                                                                .add(
425:                                                                                        layout
426:                                                                                                .createParallelGroup(
427:                                                                                                        org.jdesktop.layout.GroupLayout.TRAILING)
428:                                                                                                .add(
429:                                                                                                        org.jdesktop.layout.GroupLayout.LEADING,
430:                                                                                                        keyAliasCombo,
431:                                                                                                        0,
432:                                                                                                        169,
433:                                                                                                        Short.MAX_VALUE)
434:                                                                                                .add(
435:                                                                                                        keystorePasswordField,
436:                                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
437:                                                                                                        169,
438:                                                                                                        Short.MAX_VALUE)
439:                                                                                                .add(
440:                                                                                                        org.jdesktop.layout.GroupLayout.LEADING,
441:                                                                                                        keyPasswordField,
442:                                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
443:                                                                                                        169,
444:                                                                                                        Short.MAX_VALUE))
445:                                                                                .addPreferredGap(
446:                                                                                        org.jdesktop.layout.LayoutStyle.RELATED)
447:                                                                                .add(
448:                                                                                        loadkeysButton)
449:                                                                                .add(
450:                                                                                        68,
451:                                                                                        68,
452:                                                                                        68))
453:                                                                .add(
454:                                                                        layout
455:                                                                                .createSequentialGroup()
456:                                                                                .add(
457:                                                                                        aliasSelectorField,
458:                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
459:                                                                                        257,
460:                                                                                        Short.MAX_VALUE)
461:                                                                                .addPreferredGap(
462:                                                                                        org.jdesktop.layout.LayoutStyle.RELATED)
463:                                                                                .add(
464:                                                                                        aliasSelectorButton)))
465:                                                .add(4, 4, 4)));
466:                layout
467:                        .setVerticalGroup(layout
468:                                .createParallelGroup(
469:                                        org.jdesktop.layout.GroupLayout.LEADING)
470:                                .add(
471:                                        layout
472:                                                .createSequentialGroup()
473:                                                .addContainerGap()
474:                                                .add(
475:                                                        layout
476:                                                                .createParallelGroup(
477:                                                                        org.jdesktop.layout.GroupLayout.BASELINE)
478:                                                                .add(
479:                                                                        keystoreLocationLabel)
480:                                                                .add(
481:                                                                        keystoreLocationButton)
482:                                                                .add(
483:                                                                        keystoreLocationTextField,
484:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
485:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
486:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
487:                                                .addPreferredGap(
488:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
489:                                                .add(
490:                                                        layout
491:                                                                .createParallelGroup(
492:                                                                        org.jdesktop.layout.GroupLayout.BASELINE)
493:                                                                .add(
494:                                                                        keystorePasswordLabel)
495:                                                                .add(
496:                                                                        keystorePasswordField,
497:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
498:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
499:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
500:                                                .addPreferredGap(
501:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
502:                                                .add(
503:                                                        layout
504:                                                                .createParallelGroup(
505:                                                                        org.jdesktop.layout.GroupLayout.BASELINE)
506:                                                                .add(
507:                                                                        keyAliasLabel)
508:                                                                .add(
509:                                                                        keyAliasCombo,
510:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
511:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
512:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
513:                                                                .add(
514:                                                                        loadkeysButton))
515:                                                .addPreferredGap(
516:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
517:                                                .add(
518:                                                        layout
519:                                                                .createParallelGroup(
520:                                                                        org.jdesktop.layout.GroupLayout.BASELINE)
521:                                                                .add(
522:                                                                        keyPasswordLabel)
523:                                                                .add(
524:                                                                        keyPasswordField,
525:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
526:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
527:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
528:                                                .addPreferredGap(
529:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
530:                                                .add(
531:                                                        layout
532:                                                                .createParallelGroup(
533:                                                                        org.jdesktop.layout.GroupLayout.BASELINE)
534:                                                                .add(
535:                                                                        aliasSelectorLbl)
536:                                                                .add(
537:                                                                        aliasSelectorField,
538:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
539:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
540:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
541:                                                                .add(
542:                                                                        aliasSelectorButton))
543:                                                .addContainerGap(
544:                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
545:                                                        Short.MAX_VALUE)));
546:
547:                layout.linkSize(new java.awt.Component[] { keyAliasCombo,
548:                        keyPasswordField, keystoreLocationTextField,
549:                        keystorePasswordField },
550:                        org.jdesktop.layout.GroupLayout.VERTICAL);
551:
552:            }// </editor-fold>//GEN-END:initComponents
553:
554:            private void loadkeysButtonActionPerformed(
555:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadkeysButtonActionPerformed
556:                boolean success = reloadAliases();
557:                if (!success) {
558:                    DialogDisplayer.getDefault().notifyLater(
559:                            new NotifyDescriptor.Message(NbBundle.getMessage(
560:                                    KeystorePanel.class, "MSG_WrongPassword" //NOI18N
561:                            )));
562:                }
563:            }//GEN-LAST:event_loadkeysButtonActionPerformed
564:
565:            private void keystoreLocationButtonActionPerformed(
566:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keystoreLocationButtonActionPerformed
567:                JFileChooser chooser = new JFileChooser();
568:                FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
569:                chooser.setDialogTitle(NbBundle.getMessage(KeystorePanel.class,
570:                        "LBL_KeystoreBrowse_Title")); //NOI18N
571:                chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
572:                chooser.setMultiSelectionEnabled(false);
573:                chooser.setFileFilter(new StoreFileFilter());
574:                File f = new File(keystoreLocationTextField.getText());
575:                if ((f != null) && (f.exists())) {
576:                    if (f.isDirectory()) {
577:                        chooser.setCurrentDirectory(f);
578:                    } else {
579:                        chooser.setCurrentDirectory(f.getParentFile());
580:                    }
581:                }
582:                if (chooser.showOpenDialog(this ) == JFileChooser.APPROVE_OPTION) {
583:                    File file = chooser.getSelectedFile();
584:                    if (file != null) {
585:                        setKeystorePath(file.getPath());
586:                        String extension = FileUtil
587:                                .getExtension(file.getName());
588:                        keystoreType = StoreFileFilter.JKS_EXT
589:                                .equals(extension) ? JKS : PKCS12;
590:                    }
591:                }
592:            }//GEN-LAST:event_keystoreLocationButtonActionPerformed
593:
594:            private void aliasSelectorButtonActionPerformed(
595:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aliasSelectorButtonActionPerformed
596:                if (project != null) {
597:                    ClassDialog classDialog = new ClassDialog(project,
598:                            "com.sun.xml.wss.AliasSelector"); //NOI18N
599:                    classDialog.show();
600:                    if (classDialog.okButtonPressed()) {
601:                        Set<String> selectedClasses = classDialog
602:                                .getSelectedClasses();
603:                        for (String selectedClass : selectedClasses) {
604:                            setSelector(selectedClass);
605:                            ProprietarySecurityPolicyModelHelper
606:                                    .setAliasSelector(comp, selectedClass,
607:                                            false);
608:                            break;
609:                        }
610:                    }
611:                }
612:            }//GEN-LAST:event_aliasSelectorButtonActionPerformed
613:
614:            private boolean reloadAliases() {
615:                List<String> aliasList;
616:                try {
617:                    aliasList = Util.getAliases(getKeystorePath(),
618:                            getCharKeystorePassword(), keystoreType);
619:                } catch (IOException ex) {
620:                    return false;
621:                }
622:                keyAliasCombo.removeAllItems();
623:                if (aliasList != null) {
624:                    keyAliasCombo.addItem(""); //NOI18N
625:                    Iterator<String> aliases = aliasList.iterator();
626:                    while (aliases.hasNext()) {
627:                        String alias = aliases.next();
628:                        keyAliasCombo.addItem(alias);
629:                    }
630:                    if (keyAliasCombo.getItemCount() > 1) {
631:                        keyAliasCombo.setSelectedIndex(1);
632:                    }
633:                }
634:                return true;
635:            }
636:
637:            // Variables declaration - do not modify//GEN-BEGIN:variables
638:            private javax.swing.JButton aliasSelectorButton;
639:            private javax.swing.JTextField aliasSelectorField;
640:            private javax.swing.JLabel aliasSelectorLbl;
641:            private javax.swing.JComboBox keyAliasCombo;
642:            private javax.swing.JLabel keyAliasLabel;
643:            private javax.swing.JPasswordField keyPasswordField;
644:            private javax.swing.JLabel keyPasswordLabel;
645:            private javax.swing.JButton keystoreLocationButton;
646:            private javax.swing.JLabel keystoreLocationLabel;
647:            private javax.swing.JTextField keystoreLocationTextField;
648:            private javax.swing.JPasswordField keystorePasswordField;
649:            private javax.swing.JLabel keystorePasswordLabel;
650:            private javax.swing.JButton loadkeysButton;
651:            // End of variables declaration//GEN-END:variables
652:
653:        }
w_w_w._j___av__a___2_s___.___c_om_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.