001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.websvc.wsitconf.ui.service.profiles;
043:
044: import javax.swing.JCheckBox;
045: import javax.swing.JComboBox;
046: import org.netbeans.modules.websvc.wsitconf.ui.ComboConstants;
047: import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.AlgoSuiteModelHelper;
048: import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.SecurityPolicyModelHelper;
049: import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.SecurityTokensModelHelper;
050: import org.netbeans.modules.websvc.wsitmodelext.security.tokens.HttpsToken;
051: import org.netbeans.modules.websvc.wsitmodelext.security.tokens.TransportToken;
052: import org.netbeans.modules.xml.wsdl.model.WSDLComponent;
053:
054: /**
055: *
056: * @author Martin Grebac
057: */
058: public class TransportSecurity extends javax.swing.JPanel {
059:
060: private boolean inSync = false;
061:
062: private WSDLComponent comp;
063:
064: /**
065: * Creates new form TransportSecurity
066: */
067: public TransportSecurity(WSDLComponent comp) {
068: super ();
069: initComponents();
070: this .comp = comp;
071:
072: inSync = true;
073: layoutCombo.removeAllItems();
074: layoutCombo.addItem(ComboConstants.STRICT);
075: layoutCombo.addItem(ComboConstants.LAX);
076: layoutCombo.addItem(ComboConstants.LAXTSFIRST);
077: layoutCombo.addItem(ComboConstants.LAXTSLAST);
078:
079: algoSuiteCombo.removeAllItems();
080: algoSuiteCombo.addItem(ComboConstants.BASIC256);
081: algoSuiteCombo.addItem(ComboConstants.BASIC192);
082: algoSuiteCombo.addItem(ComboConstants.BASIC128);
083: algoSuiteCombo.addItem(ComboConstants.TRIPLEDES);
084: algoSuiteCombo.addItem(ComboConstants.BASIC256RSA15);
085: algoSuiteCombo.addItem(ComboConstants.BASIC192RSA15);
086: algoSuiteCombo.addItem(ComboConstants.BASIC128RSA15);
087: algoSuiteCombo.addItem(ComboConstants.TRIPLEDESRSA15);
088: algoSuiteCombo.addItem(ComboConstants.BASIC256SHA256);
089: algoSuiteCombo.addItem(ComboConstants.BASIC192SHA256);
090: algoSuiteCombo.addItem(ComboConstants.BASIC128SHA256);
091: algoSuiteCombo.addItem(ComboConstants.TRIPLEDESSHA256);
092: algoSuiteCombo.addItem(ComboConstants.BASIC256SHA256RSA15);
093: algoSuiteCombo.addItem(ComboConstants.BASIC192SHA256RSA15);
094: algoSuiteCombo.addItem(ComboConstants.BASIC128SHA256RSA15);
095: algoSuiteCombo.addItem(ComboConstants.TRIPLEDESSHA256RSA15);
096:
097: inSync = false;
098: sync();
099: }
100:
101: private void sync() {
102: inSync = true;
103:
104: WSDLComponent secBinding = SecurityPolicyModelHelper
105: .getSecurityBindingTypeElement(comp);
106: WSDLComponent tokenKind = SecurityTokensModelHelper
107: .getTokenElement(secBinding, TransportToken.class);
108: HttpsToken token = (HttpsToken) SecurityTokensModelHelper
109: .getTokenTypeElement(tokenKind);
110: if (token instanceof HttpsToken) {
111: setChBox(requireCertificateChBox, SecurityTokensModelHelper
112: .isRequireClientCertificate(token));
113: }
114:
115: setCombo(algoSuiteCombo, AlgoSuiteModelHelper
116: .getAlgorithmSuite(secBinding));
117:
118: setCombo(layoutCombo, SecurityPolicyModelHelper
119: .getMessageLayout(comp));
120:
121: inSync = false;
122: }
123:
124: public void setValue(javax.swing.JComponent source) {
125:
126: if (inSync)
127: return;
128:
129: WSDLComponent secBinding = SecurityPolicyModelHelper
130: .getSecurityBindingTypeElement(comp);
131:
132: if (source.equals(requireCertificateChBox)) {
133: WSDLComponent tokenKind = SecurityTokensModelHelper
134: .getTokenElement(secBinding, TransportToken.class);
135: HttpsToken token = (HttpsToken) SecurityTokensModelHelper
136: .getTokenTypeElement(tokenKind);
137: SecurityTokensModelHelper.setRequireClientCertificate(
138: token, requireCertificateChBox.isSelected());
139: }
140: if (source.equals(layoutCombo)) {
141: SecurityPolicyModelHelper.setLayout(secBinding,
142: (String) layoutCombo.getSelectedItem());
143: }
144: if (source.equals(algoSuiteCombo)) {
145: AlgoSuiteModelHelper.setAlgorithmSuite(secBinding,
146: (String) algoSuiteCombo.getSelectedItem());
147: }
148: }
149:
150: private void setCombo(JComboBox combo, String item) {
151: if (item == null) {
152: combo.setSelectedIndex(0);
153: } else {
154: combo.setSelectedItem(item);
155: }
156: }
157:
158: private void setChBox(JCheckBox chBox, Boolean enable) {
159: if (enable == null) {
160: chBox.setSelected(false);
161: } else {
162: chBox.setSelected(enable);
163: }
164: }
165:
166: /** This method is called from within the constructor to
167: * initialize the form.
168: * WARNING: Do NOT modify this code. The content of this method is
169: * always regenerated by the Form Editor.
170: */
171: // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
172: private void initComponents() {
173:
174: requireCertificateChBox = new javax.swing.JCheckBox();
175: algoSuiteLabel = new javax.swing.JLabel();
176: algoSuiteCombo = new javax.swing.JComboBox();
177: layoutLabel = new javax.swing.JLabel();
178: layoutCombo = new javax.swing.JComboBox();
179:
180: org.openide.awt.Mnemonics.setLocalizedText(
181: requireCertificateChBox, org.openide.util.NbBundle
182: .getMessage(TransportSecurity.class,
183: "LBL_RequireClientCertificate")); // NOI18N
184: requireCertificateChBox.setBorder(javax.swing.BorderFactory
185: .createEmptyBorder(0, 0, 0, 0));
186: requireCertificateChBox.setMargin(new java.awt.Insets(0, 0, 0,
187: 0));
188: requireCertificateChBox
189: .addActionListener(new java.awt.event.ActionListener() {
190: public void actionPerformed(
191: java.awt.event.ActionEvent evt) {
192: requireCertificateChBoxActionPerformed(evt);
193: }
194: });
195:
196: algoSuiteLabel.setLabelFor(algoSuiteCombo);
197: org.openide.awt.Mnemonics.setLocalizedText(algoSuiteLabel,
198: org.openide.util.NbBundle.getMessage(
199: TransportSecurity.class, "LBL_AlgoSuiteLabel")); // NOI18N
200:
201: algoSuiteCombo
202: .addActionListener(new java.awt.event.ActionListener() {
203: public void actionPerformed(
204: java.awt.event.ActionEvent evt) {
205: algoSuiteComboActionPerformed(evt);
206: }
207: });
208:
209: layoutLabel.setLabelFor(layoutCombo);
210: org.openide.awt.Mnemonics.setLocalizedText(layoutLabel,
211: org.openide.util.NbBundle.getMessage(
212: TransportSecurity.class, "LBL_LayoutLabel")); // NOI18N
213:
214: layoutCombo
215: .addActionListener(new java.awt.event.ActionListener() {
216: public void actionPerformed(
217: java.awt.event.ActionEvent evt) {
218: layoutComboActionPerformed(evt);
219: }
220: });
221:
222: org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
223: this );
224: this .setLayout(layout);
225: layout
226: .setHorizontalGroup(layout
227: .createParallelGroup(
228: org.jdesktop.layout.GroupLayout.LEADING)
229: .add(
230: layout
231: .createSequentialGroup()
232: .addContainerGap()
233: .add(
234: layout
235: .createParallelGroup(
236: org.jdesktop.layout.GroupLayout.LEADING)
237: .add(
238: layout
239: .createSequentialGroup()
240: .add(
241: layout
242: .createParallelGroup(
243: org.jdesktop.layout.GroupLayout.LEADING)
244: .add(
245: layoutLabel)
246: .add(
247: algoSuiteLabel))
248: .addPreferredGap(
249: org.jdesktop.layout.LayoutStyle.RELATED)
250: .add(
251: layout
252: .createParallelGroup(
253: org.jdesktop.layout.GroupLayout.LEADING)
254: .add(
255: layoutCombo,
256: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
257: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
258: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
259: .add(
260: algoSuiteCombo,
261: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
262: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
263: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
264: .add(
265: requireCertificateChBox))
266: .addContainerGap(
267: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
268: Short.MAX_VALUE)));
269:
270: layout.linkSize(new java.awt.Component[] { algoSuiteCombo,
271: layoutCombo },
272: org.jdesktop.layout.GroupLayout.HORIZONTAL);
273:
274: layout
275: .setVerticalGroup(layout
276: .createParallelGroup(
277: org.jdesktop.layout.GroupLayout.LEADING)
278: .add(
279: layout
280: .createSequentialGroup()
281: .addContainerGap()
282: .add(
283: layout
284: .createParallelGroup(
285: org.jdesktop.layout.GroupLayout.BASELINE)
286: .add(
287: algoSuiteLabel)
288: .add(
289: algoSuiteCombo,
290: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
291: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
292: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
293: .addPreferredGap(
294: org.jdesktop.layout.LayoutStyle.RELATED)
295: .add(
296: layout
297: .createParallelGroup(
298: org.jdesktop.layout.GroupLayout.BASELINE)
299: .add(
300: layoutLabel)
301: .add(
302: layoutCombo,
303: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
304: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
305: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
306: .addPreferredGap(
307: org.jdesktop.layout.LayoutStyle.RELATED)
308: .add(requireCertificateChBox)
309: .addContainerGap(
310: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
311: Short.MAX_VALUE)));
312:
313: layout
314: .linkSize(new java.awt.Component[] { algoSuiteCombo,
315: layoutCombo },
316: org.jdesktop.layout.GroupLayout.VERTICAL);
317:
318: }// </editor-fold>//GEN-END:initComponents
319:
320: private void layoutComboActionPerformed(
321: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_layoutComboActionPerformed
322: setValue(layoutCombo);
323: }//GEN-LAST:event_layoutComboActionPerformed
324:
325: private void algoSuiteComboActionPerformed(
326: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_algoSuiteComboActionPerformed
327: setValue(algoSuiteCombo);
328: }//GEN-LAST:event_algoSuiteComboActionPerformed
329:
330: private void requireCertificateChBoxActionPerformed(
331: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_requireCertificateChBoxActionPerformed
332: setValue(requireCertificateChBox);
333: }//GEN-LAST:event_requireCertificateChBoxActionPerformed
334:
335: // Variables declaration - do not modify//GEN-BEGIN:variables
336: private javax.swing.JComboBox algoSuiteCombo;
337: private javax.swing.JLabel algoSuiteLabel;
338: private javax.swing.JComboBox layoutCombo;
339: private javax.swing.JLabel layoutLabel;
340: private javax.swing.JCheckBox requireCertificateChBox;
341: // End of variables declaration//GEN-END:variables
342:
343: }
|