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.PolicyModelHelper; 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.policy.Policy; 32 import org.netbeans.modules.websvc.wsitmodelext.security.BootstrapPolicy; 33 import org.netbeans.modules.websvc.wsitmodelext.security.WssElement; 34 import org.netbeans.modules.websvc.wsitmodelext.security.tokens.ProtectionToken; 35 import org.netbeans.modules.websvc.wsitmodelext.security.tokens.SecureConversationToken; 36 import org.netbeans.modules.xml.wsdl.model.WSDLComponent; 37 import org.netbeans.modules.xml.wsdl.model.WSDLModel; 38 39 43 public class MessageAuthentication extends javax.swing.JPanel { 44 45 private boolean inSync = false; 46 47 private WSDLComponent comp; 48 private WSDLModel model; 49 50 53 public MessageAuthentication(WSDLComponent comp) { 54 super(); 55 initComponents(); 56 this.model = comp.getModel(); 57 this.comp = comp; 58 59 inSync = true; 60 supportTokenCombo.removeAllItems(); 61 supportTokenCombo.addItem(ComboConstants.X509); 62 supportTokenCombo.addItem(ComboConstants.USERNAME); 63 64 wssVersionCombo.removeAllItems(); 65 wssVersionCombo.addItem(ComboConstants.WSS10); 66 wssVersionCombo.addItem(ComboConstants.WSS11); 67 68 layoutCombo.removeAllItems(); 69 layoutCombo.addItem(ComboConstants.STRICT); 70 layoutCombo.addItem(ComboConstants.LAX); 71 layoutCombo.addItem(ComboConstants.LAXTSFIRST); 72 layoutCombo.addItem(ComboConstants.LAXTSLAST); 73 74 algoSuiteCombo.removeAllItems(); 75 algoSuiteCombo.addItem(ComboConstants.BASIC256); 76 algoSuiteCombo.addItem(ComboConstants.BASIC192); 77 algoSuiteCombo.addItem(ComboConstants.BASIC128); 78 algoSuiteCombo.addItem(ComboConstants.TRIPLEDES); 79 algoSuiteCombo.addItem(ComboConstants.BASIC256RSA15); 80 algoSuiteCombo.addItem(ComboConstants.BASIC192RSA15); 81 algoSuiteCombo.addItem(ComboConstants.BASIC128RSA15); 82 algoSuiteCombo.addItem(ComboConstants.TRIPLEDESRSA15); 83 92 inSync = false; 93 94 sync(); 95 } 96 97 private void sync() { 98 inSync = true; 99 100 WSDLComponent secBinding = null; 101 WSDLComponent topSecBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(comp); 102 WSDLComponent protTokenKind = SecurityTokensModelHelper.getTokenElement(topSecBinding, ProtectionToken.class); 103 WSDLComponent protToken = SecurityTokensModelHelper.getTokenTypeElement(protTokenKind); 104 105 boolean secConv = (protToken instanceof SecureConversationToken); 106 107 if (secConv) { 108 WSDLComponent bootPolicy = SecurityTokensModelHelper.getTokenElement(protToken, BootstrapPolicy.class); 109 secBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(bootPolicy); 110 Policy p = (Policy) secBinding.getParent(); 111 setChBox(secConvChBox, true); 112 setChBox(derivedKeysSecConvChBox, SecurityPolicyModelHelper.isRequireDerivedKeys(protToken)); 113 setCombo(wssVersionCombo, SecurityPolicyModelHelper.isWss11(p)); 114 setChBox(reqSigConfChBox, SecurityPolicyModelHelper.isRequireSignatureConfirmation(p)); 115 setChBox(encryptSignatureChBox, SecurityPolicyModelHelper.isEncryptSignature(bootPolicy)); 116 p = PolicyModelHelper.getTopLevelElement(bootPolicy, Policy.class); 117 WSDLComponent tokenKind = SecurityTokensModelHelper.getSupportingToken(p, SecurityTokensModelHelper.SIGNED_SUPPORTING); 118 String tokenType = SecurityTokensModelHelper.getTokenType(tokenKind); 119 setCombo(supportTokenCombo, tokenType); 120 } else { 121 secBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(comp); 122 setChBox(secConvChBox, false); 123 setCombo(wssVersionCombo, SecurityPolicyModelHelper.isWss11(comp)); 124 setChBox(reqSigConfChBox, SecurityPolicyModelHelper.isRequireSignatureConfirmation(comp)); 125 setChBox(encryptSignatureChBox, SecurityPolicyModelHelper.isEncryptSignature(comp)); 126 WSDLComponent tokenKind = SecurityTokensModelHelper.getSupportingToken(comp, SecurityTokensModelHelper.SIGNED_SUPPORTING); 127 String tokenType = SecurityTokensModelHelper.getTokenType(tokenKind); 128 setCombo(supportTokenCombo, tokenType); 129 } 130 131 setCombo(algoSuiteCombo, AlgoSuiteModelHelper.getAlgorithmSuite(secBinding)); 132 setCombo(layoutCombo, SecurityPolicyModelHelper.getMessageLayout(secBinding)); 133 134 enableDisable(); 135 136 inSync = false; 137 } 138 139 public void setValue(javax.swing.JComponent source) { 140 141 if (inSync) return; 142 143 WSDLComponent secBinding = null; 144 WSDLComponent topSecBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(comp); 145 WSDLComponent protTokenKind = SecurityTokensModelHelper.getTokenElement(topSecBinding, ProtectionToken.class); 146 WSDLComponent protToken = SecurityTokensModelHelper.getTokenTypeElement(protTokenKind); 147 148 boolean secConv = (protToken instanceof SecureConversationToken); 149 150 if (source.equals(secConvChBox)) { 151 ProfilesModelHelper.enableSecureConversation(comp, secConvChBox.isSelected(), ComboConstants.PROF_MSGAUTHSSL); 152 } 153 154 if (secConv) { 155 WSDLComponent bootPolicy = SecurityTokensModelHelper.getTokenElement(protToken, BootstrapPolicy.class); 156 secBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(bootPolicy); 157 Policy p = (Policy) secBinding.getParent(); 158 if (source.equals(reqSigConfChBox)) { 159 SecurityPolicyModelHelper.enableRequireSignatureConfirmation( 160 SecurityPolicyModelHelper.getWss11(p), reqSigConfChBox.isSelected()); 161 } 162 if (source.equals(derivedKeysSecConvChBox)) { 163 SecurityPolicyModelHelper.enableRequireDerivedKeys(protToken, derivedKeysSecConvChBox.isSelected()); 164 } 165 if (source.equals(wssVersionCombo)) { 166 boolean wss11 = ComboConstants.WSS11.equals(wssVersionCombo.getSelectedItem()); 167 WssElement wss = SecurityPolicyModelHelper.enableWss(p, wss11); 168 if (wss11) { 169 SecurityPolicyModelHelper.enableRequireSignatureConfirmation( 170 SecurityPolicyModelHelper.getWss11(p), reqSigConfChBox.isSelected()); 171 } 172 SecurityPolicyModelHelper.enableMustSupportRefKeyIdentifier(wss, true); 173 } 174 p = PolicyModelHelper.getTopLevelElement(bootPolicy, Policy.class); 175 if (source.equals(supportTokenCombo)) { 176 SecurityTokensModelHelper.setSupportingTokens(p, 177 (String )supportTokenCombo.getSelectedItem(), 178 SecurityTokensModelHelper.SIGNED_SUPPORTING); 179 } 180 } else { 181 secBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(comp); 182 if (source.equals(reqSigConfChBox)) { 183 SecurityPolicyModelHelper.enableRequireSignatureConfirmation( 184 SecurityPolicyModelHelper.getWss11(comp), reqSigConfChBox.isSelected()); 185 } 186 if (source.equals(wssVersionCombo)) { 187 boolean wss11 = ComboConstants.WSS11.equals(wssVersionCombo.getSelectedItem()); 188 WssElement wss = SecurityPolicyModelHelper.enableWss(comp, wss11); 189 if (wss11) { 190 SecurityPolicyModelHelper.enableRequireSignatureConfirmation( 191 SecurityPolicyModelHelper.getWss11(comp), reqSigConfChBox.isSelected()); 192 } 193 SecurityPolicyModelHelper.enableMustSupportRefKeyIdentifier(wss, true); 194 } 195 if (source.equals(supportTokenCombo)) { 196 SecurityTokensModelHelper.setSupportingTokens(comp, 197 (String )supportTokenCombo.getSelectedItem(), 198 SecurityTokensModelHelper.SIGNED_SUPPORTING); 199 } 200 } 201 202 if (source.equals(layoutCombo)) { 203 SecurityPolicyModelHelper.setLayout(secBinding, (String ) layoutCombo.getSelectedItem()); 204 if (secConv) { 205 SecurityPolicyModelHelper.setLayout(topSecBinding, (String ) layoutCombo.getSelectedItem()); 206 } 207 } 208 if (source.equals(algoSuiteCombo)) { 209 AlgoSuiteModelHelper.setAlgorithmSuite(secBinding, (String ) algoSuiteCombo.getSelectedItem()); 210 if (secConv) { 211 AlgoSuiteModelHelper.setAlgorithmSuite(topSecBinding, (String ) algoSuiteCombo.getSelectedItem()); 212 } 213 } 214 if (source.equals(encryptSignatureChBox)) { 215 SecurityPolicyModelHelper.enableEncryptSignature(secBinding, encryptSignatureChBox.isSelected()); 216 if (secConv) { 217 SecurityPolicyModelHelper.enableEncryptSignature(topSecBinding, encryptSignatureChBox.isSelected()); 218 } 219 } 220 221 enableDisable(); 222 } 223 224 private void enableDisable() { 225 boolean secConvEnabled = secConvChBox.isSelected(); 226 derivedKeysSecConvChBox.setEnabled(secConvEnabled); 227 boolean wss11 = ComboConstants.WSS11.equals(wssVersionCombo.getSelectedItem()); 228 reqSigConfChBox.setEnabled(wss11); 229 boolean rmEnabled = RMModelHelper.isRMEnabled(comp); 230 if (rmEnabled) { 231 secConvChBox.setEnabled(!secConvEnabled); 232 } else { 233 secConvChBox.setEnabled(true); 234 } 235 } 236 237 private void setCombo(JComboBox combo, String item) { 238 if (item == null) { 239 combo.setSelectedIndex(0); 240 } else { 241 combo.setSelectedItem(item); 242 } 243 } 244 245 private void setCombo(JComboBox combo, boolean second) { 246 combo.setSelectedIndex(second ? 1 : 0); 247 } 248 249 private void setChBox(JCheckBox chBox, Boolean enable) { 250 if (enable == null) { 251 chBox.setSelected(false); 252 } else { 253 chBox.setSelected(enable); 254 } 255 } 256 257 262 private void initComponents() { 264 265 supportTokenLabel = new javax.swing.JLabel (); 266 supportTokenCombo = new javax.swing.JComboBox (); 267 secConvChBox = new javax.swing.JCheckBox (); 268 reqSigConfChBox = new javax.swing.JCheckBox (); 269 derivedKeysSecConvChBox = new javax.swing.JCheckBox (); 270 wssVersionLabel = new javax.swing.JLabel (); 271 wssVersionCombo = new javax.swing.JComboBox (); 272 algoSuiteLabel = new javax.swing.JLabel (); 273 algoSuiteCombo = new javax.swing.JComboBox (); 274 layoutLabel = new javax.swing.JLabel (); 275 layoutCombo = new javax.swing.JComboBox (); 276 encryptSignatureChBox = new javax.swing.JCheckBox (); 277 278 supportTokenLabel.setLabelFor(supportTokenCombo); 279 org.openide.awt.Mnemonics.setLocalizedText(supportTokenLabel, org.openide.util.NbBundle.getMessage(MessageAuthentication.class, "LBL_AuthToken")); 281 supportTokenCombo.addActionListener(new java.awt.event.ActionListener () { 282 public void actionPerformed(java.awt.event.ActionEvent evt) { 283 supportTokenComboActionPerformed(evt); 284 } 285 }); 286 287 org.openide.awt.Mnemonics.setLocalizedText(secConvChBox, org.openide.util.NbBundle.getMessage(MessageAuthentication.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(reqSigConfChBox, org.openide.util.NbBundle.getMessage(MessageAuthentication.class, "LBL_RequireSigConfirmation")); reqSigConfChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 298 reqSigConfChBox.setMargin(new java.awt.Insets (0, 0, 0, 0)); 299 reqSigConfChBox.addActionListener(new java.awt.event.ActionListener () { 300 public void actionPerformed(java.awt.event.ActionEvent evt) { 301 reqSigConfChBoxActionPerformed(evt); 302 } 303 }); 304 305 org.openide.awt.Mnemonics.setLocalizedText(derivedKeysSecConvChBox, org.openide.util.NbBundle.getMessage(MessageAuthentication.class, "LBL_RequireDerivedKeysForSecConv")); derivedKeysSecConvChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 307 derivedKeysSecConvChBox.setMargin(new java.awt.Insets (0, 0, 0, 0)); 308 derivedKeysSecConvChBox.addActionListener(new java.awt.event.ActionListener () { 309 public void actionPerformed(java.awt.event.ActionEvent evt) { 310 derivedKeysSecConvChBoxActionPerformed(evt); 311 } 312 }); 313 314 wssVersionLabel.setLabelFor(wssVersionCombo); 315 org.openide.awt.Mnemonics.setLocalizedText(wssVersionLabel, org.openide.util.NbBundle.getMessage(MessageAuthentication.class, "LBL_WSSVersionLabel")); 317 wssVersionCombo.addActionListener(new java.awt.event.ActionListener () { 318 public void actionPerformed(java.awt.event.ActionEvent evt) { 319 wssVersionComboActionPerformed(evt); 320 } 321 }); 322 323 algoSuiteLabel.setLabelFor(algoSuiteCombo); 324 org.openide.awt.Mnemonics.setLocalizedText(algoSuiteLabel, org.openide.util.NbBundle.getMessage(MessageAuthentication.class, "LBL_AlgoSuiteLabel")); 326 algoSuiteCombo.addActionListener(new java.awt.event.ActionListener () { 327 public void actionPerformed(java.awt.event.ActionEvent evt) { 328 algoSuiteComboActionPerformed(evt); 329 } 330 }); 331 332 layoutLabel.setLabelFor(layoutCombo); 333 org.openide.awt.Mnemonics.setLocalizedText(layoutLabel, org.openide.util.NbBundle.getMessage(MessageAuthentication.class, "LBL_LayoutLabel")); 335 layoutCombo.addActionListener(new java.awt.event.ActionListener () { 336 public void actionPerformed(java.awt.event.ActionEvent evt) { 337 layoutComboActionPerformed(evt); 338 } 339 }); 340 341 org.openide.awt.Mnemonics.setLocalizedText(encryptSignatureChBox, org.openide.util.NbBundle.getMessage(MessageAuthentication.class, "LBL_EncryptSignatureLabel")); encryptSignatureChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 343 encryptSignatureChBox.setMargin(new java.awt.Insets (0, 0, 0, 0)); 344 encryptSignatureChBox.addActionListener(new java.awt.event.ActionListener () { 345 public void actionPerformed(java.awt.event.ActionEvent evt) { 346 encryptSignatureChBox(evt); 347 } 348 }); 349 350 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); 351 this.setLayout(layout); 352 layout.setHorizontalGroup( 353 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 354 .add(layout.createSequentialGroup() 355 .addContainerGap() 356 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 357 .add(reqSigConfChBox) 358 .add(secConvChBox) 359 .add(derivedKeysSecConvChBox) 360 .add(encryptSignatureChBox) 361 .add(layout.createSequentialGroup() 362 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 363 .add(layoutLabel) 364 .add(supportTokenLabel) 365 .add(wssVersionLabel) 366 .add(algoSuiteLabel)) 367 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 368 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 369 .add(algoSuiteCombo, 0, 145, Short.MAX_VALUE) 370 .add(layoutCombo, 0, 145, Short.MAX_VALUE) 371 .add(wssVersionCombo, 0, 145, Short.MAX_VALUE) 372 .add(supportTokenCombo, 0, 145, Short.MAX_VALUE)))) 373 .addContainerGap()) 374 ); 375 376 layout.linkSize(new java.awt.Component [] {algoSuiteCombo, layoutCombo, supportTokenCombo, wssVersionCombo}, org.jdesktop.layout.GroupLayout.HORIZONTAL); 377 378 layout.setVerticalGroup( 379 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 380 .add(layout.createSequentialGroup() 381 .addContainerGap() 382 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 383 .add(supportTokenLabel) 384 .add(supportTokenCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 385 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 386 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 387 .add(wssVersionLabel) 388 .add(wssVersionCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 389 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 390 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 391 .add(algoSuiteLabel) 392 .add(algoSuiteCombo, 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(layoutLabel) 396 .add(layoutCombo, 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(secConvChBox) 399 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 400 .add(derivedKeysSecConvChBox) 401 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 402 .add(reqSigConfChBox) 403 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 404 .add(encryptSignatureChBox) 405 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 406 ); 407 408 layout.linkSize(new java.awt.Component [] {algoSuiteCombo, layoutCombo, supportTokenCombo, wssVersionCombo}, org.jdesktop.layout.GroupLayout.VERTICAL); 409 410 } 412 private void reqSigConfChBoxActionPerformed(java.awt.event.ActionEvent evt) { setValue(reqSigConfChBox); 414 } 416 private void derivedKeysSecConvChBoxActionPerformed(java.awt.event.ActionEvent evt) { setValue(derivedKeysSecConvChBox); 418 } 420 private void secConvChBoxActionPerformed(java.awt.event.ActionEvent evt) { setValue(secConvChBox); 422 } 424 private void wssVersionComboActionPerformed(java.awt.event.ActionEvent evt) { setValue(wssVersionCombo); 426 } 428 private void supportTokenComboActionPerformed(java.awt.event.ActionEvent evt) { setValue(supportTokenCombo); 430 } 432 private void encryptSignatureChBox(java.awt.event.ActionEvent evt) { setValue(encryptSignatureChBox); 434 } 436 private void layoutComboActionPerformed(java.awt.event.ActionEvent evt) { setValue(layoutCombo); 438 } 440 private void algoSuiteComboActionPerformed(java.awt.event.ActionEvent evt) { setValue(algoSuiteCombo); 442 } 444 private javax.swing.JComboBox algoSuiteCombo; 446 private javax.swing.JLabel algoSuiteLabel; 447 private javax.swing.JCheckBox derivedKeysSecConvChBox; 448 private javax.swing.JCheckBox encryptSignatureChBox; 449 private javax.swing.JComboBox layoutCombo; 450 private javax.swing.JLabel layoutLabel; 451 private javax.swing.JCheckBox reqSigConfChBox; 452 private javax.swing.JCheckBox secConvChBox; 453 private javax.swing.JComboBox supportTokenCombo; 454 private javax.swing.JLabel supportTokenLabel; 455 private javax.swing.JComboBox wssVersionCombo; 456 private javax.swing.JLabel wssVersionLabel; 457 459 } 460 | Popular Tags |