Source Code Cross Referenced for ProfileEditorPanel.java in  » IDE-Netbeans » identity.kit » org » netbeans » modules » identity » server » manager » ui » 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 » identity.kit » org.netbeans.modules.identity.server.manager.ui 
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 1997-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.identity.server.manager.ui;
043:
044:        import java.awt.Dialog;
045:        import java.io.File;
046:        import java.lang.reflect.InvocationTargetException;
047:        import java.util.ArrayList;
048:        import java.util.Collection;
049:        import javax.swing.JComponent;
050:        import javax.swing.JFileChooser;
051:        import javax.swing.JPanel;
052:        import javax.swing.ListSelectionModel;
053:        import javax.swing.SwingUtilities;
054:        import javax.swing.event.ChangeEvent;
055:        import javax.swing.event.ChangeListener;
056:        import javax.swing.event.ListSelectionEvent;
057:        import javax.swing.event.ListSelectionListener;
058:        import javax.swing.filechooser.FileFilter;
059:        import javax.swing.table.DefaultTableCellRenderer;
060:        import javax.swing.table.DefaultTableModel;
061:        import javax.swing.table.TableColumn;
062:        import org.netbeans.modules.identity.profile.api.configurator.ConfiguratorException;
063:        import org.netbeans.modules.identity.profile.api.configurator.ProviderConfigurator.Configurable;
064:        import org.netbeans.modules.identity.profile.api.configurator.ProviderConfigurator;
065:        import org.netbeans.modules.identity.profile.api.configurator.Configurator.AccessMethod;
066:        import org.netbeans.modules.identity.profile.api.configurator.ProviderConfigurator.Type;
067:        import org.netbeans.modules.identity.profile.api.configurator.SecurityMechanism;
068:        import org.netbeans.modules.identity.server.manager.api.ServerInstance;
069:        import org.openide.DialogDescriptor;
070:        import org.openide.DialogDisplayer;
071:        import org.openide.NotifyDescriptor;
072:        import org.openide.util.HelpCtx;
073:        import org.openide.util.NbBundle;
074:
075:        /**
076:         * Visual panel for editor the security mechanism profiles.
077:         *
078:         * Created on April 14, 2006, 3:03 PM
079:         *
080:         * @author  ptliu
081:         */
082:        public class ProfileEditorPanel extends JPanel implements 
083:                ChangeListener, EditDialogDescriptor.Panel {
084:            private static final long WAIT_TIME = 400;
085:
086:            private static final String JKS_EXTENSION = ".jks"; //NOI18N
087:
088:            private static final String HELP_ID = "idmtools_am_config_am_sec_mech"; //NOI18N
089:
090:            private static final String AM_INVALID_KEYSTORE_ERR = "Invalid KeyStore"; //NOI18N
091:
092:            private enum State {
093:                INITIALIZING, INITIALIZED, NOT_RUNNING, INIT_FAILED
094:            }
095:
096:            private transient ProviderConfigurator configurator;
097:            private transient SecurityMechanism secMech;
098:            private ServerInstance instance;
099:            private Collection<ChangeListener> listeners;
100:            private Throwable cause;
101:            private State state;
102:
103:            /**
104:             * Creates new form ProfileEditorPanel
105:             */
106:            public ProfileEditorPanel(SecurityMechanism secMech,
107:                    ServerInstance instance) {
108:                initComponents();
109:
110:                this .secMech = secMech;
111:                this .instance = instance;
112:                listeners = new ArrayList<ChangeListener>();
113:                state = State.INITIALIZING;
114:
115:                initVisualState();
116:                initConfiguratorAsync();
117:            }
118:
119:            private void initConfiguratorAsync() {
120:
121:                // Call the actual initConfigurator() in a separate thread.
122:                Thread thread = new Thread() {
123:                    public void run() {
124:                        initConfigurator();
125:                    }
126:                };
127:                thread.start();
128:
129:                // Call pingServer() in another separate thread.
130:                thread = new Thread() {
131:                    public void run() {
132:                        pingServer();
133:                    }
134:                };
135:                thread.start();
136:
137:                //
138:                // Wait a little while for the configurator to initialize before
139:                // we return. In the case the configurator takes less than
140:                // WAIT_TIME to intialize, we give the user the illusion that
141:                // the panel is initialized synchronously.
142:                //
143:                synchronized (this ) {
144:                    try {
145:                        this .wait(WAIT_TIME);
146:                    } catch (InterruptedException ex) {
147:                    }
148:                }
149:            }
150:
151:            private void initConfigurator() {
152:                try {
153:                    configurator = ProviderConfigurator.getConfigurator(secMech
154:                            .getName(), Type.WSP, AccessMethod.DYNAMIC,
155:                            instance.getServerProperties(), instance.getID());
156:
157:                    SwingUtilities.invokeAndWait(new Runnable() {
158:                        public void run() {
159:                            configurator.addModifier(
160:                                    Configurable.SIGN_RESPONSE, signResponseCB);
161:                            configurator.addModifier(
162:                                    Configurable.USE_DEFAULT_KEYSTORE,
163:                                    useDefaultKeyStoreCB);
164:                            configurator.addModifier(
165:                                    Configurable.KEYSTORE_LOCATION,
166:                                    keystoreLocationTF);
167:                            configurator.addModifier(
168:                                    Configurable.KEYSTORE_PASSWORD,
169:                                    keystorePasswordTF);
170:                            configurator.addModifier(Configurable.KEY_ALIAS,
171:                                    keyAliasTF);
172:                            configurator.addModifier(Configurable.KEY_PASSWORD,
173:                                    keyPasswordTF);
174:                            configurator.addModifier(
175:                                    Configurable.USERNAME_PASSWORD_PAIRS,
176:                                    userNameTable);
177:
178:                            enableAllComponents();
179:                            initUserNameTable();
180:                            updateVisualState();
181:                        }
182:                    });
183:
184:                    updateState(State.INITIALIZED);
185:                    configurator.addChangeListener(this );
186:                } catch (InvocationTargetException ex) {
187:                    //ex.printStackTrace();
188:                } catch (InterruptedException ex) {
189:                    //ex.printStackTrace();
190:                } catch (ConfiguratorException ex) {
191:                    cause = ex.getCause();
192:                    //cause.printStackTrace();
193:                    updateState(State.INIT_FAILED);
194:                }
195:            }
196:
197:            private void pingServer() {
198:                if (!instance.isRunning()) {
199:                    updateState(State.NOT_RUNNING);
200:                }
201:            }
202:
203:            private synchronized void updateState(State newState) {
204:                //System.out.println("updateState newState = " + newState);
205:                this .state = newState;
206:                fireStateChanged();
207:            }
208:
209:            private void initUserNameTable() {
210:                if (secMech.isPasswordCredentialRequired()) {
211:                    // Make the table single select
212:                    final ListSelectionModel selectionModel = userNameTable
213:                            .getSelectionModel();
214:                    selectionModel
215:                            .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
216:
217:                    selectionModel
218:                            .addListSelectionListener(new ListSelectionListener() {
219:                                public void valueChanged(ListSelectionEvent e) {
220:                                    //Ignore extra messages.
221:                                    if (e.getValueIsAdjusting())
222:                                        return;
223:
224:                                    if (selectionModel.isSelectionEmpty()) {
225:                                        editButton.setEnabled(false);
226:                                        removeButton.setEnabled(false);
227:                                    } else {
228:                                        editButton.setEnabled(true);
229:                                        removeButton.setEnabled(true);
230:                                    }
231:                                }
232:                            });
233:
234:                    // Change the password column's cell render to display ****
235:                    TableColumn tableColumn = userNameTable
236:                            .getColumn(userNameTable.getColumnName(1));
237:
238:                    tableColumn.setCellRenderer(new DefaultTableCellRenderer() {
239:                        protected void setValue(Object value) {
240:                            if (value instanceof  String) {
241:                                StringBuffer buf = new StringBuffer(
242:                                        (String) value);
243:                                int length = buf.length();
244:
245:                                for (int i = 0; i < length; i++) {
246:                                    buf.setCharAt(i, '*');
247:                                }
248:
249:                                value = buf.toString();
250:                            }
251:
252:                            super .setValue(value);
253:                        }
254:                    });
255:                }
256:            }
257:
258:            private void initVisualState() {
259:                if (secMech.isLiberty()) {
260:                    signResponseCB.setSelected(true);
261:                    signResponseCB.setEnabled(false);
262:                }
263:
264:                if (!secMech.isPasswordCredentialRequired()) {
265:                    userNameTableScrollPane.setVisible(false);
266:                    addButton.setVisible(false);
267:                    editButton.setVisible(false);
268:                    removeButton.setVisible(false);
269:                    usernameInfoLabel.setVisible(false);
270:                    usernameInfoDescLabel.setVisible(false);
271:                }
272:            }
273:
274:            private void updateVisualState() {
275:                if (secMech.isPasswordCredentialRequired()) {
276:                    if (signResponseCB.isSelected()) {
277:                        certSettingsLabel.setEnabled(true);
278:                        useDefaultKeyStoreCB.setEnabled(true);
279:
280:                        if (useDefaultKeyStoreCB.isSelected()) {
281:                            updateKeystoreVisualState(false);
282:                        } else {
283:                            updateKeystoreVisualState(true);
284:                        }
285:                    } else {
286:                        certSettingsLabel.setEnabled(false);
287:                        useDefaultKeyStoreCB.setEnabled(false);
288:                        updateKeystoreVisualState(false);
289:                    }
290:                } else {
291:                    if (useDefaultKeyStoreCB.isSelected()) {
292:                        updateKeystoreVisualState(false);
293:                    } else {
294:                        updateKeystoreVisualState(true);
295:                    }
296:                }
297:            }
298:
299:            private void updateKeystoreVisualState(boolean flag) {
300:                keystoreLocationTF.setEnabled(flag);
301:                keystoreLocationLabel.setEnabled(flag);
302:                keystorePasswordTF.setEnabled(flag);
303:                keystorePasswordLabel.setEnabled(flag);
304:                keyAliasTF.setEnabled(flag);
305:                keyAliasLabel.setEnabled(flag);
306:                keyPasswordLabel.setEnabled(flag);
307:                keyPasswordTF.setEnabled(flag);
308:
309:                if (flag) {
310:                    if (instance.isLocal()) {
311:                        browseButton.setEnabled(true);
312:                    } else {
313:                        browseButton.setEnabled(false);
314:                    }
315:                } else {
316:                    browseButton.setEnabled(false);
317:                }
318:            }
319:
320:            public void enableAllComponents() {
321:                if (!secMech.isLiberty()) {
322:                    signResponseCB.setEnabled(true);
323:                }
324:
325:                certSettingsLabel.setEnabled(true);
326:                useDefaultKeyStoreCB.setEnabled(true);
327:                keystoreLocationTF.setEnabled(true);
328:                keystoreLocationLabel.setEnabled(true);
329:                keystorePasswordTF.setEnabled(true);
330:                keystorePasswordLabel.setEnabled(true);
331:                keyAliasTF.setEnabled(true);
332:                keyAliasLabel.setEnabled(true);
333:                browseButton.setEnabled(true);
334:                userNameTableScrollPane.setEnabled(true);
335:                addButton.setEnabled(true);
336:                //editButton.setEnabled(true);
337:                //removeButton.setEnabled(true);
338:                usernameInfoLabel.setEnabled(true);
339:                usernameInfoDescLabel.setEnabled(true);
340:            }
341:
342:            public void save() {
343:                if (configurator != null) {
344:                    configurator.save();
345:                }
346:            }
347:
348:            public JComponent[] getEditableComponents() {
349:                return new JComponent[] {};
350:            }
351:
352:            public synchronized String checkValues() {
353:                switch (state) {
354:                case INITIALIZING:
355:                    return EditDialogDescriptor.STATUS_PREFIX
356:                            + NbBundle.getMessage(ProfileEditorPanel.class,
357:                                    "MSG_Initializing");
358:                case NOT_RUNNING:
359:                    return NbBundle.getMessage(ProfileEditorPanel.class,
360:                            "MSG_ServerNotRunning");
361:                case INIT_FAILED:
362:                    //return "<html>" + cause.getMessage() + "</html>";   //NOI18N
363:                    return NbBundle.getMessage(ProfileEditorPanel.class,
364:                            "MSG_InitFailed", cause.toString());
365:                case INITIALIZED:
366:                    String errorMsg = configurator.getError();
367:
368:                    //
369:                    // Replace the unlocalized "Invalid KeyStore" message
370:                    // from the AM client code with our localized version.
371:                    //
372:                    if (errorMsg != null
373:                            && errorMsg.startsWith(AM_INVALID_KEYSTORE_ERR)) {
374:                        errorMsg = NbBundle
375:                                .getMessage(ProfileEditorPanel.class,
376:                                        "ERR_InvalidKeystore");
377:                    }
378:
379:                    return errorMsg;
380:                }
381:
382:                return null;
383:            }
384:
385:            public void addChangeListener(ChangeListener listener) {
386:                listeners.add(listener);
387:            }
388:
389:            public void fireStateChanged() {
390:                ChangeEvent event = new ChangeEvent(this );
391:
392:                for (ChangeListener l : listeners) {
393:                    l.stateChanged(event);
394:                }
395:            }
396:
397:            public void stateChanged(ChangeEvent event) {
398:                fireStateChanged();
399:            }
400:
401:            private void showUserNamePasswordEditor(boolean add) {
402:                final UserNamePasswordEditorPanel panel = new UserNamePasswordEditorPanel(
403:                        add, getUserNames());
404:                DefaultTableModel model = (DefaultTableModel) userNameTable
405:                        .getModel();
406:                int row = -1;
407:
408:                if (!add) {
409:                    row = userNameTable.getSelectedRow();
410:
411:                    // simply return if there is no row selected
412:                    if (row == -1)
413:                        return;
414:
415:                    panel.setUserName((String) model.getValueAt(row, 0));
416:                    panel.setPassword((String) model.getValueAt(row, 1));
417:                } else {
418:                    row = model.getRowCount();
419:                }
420:
421:                EditDialogDescriptor descriptor = new EditDialogDescriptor(
422:                        panel, NbBundle.getMessage(ProfileEditorPanel.class,
423:                                "TTL_User"), add,
424:                        panel.getEditableComponents(), getHelpCtx()) {
425:                    public String validate() {
426:                        return panel.checkValues();
427:                    }
428:                };
429:
430:                Dialog dlg = null;
431:                try {
432:                    dlg = DialogDisplayer.getDefault().createDialog(descriptor);
433:                    dlg.setVisible(true);
434:
435:                    if (descriptor.getValue()
436:                            .equals(DialogDescriptor.OK_OPTION)) {
437:                        String userName = panel.getUserName();
438:                        String password = panel.getPassword();
439:
440:                        if (!add) {
441:                            model.setValueAt(userName, row, 0);
442:                            model.setValueAt(password, row, 1);
443:                            model.fireTableRowsUpdated(row, row);
444:                        } else {
445:                            model.insertRow(row, new Object[] { userName,
446:                                    password });
447:                            model.fireTableRowsInserted(row, row);
448:                        }
449:                    }
450:                } finally {
451:                    if (dlg != null) {
452:                        dlg.dispose();
453:                    }
454:                }
455:            }
456:
457:            private String[] getUserNames() {
458:                DefaultTableModel model = (DefaultTableModel) userNameTable
459:                        .getModel();
460:                int rowCount = model.getRowCount();
461:                String[] userNames = new String[rowCount];
462:
463:                for (int i = 0; i < rowCount; i++) {
464:                    userNames[i] = (String) model.getValueAt(i, 0);
465:                }
466:
467:                return userNames;
468:            }
469:
470:            private HelpCtx getHelpCtx() {
471:                return new HelpCtx(HELP_ID);
472:            }
473:
474:            /** This method is called from within the constructor to
475:             * initialize the form.
476:             * WARNING: Do NOT modify this code. The content of this method is
477:             * always regenerated by the Form Editor.
478:             */
479:            // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
480:            private void initComponents() {
481:
482:                jScrollPane1 = new javax.swing.JScrollPane();
483:                jTable1 = new javax.swing.JTable();
484:                signResponseCB = new javax.swing.JCheckBox();
485:                certSettingsLabel = new javax.swing.JLabel();
486:                keystoreLocationLabel = new javax.swing.JLabel();
487:                keystoreLocationTF = new javax.swing.JTextField();
488:                keystorePasswordLabel = new javax.swing.JLabel();
489:                keyAliasLabel = new javax.swing.JLabel();
490:                keyAliasTF = new javax.swing.JTextField();
491:                browseButton = new javax.swing.JButton();
492:                userNameTableScrollPane = new javax.swing.JScrollPane();
493:                userNameTable = new javax.swing.JTable();
494:                usernameInfoLabel = new javax.swing.JLabel();
495:                addButton = new javax.swing.JButton();
496:                editButton = new javax.swing.JButton();
497:                removeButton = new javax.swing.JButton();
498:                usernameInfoDescLabel = new javax.swing.JLabel();
499:                keystorePasswordTF = new javax.swing.JPasswordField();
500:                useDefaultKeyStoreCB = new javax.swing.JCheckBox();
501:                keyPasswordLabel = new javax.swing.JLabel();
502:                keyPasswordTF = new javax.swing.JPasswordField();
503:
504:                jTable1.setModel(new javax.swing.table.DefaultTableModel(
505:                        new Object[][] { { null, null, null, null },
506:                                { null, null, null, null },
507:                                { null, null, null, null },
508:                                { null, null, null, null } }, new String[] {
509:                                "Title 1", "Title 2", "Title 3", "Title 4" }));
510:                jScrollPane1.setViewportView(jTable1);
511:
512:                java.util.ResourceBundle bundle = java.util.ResourceBundle
513:                        .getBundle("org/netbeans/modules/identity/server/manager/ui/Bundle"); // NOI18N
514:                org.openide.awt.Mnemonics.setLocalizedText(signResponseCB,
515:                        bundle.getString("LBL_SignResponse")); // NOI18N
516:                signResponseCB.setBorder(javax.swing.BorderFactory
517:                        .createEmptyBorder(0, 0, 0, 0));
518:                signResponseCB.setEnabled(false);
519:                signResponseCB.setMargin(new java.awt.Insets(0, 0, 0, 0));
520:                signResponseCB.setOpaque(false);
521:                signResponseCB
522:                        .addActionListener(new java.awt.event.ActionListener() {
523:                            public void actionPerformed(
524:                                    java.awt.event.ActionEvent evt) {
525:                                signResponseCBActionPerformed(evt);
526:                            }
527:                        });
528:
529:                certSettingsLabel.setText(bundle
530:                        .getString("LBL_CertificateSettings")); // NOI18N
531:                certSettingsLabel.setEnabled(false);
532:
533:                keystoreLocationLabel.setLabelFor(keystoreLocationTF);
534:                org.openide.awt.Mnemonics.setLocalizedText(
535:                        keystoreLocationLabel, bundle
536:                                .getString("LBL_KeyStoreLocation")); // NOI18N
537:                keystoreLocationLabel.setEnabled(false);
538:
539:                keystoreLocationTF.setEnabled(false);
540:                keystoreLocationTF.setNextFocusableComponent(browseButton);
541:
542:                keystorePasswordLabel.setLabelFor(keystorePasswordTF);
543:                org.openide.awt.Mnemonics.setLocalizedText(
544:                        keystorePasswordLabel, bundle
545:                                .getString("LBL_KeystorePassword")); // NOI18N
546:                keystorePasswordLabel.setEnabled(false);
547:
548:                keyAliasLabel.setLabelFor(keyAliasTF);
549:                org.openide.awt.Mnemonics.setLocalizedText(keyAliasLabel,
550:                        bundle.getString("LBL_KeyAlias")); // NOI18N
551:                keyAliasLabel.setEnabled(false);
552:
553:                keyAliasTF.setEnabled(false);
554:                keyAliasTF.setNextFocusableComponent(keyPasswordTF);
555:
556:                org.openide.awt.Mnemonics.setLocalizedText(browseButton, bundle
557:                        .getString("LBL_Browse")); // NOI18N
558:                browseButton.setEnabled(false);
559:                browseButton.setNextFocusableComponent(keystorePasswordTF);
560:                browseButton
561:                        .addActionListener(new java.awt.event.ActionListener() {
562:                            public void actionPerformed(
563:                                    java.awt.event.ActionEvent evt) {
564:                                browseButtonActionPerformed(evt);
565:                            }
566:                        });
567:
568:                userNameTableScrollPane.setEnabled(false);
569:
570:                userNameTable.setModel(new javax.swing.table.DefaultTableModel(
571:                        new Object[][] { {}, {}, {}, {} }, new String[] {
572:
573:                        }));
574:                userNameTableScrollPane.setViewportView(userNameTable);
575:
576:                usernameInfoLabel.setLabelFor(userNameTable);
577:                org.openide.awt.Mnemonics.setLocalizedText(usernameInfoLabel,
578:                        bundle.getString("LBL_UsernameTokenProfileInfo")); // NOI18N
579:                usernameInfoLabel.setEnabled(false);
580:
581:                org.openide.awt.Mnemonics.setLocalizedText(addButton, bundle
582:                        .getString("LBL_Add")); // NOI18N
583:                addButton.setEnabled(false);
584:                addButton
585:                        .addActionListener(new java.awt.event.ActionListener() {
586:                            public void actionPerformed(
587:                                    java.awt.event.ActionEvent evt) {
588:                                addButtonActionPerformed(evt);
589:                            }
590:                        });
591:
592:                org.openide.awt.Mnemonics.setLocalizedText(editButton, bundle
593:                        .getString("LBL_Edit")); // NOI18N
594:                editButton.setEnabled(false);
595:                editButton
596:                        .addActionListener(new java.awt.event.ActionListener() {
597:                            public void actionPerformed(
598:                                    java.awt.event.ActionEvent evt) {
599:                                editButtonActionPerformed(evt);
600:                            }
601:                        });
602:
603:                org.openide.awt.Mnemonics.setLocalizedText(removeButton, bundle
604:                        .getString("LBL_Remove")); // NOI18N
605:                removeButton.setEnabled(false);
606:                removeButton
607:                        .addActionListener(new java.awt.event.ActionListener() {
608:                            public void actionPerformed(
609:                                    java.awt.event.ActionEvent evt) {
610:                                removeButtonActionPerformed(evt);
611:                            }
612:                        });
613:
614:                usernameInfoDescLabel.setText(bundle
615:                        .getString("LBL_UsernameInfoDesc")); // NOI18N
616:                usernameInfoDescLabel.setEnabled(false);
617:
618:                keystorePasswordTF.setEnabled(false);
619:                keystorePasswordTF.setNextFocusableComponent(keyAliasTF);
620:
621:                org.openide.awt.Mnemonics.setLocalizedText(
622:                        useDefaultKeyStoreCB, bundle
623:                                .getString("LBL_UseDefaultKeyStore")); // NOI18N
624:                useDefaultKeyStoreCB.setBorder(javax.swing.BorderFactory
625:                        .createEmptyBorder(0, 0, 0, 0));
626:                useDefaultKeyStoreCB.setEnabled(false);
627:                useDefaultKeyStoreCB.setMargin(new java.awt.Insets(0, 0, 0, 0));
628:                useDefaultKeyStoreCB
629:                        .setNextFocusableComponent(keystoreLocationTF);
630:                useDefaultKeyStoreCB
631:                        .addActionListener(new java.awt.event.ActionListener() {
632:                            public void actionPerformed(
633:                                    java.awt.event.ActionEvent evt) {
634:                                useDefaultKeyStoreCBActionPerformed(evt);
635:                            }
636:                        });
637:
638:                keyPasswordLabel.setLabelFor(keyPasswordTF);
639:                org.openide.awt.Mnemonics.setLocalizedText(keyPasswordLabel,
640:                        bundle.getString("LBL_KeyAliasPassword")); // NOI18N
641:                keyPasswordLabel.setEnabled(false);
642:
643:                keyPasswordTF.setEnabled(false);
644:
645:                org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
646:                        this );
647:                this .setLayout(layout);
648:                layout
649:                        .setHorizontalGroup(layout
650:                                .createParallelGroup(
651:                                        org.jdesktop.layout.GroupLayout.LEADING)
652:                                .add(
653:                                        layout
654:                                                .createSequentialGroup()
655:                                                .addContainerGap()
656:                                                .add(
657:                                                        layout
658:                                                                .createParallelGroup(
659:                                                                        org.jdesktop.layout.GroupLayout.LEADING)
660:                                                                .add(
661:                                                                        layout
662:                                                                                .createSequentialGroup()
663:                                                                                .add(
664:                                                                                        10,
665:                                                                                        10,
666:                                                                                        10)
667:                                                                                .add(
668:                                                                                        useDefaultKeyStoreCB))
669:                                                                .add(
670:                                                                        signResponseCB)
671:                                                                .add(
672:                                                                        org.jdesktop.layout.GroupLayout.TRAILING,
673:                                                                        layout
674:                                                                                .createSequentialGroup()
675:                                                                                .add(
676:                                                                                        layout
677:                                                                                                .createParallelGroup(
678:                                                                                                        org.jdesktop.layout.GroupLayout.LEADING)
679:                                                                                                .add(
680:                                                                                                        layout
681:                                                                                                                .createSequentialGroup()
682:                                                                                                                .add(
683:                                                                                                                        certSettingsLabel)
684:                                                                                                                .addPreferredGap(
685:                                                                                                                        org.jdesktop.layout.LayoutStyle.RELATED,
686:                                                                                                                        316,
687:                                                                                                                        Short.MAX_VALUE))
688:                                                                                                .add(
689:                                                                                                        layout
690:                                                                                                                .createSequentialGroup()
691:                                                                                                                .add(
692:                                                                                                                        10,
693:                                                                                                                        10,
694:                                                                                                                        10)
695:                                                                                                                .add(
696:                                                                                                                        layout
697:                                                                                                                                .createParallelGroup(
698:                                                                                                                                        org.jdesktop.layout.GroupLayout.LEADING)
699:                                                                                                                                .add(
700:                                                                                                                                        keystorePasswordLabel)
701:                                                                                                                                .add(
702:                                                                                                                                        keyAliasLabel)
703:                                                                                                                                .add(
704:                                                                                                                                        keystoreLocationLabel)
705:                                                                                                                                .add(
706:                                                                                                                                        keyPasswordLabel))
707:                                                                                                                .addPreferredGap(
708:                                                                                                                        org.jdesktop.layout.LayoutStyle.RELATED)
709:                                                                                                                .add(
710:                                                                                                                        layout
711:                                                                                                                                .createParallelGroup(
712:                                                                                                                                        org.jdesktop.layout.GroupLayout.LEADING)
713:                                                                                                                                .add(
714:                                                                                                                                        keyPasswordTF,
715:                                                                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
716:                                                                                                                                        346,
717:                                                                                                                                        Short.MAX_VALUE)
718:                                                                                                                                .add(
719:                                                                                                                                        keyAliasTF,
720:                                                                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
721:                                                                                                                                        346,
722:                                                                                                                                        Short.MAX_VALUE)
723:                                                                                                                                .add(
724:                                                                                                                                        keystorePasswordTF,
725:                                                                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
726:                                                                                                                                        346,
727:                                                                                                                                        Short.MAX_VALUE)
728:                                                                                                                                .add(
729:                                                                                                                                        org.jdesktop.layout.GroupLayout.TRAILING,
730:                                                                                                                                        keystoreLocationTF,
731:                                                                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
732:                                                                                                                                        346,
733:                                                                                                                                        Short.MAX_VALUE))
734:                                                                                                                .add(
735:                                                                                                                        7,
736:                                                                                                                        7,
737:                                                                                                                        7)))
738:                                                                                .addPreferredGap(
739:                                                                                        org.jdesktop.layout.LayoutStyle.RELATED)
740:                                                                                .add(
741:                                                                                        browseButton))
742:                                                                .add(
743:                                                                        usernameInfoLabel)
744:                                                                .add(
745:                                                                        layout
746:                                                                                .createSequentialGroup()
747:                                                                                .add(
748:                                                                                        addButton)
749:                                                                                .addPreferredGap(
750:                                                                                        org.jdesktop.layout.LayoutStyle.RELATED)
751:                                                                                .add(
752:                                                                                        editButton)
753:                                                                                .addPreferredGap(
754:                                                                                        org.jdesktop.layout.LayoutStyle.RELATED)
755:                                                                                .add(
756:                                                                                        removeButton))
757:                                                                .add(
758:                                                                        usernameInfoDescLabel,
759:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
760:                                                                        558,
761:                                                                        Short.MAX_VALUE)
762:                                                                .add(
763:                                                                        org.jdesktop.layout.GroupLayout.TRAILING,
764:                                                                        userNameTableScrollPane,
765:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
766:                                                                        558,
767:                                                                        Short.MAX_VALUE))
768:                                                .addContainerGap()));
769:                layout
770:                        .setVerticalGroup(layout
771:                                .createParallelGroup(
772:                                        org.jdesktop.layout.GroupLayout.LEADING)
773:                                .add(
774:                                        layout
775:                                                .createSequentialGroup()
776:                                                .addContainerGap()
777:                                                .add(signResponseCB)
778:                                                .addPreferredGap(
779:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
780:                                                .add(certSettingsLabel)
781:                                                .addPreferredGap(
782:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
783:                                                .add(
784:                                                        useDefaultKeyStoreCB,
785:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
786:                                                        15,
787:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
788:                                                .addPreferredGap(
789:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
790:                                                .add(
791:                                                        layout
792:                                                                .createParallelGroup(
793:                                                                        org.jdesktop.layout.GroupLayout.BASELINE)
794:                                                                .add(
795:                                                                        keystoreLocationLabel)
796:                                                                .add(
797:                                                                        browseButton)
798:                                                                .add(
799:                                                                        keystoreLocationTF,
800:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
801:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
802:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
803:                                                .add(7, 7, 7)
804:                                                .add(
805:                                                        layout
806:                                                                .createParallelGroup(
807:                                                                        org.jdesktop.layout.GroupLayout.BASELINE)
808:                                                                .add(
809:                                                                        keystorePasswordLabel)
810:                                                                .add(
811:                                                                        keystorePasswordTF,
812:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
813:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
814:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
815:                                                .addPreferredGap(
816:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
817:                                                .add(
818:                                                        layout
819:                                                                .createParallelGroup(
820:                                                                        org.jdesktop.layout.GroupLayout.BASELINE)
821:                                                                .add(
822:                                                                        keyAliasLabel)
823:                                                                .add(
824:                                                                        keyAliasTF,
825:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
826:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
827:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
828:                                                .addPreferredGap(
829:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
830:                                                .add(
831:                                                        layout
832:                                                                .createParallelGroup(
833:                                                                        org.jdesktop.layout.GroupLayout.BASELINE)
834:                                                                .add(
835:                                                                        keyPasswordLabel)
836:                                                                .add(
837:                                                                        keyPasswordTF,
838:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
839:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
840:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
841:                                                .addPreferredGap(
842:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
843:                                                .add(usernameInfoLabel)
844:                                                .addPreferredGap(
845:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
846:                                                .add(usernameInfoDescLabel)
847:                                                .addPreferredGap(
848:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
849:                                                .add(
850:                                                        userNameTableScrollPane,
851:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
852:                                                        86,
853:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
854:                                                .addPreferredGap(
855:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
856:                                                .add(
857:                                                        layout
858:                                                                .createParallelGroup(
859:                                                                        org.jdesktop.layout.GroupLayout.BASELINE)
860:                                                                .add(addButton)
861:                                                                .add(editButton)
862:                                                                .add(
863:                                                                        removeButton))
864:                                                .addContainerGap(
865:                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
866:                                                        Short.MAX_VALUE)));
867:            }// </editor-fold>//GEN-END:initComponents
868:
869:            private void useDefaultKeyStoreCBActionPerformed(
870:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_useDefaultKeyStoreCBActionPerformed
871:            // TODO add your handling code here:
872:                updateVisualState();
873:            }//GEN-LAST:event_useDefaultKeyStoreCBActionPerformed
874:
875:            private void browseButtonActionPerformed(
876:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
877:            // TODO add your handling code here:
878:                JFileChooser chooser = new JFileChooser();
879:
880:                chooser.setFileFilter(new FileFilter() {
881:                    public boolean accept(File file) {
882:                        if (file.isFile()) {
883:                            if (file.getName().endsWith(JKS_EXTENSION)) {
884:                                return true;
885:                            } else {
886:                                return false;
887:                            }
888:                        }
889:
890:                        return true;
891:                    }
892:
893:                    public String getDescription() {
894:                        return NbBundle.getMessage(ProfileEditorPanel.class,
895:                                "TXT_JavaKeyStore");
896:                    }
897:                });
898:
899:                int returnVal = chooser.showOpenDialog(this );
900:
901:                if (returnVal == JFileChooser.APPROVE_OPTION) {
902:                    keystoreLocationTF.setText(chooser.getSelectedFile()
903:                            .getPath());
904:                }
905:            }//GEN-LAST:event_browseButtonActionPerformed
906:
907:            private void signResponseCBActionPerformed(
908:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_signResponseCBActionPerformed
909:            // TODO add your handling code here:
910:                updateVisualState();
911:            }//GEN-LAST:event_signResponseCBActionPerformed
912:
913:            private void removeButtonActionPerformed(
914:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeButtonActionPerformed
915:            // TODO add your handling code here:
916:                int row = userNameTable.getSelectedRow();
917:
918:                // simply return if there is no row selected;
919:                if (row == -1)
920:                    return;
921:
922:                DefaultTableModel model = (DefaultTableModel) userNameTable
923:                        .getModel();
924:                String userName = (String) model.getValueAt(row, 0);
925:
926:                NotifyDescriptor d = new NotifyDescriptor.Confirmation(NbBundle
927:                        .getMessage(ProfileEditorPanel.class,
928:                                "LBL_ReallyRemove", userName),
929:                        NbBundle.getMessage(ProfileEditorPanel.class,
930:                                "TTL_RemoveUser"),
931:                        NotifyDescriptor.OK_CANCEL_OPTION);
932:
933:                if (DialogDisplayer.getDefault().notify(d) == NotifyDescriptor.OK_OPTION) {
934:                    model.removeRow(row);
935:                    model.fireTableRowsDeleted(row, row);
936:                }
937:            }//GEN-LAST:event_removeButtonActionPerformed
938:
939:            private void editButtonActionPerformed(
940:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editButtonActionPerformed
941:            // TODO add your handling code here:
942:                showUserNamePasswordEditor(false);
943:            }//GEN-LAST:event_editButtonActionPerformed
944:
945:            private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButtonActionPerformed
946:            // TODO add your handling code here:
947:                showUserNamePasswordEditor(true);
948:            }//GEN-LAST:event_addButtonActionPerformed
949:
950:            // Variables declaration - do not modify//GEN-BEGIN:variables
951:            private javax.swing.JButton addButton;
952:            private javax.swing.JButton browseButton;
953:            private javax.swing.JLabel certSettingsLabel;
954:            private javax.swing.JButton editButton;
955:            private javax.swing.JScrollPane jScrollPane1;
956:            private javax.swing.JTable jTable1;
957:            private javax.swing.JLabel keyAliasLabel;
958:            private javax.swing.JTextField keyAliasTF;
959:            private javax.swing.JLabel keyPasswordLabel;
960:            private javax.swing.JPasswordField keyPasswordTF;
961:            private javax.swing.JLabel keystoreLocationLabel;
962:            private javax.swing.JTextField keystoreLocationTF;
963:            private javax.swing.JLabel keystorePasswordLabel;
964:            private javax.swing.JPasswordField keystorePasswordTF;
965:            private javax.swing.JButton removeButton;
966:            private javax.swing.JCheckBox signResponseCB;
967:            private javax.swing.JCheckBox useDefaultKeyStoreCB;
968:            private javax.swing.JTable userNameTable;
969:            private javax.swing.JScrollPane userNameTableScrollPane;
970:            private javax.swing.JLabel usernameInfoDescLabel;
971:            private javax.swing.JLabel usernameInfoLabel;
972:            // End of variables declaration//GEN-END:variables
973:
974:        }
w___w___w_._j__a__va___2__s.c_o_m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.