KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > share > configbean > customizers > webservice > SelectedEndpointPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 /*
20  * SelectedEndpointPanel.java
21  *
22  * Created on April 7, 2006, 2:31 PM
23  */

24
25 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.webservice;
26
27 import java.awt.Component JavaDoc;
28 import java.awt.Container JavaDoc;
29 import java.awt.GridBagConstraints JavaDoc;
30 import java.util.ResourceBundle JavaDoc;
31
32 import javax.swing.DefaultComboBoxModel JavaDoc;
33
34 import org.openide.ErrorManager;
35
36 import org.netbeans.modules.j2ee.sun.dd.api.VersionNotSupportedException;
37 import org.netbeans.modules.j2ee.sun.dd.api.common.LoginConfig;
38 import org.netbeans.modules.j2ee.sun.dd.api.common.MessageSecurityBinding;
39 import org.netbeans.modules.j2ee.sun.dd.api.common.WebserviceEndpoint;
40
41 import org.netbeans.modules.j2ee.sun.share.configbean.ASDDVersion;
42 import org.netbeans.modules.j2ee.sun.share.configbean.Utils;
43 import org.netbeans.modules.j2ee.sun.share.configbean.WebServiceDescriptor;
44 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.TextMapping;
45
46
47 /**
48  *
49  * @author Peter Williams
50  */

51 public class SelectedEndpointPanel extends javax.swing.JPanel JavaDoc {
52
53     private static final int SECURITY_NONE = 0; // No security settings
54
private static final int SECURITY_AUTHENTICATION = 1; // login-config/authentication is set
55
private static final int SECURITY_MESSAGE = 2; // message level security is set.
56

57     private static final ResourceBundle JavaDoc commonBundle = ResourceBundle.getBundle(
58        "org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.Bundle"); // NOI18N
59

60     private static final ResourceBundle JavaDoc webserviceBundle = ResourceBundle.getBundle(
61        "org.netbeans.modules.j2ee.sun.share.configbean.customizers.webservice.Bundle"); // NOI18N
62

63     /** xml <--> ui mapping for authorization method combo box */
64     private static final TextMapping [] authMethodTypes = {
65         new TextMapping("", ""), // NOI18N
66
new TextMapping("BASIC", webserviceBundle.getString("AUTHORIZATION_Basic")), // NOI18N
67
new TextMapping("CLIENT-CERT", webserviceBundle.getString("AUTHORIZATION_ClientCert")), // NOI18N
68
};
69
70     /** xml <--> ui mapping for transport guarantee combo box */
71     private static final TextMapping [] transportTypes = {
72         new TextMapping("", ""), // NOI18N
73
new TextMapping("NONE", webserviceBundle.getString("TRANSPORT_None")), // NOI18N
74
new TextMapping("INTEGRAL", webserviceBundle.getString("TRANSPORT_Integral")), // NOI18N
75
new TextMapping("CONFIDENTIAL", webserviceBundle.getString("TRANSPORT_Confidential")), // NOI18N
76
};
77     
78     private WebServiceDescriptorCustomizer masterPanel;
79
80     // selected endpoint management
81
private EndpointMapping selectedEndpointMap;
82     private WebserviceEndpoint selectedEndpoint;
83     private boolean selectedEndpointSetup;
84
85     // For ejb endpoints, holds prior config binding if the user is switching
86
// the radio buttons. Only the last selected item will be saved into the
87
// endpoint though.
88
private LoginConfig loginConfig;
89     private MessageSecurityBinding messageBinding;
90     
91     // authorization method combo box model
92
private DefaultComboBoxModel JavaDoc authMethodModel;
93
94     // transport guarantee combo box model
95
private DefaultComboBoxModel JavaDoc transportGuaranteeModel;
96
97     // true if AS 9.0+ fields are visible.
98
private boolean as90FeaturesVisible;
99
100     /** Creates new form SelectedEndpointPanel */
101     public SelectedEndpointPanel(WebServiceDescriptorCustomizer src) {
102         masterPanel = src;
103         selectedEndpointSetup = false;
104
105         initComponents();
106         initUserComponents();
107     }
108     
109     /** This method is called from within the constructor to
110      * initialize the form.
111      * WARNING: Do NOT modify this code. The content of this method is
112      * always regenerated by the Form Editor.
113      */

114     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
115
private void initComponents() {
116         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
117
118         bgSecurity = new javax.swing.ButtonGroup JavaDoc();
119         jLblEndpointAddressURI = new javax.swing.JLabel JavaDoc();
120         jTxtEndpointAddressURI = new javax.swing.JTextField JavaDoc();
121         jLblTransportGuarantee = new javax.swing.JLabel JavaDoc();
122         jCbxTransportGuarantee = new javax.swing.JComboBox JavaDoc();
123         jLblDebugEnabled = new javax.swing.JLabel JavaDoc();
124         jChkDebugEnabled = new javax.swing.JCheckBox JavaDoc();
125         jLblSecuritySettings = new javax.swing.JLabel JavaDoc();
126         jRBnNoSecurity = new javax.swing.JRadioButton JavaDoc();
127         jRBnMessageSecurity = new javax.swing.JRadioButton JavaDoc();
128         jLblEnableMsgSecurity = new javax.swing.JLabel JavaDoc();
129         jChkEnableMsgSecurity = new javax.swing.JCheckBox JavaDoc();
130         jBtnEditBindings = new javax.swing.JButton JavaDoc();
131         jRBnLoginConfig = new javax.swing.JRadioButton JavaDoc();
132         jLblRealm = new javax.swing.JLabel JavaDoc();
133         jTxtRealm = new javax.swing.JTextField JavaDoc();
134         jLblAuthentication = new javax.swing.JLabel JavaDoc();
135         jCbxAuthentication = new javax.swing.JComboBox JavaDoc();
136
137         setLayout(new java.awt.GridBagLayout JavaDoc());
138
139         setBorder(javax.swing.BorderFactory.createEtchedBorder());
140         jLblEndpointAddressURI.setLabelFor(jTxtEndpointAddressURI);
141         jLblEndpointAddressURI.setText(WebServiceDescriptorCustomizer.bundle.getString("LBL_EndpointAddressURI_1"));
142         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
143         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
144         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 6, 0, 0);
145         add(jLblEndpointAddressURI, gridBagConstraints);
146
147         jTxtEndpointAddressURI.addKeyListener(new java.awt.event.KeyAdapter JavaDoc() {
148             public void keyReleased(java.awt.event.KeyEvent JavaDoc evt) {
149                 jTxtEndpointAddressURIKeyReleased(evt);
150             }
151         });
152
153         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
154         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
155         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
156         gridBagConstraints.weightx = 1.0;
157         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 6, 0, 5);
158         add(jTxtEndpointAddressURI, gridBagConstraints);
159         jTxtEndpointAddressURI.getAccessibleContext().setAccessibleName(WebServiceDescriptorCustomizer.bundle.getString("ACSN_EndpointAddressURI"));
160         jTxtEndpointAddressURI.getAccessibleContext().setAccessibleDescription(WebServiceDescriptorCustomizer.bundle.getString("ACSD_EndpointAddressURI"));
161
162         jLblTransportGuarantee.setLabelFor(jCbxTransportGuarantee);
163         jLblTransportGuarantee.setText(WebServiceDescriptorCustomizer.bundle.getString("LBL_TransportGuarantee_1"));
164         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
165         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
166         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 6, 0, 0);
167         add(jLblTransportGuarantee, gridBagConstraints);
168
169         jCbxTransportGuarantee.addActionListener(new java.awt.event.ActionListener JavaDoc() {
170             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
171                 jCbxTransportGuaranteeActionPerformed(evt);
172             }
173         });
174
175         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
176         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
177         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
178         gridBagConstraints.weightx = 1.0;
179         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 6, 0, 5);
180         add(jCbxTransportGuarantee, gridBagConstraints);
181         jCbxTransportGuarantee.getAccessibleContext().setAccessibleName(WebServiceDescriptorCustomizer.bundle.getString("ACSN_TransportGuarantee"));
182         jCbxTransportGuarantee.getAccessibleContext().setAccessibleDescription(WebServiceDescriptorCustomizer.bundle.getString("ACSD_TransportGuarantee"));
183
184         jLblDebugEnabled.setLabelFor(jChkDebugEnabled);
185         jLblDebugEnabled.setText(WebServiceDescriptorCustomizer.bundle.getString("LBL_DebugEnabled_1"));
186         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
187         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
188         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 6, 0, 0);
189         add(jLblDebugEnabled, gridBagConstraints);
190
191         jChkDebugEnabled.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
192         jChkDebugEnabled.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
193         jChkDebugEnabled.addItemListener(new java.awt.event.ItemListener JavaDoc() {
194             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
195                 jChkDebugEnabledItemStateChanged(evt);
196             }
197         });
198
199         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
200         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
201         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
202         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 6, 0, 5);
203         add(jChkDebugEnabled, gridBagConstraints);
204         jChkDebugEnabled.getAccessibleContext().setAccessibleName(WebServiceDescriptorCustomizer.bundle.getString("ACSN_DebugEnabled"));
205         jChkDebugEnabled.getAccessibleContext().setAccessibleDescription(WebServiceDescriptorCustomizer.bundle.getString("ACSD_DebugEnabled"));
206
207         jLblSecuritySettings.setText("Security Settings :");
208         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
209         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
210         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
211         gridBagConstraints.insets = new java.awt.Insets JavaDoc(10, 6, 0, 0);
212         add(jLblSecuritySettings, gridBagConstraints);
213
214         bgSecurity.add(jRBnNoSecurity);
215         jRBnNoSecurity.setText("No Security");
216         jRBnNoSecurity.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
217         jRBnNoSecurity.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
218         jRBnNoSecurity.addActionListener(new java.awt.event.ActionListener JavaDoc() {
219             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
220                 jRBnNoSecurityActionPerformed(evt);
221             }
222         });
223
224         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
225         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
226         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
227         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 12, 0, 0);
228         add(jRBnNoSecurity, gridBagConstraints);
229
230         bgSecurity.add(jRBnMessageSecurity);
231         jRBnMessageSecurity.setText("Message Security");
232         jRBnMessageSecurity.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
233         jRBnMessageSecurity.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
234         jRBnMessageSecurity.addActionListener(new java.awt.event.ActionListener JavaDoc() {
235             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
236                 jRBnMessageSecurityActionPerformed(evt);
237             }
238         });
239
240         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
241         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
242         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 12, 5, 0);
243         add(jRBnMessageSecurity, gridBagConstraints);
244
245         jLblEnableMsgSecurity.setLabelFor(jChkEnableMsgSecurity);
246         jLblEnableMsgSecurity.setText(WebServiceDescriptorCustomizer.bundle.getString("LBL_EnableMsgSecurity_1"));
247         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
248         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
249         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 6, 5, 0);
250         add(jLblEnableMsgSecurity, gridBagConstraints);
251
252         jChkEnableMsgSecurity.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
253         jChkEnableMsgSecurity.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
254         jChkEnableMsgSecurity.addItemListener(new java.awt.event.ItemListener JavaDoc() {
255             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
256                 jChkEnableMsgSecurityItemStateChanged(evt);
257             }
258         });
259
260         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
261         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
262         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 6, 5, 12);
263         add(jChkEnableMsgSecurity, gridBagConstraints);
264         jChkEnableMsgSecurity.getAccessibleContext().setAccessibleName(WebServiceDescriptorCustomizer.bundle.getString("ACSN_EnableMsgSecurity"));
265         jChkEnableMsgSecurity.getAccessibleContext().setAccessibleDescription(WebServiceDescriptorCustomizer.bundle.getString("ACSD_EnableMsgSecurity"));
266
267         jBtnEditBindings.setText(WebServiceDescriptorCustomizer.bundle.getString("LBL_EditMsgSecBindings"));
268         jBtnEditBindings.addActionListener(new java.awt.event.ActionListener JavaDoc() {
269             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
270                 jBtnEditBindingsActionPerformed(evt);
271             }
272         });
273
274         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
275         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
276         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
277         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 6, 5, 5);
278         add(jBtnEditBindings, gridBagConstraints);
279         jBtnEditBindings.getAccessibleContext().setAccessibleName(WebServiceDescriptorCustomizer.bundle.getString("ACSN_EditMsgSecBindings"));
280         jBtnEditBindings.getAccessibleContext().setAccessibleDescription(WebServiceDescriptorCustomizer.bundle.getString("ACSD_EditMsgSecBindings"));
281
282         bgSecurity.add(jRBnLoginConfig);
283         jRBnLoginConfig.setText("Login Configuration");
284         jRBnLoginConfig.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
285         jRBnLoginConfig.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
286         jRBnLoginConfig.addActionListener(new java.awt.event.ActionListener JavaDoc() {
287             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
288                 jRBnLoginConfigActionPerformed(evt);
289             }
290         });
291
292         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
293         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
294         gridBagConstraints.insets = new java.awt.Insets JavaDoc(1, 12, 0, 0);
295         add(jRBnLoginConfig, gridBagConstraints);
296
297         jLblRealm.setLabelFor(jTxtRealm);
298         jLblRealm.setText("Realm :");
299         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
300         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
301         gridBagConstraints.insets = new java.awt.Insets JavaDoc(1, 6, 0, 0);
302         add(jLblRealm, gridBagConstraints);
303
304         jTxtRealm.addKeyListener(new java.awt.event.KeyAdapter JavaDoc() {
305             public void keyReleased(java.awt.event.KeyEvent JavaDoc evt) {
306                 jTxtRealmKeyReleased(evt);
307             }
308         });
309
310         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
311         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
312         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
313         gridBagConstraints.weightx = 1.0;
314         gridBagConstraints.insets = new java.awt.Insets JavaDoc(1, 6, 0, 5);
315         add(jTxtRealm, gridBagConstraints);
316
317         jLblAuthentication.setLabelFor(jCbxAuthentication);
318         jLblAuthentication.setText("Authentication Method :");
319         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
320         gridBagConstraints.gridx = 1;
321         gridBagConstraints.gridwidth = 2;
322         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
323         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 6, 5, 0);
324         add(jLblAuthentication, gridBagConstraints);
325
326         jCbxAuthentication.addActionListener(new java.awt.event.ActionListener JavaDoc() {
327             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
328                 jCbxAuthenticationActionPerformed(evt);
329             }
330         });
331
332         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
333         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
334         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
335         gridBagConstraints.weightx = 1.0;
336         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 6, 5, 5);
337         add(jCbxAuthentication, gridBagConstraints);
338
339     }// </editor-fold>//GEN-END:initComponents
340

341     private void jRBnLoginConfigActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jRBnLoginConfigActionPerformed
342
if(!selectedEndpointSetup) {
343             selectedEndpoint.setLoginConfig((LoginConfig) loginConfig.clone());
344             
345             String JavaDoc authMethod = loginConfig.getAuthMethod();
346             jCbxAuthentication.setSelectedItem(getAuthorizationMethodMapping(authMethod));
347             if(as90FeaturesVisible) {
348                 try {
349                     String JavaDoc realm = loginConfig.getRealm();
350                     jTxtRealm.setText(realm);
351                 } catch(VersionNotSupportedException ex) {
352                     ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
353                 }
354             }
355             
356             enableMessageSecurityUI(false);
357             enableAuthenticationUI(true);
358             masterPanel.getBean().firePropertyChange("loginConfig", null, loginConfig); // NOI18N
359
}
360     }//GEN-LAST:event_jRBnLoginConfigActionPerformed
361

362     private void jRBnMessageSecurityActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jRBnMessageSecurityActionPerformed
363
if(!selectedEndpointSetup) {
364             try {
365                 selectedEndpoint.setMessageSecurityBinding((MessageSecurityBinding) messageBinding.clone());
366             } catch (VersionNotSupportedException ex) {
367                 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
368             }
369             
370             jCbxAuthentication.setSelectedItem(getAuthorizationMethodMapping(""));
371             jTxtRealm.setText("");
372
373             enableMessageSecurityUI(true);
374             enableAuthenticationUI(false);
375             masterPanel.getBean().firePropertyChange("messageSecurity", null, messageBinding); // NOI18N
376
}
377     }//GEN-LAST:event_jRBnMessageSecurityActionPerformed
378

379     private void jRBnNoSecurityActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jRBnNoSecurityActionPerformed
380
if(!selectedEndpointSetup) {
381             selectedEndpoint.setLoginConfig(null);
382             try {
383                 selectedEndpoint.setMessageSecurityBinding(null);
384             } catch (VersionNotSupportedException ex) {
385                 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
386             }
387             
388             jCbxAuthentication.setSelectedItem(getAuthorizationMethodMapping(""));
389             jTxtRealm.setText("");
390
391             enableMessageSecurityUI(false);
392             enableAuthenticationUI(false);
393             masterPanel.getBean().setDirty();
394         }
395     }//GEN-LAST:event_jRBnNoSecurityActionPerformed
396

397     private void jTxtRealmKeyReleased(java.awt.event.KeyEvent JavaDoc evt) {//GEN-FIRST:event_jTxtRealmKeyReleased
398
if(!selectedEndpointSetup && jRBnLoginConfig.isSelected() && jRBnLoginConfig.isVisible()) {
399             String JavaDoc newRealm = jTxtRealm.getText();
400             if(newRealm != null) {
401                 newRealm = newRealm.trim();
402             }
403             try {
404                 String JavaDoc oldRealm = loginConfig.getRealm();
405                 if(!Utils.strEquivalent(newRealm, oldRealm)) {
406                     loginConfig.setRealm(newRealm);
407                     selectedEndpoint.getLoginConfig().setRealm(newRealm);
408                     masterPanel.getBean().firePropertyChange("loginConfig-realm", oldRealm, newRealm);
409                 }
410             } catch(VersionNotSupportedException ex) {
411                 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
412             }
413         }
414     }//GEN-LAST:event_jTxtRealmKeyReleased
415

416     private void jCbxAuthenticationActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jCbxAuthenticationActionPerformed
417
if(!selectedEndpointSetup && jRBnLoginConfig.isSelected() && jRBnLoginConfig.isVisible()) {
418             TextMapping authMapping = (TextMapping) authMethodModel.getSelectedItem();
419             String JavaDoc oldAuthMethod = loginConfig.getAuthMethod();
420             String JavaDoc newAuthMethod = authMapping.getXMLString();
421             if(!Utils.strEquals(newAuthMethod, oldAuthMethod)) {
422                 loginConfig.setAuthMethod(newAuthMethod);
423                 selectedEndpoint.getLoginConfig().setAuthMethod(newAuthMethod);
424                 masterPanel.getBean().firePropertyChange("loginConfig-authMethod", oldAuthMethod, newAuthMethod); // NOI18N
425
}
426         }
427     }//GEN-LAST:event_jCbxAuthenticationActionPerformed
428

429     private void jCbxTransportGuaranteeActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jCbxTransportGuaranteeActionPerformed
430
if(!selectedEndpointSetup) {
431             TextMapping transportMapping = (TextMapping) transportGuaranteeModel.getSelectedItem();
432             String JavaDoc oldTransportGuarantee = selectedEndpoint.getTransportGuarantee();
433             String JavaDoc newTransportGuarantee = transportMapping.getXMLString();
434             if(!Utils.strEquals(newTransportGuarantee, oldTransportGuarantee)) {
435                 selectedEndpoint.setTransportGuarantee(newTransportGuarantee);
436                 masterPanel.getBean().firePropertyChange("transportGuarantee", oldTransportGuarantee, newTransportGuarantee); // NOI18N
437
}
438         }
439     }//GEN-LAST:event_jCbxTransportGuaranteeActionPerformed
440

441     private void jChkEnableMsgSecurityItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_jChkEnableMsgSecurityItemStateChanged
442
if(!selectedEndpointSetup) {
443             boolean hasMessageSecurity = Utils.interpretCheckboxState(evt);
444             
445             try {
446                 MessageSecurityBinding oldBinding = null, newBinding = null;
447                 if(hasMessageSecurity) {
448                     if(messageBinding != null) {
449                         newBinding = (MessageSecurityBinding) messageBinding.clone();
450                         selectedEndpoint.setMessageSecurityBinding(newBinding);
451                     }
452                 } else {
453                     oldBinding = messageBinding = selectedEndpoint.getMessageSecurityBinding();
454                     selectedEndpoint.setMessageSecurityBinding(null);
455                 }
456                 
457                 masterPanel.getBean().firePropertyChange("messageSecurityBinding", oldBinding, newBinding); // NOI18N
458
} catch (VersionNotSupportedException ex) {
459                 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
460             }
461             
462             enableMessageSecurityUI(hasMessageSecurity);
463         }
464     }//GEN-LAST:event_jChkEnableMsgSecurityItemStateChanged
465

466     private void jChkDebugEnabledItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_jChkDebugEnabledItemStateChanged
467
if(!selectedEndpointSetup) {
468             boolean newDebugEnabledFlag = Utils.interpretCheckboxState(evt);
469             try {
470                 String JavaDoc oldDebugEnabled = selectedEndpoint.getDebuggingEnabled();
471                 String JavaDoc newDebugEnabled = newDebugEnabledFlag ? "true" : null; // NOI18N
472
selectedEndpoint.setDebuggingEnabled(newDebugEnabled);
473                 masterPanel.getBean().firePropertyChange("debugEnabled", oldDebugEnabled, newDebugEnabled); // NOI18N
474
} catch (VersionNotSupportedException ex) {
475                 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
476             }
477         }
478     }//GEN-LAST:event_jChkDebugEnabledItemStateChanged
479

480     private void jTxtEndpointAddressURIKeyReleased(java.awt.event.KeyEvent JavaDoc evt) {//GEN-FIRST:event_jTxtEndpointAddressURIKeyReleased
481
if(!selectedEndpointSetup) {
482             String JavaDoc oldEndpointAddressUri = selectedEndpoint.getEndpointAddressUri();
483             String JavaDoc newEndpointAddressUri = jTxtEndpointAddressURI.getText().trim();
484             if(!Utils.strEquals(newEndpointAddressUri, oldEndpointAddressUri)) {
485                 selectedEndpoint.setEndpointAddressUri(newEndpointAddressUri);
486                 masterPanel.getBean().firePropertyChange("endpointAddressUri", oldEndpointAddressUri, newEndpointAddressUri); // NOI18N
487
}
488         }
489     }//GEN-LAST:event_jTxtEndpointAddressURIKeyReleased
490

491     private void jBtnEditBindingsActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jBtnEditBindingsActionPerformed
492
if(!selectedEndpointSetup) {
493             try {
494                 WebServiceDescriptor theBean = masterPanel.getBean();
495                 ASDDVersion asVersion = theBean.getAppServerVersion();
496                 String JavaDoc asCloneVersion = "";
497
498                 if(theBean.isWarModule()) {
499                     asCloneVersion = asVersion.getWebAppVersionAsString();
500                 } else if(theBean.isEjbModule()) {
501                     asCloneVersion = asVersion.getEjbJarVersionAsString();
502                 }
503                 
504                 MessageSecurityBinding binding = selectedEndpoint.getMessageSecurityBinding();
505                 if(binding == null) {
506                     binding = selectedEndpoint.newMessageSecurityBinding();
507                     selectedEndpoint.setMessageSecurityBinding(binding);
508                 }
509
510                 EditBinding.editMessageSecurityBinding(masterPanel, theBean, false, binding, asVersion, asCloneVersion);
511             } catch (VersionNotSupportedException ex) {
512                 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
513             }
514         }
515     }//GEN-LAST:event_jBtnEditBindingsActionPerformed
516

517     
518     // Variables declaration - do not modify//GEN-BEGIN:variables
519
private javax.swing.ButtonGroup JavaDoc bgSecurity;
520     private javax.swing.JButton JavaDoc jBtnEditBindings;
521     private javax.swing.JComboBox JavaDoc jCbxAuthentication;
522     private javax.swing.JComboBox JavaDoc jCbxTransportGuarantee;
523     private javax.swing.JCheckBox JavaDoc jChkDebugEnabled;
524     private javax.swing.JCheckBox JavaDoc jChkEnableMsgSecurity;
525     private javax.swing.JLabel JavaDoc jLblAuthentication;
526     private javax.swing.JLabel JavaDoc jLblDebugEnabled;
527     private javax.swing.JLabel JavaDoc jLblEnableMsgSecurity;
528     private javax.swing.JLabel JavaDoc jLblEndpointAddressURI;
529     private javax.swing.JLabel JavaDoc jLblRealm;
530     private javax.swing.JLabel JavaDoc jLblSecuritySettings;
531     private javax.swing.JLabel JavaDoc jLblTransportGuarantee;
532     private javax.swing.JRadioButton JavaDoc jRBnLoginConfig;
533     private javax.swing.JRadioButton JavaDoc jRBnMessageSecurity;
534     private javax.swing.JRadioButton JavaDoc jRBnNoSecurity;
535     private javax.swing.JTextField JavaDoc jTxtEndpointAddressURI;
536     private javax.swing.JTextField JavaDoc jTxtRealm;
537     // End of variables declaration//GEN-END:variables
538

539     private void initUserComponents() {
540         as90FeaturesVisible = true;
541
542         // Setup authorization method combobox
543
authMethodModel = new DefaultComboBoxModel JavaDoc();
544         for(int i = 0; i < authMethodTypes.length; i++) {
545                 authMethodModel.addElement(authMethodTypes[i]);
546         }
547         jCbxAuthentication.setModel(authMethodModel);
548         
549         // Setup transport guarantee combobox
550
transportGuaranteeModel = new DefaultComboBoxModel JavaDoc();
551         for(int i = 0; i < transportTypes.length; i++) {
552                 transportGuaranteeModel.addElement(transportTypes[i]);
553         }
554         jCbxTransportGuarantee.setModel(transportGuaranteeModel);
555         
556         GridBagConstraints JavaDoc gridBagConstraints = new GridBagConstraints JavaDoc();
557         gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
558         gridBagConstraints.fill = GridBagConstraints.BOTH;
559         gridBagConstraints.weightx = 1.0;
560         gridBagConstraints.weighty = 1.0;
561         add(new javax.swing.JPanel JavaDoc(), gridBagConstraints);
562     }
563     
564     public void setEndpointMapping(EndpointMapping endpointMapping) {
565         try {
566             selectedEndpointSetup = true;
567             
568             WebServiceDescriptor theBean = masterPanel.getBean();
569             ASDDVersion asVersion = theBean.getAppServerVersion();
570             String JavaDoc asCloneVersion = "";
571             selectedEndpointMap = endpointMapping;
572             
573             if(theBean.isWarModule()) {
574                 asCloneVersion = asVersion.getWebAppVersionAsString();
575             } else if(theBean.isEjbModule()) {
576                 asCloneVersion = asVersion.getEjbJarVersionAsString();
577             }
578
579             handleAS90FieldVisibility(ASDDVersion.SUN_APPSERVER_9_0.compareTo(asVersion) <= 0);
580
581             // Relies on version field initialization from handleAS90FieldVisibility(), above
582
showSecurityUI(theBean.isWarModule(), theBean.isEjbModule());
583             
584             if(selectedEndpointMap != null) {
585                 selectedEndpoint = selectedEndpointMap.getEndpoint();
586             } else {
587                 selectedEndpoint = null;
588             }
589
590             // initialize standard data
591
if(selectedEndpoint != null) {
592                 // endpoint uri
593
jTxtEndpointAddressURI.setText(selectedEndpoint.getEndpointAddressUri());
594
595                 // transport guarantee
596
String JavaDoc transportGuarantee = selectedEndpoint.getTransportGuarantee();
597                 jCbxTransportGuarantee.setSelectedItem(getTransportGuaranteeMapping(transportGuarantee));
598                 
599                 // debug enabled
600
if(as90FeaturesVisible) {
601                     boolean debugEnabled;
602                     try {
603                         debugEnabled = Utils.booleanValueOf(selectedEndpoint.getDebuggingEnabled());
604                     } catch (VersionNotSupportedException ex) {
605                         debugEnabled = false;
606                     }
607                     jChkDebugEnabled.setSelected(debugEnabled);
608                 }
609                 
610                 // security (all)
611
boolean authenticationEnabled = false;
612                 boolean messageSecurityEnabled = false;
613
614                 loginConfig = selectedEndpoint.getLoginConfig();
615                 if(loginConfig != null) {
616                     loginConfig = (LoginConfig) loginConfig.cloneVersion(asCloneVersion);
617                     authenticationEnabled = true;
618                 } else {
619                     loginConfig = selectedEndpoint.newLoginConfig();
620                 }
621                 
622                 try {
623                     messageBinding = selectedEndpoint.getMessageSecurityBinding();
624                     if(messageBinding != null) {
625                         messageBinding = (MessageSecurityBinding) messageBinding.cloneVersion(asCloneVersion);
626                         messageSecurityEnabled = true;
627                     } else {
628                         messageBinding = masterPanel.getBean().getConfig().getStorageFactory().createMessageSecurityBinding();
629                     }
630                 } catch (VersionNotSupportedException ex) {
631                     ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
632                     messageBinding = null;
633                 }
634                 
635                 // security (web)
636
if(theBean.isWarModule()) {
637                     jChkEnableMsgSecurity.setSelected(messageSecurityEnabled);
638                     enableMessageSecurityUI(messageSecurityEnabled);
639                 }
640                 // security (ejb)
641
else if(theBean.isEjbModule()) {
642                     if(messageSecurityEnabled) {
643                         jRBnMessageSecurity.setSelected(true);
644                         jCbxAuthentication.setSelectedItem(getAuthorizationMethodMapping(""));
645                         jTxtRealm.setText("");
646                     } else if(authenticationEnabled) {
647                         jRBnLoginConfig.setSelected(true);
648                         String JavaDoc authMethod = loginConfig.getAuthMethod();
649                         jCbxAuthentication.setSelectedItem(getAuthorizationMethodMapping(authMethod));
650
651                         if(as90FeaturesVisible) {
652                             try {
653                                 String JavaDoc realm = loginConfig.getRealm();
654                                 jTxtRealm.setText(realm);
655                             } catch(VersionNotSupportedException ex) {
656                                 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
657                             }
658                         }
659                     } else {
660                         jRBnNoSecurity.setSelected(true);
661                         jCbxAuthentication.setSelectedItem(getAuthorizationMethodMapping(""));
662                         jTxtRealm.setText("");
663                     }
664                     
665                     enableMessageSecurityUI(messageSecurityEnabled);
666                     enableAuthenticationUI(authenticationEnabled);
667                 }
668             } else {
669                 jTxtEndpointAddressURI.setText(""); // NOI18N
670
jCbxTransportGuarantee.setSelectedItem(getTransportGuaranteeMapping(null));
671                 jChkDebugEnabled.setSelected(false);
672                 enableMessageSecurityUI(false);
673             }
674         } finally {
675                 selectedEndpointSetup = false;
676         }
677     }
678
679     private void handleAS90FieldVisibility(boolean visible) {
680         if(as90FeaturesVisible != visible) {
681             jLblDebugEnabled.setVisible(visible);
682             jChkDebugEnabled.setVisible(visible);
683             as90FeaturesVisible = visible;
684         }
685     }
686     
687     void reloadEndpointMapping() {
688         setEndpointMapping(selectedEndpointMap);
689     }
690     
691     /** This method displays the correct security related UI based on whether the
692      * host is a web module or an ejb jar.
693      */

694     private void showSecurityUI(boolean showForWebApp, boolean showForEjbJar) {
695         // Show web app security fields.
696
jLblEnableMsgSecurity.setVisible(showForWebApp);
697         jChkEnableMsgSecurity.setVisible(showForWebApp);
698         
699         // Hide ejb-jar security fields.
700
jLblSecuritySettings.setVisible(showForEjbJar);
701         jRBnNoSecurity.setVisible(showForEjbJar);
702         jRBnMessageSecurity.setVisible(showForEjbJar);
703         jRBnLoginConfig.setVisible(showForEjbJar);
704         jLblRealm.setVisible(showForEjbJar && as90FeaturesVisible);
705         jTxtRealm.setVisible(showForEjbJar && as90FeaturesVisible);
706         jLblAuthentication.setVisible(showForEjbJar);
707         jCbxAuthentication.setVisible(showForEjbJar);
708         
709         // This button is shown for both, but if both are false, then we want to hide it
710
jBtnEditBindings.setVisible(showForWebApp || showForEjbJar);
711     }
712
713     private void enableMessageSecurityUI(boolean enable) {
714         jBtnEditBindings.setEnabled(enable);
715     }
716     
717     private void enableAuthenticationUI(boolean enable) {
718         jLblRealm.setEnabled(enable);
719         jTxtRealm.setEnabled(enable);
720         jLblAuthentication.setEnabled(enable);
721         jCbxAuthentication.setEnabled(enable);
722     }
723   
724     private TextMapping getAuthorizationMethodMapping(String JavaDoc xmlKey) {
725         TextMapping result = authMethodTypes[0]; // Default to BLANK
726
if(xmlKey == null) {
727             xmlKey = ""; // NOI18N
728
}
729         for(int i = 0; i < authMethodTypes.length; i++) {
730             if(authMethodTypes[i].getXMLString().compareTo(xmlKey) == 0) {
731                 result = authMethodTypes[i];
732                 break;
733             }
734         }
735
736         return result;
737     }
738
739     private TextMapping getTransportGuaranteeMapping(String JavaDoc xmlKey) {
740         TextMapping result = transportTypes[0]; // Default to BLANK
741
if(xmlKey == null) {
742             xmlKey = ""; // NOI18N
743
}
744         for(int i = 0; i < transportTypes.length; i++) {
745             if(transportTypes[i].getXMLString().compareTo(xmlKey) == 0) {
746                 result = transportTypes[i];
747                 break;
748             }
749         }
750
751         return result;
752     }
753     
754     public void setContainerEnabled(Container JavaDoc container, boolean enabled) {
755         Component JavaDoc [] components = container.getComponents();
756         for(int i = 0; i < components.length; i++) {
757             components[i].setEnabled(enabled);
758             if(components[i] instanceof Container JavaDoc) {
759                 setContainerEnabled((Container JavaDoc) components[i], enabled);
760             }
761         }
762     }
763 }
764
Popular Tags