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