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 SAMLHolderOfKey extends javax.swing.JPanel { 43 44 private boolean inSync = false; 45 46 private WSDLComponent comp; 47 private WSDLModel model; 48 49 52 public SAMLHolderOfKey(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 samlVersionCombo.removeAllItems(); 66 samlVersionCombo.addItem(ComboConstants.SAML_V1010); 67 samlVersionCombo.addItem(ComboConstants.SAML_V1011); 68 samlVersionCombo.addItem(ComboConstants.SAML_V1110); 69 samlVersionCombo.addItem(ComboConstants.SAML_V1111); 70 samlVersionCombo.addItem(ComboConstants.SAML_V2011); 71 72 algoSuiteCombo.removeAllItems(); 73 algoSuiteCombo.addItem(ComboConstants.BASIC256); 74 algoSuiteCombo.addItem(ComboConstants.BASIC192); 75 algoSuiteCombo.addItem(ComboConstants.BASIC128); 76 algoSuiteCombo.addItem(ComboConstants.TRIPLEDES); 77 algoSuiteCombo.addItem(ComboConstants.BASIC256RSA15); 78 algoSuiteCombo.addItem(ComboConstants.BASIC192RSA15); 79 algoSuiteCombo.addItem(ComboConstants.BASIC128RSA15); 80 algoSuiteCombo.addItem(ComboConstants.TRIPLEDESRSA15); 81 90 inSync = false; 91 92 sync(); 93 } 94 95 private void sync() { 96 inSync = true; 97 98 WSDLComponent secBinding = null; 99 WSDLComponent topSecBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(comp); 100 WSDLComponent protTokenKind = SecurityTokensModelHelper.getTokenElement(topSecBinding, ProtectionToken.class); 101 WSDLComponent protToken = SecurityTokensModelHelper.getTokenTypeElement(protTokenKind); 102 103 boolean secConv = (protToken instanceof SecureConversationToken); 104 105 if (secConv) { 106 WSDLComponent bootPolicy = SecurityTokensModelHelper.getTokenElement(protToken, BootstrapPolicy.class); 107 secBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(bootPolicy); 108 setChBox(secConvChBox, true); 109 setChBox(derivedKeysChBox, SecurityPolicyModelHelper.isRequireDerivedKeys(protToken)); 110 setChBox(encryptSignatureChBox, SecurityPolicyModelHelper.isEncryptSignature(bootPolicy)); 111 setChBox(encryptOrderChBox, SecurityPolicyModelHelper.isEncryptBeforeSigning(bootPolicy)); 112 } else { 113 secBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(comp); 114 setChBox(secConvChBox, false); 115 setChBox(encryptSignatureChBox, SecurityPolicyModelHelper.isEncryptSignature(comp)); 116 setChBox(encryptOrderChBox, SecurityPolicyModelHelper.isEncryptBeforeSigning(comp)); 117 } 118 119 WSDLComponent tokenKind = SecurityTokensModelHelper.getTokenElement(secBinding, InitiatorToken.class); 120 WSDLComponent token = SecurityTokensModelHelper.getTokenTypeElement(tokenKind); 121 String samlVersion = SecurityTokensModelHelper.getTokenProfileVersion(token); 122 setCombo(samlVersionCombo, samlVersion); 123 124 tokenKind = SecurityTokensModelHelper.getTokenElement(secBinding, RecipientToken.class); 125 token = SecurityTokensModelHelper.getTokenTypeElement(tokenKind); 126 setChBox(reqDerivedKeys, SecurityPolicyModelHelper.isRequireDerivedKeys(token)); 127 128 setCombo(algoSuiteCombo, AlgoSuiteModelHelper.getAlgorithmSuite(secBinding)); 129 setCombo(layoutCombo, SecurityPolicyModelHelper.getMessageLayout(secBinding)); 130 131 enableDisable(); 132 133 inSync = false; 134 } 135 136 public void setValue(javax.swing.JComponent source) { 137 138 if (inSync) return; 139 140 WSDLComponent secBinding = null; 141 WSDLComponent topSecBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(comp); 142 WSDLComponent protTokenKind = SecurityTokensModelHelper.getTokenElement(topSecBinding, ProtectionToken.class); 143 WSDLComponent protToken = SecurityTokensModelHelper.getTokenTypeElement(protTokenKind); 144 145 boolean secConv = (protToken instanceof SecureConversationToken); 146 147 if (source.equals(secConvChBox)) { 148 ProfilesModelHelper.enableSecureConversation(comp, secConvChBox.isSelected(), ComboConstants.PROF_MSGAUTHSSL); 149 } 150 151 if (secConv) { 152 WSDLComponent bootPolicy = SecurityTokensModelHelper.getTokenElement(protToken, BootstrapPolicy.class); 153 secBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(bootPolicy); 154 if (source.equals(derivedKeysChBox)) { 155 SecurityPolicyModelHelper.enableRequireDerivedKeys(protToken, derivedKeysChBox.isSelected()); 156 } 157 } else { 158 secBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(comp); 159 } 160 161 if (source.equals(encryptSignatureChBox)) { 162 SecurityPolicyModelHelper.enableEncryptSignature(secBinding, encryptSignatureChBox.isSelected()); 163 if (secConv) { 164 SecurityPolicyModelHelper.enableEncryptSignature(topSecBinding, encryptSignatureChBox.isSelected()); 165 } 166 } 167 if (source.equals(encryptOrderChBox)) { 168 SecurityPolicyModelHelper.enableEncryptBeforeSigning(secBinding, encryptOrderChBox.isSelected()); 169 if (secConv) { 170 SecurityPolicyModelHelper.enableEncryptBeforeSigning(topSecBinding, encryptOrderChBox.isSelected()); 171 } 172 } 173 if (source.equals(layoutCombo)) { 174 SecurityPolicyModelHelper.setLayout(secBinding, (String ) layoutCombo.getSelectedItem()); 175 if (secConv) { 176 SecurityPolicyModelHelper.setLayout(topSecBinding, (String ) layoutCombo.getSelectedItem()); 177 } 178 } 179 if (source.equals(algoSuiteCombo)) { 180 AlgoSuiteModelHelper.setAlgorithmSuite(secBinding, (String ) algoSuiteCombo.getSelectedItem()); 181 if (secConv) { 182 AlgoSuiteModelHelper.setAlgorithmSuite(topSecBinding, (String ) algoSuiteCombo.getSelectedItem()); 183 } 184 } 185 if (source.equals(reqDerivedKeys)) { 186 WSDLComponent tokenKind = SecurityTokensModelHelper.getTokenElement(secBinding, RecipientToken.class); 187 WSDLComponent token = SecurityTokensModelHelper.getTokenTypeElement(tokenKind); 188 SecurityPolicyModelHelper.enableRequireDerivedKeys(token, reqDerivedKeys.isSelected()); 189 return; 190 } 191 if (source.equals(samlVersionCombo)) { 192 WSDLComponent tokenKind = SecurityTokensModelHelper.getTokenElement(secBinding, InitiatorToken.class); 193 WSDLComponent token = SecurityTokensModelHelper.getTokenTypeElement(tokenKind); 194 SecurityTokensModelHelper.setTokenProfileVersion(token, (String ) samlVersionCombo.getSelectedItem()); 195 } 196 197 enableDisable(); 198 } 199 200 private void enableDisable() { 201 boolean secConvEnabled = secConvChBox.isSelected(); 202 derivedKeysChBox.setEnabled(secConvEnabled); 203 boolean rmEnabled = RMModelHelper.isRMEnabled(comp); 204 if (rmEnabled) { 205 secConvChBox.setEnabled(!secConvEnabled); 206 } else { 207 secConvChBox.setEnabled(true); 208 } 209 } 210 211 private void setCombo(JComboBox combo, String item) { 212 if (item == null) { 213 combo.setSelectedIndex(0); 214 } else { 215 combo.setSelectedItem(item); 216 } 217 } 218 219 private void setCombo(JComboBox combo, boolean second) { 220 combo.setSelectedIndex(second ? 1 : 0); 221 } 222 223 private void setChBox(JCheckBox chBox, Boolean enable) { 224 if (enable == null) { 225 chBox.setSelected(false); 226 } else { 227 chBox.setSelected(enable); 228 } 229 } 230 231 236 private void initComponents() { 238 239 secConvChBox = new javax.swing.JCheckBox (); 240 derivedKeysChBox = new javax.swing.JCheckBox (); 241 algoSuiteLabel = new javax.swing.JLabel (); 242 algoSuiteCombo = new javax.swing.JComboBox (); 243 layoutLabel = new javax.swing.JLabel (); 244 layoutCombo = new javax.swing.JComboBox (); 245 encryptSignatureChBox = new javax.swing.JCheckBox (); 246 reqDerivedKeys = new javax.swing.JCheckBox (); 247 encryptOrderChBox = new javax.swing.JCheckBox (); 248 samlVersionCombo = new javax.swing.JComboBox (); 249 samlVersionLabel = new javax.swing.JLabel (); 250 251 org.openide.awt.Mnemonics.setLocalizedText(secConvChBox, org.openide.util.NbBundle.getMessage(SAMLHolderOfKey.class, "LBL_SecConvLabel")); secConvChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 253 secConvChBox.setMargin(new java.awt.Insets (0, 0, 0, 0)); 254 secConvChBox.addActionListener(new java.awt.event.ActionListener () { 255 public void actionPerformed(java.awt.event.ActionEvent evt) { 256 secConvChBoxActionPerformed(evt); 257 } 258 }); 259 260 org.openide.awt.Mnemonics.setLocalizedText(derivedKeysChBox, org.openide.util.NbBundle.getMessage(SAMLHolderOfKey.class, "LBL_RequireDerivedKeysForSecConv")); derivedKeysChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 262 derivedKeysChBox.setMargin(new java.awt.Insets (0, 0, 0, 0)); 263 derivedKeysChBox.addActionListener(new java.awt.event.ActionListener () { 264 public void actionPerformed(java.awt.event.ActionEvent evt) { 265 derivedKeysChBoxActionPerformed(evt); 266 } 267 }); 268 269 algoSuiteLabel.setLabelFor(algoSuiteCombo); 270 org.openide.awt.Mnemonics.setLocalizedText(algoSuiteLabel, org.openide.util.NbBundle.getMessage(SAMLHolderOfKey.class, "LBL_AlgoSuiteLabel")); 272 algoSuiteCombo.addActionListener(new java.awt.event.ActionListener () { 273 public void actionPerformed(java.awt.event.ActionEvent evt) { 274 algoSuiteComboActionPerformed(evt); 275 } 276 }); 277 278 layoutLabel.setLabelFor(layoutCombo); 279 org.openide.awt.Mnemonics.setLocalizedText(layoutLabel, org.openide.util.NbBundle.getMessage(SAMLHolderOfKey.class, "LBL_LayoutLabel")); 281 layoutCombo.addActionListener(new java.awt.event.ActionListener () { 282 public void actionPerformed(java.awt.event.ActionEvent evt) { 283 layoutComboActionPerformed(evt); 284 } 285 }); 286 287 org.openide.awt.Mnemonics.setLocalizedText(encryptSignatureChBox, org.openide.util.NbBundle.getMessage(SAMLHolderOfKey.class, "LBL_EncryptSignatureLabel")); encryptSignatureChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 289 encryptSignatureChBox.setMargin(new java.awt.Insets (0, 0, 0, 0)); 290 encryptSignatureChBox.addActionListener(new java.awt.event.ActionListener () { 291 public void actionPerformed(java.awt.event.ActionEvent evt) { 292 encryptSignatureChBox(evt); 293 } 294 }); 295 296 org.openide.awt.Mnemonics.setLocalizedText(reqDerivedKeys, org.openide.util.NbBundle.getMessage(SAMLHolderOfKey.class, "LBL_RequireDerivedKeys")); reqDerivedKeys.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 298 reqDerivedKeys.setMargin(new java.awt.Insets (0, 0, 0, 0)); 299 reqDerivedKeys.addActionListener(new java.awt.event.ActionListener () { 300 public void actionPerformed(java.awt.event.ActionEvent evt) { 301 reqDerivedKeysActionPerformed(evt); 302 } 303 }); 304 305 org.openide.awt.Mnemonics.setLocalizedText(encryptOrderChBox, org.openide.util.NbBundle.getMessage(SAMLHolderOfKey.class, "LBL_EncryptOrderLabel")); encryptOrderChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 307 encryptOrderChBox.setMargin(new java.awt.Insets (0, 0, 0, 0)); 308 encryptOrderChBox.addActionListener(new java.awt.event.ActionListener () { 309 public void actionPerformed(java.awt.event.ActionEvent evt) { 310 encryptOrderChBoxActionPerformed(evt); 311 } 312 }); 313 314 samlVersionCombo.addActionListener(new java.awt.event.ActionListener () { 315 public void actionPerformed(java.awt.event.ActionEvent evt) { 316 samlVersionComboActionPerformed(evt); 317 } 318 }); 319 320 samlVersionLabel.setLabelFor(samlVersionCombo); 321 org.openide.awt.Mnemonics.setLocalizedText(samlVersionLabel, org.openide.util.NbBundle.getMessage(SAMLHolderOfKey.class, "LBL_SamlVersion")); 323 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); 324 this.setLayout(layout); 325 layout.setHorizontalGroup( 326 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 327 .add(layout.createSequentialGroup() 328 .addContainerGap() 329 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) 330 .add(reqDerivedKeys) 331 .add(secConvChBox) 332 .add(derivedKeysChBox) 333 .add(encryptSignatureChBox) 334 .add(encryptOrderChBox) 335 .add(layout.createSequentialGroup() 336 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 337 .add(layoutLabel) 338 .add(algoSuiteLabel) 339 .add(samlVersionLabel)) 340 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 341 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) 342 .add(algoSuiteCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 343 .add(layoutCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 344 .add(samlVersionCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 145, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))) 345 .addContainerGap()) 346 ); 347 348 layout.linkSize(new java.awt.Component [] {algoSuiteCombo, layoutCombo, samlVersionCombo}, org.jdesktop.layout.GroupLayout.HORIZONTAL); 349 350 layout.setVerticalGroup( 351 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 352 .add(layout.createSequentialGroup() 353 .addContainerGap() 354 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 355 .add(samlVersionLabel) 356 .add(samlVersionCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 357 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 358 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 359 .add(algoSuiteLabel) 360 .add(algoSuiteCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 361 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 362 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 363 .add(layoutLabel) 364 .add(layoutCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 365 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 366 .add(reqDerivedKeys) 367 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 368 .add(secConvChBox) 369 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 370 .add(derivedKeysChBox) 371 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 372 .add(encryptSignatureChBox) 373 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 374 .add(encryptOrderChBox) 375 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 376 ); 377 378 layout.linkSize(new java.awt.Component [] {algoSuiteCombo, layoutCombo, samlVersionCombo}, org.jdesktop.layout.GroupLayout.VERTICAL); 379 380 } 382 private void samlVersionComboActionPerformed(java.awt.event.ActionEvent evt) { setValue(samlVersionCombo); 384 } 386 private void encryptOrderChBoxActionPerformed(java.awt.event.ActionEvent evt) { setValue(encryptOrderChBox); 388 } 390 private void reqDerivedKeysActionPerformed(java.awt.event.ActionEvent evt) { setValue(reqDerivedKeys); 392 } 394 private void derivedKeysChBoxActionPerformed(java.awt.event.ActionEvent evt) { setValue(derivedKeysChBox); 396 } 398 private void secConvChBoxActionPerformed(java.awt.event.ActionEvent evt) { setValue(secConvChBox); 400 } 402 private void encryptSignatureChBox(java.awt.event.ActionEvent evt) { setValue(encryptSignatureChBox); 404 } 406 private void layoutComboActionPerformed(java.awt.event.ActionEvent evt) { setValue(layoutCombo); 408 } 410 private void algoSuiteComboActionPerformed(java.awt.event.ActionEvent evt) { setValue(algoSuiteCombo); 412 } 414 private javax.swing.JComboBox algoSuiteCombo; 416 private javax.swing.JLabel algoSuiteLabel; 417 private javax.swing.JCheckBox derivedKeysChBox; 418 private javax.swing.JCheckBox encryptOrderChBox; 419 private javax.swing.JCheckBox encryptSignatureChBox; 420 private javax.swing.JComboBox layoutCombo; 421 private javax.swing.JLabel layoutLabel; 422 private javax.swing.JCheckBox reqDerivedKeys; 423 private javax.swing.JComboBox samlVersionCombo; 424 private javax.swing.JLabel samlVersionLabel; 425 private javax.swing.JCheckBox secConvChBox; 426 428 } 429 | Popular Tags |