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.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.security.BootstrapPolicy; 31 import org.netbeans.modules.websvc.wsitmodelext.security.tokens.InitiatorToken; 32 import org.netbeans.modules.websvc.wsitmodelext.security.tokens.ProtectionToken; 33 import org.netbeans.modules.websvc.wsitmodelext.security.tokens.RecipientToken; 34 import org.netbeans.modules.websvc.wsitmodelext.security.tokens.SecureConversationToken; 35 import org.netbeans.modules.xml.wsdl.model.WSDLComponent; 36 import org.netbeans.modules.xml.wsdl.model.WSDLModel; 37 38 42 public class MutualCertificates extends javax.swing.JPanel { 43 44 private boolean inSync = false; 45 46 private WSDLComponent comp; 47 private WSDLModel model; 48 49 52 public MutualCertificates(WSDLComponent comp) { 53 super(); 54 initComponents(); 55 this.model = comp.getModel(); 56 this.comp = comp; 57 58 inSync = true; 59 layoutCombo.removeAllItems(); 60 layoutCombo.addItem(ComboConstants.STRICT); 61 layoutCombo.addItem(ComboConstants.LAX); 62 layoutCombo.addItem(ComboConstants.LAXTSFIRST); 63 layoutCombo.addItem(ComboConstants.LAXTSLAST); 64 65 algoSuiteCombo.removeAllItems(); 66 algoSuiteCombo.addItem(ComboConstants.BASIC256); 67 algoSuiteCombo.addItem(ComboConstants.BASIC192); 68 algoSuiteCombo.addItem(ComboConstants.BASIC128); 69 algoSuiteCombo.addItem(ComboConstants.TRIPLEDES); 70 algoSuiteCombo.addItem(ComboConstants.BASIC256RSA15); 71 algoSuiteCombo.addItem(ComboConstants.BASIC192RSA15); 72 algoSuiteCombo.addItem(ComboConstants.BASIC128RSA15); 73 algoSuiteCombo.addItem(ComboConstants.TRIPLEDESRSA15); 74 83 inSync = false; 84 85 sync(); 86 } 87 88 private void sync() { 89 inSync = true; 90 91 WSDLComponent secBinding = null; 92 WSDLComponent topSecBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(comp); 93 WSDLComponent protTokenKind = SecurityTokensModelHelper.getTokenElement(topSecBinding, ProtectionToken.class); 94 WSDLComponent protToken = SecurityTokensModelHelper.getTokenTypeElement(protTokenKind); 95 96 boolean secConv = (protToken instanceof SecureConversationToken); 97 98 if (secConv) { 99 WSDLComponent bootPolicy = SecurityTokensModelHelper.getTokenElement(protToken, BootstrapPolicy.class); 100 secBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(bootPolicy); 101 setChBox(secConvChBox, true); 102 setChBox(derivedKeysChBox, SecurityPolicyModelHelper.isRequireDerivedKeys(protToken)); 103 setChBox(encryptSignatureChBox, SecurityPolicyModelHelper.isEncryptSignature(bootPolicy)); 104 setChBox(encryptOrderChBox, SecurityPolicyModelHelper.isEncryptBeforeSigning(bootPolicy)); 105 } else { 106 secBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(comp); 107 setChBox(secConvChBox, false); 108 setChBox(encryptSignatureChBox, SecurityPolicyModelHelper.isEncryptSignature(comp)); 109 setChBox(encryptOrderChBox, SecurityPolicyModelHelper.isEncryptBeforeSigning(comp)); 110 } 111 112 WSDLComponent tokenKind = SecurityTokensModelHelper.getTokenElement(secBinding, RecipientToken.class); 113 WSDLComponent token = SecurityTokensModelHelper.getTokenTypeElement(tokenKind); 114 setChBox(reqDerivedKeys, SecurityPolicyModelHelper.isRequireDerivedKeys(token)); 115 116 setCombo(algoSuiteCombo, AlgoSuiteModelHelper.getAlgorithmSuite(secBinding)); 117 setCombo(layoutCombo, SecurityPolicyModelHelper.getMessageLayout(secBinding)); 118 119 enableDisable(); 120 121 inSync = false; 122 } 123 124 public void setValue(javax.swing.JComponent source) { 125 126 if (inSync) return; 127 128 WSDLComponent secBinding = null; 129 WSDLComponent topSecBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(comp); 130 WSDLComponent protTokenKind = SecurityTokensModelHelper.getTokenElement(topSecBinding, ProtectionToken.class); 131 WSDLComponent protToken = SecurityTokensModelHelper.getTokenTypeElement(protTokenKind); 132 133 boolean secConv = (protToken instanceof SecureConversationToken); 134 135 if (source.equals(secConvChBox)) { 136 ProfilesModelHelper.enableSecureConversation(comp, secConvChBox.isSelected(), ComboConstants.PROF_MSGAUTHSSL); 137 } 138 139 if (secConv) { 140 WSDLComponent bootPolicy = SecurityTokensModelHelper.getTokenElement(protToken, BootstrapPolicy.class); 141 secBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(bootPolicy); 142 if (source.equals(derivedKeysChBox)) { 143 SecurityPolicyModelHelper.enableRequireDerivedKeys(protToken, derivedKeysChBox.isSelected()); 144 } 145 } else { 146 secBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(comp); 147 } 148 149 if (source.equals(encryptSignatureChBox)) { 150 SecurityPolicyModelHelper.enableEncryptSignature(secBinding, encryptSignatureChBox.isSelected()); 151 if (secConv) { 152 SecurityPolicyModelHelper.enableEncryptSignature(topSecBinding, encryptSignatureChBox.isSelected()); 153 } 154 } 155 if (source.equals(encryptOrderChBox)) { 156 SecurityPolicyModelHelper.enableEncryptBeforeSigning(secBinding, encryptOrderChBox.isSelected()); 157 if (secConv) { 158 SecurityPolicyModelHelper.enableEncryptBeforeSigning(topSecBinding, encryptOrderChBox.isSelected()); 159 } 160 } 161 if (source.equals(layoutCombo)) { 162 SecurityPolicyModelHelper.setLayout(secBinding, (String ) layoutCombo.getSelectedItem()); 163 if (secConv) { 164 SecurityPolicyModelHelper.setLayout(topSecBinding, (String ) layoutCombo.getSelectedItem()); 165 } 166 } 167 if (source.equals(algoSuiteCombo)) { 168 AlgoSuiteModelHelper.setAlgorithmSuite(secBinding, (String ) algoSuiteCombo.getSelectedItem()); 169 if (secConv) { 170 AlgoSuiteModelHelper.setAlgorithmSuite(topSecBinding, (String ) algoSuiteCombo.getSelectedItem()); 171 } 172 } 173 if (source.equals(reqDerivedKeys)) { 174 WSDLComponent tokenKind = SecurityTokensModelHelper.getTokenElement(secBinding, RecipientToken.class); 175 WSDLComponent token = SecurityTokensModelHelper.getTokenTypeElement(tokenKind); 176 SecurityPolicyModelHelper.enableRequireDerivedKeys(token, reqDerivedKeys.isSelected()); 177 tokenKind = SecurityTokensModelHelper.getTokenElement(secBinding, InitiatorToken.class); 178 token = SecurityTokensModelHelper.getTokenTypeElement(tokenKind); 179 SecurityPolicyModelHelper.enableRequireDerivedKeys(token, reqDerivedKeys.isSelected()); 180 return; 181 } 182 183 enableDisable(); 184 } 185 186 private void enableDisable() { 187 boolean secConvEnabled = secConvChBox.isSelected(); 188 derivedKeysChBox.setEnabled(secConvEnabled); 189 boolean rmEnabled = RMModelHelper.isRMEnabled(comp); 190 if (rmEnabled) { 191 secConvChBox.setEnabled(!secConvEnabled); 192 } else { 193 secConvChBox.setEnabled(true); 194 } 195 } 196 197 private void setCombo(JComboBox combo, String item) { 198 if (item == null) { 199 combo.setSelectedIndex(0); 200 } else { 201 combo.setSelectedItem(item); 202 } 203 } 204 205 private void setCombo(JComboBox combo, boolean second) { 206 combo.setSelectedIndex(second ? 1 : 0); 207 } 208 209 private void setChBox(JCheckBox chBox, Boolean enable) { 210 if (enable == null) { 211 chBox.setSelected(false); 212 } else { 213 chBox.setSelected(enable); 214 } 215 } 216 217 222 private void initComponents() { 224 225 secConvChBox = new javax.swing.JCheckBox (); 226 derivedKeysChBox = new javax.swing.JCheckBox (); 227 algoSuiteLabel = new javax.swing.JLabel (); 228 algoSuiteCombo = new javax.swing.JComboBox (); 229 layoutLabel = new javax.swing.JLabel (); 230 layoutCombo = new javax.swing.JComboBox (); 231 encryptSignatureChBox = new javax.swing.JCheckBox (); 232 reqDerivedKeys = new javax.swing.JCheckBox (); 233 encryptOrderChBox = new javax.swing.JCheckBox (); 234 235 org.openide.awt.Mnemonics.setLocalizedText(secConvChBox, org.openide.util.NbBundle.getMessage(MutualCertificates.class, "LBL_SecConvLabel")); secConvChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 237 secConvChBox.setMargin(new java.awt.Insets (0, 0, 0, 0)); 238 secConvChBox.addActionListener(new java.awt.event.ActionListener () { 239 public void actionPerformed(java.awt.event.ActionEvent evt) { 240 secConvChBoxActionPerformed(evt); 241 } 242 }); 243 244 org.openide.awt.Mnemonics.setLocalizedText(derivedKeysChBox, org.openide.util.NbBundle.getMessage(MutualCertificates.class, "LBL_RequireDerivedKeysForSecConv")); derivedKeysChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 246 derivedKeysChBox.setMargin(new java.awt.Insets (0, 0, 0, 0)); 247 derivedKeysChBox.addActionListener(new java.awt.event.ActionListener () { 248 public void actionPerformed(java.awt.event.ActionEvent evt) { 249 derivedKeysChBoxActionPerformed(evt); 250 } 251 }); 252 253 algoSuiteLabel.setLabelFor(algoSuiteCombo); 254 org.openide.awt.Mnemonics.setLocalizedText(algoSuiteLabel, org.openide.util.NbBundle.getMessage(MutualCertificates.class, "LBL_AlgoSuiteLabel")); 256 algoSuiteCombo.addActionListener(new java.awt.event.ActionListener () { 257 public void actionPerformed(java.awt.event.ActionEvent evt) { 258 algoSuiteComboActionPerformed(evt); 259 } 260 }); 261 262 layoutLabel.setLabelFor(layoutCombo); 263 org.openide.awt.Mnemonics.setLocalizedText(layoutLabel, org.openide.util.NbBundle.getMessage(MutualCertificates.class, "LBL_LayoutLabel")); 265 layoutCombo.addActionListener(new java.awt.event.ActionListener () { 266 public void actionPerformed(java.awt.event.ActionEvent evt) { 267 layoutComboActionPerformed(evt); 268 } 269 }); 270 271 org.openide.awt.Mnemonics.setLocalizedText(encryptSignatureChBox, org.openide.util.NbBundle.getMessage(MutualCertificates.class, "LBL_EncryptSignatureLabel")); encryptSignatureChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 273 encryptSignatureChBox.setMargin(new java.awt.Insets (0, 0, 0, 0)); 274 encryptSignatureChBox.addActionListener(new java.awt.event.ActionListener () { 275 public void actionPerformed(java.awt.event.ActionEvent evt) { 276 encryptSignatureChBox(evt); 277 } 278 }); 279 280 org.openide.awt.Mnemonics.setLocalizedText(reqDerivedKeys, org.openide.util.NbBundle.getMessage(MutualCertificates.class, "LBL_RequireDerivedKeys")); reqDerivedKeys.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 282 reqDerivedKeys.setMargin(new java.awt.Insets (0, 0, 0, 0)); 283 reqDerivedKeys.addActionListener(new java.awt.event.ActionListener () { 284 public void actionPerformed(java.awt.event.ActionEvent evt) { 285 reqDerivedKeysActionPerformed(evt); 286 } 287 }); 288 289 org.openide.awt.Mnemonics.setLocalizedText(encryptOrderChBox, org.openide.util.NbBundle.getMessage(MutualCertificates.class, "LBL_EncryptOrderLabel")); encryptOrderChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 291 encryptOrderChBox.setMargin(new java.awt.Insets (0, 0, 0, 0)); 292 encryptOrderChBox.addActionListener(new java.awt.event.ActionListener () { 293 public void actionPerformed(java.awt.event.ActionEvent evt) { 294 encryptOrderChBoxActionPerformed(evt); 295 } 296 }); 297 298 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); 299 this.setLayout(layout); 300 layout.setHorizontalGroup( 301 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 302 .add(layout.createSequentialGroup() 303 .addContainerGap() 304 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) 305 .add(reqDerivedKeys) 306 .add(secConvChBox) 307 .add(derivedKeysChBox) 308 .add(encryptSignatureChBox) 309 .add(encryptOrderChBox) 310 .add(layout.createSequentialGroup() 311 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 312 .add(layoutLabel) 313 .add(algoSuiteLabel)) 314 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 315 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) 316 .add(layoutCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 145, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 317 .add(algoSuiteCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 145, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))) 318 .addContainerGap()) 319 ); 320 321 layout.linkSize(new java.awt.Component [] {algoSuiteCombo, layoutCombo}, org.jdesktop.layout.GroupLayout.HORIZONTAL); 322 323 layout.setVerticalGroup( 324 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 325 .add(layout.createSequentialGroup() 326 .addContainerGap() 327 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 328 .add(algoSuiteLabel) 329 .add(algoSuiteCombo, 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(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 332 .add(layoutLabel) 333 .add(layoutCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 334 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 335 .add(reqDerivedKeys) 336 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 337 .add(secConvChBox) 338 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 339 .add(derivedKeysChBox) 340 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 341 .add(encryptSignatureChBox) 342 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 343 .add(encryptOrderChBox) 344 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 345 ); 346 347 layout.linkSize(new java.awt.Component [] {algoSuiteCombo, layoutCombo}, org.jdesktop.layout.GroupLayout.VERTICAL); 348 349 } 351 private void encryptOrderChBoxActionPerformed(java.awt.event.ActionEvent evt) { setValue(encryptOrderChBox); 353 } 355 private void reqDerivedKeysActionPerformed(java.awt.event.ActionEvent evt) { setValue(reqDerivedKeys); 357 } 359 private void derivedKeysChBoxActionPerformed(java.awt.event.ActionEvent evt) { setValue(derivedKeysChBox); 361 } 363 private void secConvChBoxActionPerformed(java.awt.event.ActionEvent evt) { setValue(secConvChBox); 365 } 367 private void encryptSignatureChBox(java.awt.event.ActionEvent evt) { setValue(encryptSignatureChBox); 369 } 371 private void layoutComboActionPerformed(java.awt.event.ActionEvent evt) { setValue(layoutCombo); 373 } 375 private void algoSuiteComboActionPerformed(java.awt.event.ActionEvent evt) { setValue(algoSuiteCombo); 377 } 379 private javax.swing.JComboBox algoSuiteCombo; 381 private javax.swing.JLabel algoSuiteLabel; 382 private javax.swing.JCheckBox derivedKeysChBox; 383 private javax.swing.JCheckBox encryptOrderChBox; 384 private javax.swing.JCheckBox encryptSignatureChBox; 385 private javax.swing.JComboBox layoutCombo; 386 private javax.swing.JLabel layoutLabel; 387 private javax.swing.JCheckBox reqDerivedKeys; 388 private javax.swing.JCheckBox secConvChBox; 389 391 } 392 | Popular Tags |