KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > wsitconf > ui > service > profiles > EndorsingCertificate


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 2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.websvc.wsitconf.ui.service.profiles;
21
22 import javax.swing.JCheckBox JavaDoc;
23 import javax.swing.JComboBox JavaDoc;
24 import org.netbeans.modules.websvc.wsitconf.ui.ComboConstants;
25 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.AlgoSuiteModelHelper;
26 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.ProfilesModelHelper;
27 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.RMModelHelper;
28 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.SecurityPolicyModelHelper;
29 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.SecurityTokensModelHelper;
30 import org.netbeans.modules.websvc.wsitmodelext.policy.Policy;
31 import org.netbeans.modules.websvc.wsitmodelext.security.BootstrapPolicy;
32 import org.netbeans.modules.websvc.wsitmodelext.security.tokens.ProtectionToken;
33 import org.netbeans.modules.websvc.wsitmodelext.security.tokens.SecureConversationToken;
34 import org.netbeans.modules.xml.wsdl.model.WSDLComponent;
35 import org.netbeans.modules.xml.wsdl.model.WSDLModel;
36
37 /**
38  *
39  * @author Martin Grebac
40  */

41 public class EndorsingCertificate extends javax.swing.JPanel JavaDoc {
42
43     private boolean inSync = false;
44
45     private WSDLComponent comp;
46     private WSDLModel model;
47     
48     /**
49      * Creates new form EndorsingCertificate
50      */

51     public EndorsingCertificate(WSDLComponent comp) {
52         super();
53         initComponents();
54         this.model = comp.getModel();
55         this.comp = comp;
56
57         inSync = true;
58         layoutCombo.removeAllItems();
59         layoutCombo.addItem(ComboConstants.STRICT);
60         layoutCombo.addItem(ComboConstants.LAX);
61         layoutCombo.addItem(ComboConstants.LAXTSFIRST);
62         layoutCombo.addItem(ComboConstants.LAXTSLAST);
63         
64         algoSuiteCombo.removeAllItems();
65         algoSuiteCombo.addItem(ComboConstants.BASIC256);
66         algoSuiteCombo.addItem(ComboConstants.BASIC192);
67         algoSuiteCombo.addItem(ComboConstants.BASIC128);
68         algoSuiteCombo.addItem(ComboConstants.TRIPLEDES);
69         algoSuiteCombo.addItem(ComboConstants.BASIC256RSA15);
70         algoSuiteCombo.addItem(ComboConstants.BASIC192RSA15);
71         algoSuiteCombo.addItem(ComboConstants.BASIC128RSA15);
72         algoSuiteCombo.addItem(ComboConstants.TRIPLEDESRSA15);
73 // algoSuiteCombo.addItem(ComboConstants.BASIC256SHA256);
74
// algoSuiteCombo.addItem(ComboConstants.BASIC192SHA256);
75
// algoSuiteCombo.addItem(ComboConstants.BASIC128SHA256);
76
// algoSuiteCombo.addItem(ComboConstants.TRIPLEDESSHA256);
77
// algoSuiteCombo.addItem(ComboConstants.BASIC256SHA256RSA15);
78
// algoSuiteCombo.addItem(ComboConstants.BASIC192SHA256RSA15);
79
// algoSuiteCombo.addItem(ComboConstants.BASIC128SHA256RSA15);
80
// algoSuiteCombo.addItem(ComboConstants.TRIPLEDESSHA256RSA15);
81

82         inSync = false;
83         
84         sync();
85     }
86     
87     private void sync() {
88         inSync = true;
89
90         WSDLComponent secBinding = null;
91         WSDLComponent topSecBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(comp);
92         WSDLComponent protTokenKind = SecurityTokensModelHelper.getTokenElement(topSecBinding, ProtectionToken.class);
93         WSDLComponent protToken = SecurityTokensModelHelper.getTokenTypeElement(protTokenKind);
94         
95         boolean secConv = (protToken instanceof SecureConversationToken);
96         setChBox(secConvChBox, secConv);
97         
98         if (secConv) {
99             WSDLComponent bootPolicy = SecurityTokensModelHelper.getTokenElement(protToken, BootstrapPolicy.class);
100             secBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(bootPolicy);
101             Policy p = (Policy) secBinding.getParent();
102             setChBox(derivedKeysChBox, SecurityPolicyModelHelper.isRequireDerivedKeys(protToken));
103             setChBox(reqSigConfChBox, SecurityPolicyModelHelper.isRequireSignatureConfirmation(p));
104             setChBox(encryptSignatureChBox, SecurityPolicyModelHelper.isEncryptSignature(bootPolicy));
105             setChBox(encryptOrderChBox, SecurityPolicyModelHelper.isEncryptBeforeSigning(bootPolicy));
106         } else {
107             secBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(comp);
108             setChBox(reqSigConfChBox, SecurityPolicyModelHelper.isRequireSignatureConfirmation(comp));
109             setChBox(encryptSignatureChBox, SecurityPolicyModelHelper.isEncryptSignature(comp));
110             setChBox(encryptOrderChBox, SecurityPolicyModelHelper.isEncryptBeforeSigning(comp));
111         }
112
113         setCombo(algoSuiteCombo, AlgoSuiteModelHelper.getAlgorithmSuite(secBinding));
114         setCombo(layoutCombo, SecurityPolicyModelHelper.getMessageLayout(secBinding));
115
116         enableDisable();
117         
118         inSync = false;
119     }
120
121     public void setValue(javax.swing.JComponent JavaDoc source) {
122
123         if (inSync) return;
124
125         WSDLComponent secBinding = null;
126         WSDLComponent topSecBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(comp);
127         WSDLComponent protTokenKind = SecurityTokensModelHelper.getTokenElement(topSecBinding, ProtectionToken.class);
128         WSDLComponent protToken = SecurityTokensModelHelper.getTokenTypeElement(protTokenKind);
129         
130         boolean secConv = (protToken instanceof SecureConversationToken);
131
132         if (source.equals(secConvChBox)) {
133             ProfilesModelHelper.enableSecureConversation(comp, secConvChBox.isSelected(), ComboConstants.PROF_MSGAUTHSSL);
134         }
135
136         if (secConv) {
137             WSDLComponent bootPolicy = SecurityTokensModelHelper.getTokenElement(protToken, BootstrapPolicy.class);
138             secBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(bootPolicy);
139             Policy p = (Policy) secBinding.getParent();
140             if (source.equals(reqSigConfChBox)) {
141                 SecurityPolicyModelHelper.enableRequireSignatureConfirmation(
142                         SecurityPolicyModelHelper.getWss11(p), reqSigConfChBox.isSelected());
143             }
144             if (source.equals(derivedKeysChBox)) {
145                 SecurityPolicyModelHelper.enableRequireDerivedKeys(protToken, derivedKeysChBox.isSelected());
146             }
147         } else {
148             secBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(comp);
149             if (source.equals(reqSigConfChBox)) {
150                 SecurityPolicyModelHelper.enableRequireSignatureConfirmation(SecurityPolicyModelHelper.getWss11(comp), reqSigConfChBox.isSelected());
151             }
152         }
153         
154         if (source.equals(encryptSignatureChBox)) {
155             SecurityPolicyModelHelper.enableEncryptSignature(secBinding, encryptSignatureChBox.isSelected());
156             if (secConv) {
157                 SecurityPolicyModelHelper.enableEncryptSignature(topSecBinding, encryptSignatureChBox.isSelected());
158             }
159         }
160         if (source.equals(encryptOrderChBox)) {
161             SecurityPolicyModelHelper.enableEncryptBeforeSigning(secBinding, encryptOrderChBox.isSelected());
162             if (secConv) {
163                 SecurityPolicyModelHelper.enableEncryptBeforeSigning(topSecBinding, encryptOrderChBox.isSelected());
164             }
165         }
166         if (source.equals(layoutCombo)) {
167             SecurityPolicyModelHelper.setLayout(secBinding, (String JavaDoc) layoutCombo.getSelectedItem());
168             if (secConv) {
169                 SecurityPolicyModelHelper.setLayout(topSecBinding, (String JavaDoc) layoutCombo.getSelectedItem());
170             }
171         }
172         if (source.equals(algoSuiteCombo)) {
173             AlgoSuiteModelHelper.setAlgorithmSuite(secBinding, (String JavaDoc) algoSuiteCombo.getSelectedItem());
174             if (secConv) {
175                 AlgoSuiteModelHelper.setAlgorithmSuite(topSecBinding, (String JavaDoc) algoSuiteCombo.getSelectedItem());
176             }
177         }
178         
179         enableDisable();
180     }
181
182     private void enableDisable() {
183         boolean secConvEnabled = secConvChBox.isSelected();
184         derivedKeysChBox.setEnabled(secConvEnabled);
185         boolean rmEnabled = RMModelHelper.isRMEnabled(comp);
186         if (rmEnabled) {
187             secConvChBox.setEnabled(!secConvEnabled);
188         } else {
189             secConvChBox.setEnabled(true);
190         }
191     }
192     
193     private void setCombo(JComboBox JavaDoc combo, String JavaDoc item) {
194         if (item == null) {
195             combo.setSelectedIndex(0);
196         } else {
197             combo.setSelectedItem(item);
198         }
199     }
200
201     private void setCombo(JComboBox JavaDoc combo, boolean second) {
202         combo.setSelectedIndex(second ? 1 : 0);
203     }
204         
205     private void setChBox(JCheckBox JavaDoc chBox, Boolean JavaDoc enable) {
206         if (enable == null) {
207             chBox.setSelected(false);
208         } else {
209             chBox.setSelected(enable);
210         }
211     }
212     
213     /** This method is called from within the constructor to
214      * initialize the form.
215      * WARNING: Do NOT modify this code. The content of this method is
216      * always regenerated by the Form Editor.
217      */

218     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
219
private void initComponents() {
220
221         secConvChBox = new javax.swing.JCheckBox JavaDoc();
222         reqSigConfChBox = new javax.swing.JCheckBox JavaDoc();
223         derivedKeysChBox = new javax.swing.JCheckBox JavaDoc();
224         algoSuiteLabel = new javax.swing.JLabel JavaDoc();
225         algoSuiteCombo = new javax.swing.JComboBox JavaDoc();
226         layoutLabel = new javax.swing.JLabel JavaDoc();
227         layoutCombo = new javax.swing.JComboBox JavaDoc();
228         encryptSignatureChBox = new javax.swing.JCheckBox JavaDoc();
229         encryptOrderChBox = new javax.swing.JCheckBox JavaDoc();
230
231         org.openide.awt.Mnemonics.setLocalizedText(secConvChBox, org.openide.util.NbBundle.getMessage(EndorsingCertificate.class, "LBL_SecConvLabel")); // NOI18N
232
secConvChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
233         secConvChBox.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
234         secConvChBox.addActionListener(new java.awt.event.ActionListener JavaDoc() {
235             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
236                 secConvChBoxActionPerformed(evt);
237             }
238         });
239
240         org.openide.awt.Mnemonics.setLocalizedText(reqSigConfChBox, org.openide.util.NbBundle.getMessage(EndorsingCertificate.class, "LBL_RequireSigConfirmation")); // NOI18N
241
reqSigConfChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
242         reqSigConfChBox.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
243         reqSigConfChBox.addActionListener(new java.awt.event.ActionListener JavaDoc() {
244             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
245                 reqSigConfChBoxActionPerformed(evt);
246             }
247         });
248
249         org.openide.awt.Mnemonics.setLocalizedText(derivedKeysChBox, org.openide.util.NbBundle.getMessage(EndorsingCertificate.class, "LBL_RequireDerivedKeysForSecConv")); // NOI18N
250
derivedKeysChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
251         derivedKeysChBox.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
252         derivedKeysChBox.addActionListener(new java.awt.event.ActionListener JavaDoc() {
253             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
254                 derivedKeysChBoxActionPerformed(evt);
255             }
256         });
257
258         algoSuiteLabel.setLabelFor(algoSuiteCombo);
259         org.openide.awt.Mnemonics.setLocalizedText(algoSuiteLabel, org.openide.util.NbBundle.getMessage(EndorsingCertificate.class, "LBL_AlgoSuiteLabel")); // NOI18N
260

261         algoSuiteCombo.addActionListener(new java.awt.event.ActionListener JavaDoc() {
262             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
263                 algoSuiteComboActionPerformed(evt);
264             }
265         });
266
267         layoutLabel.setLabelFor(layoutCombo);
268         org.openide.awt.Mnemonics.setLocalizedText(layoutLabel, org.openide.util.NbBundle.getMessage(EndorsingCertificate.class, "LBL_LayoutLabel")); // NOI18N
269

270         layoutCombo.addActionListener(new java.awt.event.ActionListener JavaDoc() {
271             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
272                 layoutComboActionPerformed(evt);
273             }
274         });
275
276         org.openide.awt.Mnemonics.setLocalizedText(encryptSignatureChBox, org.openide.util.NbBundle.getMessage(EndorsingCertificate.class, "LBL_EncryptSignatureLabel")); // NOI18N
277
encryptSignatureChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
278         encryptSignatureChBox.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
279         encryptSignatureChBox.addActionListener(new java.awt.event.ActionListener JavaDoc() {
280             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
281                 encryptSignatureChBox(evt);
282             }
283         });
284
285         org.openide.awt.Mnemonics.setLocalizedText(encryptOrderChBox, org.openide.util.NbBundle.getMessage(EndorsingCertificate.class, "LBL_EncryptOrderLabel")); // NOI18N
286
encryptOrderChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
287         encryptOrderChBox.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
288         encryptOrderChBox.addActionListener(new java.awt.event.ActionListener JavaDoc() {
289             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
290                 encryptOrderChBoxActionPerformed(evt);
291             }
292         });
293
294         org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
295         this.setLayout(layout);
296         layout.setHorizontalGroup(
297             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
298             .add(layout.createSequentialGroup()
299                 .addContainerGap()
300                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
301                     .add(reqSigConfChBox)
302                     .add(secConvChBox)
303                     .add(derivedKeysChBox)
304                     .add(encryptSignatureChBox)
305                     .add(encryptOrderChBox)
306                     .add(layout.createSequentialGroup()
307                         .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
308                             .add(layoutLabel)
309                             .add(algoSuiteLabel))
310                         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
311                         .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
312                             .add(layoutCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 145, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
313                             .add(algoSuiteCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 145, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
314                 .addContainerGap())
315         );
316
317         layout.linkSize(new java.awt.Component JavaDoc[] {algoSuiteCombo, layoutCombo}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
318
319         layout.setVerticalGroup(
320             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
321             .add(layout.createSequentialGroup()
322                 .addContainerGap()
323                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
324                     .add(algoSuiteLabel)
325                     .add(algoSuiteCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
326                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
327                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
328                     .add(layoutLabel)
329                     .add(layoutCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
330                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
331                 .add(secConvChBox)
332                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
333                 .add(derivedKeysChBox)
334                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
335                 .add(reqSigConfChBox)
336                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
337                 .add(encryptSignatureChBox)
338                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
339                 .add(encryptOrderChBox)
340                 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
341         );
342
343         layout.linkSize(new java.awt.Component JavaDoc[] {algoSuiteCombo, layoutCombo}, org.jdesktop.layout.GroupLayout.VERTICAL);
344
345     }// </editor-fold>//GEN-END:initComponents
346

347     private void encryptOrderChBoxActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_encryptOrderChBoxActionPerformed
348
setValue(encryptOrderChBox);
349     }//GEN-LAST:event_encryptOrderChBoxActionPerformed
350

351     private void reqSigConfChBoxActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_reqSigConfChBoxActionPerformed
352
setValue(reqSigConfChBox);
353     }//GEN-LAST:event_reqSigConfChBoxActionPerformed
354

355     private void derivedKeysChBoxActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_derivedKeysChBoxActionPerformed
356
setValue(derivedKeysChBox);
357     }//GEN-LAST:event_derivedKeysChBoxActionPerformed
358

359     private void secConvChBoxActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_secConvChBoxActionPerformed
360
setValue(secConvChBox);
361     }//GEN-LAST:event_secConvChBoxActionPerformed
362

363     private void encryptSignatureChBox(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_encryptSignatureChBox
364
setValue(encryptSignatureChBox);
365     }//GEN-LAST:event_encryptSignatureChBox
366

367     private void layoutComboActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_layoutComboActionPerformed
368
setValue(layoutCombo);
369     }//GEN-LAST:event_layoutComboActionPerformed
370

371     private void algoSuiteComboActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_algoSuiteComboActionPerformed
372
setValue(algoSuiteCombo);
373     }//GEN-LAST:event_algoSuiteComboActionPerformed
374

375     // Variables declaration - do not modify//GEN-BEGIN:variables
376
private javax.swing.JComboBox JavaDoc algoSuiteCombo;
377     private javax.swing.JLabel JavaDoc algoSuiteLabel;
378     private javax.swing.JCheckBox JavaDoc derivedKeysChBox;
379     private javax.swing.JCheckBox JavaDoc encryptOrderChBox;
380     private javax.swing.JCheckBox JavaDoc encryptSignatureChBox;
381     private javax.swing.JComboBox JavaDoc layoutCombo;
382     private javax.swing.JLabel JavaDoc layoutLabel;
383     private javax.swing.JCheckBox JavaDoc reqSigConfChBox;
384     private javax.swing.JCheckBox JavaDoc secConvChBox;
385     // End of variables declaration//GEN-END:variables
386

387 }
388
Popular Tags