1 19 20 package org.netbeans.modules.websvc.wsitconf.ui.service.profiles; 21 22 import javax.swing.JCheckBox ; 23 import javax.swing.JComboBox ; 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.SecurityPolicyModelHelper; 27 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.SecurityTokensModelHelper; 28 import org.netbeans.modules.websvc.wsitmodelext.security.tokens.HttpsToken; 29 import org.netbeans.modules.websvc.wsitmodelext.security.tokens.TransportToken; 30 import org.netbeans.modules.xml.wsdl.model.WSDLComponent; 31 import org.netbeans.modules.xml.wsdl.model.WSDLModel; 32 33 37 public class TransportSecurity extends javax.swing.JPanel { 38 39 private boolean inSync = false; 40 41 private WSDLComponent comp; 42 private WSDLModel model; 43 44 47 public TransportSecurity(WSDLComponent comp) { 48 super(); 49 initComponents(); 50 this.model = comp.getModel(); 51 this.comp = comp; 52 53 inSync = true; 54 layoutCombo.removeAllItems(); 55 layoutCombo.addItem(ComboConstants.STRICT); 56 layoutCombo.addItem(ComboConstants.LAX); 57 layoutCombo.addItem(ComboConstants.LAXTSFIRST); 58 layoutCombo.addItem(ComboConstants.LAXTSLAST); 59 60 algoSuiteCombo.removeAllItems(); 61 algoSuiteCombo.addItem(ComboConstants.BASIC256); 62 algoSuiteCombo.addItem(ComboConstants.BASIC192); 63 algoSuiteCombo.addItem(ComboConstants.BASIC128); 64 algoSuiteCombo.addItem(ComboConstants.TRIPLEDES); 65 algoSuiteCombo.addItem(ComboConstants.BASIC256RSA15); 66 algoSuiteCombo.addItem(ComboConstants.BASIC192RSA15); 67 algoSuiteCombo.addItem(ComboConstants.BASIC128RSA15); 68 algoSuiteCombo.addItem(ComboConstants.TRIPLEDESRSA15); 69 78 inSync = false; 79 sync(); 80 } 81 82 private void sync() { 83 inSync = true; 84 85 WSDLComponent secBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(comp); 86 WSDLComponent tokenKind = SecurityTokensModelHelper.getTokenElement(secBinding, TransportToken.class); 87 HttpsToken token = (HttpsToken) SecurityTokensModelHelper.getTokenTypeElement(tokenKind); 88 if (token instanceof HttpsToken) { 89 setChBox(requireCertificateChBox, SecurityTokensModelHelper.isRequireClientCertificate((HttpsToken) token)); 90 } 91 92 setCombo(algoSuiteCombo, AlgoSuiteModelHelper.getAlgorithmSuite(secBinding)); 93 94 setCombo(layoutCombo, SecurityPolicyModelHelper.getMessageLayout(comp)); 95 96 inSync = false; 97 } 98 99 public void setValue(javax.swing.JComponent source) { 100 101 if (inSync) return; 102 103 WSDLComponent secBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(comp); 104 105 if (source.equals(requireCertificateChBox)) { 106 WSDLComponent tokenKind = SecurityTokensModelHelper.getTokenElement(secBinding, TransportToken.class); 107 HttpsToken token = (HttpsToken) SecurityTokensModelHelper.getTokenTypeElement(tokenKind); 108 SecurityTokensModelHelper.setRequireClientCertificate(token, requireCertificateChBox.isSelected()); 109 } 110 if (source.equals(layoutCombo)) { 111 SecurityPolicyModelHelper.setLayout(secBinding, (String ) layoutCombo.getSelectedItem()); 112 } 113 if (source.equals(algoSuiteCombo)) { 114 AlgoSuiteModelHelper.setAlgorithmSuite(secBinding, (String ) algoSuiteCombo.getSelectedItem()); 115 } 116 } 117 118 private void setCombo(JComboBox combo, String item) { 119 if (item == null) { 120 combo.setSelectedIndex(0); 121 } else { 122 combo.setSelectedItem(item); 123 } 124 } 125 126 private void setChBox(JCheckBox chBox, Boolean enable) { 127 if (enable == null) { 128 chBox.setSelected(false); 129 } else { 130 chBox.setSelected(enable); 131 } 132 } 133 134 139 private void initComponents() { 141 142 requireCertificateChBox = new javax.swing.JCheckBox (); 143 algoSuiteLabel = new javax.swing.JLabel (); 144 algoSuiteCombo = new javax.swing.JComboBox (); 145 layoutLabel = new javax.swing.JLabel (); 146 layoutCombo = new javax.swing.JComboBox (); 147 148 org.openide.awt.Mnemonics.setLocalizedText(requireCertificateChBox, org.openide.util.NbBundle.getMessage(TransportSecurity.class, "LBL_RequireClientCertificate")); requireCertificateChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 150 requireCertificateChBox.setMargin(new java.awt.Insets (0, 0, 0, 0)); 151 requireCertificateChBox.addActionListener(new java.awt.event.ActionListener () { 152 public void actionPerformed(java.awt.event.ActionEvent evt) { 153 requireCertificateChBoxActionPerformed(evt); 154 } 155 }); 156 157 algoSuiteLabel.setLabelFor(algoSuiteCombo); 158 org.openide.awt.Mnemonics.setLocalizedText(algoSuiteLabel, org.openide.util.NbBundle.getMessage(TransportSecurity.class, "LBL_AlgoSuiteLabel")); 160 algoSuiteCombo.addActionListener(new java.awt.event.ActionListener () { 161 public void actionPerformed(java.awt.event.ActionEvent evt) { 162 algoSuiteComboActionPerformed(evt); 163 } 164 }); 165 166 layoutLabel.setLabelFor(layoutCombo); 167 org.openide.awt.Mnemonics.setLocalizedText(layoutLabel, org.openide.util.NbBundle.getMessage(TransportSecurity.class, "LBL_LayoutLabel")); 169 layoutCombo.addActionListener(new java.awt.event.ActionListener () { 170 public void actionPerformed(java.awt.event.ActionEvent evt) { 171 layoutComboActionPerformed(evt); 172 } 173 }); 174 175 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); 176 this.setLayout(layout); 177 layout.setHorizontalGroup( 178 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 179 .add(layout.createSequentialGroup() 180 .addContainerGap() 181 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 182 .add(layout.createSequentialGroup() 183 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 184 .add(layoutLabel) 185 .add(algoSuiteLabel)) 186 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 187 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 188 .add(algoSuiteCombo, 0, 133, Short.MAX_VALUE) 189 .add(layoutCombo, 0, 133, Short.MAX_VALUE))) 190 .add(requireCertificateChBox)) 191 .addContainerGap()) 192 ); 193 194 layout.linkSize(new java.awt.Component [] {algoSuiteCombo, layoutCombo}, org.jdesktop.layout.GroupLayout.HORIZONTAL); 195 196 layout.setVerticalGroup( 197 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 198 .add(layout.createSequentialGroup() 199 .addContainerGap() 200 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 201 .add(algoSuiteLabel) 202 .add(algoSuiteCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 203 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 204 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 205 .add(layoutLabel) 206 .add(layoutCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 207 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 208 .add(requireCertificateChBox) 209 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 210 ); 211 212 layout.linkSize(new java.awt.Component [] {algoSuiteCombo, layoutCombo}, org.jdesktop.layout.GroupLayout.VERTICAL); 213 214 } 216 private void layoutComboActionPerformed(java.awt.event.ActionEvent evt) { setValue(layoutCombo); 218 } 220 private void algoSuiteComboActionPerformed(java.awt.event.ActionEvent evt) { setValue(algoSuiteCombo); 222 } 224 private void requireCertificateChBoxActionPerformed(java.awt.event.ActionEvent evt) { setValue(requireCertificateChBox); 226 } 228 private javax.swing.JComboBox algoSuiteCombo; 230 private javax.swing.JLabel algoSuiteLabel; 231 private javax.swing.JComboBox layoutCombo; 232 private javax.swing.JLabel layoutLabel; 233 private javax.swing.JCheckBox requireCertificateChBox; 234 236 } 237 | Popular Tags |