1 19 20 package org.netbeans.modules.websvc.wsitconf.ui.service.profiles; 21 22 import java.util.Collection ; 23 import javax.swing.JCheckBox ; 24 import javax.swing.JComboBox ; 25 import org.netbeans.modules.websvc.wsitconf.ui.ComboConstants; 26 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.AlgoSuiteModelHelper; 27 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.ProfilesModelHelper; 28 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.RMModelHelper; 29 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.SecurityPolicyModelHelper; 30 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.SecurityTokensModelHelper; 31 import org.netbeans.modules.websvc.wsitmodelext.security.BootstrapPolicy; 32 import org.netbeans.modules.websvc.wsitmodelext.security.tokens.InitiatorToken; 33 import org.netbeans.modules.websvc.wsitmodelext.security.tokens.ProtectionToken; 34 import org.netbeans.modules.websvc.wsitmodelext.security.tokens.RecipientToken; 35 import org.netbeans.modules.websvc.wsitmodelext.security.tokens.SecureConversationToken; 36 import org.netbeans.modules.xml.wsdl.model.Binding; 37 import org.netbeans.modules.xml.wsdl.model.BindingInput; 38 import org.netbeans.modules.xml.wsdl.model.BindingOperation; 39 import org.netbeans.modules.xml.wsdl.model.WSDLComponent; 40 import org.netbeans.modules.xml.wsdl.model.WSDLModel; 41 42 46 public class SenderVouches extends javax.swing.JPanel { 47 48 private boolean inSync = false; 49 50 private WSDLComponent comp; 51 private WSDLModel model; 52 53 56 public SenderVouches(WSDLComponent comp) { 57 super(); 58 initComponents(); 59 this.model = comp.getModel(); 60 this.comp = comp; 61 62 inSync = true; 63 layoutCombo.removeAllItems(); 64 layoutCombo.addItem(ComboConstants.STRICT); 65 layoutCombo.addItem(ComboConstants.LAX); 66 layoutCombo.addItem(ComboConstants.LAXTSFIRST); 67 layoutCombo.addItem(ComboConstants.LAXTSLAST); 68 69 samlVersionCombo.removeAllItems(); 70 samlVersionCombo.addItem(ComboConstants.SAML_V1010); 71 samlVersionCombo.addItem(ComboConstants.SAML_V1011); 72 samlVersionCombo.addItem(ComboConstants.SAML_V1110); 73 samlVersionCombo.addItem(ComboConstants.SAML_V1111); 74 samlVersionCombo.addItem(ComboConstants.SAML_V2011); 75 76 algoSuiteCombo.removeAllItems(); 77 algoSuiteCombo.addItem(ComboConstants.BASIC256); 78 algoSuiteCombo.addItem(ComboConstants.BASIC192); 79 algoSuiteCombo.addItem(ComboConstants.BASIC128); 80 algoSuiteCombo.addItem(ComboConstants.TRIPLEDES); 81 algoSuiteCombo.addItem(ComboConstants.BASIC256RSA15); 82 algoSuiteCombo.addItem(ComboConstants.BASIC192RSA15); 83 algoSuiteCombo.addItem(ComboConstants.BASIC128RSA15); 84 algoSuiteCombo.addItem(ComboConstants.TRIPLEDESRSA15); 85 94 inSync = false; 95 96 sync(); 97 } 98 99 private void sync() { 100 inSync = true; 101 102 WSDLComponent secBinding = null; 103 WSDLComponent topSecBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(comp); 104 WSDLComponent protTokenKind = SecurityTokensModelHelper.getTokenElement(topSecBinding, ProtectionToken.class); 105 WSDLComponent protToken = SecurityTokensModelHelper.getTokenTypeElement(protTokenKind); 106 107 boolean secConv = (protToken instanceof SecureConversationToken); 108 109 if (secConv) { 110 WSDLComponent bootPolicy = SecurityTokensModelHelper.getTokenElement(protToken, BootstrapPolicy.class); 111 secBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(bootPolicy); 112 setChBox(secConvChBox, true); 113 setChBox(derivedKeysChBox, SecurityPolicyModelHelper.isRequireDerivedKeys(protToken)); 114 setChBox(encryptSignatureChBox, SecurityPolicyModelHelper.isEncryptSignature(bootPolicy)); 115 setChBox(encryptOrderChBox, SecurityPolicyModelHelper.isEncryptBeforeSigning(bootPolicy)); 116 } else { 117 secBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(comp); 118 setChBox(secConvChBox, false); 119 setChBox(encryptSignatureChBox, SecurityPolicyModelHelper.isEncryptSignature(comp)); 120 setChBox(encryptOrderChBox, SecurityPolicyModelHelper.isEncryptBeforeSigning(comp)); 121 } 122 123 if (comp instanceof Binding) { 124 Collection <BindingOperation> ops = ((Binding)comp).getBindingOperations(); 125 for (BindingOperation o : ops) { 126 if (!SecurityPolicyModelHelper.isSecurityEnabled(o)) { 127 BindingInput input = o.getBindingInput(); 128 WSDLComponent tokenKind = SecurityTokensModelHelper.getSupportingToken(input, SecurityTokensModelHelper.SIGNED_SUPPORTING); 129 WSDLComponent token = SecurityTokensModelHelper.getTokenTypeElement(tokenKind); 130 String samlVersion = SecurityTokensModelHelper.getTokenProfileVersion(token); 131 setCombo(samlVersionCombo, samlVersion); 132 break; 133 } 134 } 135 } else { 136 BindingInput input = ((BindingOperation)comp).getBindingInput(); 137 WSDLComponent tokenKind = SecurityTokensModelHelper.getSupportingToken(input, SecurityTokensModelHelper.SIGNED_SUPPORTING); 138 WSDLComponent token = SecurityTokensModelHelper.getTokenTypeElement(tokenKind); 139 String samlVersion = SecurityTokensModelHelper.getTokenProfileVersion(token); 140 setCombo(samlVersionCombo, samlVersion); 141 } 142 143 WSDLComponent tokenKind = SecurityTokensModelHelper.getTokenElement(secBinding, RecipientToken.class); 144 WSDLComponent token = SecurityTokensModelHelper.getTokenTypeElement(tokenKind); 145 setChBox(reqDerivedKeys, SecurityPolicyModelHelper.isRequireDerivedKeys(token)); 146 147 setCombo(algoSuiteCombo, AlgoSuiteModelHelper.getAlgorithmSuite(secBinding)); 148 setCombo(layoutCombo, SecurityPolicyModelHelper.getMessageLayout(secBinding)); 149 150 enableDisable(); 151 152 inSync = false; 153 } 154 155 public void setValue(javax.swing.JComponent source) { 156 157 if (inSync) return; 158 159 WSDLComponent secBinding = null; 160 WSDLComponent topSecBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(comp); 161 WSDLComponent protTokenKind = SecurityTokensModelHelper.getTokenElement(topSecBinding, ProtectionToken.class); 162 WSDLComponent protToken = SecurityTokensModelHelper.getTokenTypeElement(protTokenKind); 163 164 boolean secConv = (protToken instanceof SecureConversationToken); 165 166 if (source.equals(secConvChBox)) { 167 ProfilesModelHelper.enableSecureConversation(comp, secConvChBox.isSelected(), ComboConstants.PROF_MSGAUTHSSL); 168 } 169 170 if (secConv) { 171 WSDLComponent bootPolicy = SecurityTokensModelHelper.getTokenElement(protToken, BootstrapPolicy.class); 172 secBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(bootPolicy); 173 if (source.equals(derivedKeysChBox)) { 174 SecurityPolicyModelHelper.enableRequireDerivedKeys(protToken, derivedKeysChBox.isSelected()); 175 } 176 } else { 177 secBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(comp); 178 } 179 180 if (source.equals(encryptSignatureChBox)) { 181 SecurityPolicyModelHelper.enableEncryptSignature(secBinding, encryptSignatureChBox.isSelected()); 182 if (secConv) { 183 SecurityPolicyModelHelper.enableEncryptSignature(topSecBinding, encryptSignatureChBox.isSelected()); 184 } 185 } 186 if (source.equals(encryptOrderChBox)) { 187 SecurityPolicyModelHelper.enableEncryptBeforeSigning(secBinding, encryptOrderChBox.isSelected()); 188 if (secConv) { 189 SecurityPolicyModelHelper.enableEncryptBeforeSigning(topSecBinding, encryptOrderChBox.isSelected()); 190 } 191 } 192 if (source.equals(layoutCombo)) { 193 SecurityPolicyModelHelper.setLayout(secBinding, (String ) layoutCombo.getSelectedItem()); 194 if (secConv) { 195 SecurityPolicyModelHelper.setLayout(topSecBinding, (String ) layoutCombo.getSelectedItem()); 196 } 197 } 198 if (source.equals(algoSuiteCombo)) { 199 AlgoSuiteModelHelper.setAlgorithmSuite(secBinding, (String ) algoSuiteCombo.getSelectedItem()); 200 if (secConv) { 201 AlgoSuiteModelHelper.setAlgorithmSuite(topSecBinding, (String ) algoSuiteCombo.getSelectedItem()); 202 } 203 } 204 if (source.equals(reqDerivedKeys)) { 205 WSDLComponent tokenKind = SecurityTokensModelHelper.getTokenElement(secBinding, RecipientToken.class); 206 WSDLComponent token = SecurityTokensModelHelper.getTokenTypeElement(tokenKind); 207 SecurityPolicyModelHelper.enableRequireDerivedKeys(token, reqDerivedKeys.isSelected()); 208 tokenKind = SecurityTokensModelHelper.getTokenElement(secBinding, InitiatorToken.class); 209 token = SecurityTokensModelHelper.getTokenTypeElement(tokenKind); 210 SecurityPolicyModelHelper.enableRequireDerivedKeys(token, reqDerivedKeys.isSelected()); 211 return; 212 } 213 if (source.equals(samlVersionCombo)) { 214 if (comp instanceof Binding) { 215 Collection <BindingOperation> ops = ((Binding)comp).getBindingOperations(); 216 for (BindingOperation o : ops) { 217 if (!SecurityPolicyModelHelper.isSecurityEnabled(o)) { 218 BindingInput input = o.getBindingInput(); 219 WSDLComponent tokenKind = SecurityTokensModelHelper.getSupportingToken(input, 220 SecurityTokensModelHelper.SIGNED_SUPPORTING); 221 WSDLComponent token = SecurityTokensModelHelper.getTokenTypeElement(tokenKind); 222 SecurityTokensModelHelper.setTokenProfileVersion(token, (String ) samlVersionCombo.getSelectedItem()); 223 } 224 } 225 } else { 226 BindingInput input = ((BindingOperation)comp).getBindingInput(); 227 WSDLComponent token = SecurityTokensModelHelper.getSupportingToken(input, 228 SecurityTokensModelHelper.SIGNED_SUPPORTING); 229 SecurityTokensModelHelper.setTokenProfileVersion(token, (String ) samlVersionCombo.getSelectedItem()); 230 } 231 } 232 233 enableDisable(); 234 } 235 236 private void enableDisable() { 237 boolean secConvEnabled = secConvChBox.isSelected(); 238 derivedKeysChBox.setEnabled(secConvEnabled); 239 boolean rmEnabled = RMModelHelper.isRMEnabled(comp); 240 if (rmEnabled) { 241 secConvChBox.setEnabled(!secConvEnabled); 242 } else { 243 secConvChBox.setEnabled(true); 244 } 245 } 246 247 private void setCombo(JComboBox combo, String item) { 248 if (item == null) { 249 combo.setSelectedIndex(0); 250 } else { 251 combo.setSelectedItem(item); 252 } 253 } 254 255 private void setCombo(JComboBox combo, boolean second) { 256 combo.setSelectedIndex(second ? 1 : 0); 257 } 258 259 private void setChBox(JCheckBox chBox, Boolean enable) { 260 if (enable == null) { 261 chBox.setSelected(false); 262 } else { 263 chBox.setSelected(enable); 264 } 265 } 266 267 272 private void initComponents() { 274 275 secConvChBox = new javax.swing.JCheckBox (); 276 derivedKeysChBox = new javax.swing.JCheckBox (); 277 algoSuiteLabel = new javax.swing.JLabel (); 278 algoSuiteCombo = new javax.swing.JComboBox (); 279 layoutLabel = new javax.swing.JLabel (); 280 layoutCombo = new javax.swing.JComboBox (); 281 encryptSignatureChBox = new javax.swing.JCheckBox (); 282 reqDerivedKeys = new javax.swing.JCheckBox (); 283 encryptOrderChBox = new javax.swing.JCheckBox (); 284 samlVersionCombo = new javax.swing.JComboBox (); 285 samlVersionLabel = new javax.swing.JLabel (); 286 287 org.openide.awt.Mnemonics.setLocalizedText(secConvChBox, org.openide.util.NbBundle.getMessage(SenderVouches.class, "LBL_SecConvLabel")); secConvChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 289 secConvChBox.setMargin(new java.awt.Insets (0, 0, 0, 0)); 290 secConvChBox.addActionListener(new java.awt.event.ActionListener () { 291 public void actionPerformed(java.awt.event.ActionEvent evt) { 292 secConvChBoxActionPerformed(evt); 293 } 294 }); 295 296 org.openide.awt.Mnemonics.setLocalizedText(derivedKeysChBox, org.openide.util.NbBundle.getMessage(SenderVouches.class, "LBL_RequireDerivedKeysForSecConv")); derivedKeysChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 298 derivedKeysChBox.setMargin(new java.awt.Insets (0, 0, 0, 0)); 299 derivedKeysChBox.addActionListener(new java.awt.event.ActionListener () { 300 public void actionPerformed(java.awt.event.ActionEvent evt) { 301 derivedKeysChBoxActionPerformed(evt); 302 } 303 }); 304 305 algoSuiteLabel.setLabelFor(algoSuiteCombo); 306 org.openide.awt.Mnemonics.setLocalizedText(algoSuiteLabel, org.openide.util.NbBundle.getMessage(SenderVouches.class, "LBL_AlgoSuiteLabel")); 308 algoSuiteCombo.addActionListener(new java.awt.event.ActionListener () { 309 public void actionPerformed(java.awt.event.ActionEvent evt) { 310 algoSuiteComboActionPerformed(evt); 311 } 312 }); 313 314 layoutLabel.setLabelFor(layoutCombo); 315 org.openide.awt.Mnemonics.setLocalizedText(layoutLabel, org.openide.util.NbBundle.getMessage(SenderVouches.class, "LBL_LayoutLabel")); 317 layoutCombo.addActionListener(new java.awt.event.ActionListener () { 318 public void actionPerformed(java.awt.event.ActionEvent evt) { 319 layoutComboActionPerformed(evt); 320 } 321 }); 322 323 org.openide.awt.Mnemonics.setLocalizedText(encryptSignatureChBox, org.openide.util.NbBundle.getMessage(SenderVouches.class, "LBL_EncryptSignatureLabel")); encryptSignatureChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 325 encryptSignatureChBox.setMargin(new java.awt.Insets (0, 0, 0, 0)); 326 encryptSignatureChBox.addActionListener(new java.awt.event.ActionListener () { 327 public void actionPerformed(java.awt.event.ActionEvent evt) { 328 encryptSignatureChBox(evt); 329 } 330 }); 331 332 org.openide.awt.Mnemonics.setLocalizedText(reqDerivedKeys, org.openide.util.NbBundle.getMessage(SenderVouches.class, "LBL_RequireDerivedKeys")); reqDerivedKeys.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 334 reqDerivedKeys.setMargin(new java.awt.Insets (0, 0, 0, 0)); 335 reqDerivedKeys.addActionListener(new java.awt.event.ActionListener () { 336 public void actionPerformed(java.awt.event.ActionEvent evt) { 337 reqDerivedKeysActionPerformed(evt); 338 } 339 }); 340 341 org.openide.awt.Mnemonics.setLocalizedText(encryptOrderChBox, org.openide.util.NbBundle.getMessage(SenderVouches.class, "LBL_EncryptOrderLabel")); encryptOrderChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 343 encryptOrderChBox.setMargin(new java.awt.Insets (0, 0, 0, 0)); 344 encryptOrderChBox.addActionListener(new java.awt.event.ActionListener () { 345 public void actionPerformed(java.awt.event.ActionEvent evt) { 346 encryptOrderChBoxActionPerformed(evt); 347 } 348 }); 349 350 samlVersionCombo.addActionListener(new java.awt.event.ActionListener () { 351 public void actionPerformed(java.awt.event.ActionEvent evt) { 352 samlVersionComboActionPerformed(evt); 353 } 354 }); 355 356 samlVersionLabel.setLabelFor(samlVersionCombo); 357 org.openide.awt.Mnemonics.setLocalizedText(samlVersionLabel, org.openide.util.NbBundle.getMessage(SenderVouches.class, "LBL_SamlVersion")); 359 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); 360 this.setLayout(layout); 361 layout.setHorizontalGroup( 362 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 363 .add(layout.createSequentialGroup() 364 .addContainerGap() 365 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) 366 .add(reqDerivedKeys) 367 .add(secConvChBox) 368 .add(derivedKeysChBox) 369 .add(encryptSignatureChBox) 370 .add(encryptOrderChBox) 371 .add(layout.createSequentialGroup() 372 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 373 .add(layoutLabel) 374 .add(algoSuiteLabel) 375 .add(samlVersionLabel)) 376 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 377 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) 378 .add(samlVersionCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 145, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 379 .add(algoSuiteCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 145, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 380 .add(layoutCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 145, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))) 381 .addContainerGap()) 382 ); 383 384 layout.linkSize(new java.awt.Component [] {algoSuiteCombo, layoutCombo, samlVersionCombo}, org.jdesktop.layout.GroupLayout.HORIZONTAL); 385 386 layout.setVerticalGroup( 387 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 388 .add(layout.createSequentialGroup() 389 .addContainerGap() 390 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 391 .add(samlVersionLabel) 392 .add(samlVersionCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 393 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 394 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 395 .add(algoSuiteLabel) 396 .add(algoSuiteCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 397 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 398 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 399 .add(layoutLabel) 400 .add(layoutCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 401 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 402 .add(reqDerivedKeys) 403 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 404 .add(secConvChBox) 405 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 406 .add(derivedKeysChBox) 407 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 408 .add(encryptSignatureChBox) 409 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 410 .add(encryptOrderChBox) 411 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 412 ); 413 414 layout.linkSize(new java.awt.Component [] {algoSuiteCombo, layoutCombo, samlVersionCombo}, org.jdesktop.layout.GroupLayout.VERTICAL); 415 416 } 418 private void samlVersionComboActionPerformed(java.awt.event.ActionEvent evt) { setValue(samlVersionCombo); 420 } 422 private void encryptOrderChBoxActionPerformed(java.awt.event.ActionEvent evt) { setValue(encryptOrderChBox); 424 } 426 private void reqDerivedKeysActionPerformed(java.awt.event.ActionEvent evt) { setValue(reqDerivedKeys); 428 } 430 private void derivedKeysChBoxActionPerformed(java.awt.event.ActionEvent evt) { setValue(derivedKeysChBox); 432 } 434 private void secConvChBoxActionPerformed(java.awt.event.ActionEvent evt) { setValue(secConvChBox); 436 } 438 private void encryptSignatureChBox(java.awt.event.ActionEvent evt) { setValue(encryptSignatureChBox); 440 } 442 private void layoutComboActionPerformed(java.awt.event.ActionEvent evt) { setValue(layoutCombo); 444 } 446 private void algoSuiteComboActionPerformed(java.awt.event.ActionEvent evt) { setValue(algoSuiteCombo); 448 } 450 private javax.swing.JComboBox algoSuiteCombo; 452 private javax.swing.JLabel algoSuiteLabel; 453 private javax.swing.JCheckBox derivedKeysChBox; 454 private javax.swing.JCheckBox encryptOrderChBox; 455 private javax.swing.JCheckBox encryptSignatureChBox; 456 private javax.swing.JComboBox layoutCombo; 457 private javax.swing.JLabel layoutLabel; 458 private javax.swing.JCheckBox reqDerivedKeys; 459 private javax.swing.JComboBox samlVersionCombo; 460 private javax.swing.JLabel samlVersionLabel; 461 private javax.swing.JCheckBox secConvChBox; 462 464 } 465 | Popular Tags |