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