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.WssElement;
051: import org.netbeans.modules.websvc.wsitmodelext.security.tokens.HttpsToken;
052: import org.netbeans.modules.websvc.wsitmodelext.security.tokens.TransportToken;
053: import org.netbeans.modules.xml.wsdl.model.Binding;
054: import org.netbeans.modules.xml.wsdl.model.WSDLComponent;
055:
056: /**
057: *
058: * @author Martin Grebac
059: */
060: public class SAMLAuthorizationOverSSL extends javax.swing.JPanel
061: implements ComboConstants {
062:
063: private boolean inSync = false;
064:
065: private WSDLComponent comp;
066:
067: /**
068: * Creates new form MessageAuthentication
069: */
070: public SAMLAuthorizationOverSSL(WSDLComponent comp) {
071: super ();
072: initComponents();
073: this .comp = comp;
074:
075: inSync = true;
076: samlVersionCombo.removeAllItems();
077: samlVersionCombo.addItem(ComboConstants.SAML_V1010);
078: samlVersionCombo.addItem(ComboConstants.SAML_V1011);
079: samlVersionCombo.addItem(ComboConstants.SAML_V1110);
080: samlVersionCombo.addItem(ComboConstants.SAML_V1111);
081: samlVersionCombo.addItem(ComboConstants.SAML_V2011);
082:
083: wssVersionCombo.removeAllItems();
084: wssVersionCombo.addItem(ComboConstants.WSS10);
085: wssVersionCombo.addItem(ComboConstants.WSS11);
086:
087: layoutCombo.removeAllItems();
088: layoutCombo.addItem(ComboConstants.STRICT);
089: layoutCombo.addItem(ComboConstants.LAX);
090: layoutCombo.addItem(ComboConstants.LAXTSFIRST);
091: layoutCombo.addItem(ComboConstants.LAXTSLAST);
092:
093: algoSuiteCombo.removeAllItems();
094: algoSuiteCombo.addItem(ComboConstants.BASIC256);
095: algoSuiteCombo.addItem(ComboConstants.BASIC192);
096: algoSuiteCombo.addItem(ComboConstants.BASIC128);
097: algoSuiteCombo.addItem(ComboConstants.TRIPLEDES);
098: algoSuiteCombo.addItem(ComboConstants.BASIC256RSA15);
099: algoSuiteCombo.addItem(ComboConstants.BASIC192RSA15);
100: algoSuiteCombo.addItem(ComboConstants.BASIC128RSA15);
101: algoSuiteCombo.addItem(ComboConstants.TRIPLEDESRSA15);
102: algoSuiteCombo.addItem(ComboConstants.BASIC256SHA256);
103: algoSuiteCombo.addItem(ComboConstants.BASIC192SHA256);
104: algoSuiteCombo.addItem(ComboConstants.BASIC128SHA256);
105: algoSuiteCombo.addItem(ComboConstants.TRIPLEDESSHA256);
106: algoSuiteCombo.addItem(ComboConstants.BASIC256SHA256RSA15);
107: algoSuiteCombo.addItem(ComboConstants.BASIC192SHA256RSA15);
108: algoSuiteCombo.addItem(ComboConstants.BASIC128SHA256RSA15);
109: algoSuiteCombo.addItem(ComboConstants.TRIPLEDESSHA256RSA15);
110:
111: inSync = false;
112:
113: sync();
114: }
115:
116: private void sync() {
117: inSync = true;
118:
119: WSDLComponent secBinding = SecurityPolicyModelHelper
120: .getSecurityBindingTypeElement(comp);
121:
122: if (comp instanceof Binding) {
123: WSDLComponent tokenKind = SecurityTokensModelHelper
124: .getSupportingToken(comp,
125: SecurityTokensModelHelper.SIGNED_SUPPORTING);
126: WSDLComponent token = SecurityTokensModelHelper
127: .getTokenTypeElement(tokenKind);
128: String samlVersion = SecurityTokensModelHelper
129: .getTokenProfileVersion(token);
130: setCombo(samlVersionCombo, samlVersion);
131: }
132:
133: setCombo(wssVersionCombo, SecurityPolicyModelHelper
134: .isWss11(comp));
135: setCombo(algoSuiteCombo, AlgoSuiteModelHelper
136: .getAlgorithmSuite(secBinding));
137: setCombo(layoutCombo, SecurityPolicyModelHelper
138: .getMessageLayout(comp));
139: setChBox(reqSigConfChBox, SecurityPolicyModelHelper
140: .isRequireSignatureConfirmation(comp));
141:
142: enableDisable();
143:
144: inSync = false;
145: }
146:
147: private void enableDisable() {
148: boolean wss11 = ComboConstants.WSS11.equals(wssVersionCombo
149: .getSelectedItem());
150: reqSigConfChBox.setEnabled(wss11);
151: }
152:
153: public void setValue(javax.swing.JComponent source) {
154:
155: if (inSync)
156: return;
157:
158: WSDLComponent secBinding = SecurityPolicyModelHelper
159: .getSecurityBindingTypeElement(comp);
160:
161: if (source.equals(reqClientCertChBox)) {
162: WSDLComponent tokenKind = SecurityTokensModelHelper
163: .getTokenElement(secBinding, TransportToken.class);
164: HttpsToken token = (HttpsToken) SecurityTokensModelHelper
165: .getTokenTypeElement(tokenKind);
166: SecurityTokensModelHelper.setRequireClientCertificate(
167: token, reqClientCertChBox.isSelected());
168: }
169: if (source.equals(reqSigConfChBox)) {
170: SecurityPolicyModelHelper
171: .enableRequireSignatureConfirmation(
172: SecurityPolicyModelHelper.getWss11(comp),
173: reqSigConfChBox.isSelected());
174: }
175: if (source.equals(layoutCombo)) {
176: SecurityPolicyModelHelper.setLayout(secBinding,
177: (String) layoutCombo.getSelectedItem());
178: }
179: if (source.equals(algoSuiteCombo)) {
180: AlgoSuiteModelHelper.setAlgorithmSuite(secBinding,
181: (String) algoSuiteCombo.getSelectedItem());
182: }
183: if (source.equals(wssVersionCombo)) {
184: boolean wss11 = ComboConstants.WSS11.equals(wssVersionCombo
185: .getSelectedItem());
186: WssElement wss = SecurityPolicyModelHelper.enableWss(comp,
187: wss11);
188: if (wss11) {
189: SecurityPolicyModelHelper
190: .enableRequireSignatureConfirmation(
191: SecurityPolicyModelHelper
192: .getWss11(comp),
193: reqSigConfChBox.isSelected());
194: }
195: SecurityPolicyModelHelper
196: .enableMustSupportRefKeyIdentifier(wss, true);
197: }
198: if (source.equals(samlVersionCombo)) {
199: if (comp instanceof Binding) {
200: WSDLComponent tokenKind = SecurityTokensModelHelper
201: .getSupportingToken(
202: comp,
203: SecurityTokensModelHelper.SIGNED_SUPPORTING);
204: WSDLComponent token = SecurityTokensModelHelper
205: .getTokenTypeElement(tokenKind);
206: SecurityTokensModelHelper.setTokenProfileVersion(token,
207: (String) samlVersionCombo.getSelectedItem());
208: }
209: }
210: enableDisable();
211: }
212:
213: private void setCombo(JComboBox combo, String item) {
214: if (item == null) {
215: combo.setSelectedIndex(0);
216: } else {
217: combo.setSelectedItem(item);
218: }
219: }
220:
221: private void setCombo(JComboBox combo, boolean second) {
222: combo.setSelectedIndex(second ? 1 : 0);
223: }
224:
225: private void setChBox(JCheckBox chBox, Boolean enable) {
226: if (enable == null) {
227: chBox.setSelected(false);
228: } else {
229: chBox.setSelected(enable);
230: }
231: }
232:
233: /** This method is called from within the constructor to
234: * initialize the form.
235: * WARNING: Do NOT modify this code. The content of this method is
236: * always regenerated by the Form Editor.
237: */
238: // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
239: private void initComponents() {
240:
241: samlVersionLabel = new javax.swing.JLabel();
242: samlVersionCombo = new javax.swing.JComboBox();
243: reqSigConfChBox = new javax.swing.JCheckBox();
244: reqClientCertChBox = new javax.swing.JCheckBox();
245: wssVersionLabel = new javax.swing.JLabel();
246: wssVersionCombo = new javax.swing.JComboBox();
247: algoSuiteLabel = new javax.swing.JLabel();
248: algoSuiteCombo = new javax.swing.JComboBox();
249: layoutLabel = new javax.swing.JLabel();
250: layoutCombo = new javax.swing.JComboBox();
251:
252: samlVersionLabel.setLabelFor(samlVersionCombo);
253: org.openide.awt.Mnemonics.setLocalizedText(samlVersionLabel,
254: org.openide.util.NbBundle.getMessage(
255: SAMLAuthorizationOverSSL.class,
256: "LBL_SamlVersion")); // NOI18N
257:
258: samlVersionCombo
259: .addActionListener(new java.awt.event.ActionListener() {
260: public void actionPerformed(
261: java.awt.event.ActionEvent evt) {
262: samlVersionComboActionPerformed(evt);
263: }
264: });
265:
266: org.openide.awt.Mnemonics.setLocalizedText(reqSigConfChBox,
267: org.openide.util.NbBundle.getMessage(
268: SAMLAuthorizationOverSSL.class,
269: "LBL_RequireSigConfirmation")); // NOI18N
270: reqSigConfChBox.setBorder(javax.swing.BorderFactory
271: .createEmptyBorder(0, 0, 0, 0));
272: reqSigConfChBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
273: reqSigConfChBox
274: .addActionListener(new java.awt.event.ActionListener() {
275: public void actionPerformed(
276: java.awt.event.ActionEvent evt) {
277: reqSigConfChBoxActionPerformed(evt);
278: }
279: });
280:
281: org.openide.awt.Mnemonics.setLocalizedText(reqClientCertChBox,
282: org.openide.util.NbBundle.getMessage(
283: SAMLAuthorizationOverSSL.class,
284: "LBL_RequireClientCertificate")); // NOI18N
285: reqClientCertChBox.setBorder(javax.swing.BorderFactory
286: .createEmptyBorder(0, 0, 0, 0));
287: reqClientCertChBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
288: reqClientCertChBox
289: .addActionListener(new java.awt.event.ActionListener() {
290: public void actionPerformed(
291: java.awt.event.ActionEvent evt) {
292: reqClientCertChBoxActionPerformed(evt);
293: }
294: });
295:
296: wssVersionLabel.setLabelFor(wssVersionCombo);
297: org.openide.awt.Mnemonics.setLocalizedText(wssVersionLabel,
298: org.openide.util.NbBundle.getMessage(
299: SAMLAuthorizationOverSSL.class,
300: "LBL_WSSVersionLabel")); // NOI18N
301:
302: wssVersionCombo
303: .addActionListener(new java.awt.event.ActionListener() {
304: public void actionPerformed(
305: java.awt.event.ActionEvent evt) {
306: wssVersionComboActionPerformed(evt);
307: }
308: });
309:
310: algoSuiteLabel.setLabelFor(algoSuiteCombo);
311: org.openide.awt.Mnemonics.setLocalizedText(algoSuiteLabel,
312: org.openide.util.NbBundle.getMessage(
313: SAMLAuthorizationOverSSL.class,
314: "LBL_AlgoSuiteLabel")); // NOI18N
315:
316: algoSuiteCombo
317: .addActionListener(new java.awt.event.ActionListener() {
318: public void actionPerformed(
319: java.awt.event.ActionEvent evt) {
320: algoSuiteComboActionPerformed(evt);
321: }
322: });
323:
324: layoutLabel.setLabelFor(layoutCombo);
325: org.openide.awt.Mnemonics.setLocalizedText(layoutLabel,
326: org.openide.util.NbBundle.getMessage(
327: SAMLAuthorizationOverSSL.class,
328: "LBL_LayoutLabel")); // NOI18N
329:
330: layoutCombo
331: .addActionListener(new java.awt.event.ActionListener() {
332: public void actionPerformed(
333: java.awt.event.ActionEvent evt) {
334: layoutComboActionPerformed(evt);
335: }
336: });
337:
338: org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
339: this );
340: this .setLayout(layout);
341: layout
342: .setHorizontalGroup(layout
343: .createParallelGroup(
344: org.jdesktop.layout.GroupLayout.LEADING)
345: .add(
346: layout
347: .createSequentialGroup()
348: .addContainerGap()
349: .add(
350: layout
351: .createParallelGroup(
352: org.jdesktop.layout.GroupLayout.LEADING)
353: .add(
354: reqClientCertChBox)
355: .add(
356: reqSigConfChBox)
357: .add(
358: layout
359: .createSequentialGroup()
360: .add(
361: layout
362: .createParallelGroup(
363: org.jdesktop.layout.GroupLayout.LEADING)
364: .add(
365: samlVersionLabel)
366: .add(
367: wssVersionLabel)
368: .add(
369: algoSuiteLabel)
370: .add(
371: layoutLabel))
372: .add(
373: 12,
374: 12,
375: 12)
376: .add(
377: layout
378: .createParallelGroup(
379: org.jdesktop.layout.GroupLayout.TRAILING)
380: .add(
381: org.jdesktop.layout.GroupLayout.LEADING,
382: samlVersionCombo,
383: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
384: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
385: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
386: .add(
387: org.jdesktop.layout.GroupLayout.LEADING,
388: wssVersionCombo,
389: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
390: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
391: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
392: .add(
393: org.jdesktop.layout.GroupLayout.LEADING,
394: algoSuiteCombo,
395: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
396: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
397: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
398: .add(
399: org.jdesktop.layout.GroupLayout.LEADING,
400: layoutCombo,
401: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
402: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
403: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
404: .addContainerGap(
405: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
406: Short.MAX_VALUE)));
407:
408: layout.linkSize(new java.awt.Component[] { algoSuiteCombo,
409: layoutCombo, samlVersionCombo, wssVersionCombo },
410: org.jdesktop.layout.GroupLayout.HORIZONTAL);
411:
412: layout
413: .setVerticalGroup(layout
414: .createParallelGroup(
415: org.jdesktop.layout.GroupLayout.LEADING)
416: .add(
417: layout
418: .createSequentialGroup()
419: .addContainerGap()
420: .add(
421: layout
422: .createParallelGroup(
423: org.jdesktop.layout.GroupLayout.BASELINE)
424: .add(
425: samlVersionLabel)
426: .add(
427: samlVersionCombo,
428: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
429: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
430: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
431: .addPreferredGap(
432: org.jdesktop.layout.LayoutStyle.RELATED)
433: .add(
434: layout
435: .createParallelGroup(
436: org.jdesktop.layout.GroupLayout.BASELINE)
437: .add(
438: wssVersionLabel)
439: .add(
440: wssVersionCombo,
441: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
442: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
443: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
444: .addPreferredGap(
445: org.jdesktop.layout.LayoutStyle.RELATED)
446: .add(
447: layout
448: .createParallelGroup(
449: org.jdesktop.layout.GroupLayout.BASELINE)
450: .add(
451: algoSuiteLabel)
452: .add(
453: algoSuiteCombo,
454: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
455: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
456: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
457: .addPreferredGap(
458: org.jdesktop.layout.LayoutStyle.RELATED)
459: .add(
460: layout
461: .createParallelGroup(
462: org.jdesktop.layout.GroupLayout.BASELINE)
463: .add(
464: layoutLabel)
465: .add(
466: layoutCombo,
467: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
468: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
469: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
470: .addPreferredGap(
471: org.jdesktop.layout.LayoutStyle.RELATED)
472: .add(reqClientCertChBox)
473: .addPreferredGap(
474: org.jdesktop.layout.LayoutStyle.RELATED)
475: .add(reqSigConfChBox)
476: .addContainerGap(
477: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
478: Short.MAX_VALUE)));
479:
480: layout.linkSize(new java.awt.Component[] { algoSuiteCombo,
481: layoutCombo, samlVersionCombo, wssVersionCombo },
482: org.jdesktop.layout.GroupLayout.VERTICAL);
483:
484: }// </editor-fold>//GEN-END:initComponents
485:
486: private void reqSigConfChBoxActionPerformed(
487: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_reqSigConfChBoxActionPerformed
488: setValue(reqSigConfChBox);
489: }//GEN-LAST:event_reqSigConfChBoxActionPerformed
490:
491: private void reqClientCertChBoxActionPerformed(
492: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_reqClientCertChBoxActionPerformed
493: setValue(reqClientCertChBox);
494: }//GEN-LAST:event_reqClientCertChBoxActionPerformed
495:
496: private void wssVersionComboActionPerformed(
497: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_wssVersionComboActionPerformed
498: setValue(wssVersionCombo);
499: }//GEN-LAST:event_wssVersionComboActionPerformed
500:
501: private void samlVersionComboActionPerformed(
502: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_samlVersionComboActionPerformed
503: setValue(samlVersionCombo);
504: }//GEN-LAST:event_samlVersionComboActionPerformed
505:
506: private void layoutComboActionPerformed(
507: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_layoutComboActionPerformed
508: setValue(layoutCombo);
509: }//GEN-LAST:event_layoutComboActionPerformed
510:
511: private void algoSuiteComboActionPerformed(
512: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_algoSuiteComboActionPerformed
513: setValue(algoSuiteCombo);
514: }//GEN-LAST:event_algoSuiteComboActionPerformed
515:
516: // Variables declaration - do not modify//GEN-BEGIN:variables
517: private javax.swing.JComboBox algoSuiteCombo;
518: private javax.swing.JLabel algoSuiteLabel;
519: private javax.swing.JComboBox layoutCombo;
520: private javax.swing.JLabel layoutLabel;
521: private javax.swing.JCheckBox reqClientCertChBox;
522: private javax.swing.JCheckBox reqSigConfChBox;
523: private javax.swing.JComboBox samlVersionCombo;
524: private javax.swing.JLabel samlVersionLabel;
525: private javax.swing.JComboBox wssVersionCombo;
526: private javax.swing.JLabel wssVersionLabel;
527: // End of variables declaration//GEN-END:variables
528:
529: }
|