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.SecurityPolicyModelHelper; 28 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.SecurityTokensModelHelper; 29 import org.netbeans.modules.websvc.wsitmodelext.security.WssElement; 30 import org.netbeans.modules.websvc.wsitmodelext.security.tokens.HttpsToken; 31 import org.netbeans.modules.websvc.wsitmodelext.security.tokens.TransportToken; 32 import org.netbeans.modules.xml.wsdl.model.Binding; 33 import org.netbeans.modules.xml.wsdl.model.BindingInput; 34 import org.netbeans.modules.xml.wsdl.model.BindingOperation; 35 import org.netbeans.modules.xml.wsdl.model.WSDLComponent; 36 import org.netbeans.modules.xml.wsdl.model.WSDLModel; 37 38 42 public class SAMLAuthorizationOverSSL extends javax.swing.JPanel implements ComboConstants { 43 44 private boolean inSync = false; 45 46 private WSDLComponent comp; 47 private WSDLModel model; 48 49 52 public SAMLAuthorizationOverSSL(WSDLComponent comp) { 53 super(); 54 initComponents(); 55 this.model = comp.getModel(); 56 this.comp = comp; 57 58 inSync = true; 59 samlVersionCombo.removeAllItems(); 60 samlVersionCombo.addItem(ComboConstants.SAML_V1010); 61 samlVersionCombo.addItem(ComboConstants.SAML_V1011); 62 samlVersionCombo.addItem(ComboConstants.SAML_V1110); 63 samlVersionCombo.addItem(ComboConstants.SAML_V1111); 64 samlVersionCombo.addItem(ComboConstants.SAML_V2011); 65 66 wssVersionCombo.removeAllItems(); 67 wssVersionCombo.addItem(ComboConstants.WSS10); 68 wssVersionCombo.addItem(ComboConstants.WSS11); 69 70 layoutCombo.removeAllItems(); 71 layoutCombo.addItem(ComboConstants.STRICT); 72 layoutCombo.addItem(ComboConstants.LAX); 73 layoutCombo.addItem(ComboConstants.LAXTSFIRST); 74 layoutCombo.addItem(ComboConstants.LAXTSLAST); 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 = SecurityPolicyModelHelper.getSecurityBindingTypeElement(comp); 103 104 if (comp instanceof Binding) { 105 Collection <BindingOperation> ops = ((Binding)comp).getBindingOperations(); 106 for (BindingOperation o : ops) { 107 if (!SecurityPolicyModelHelper.isSecurityEnabled(o)) { 108 BindingInput input = o.getBindingInput(); 109 WSDLComponent tokenKind = SecurityTokensModelHelper.getSupportingToken(input, SecurityTokensModelHelper.SIGNED_SUPPORTING); 110 WSDLComponent token = SecurityTokensModelHelper.getTokenTypeElement(tokenKind); 111 String samlVersion = SecurityTokensModelHelper.getTokenProfileVersion(token); 112 setCombo(samlVersionCombo, samlVersion); 113 break; 114 } 115 } 116 } else { 117 BindingInput input = ((BindingOperation)comp).getBindingInput(); 118 WSDLComponent tokenKind = SecurityTokensModelHelper.getSupportingToken(input, SecurityTokensModelHelper.SIGNED_SUPPORTING); 119 WSDLComponent token = SecurityTokensModelHelper.getTokenTypeElement(tokenKind); 120 String samlVersion = SecurityTokensModelHelper.getTokenProfileVersion(token); 121 setCombo(samlVersionCombo, samlVersion); 122 } 123 124 setCombo(wssVersionCombo, SecurityPolicyModelHelper.isWss11(comp)); 125 setCombo(algoSuiteCombo, AlgoSuiteModelHelper.getAlgorithmSuite(secBinding)); 126 setCombo(layoutCombo, SecurityPolicyModelHelper.getMessageLayout(comp)); 127 setChBox(reqSigConfChBox, SecurityPolicyModelHelper.isRequireSignatureConfirmation(comp)); 128 setChBox(encryptSignatureChBox, SecurityPolicyModelHelper.isEncryptSignature(comp)); 129 130 enableDisable(); 131 132 inSync = false; 133 } 134 135 private void enableDisable() { 136 boolean wss11 = ComboConstants.WSS11.equals(wssVersionCombo.getSelectedItem()); 137 reqSigConfChBox.setEnabled(wss11); 138 } 139 140 public void setValue(javax.swing.JComponent source) { 141 142 if (inSync) return; 143 144 WSDLComponent secBinding = SecurityPolicyModelHelper.getSecurityBindingTypeElement(comp); 145 146 if (source.equals(reqClientCertChBox)) { 147 WSDLComponent tokenKind = SecurityTokensModelHelper.getTokenElement(secBinding, TransportToken.class); 148 HttpsToken token = (HttpsToken) SecurityTokensModelHelper.getTokenTypeElement(tokenKind); 149 SecurityTokensModelHelper.setRequireClientCertificate(token, reqClientCertChBox.isSelected()); 150 } 151 if (source.equals(encryptSignatureChBox)) { 152 SecurityPolicyModelHelper.enableEncryptSignature(secBinding, encryptSignatureChBox.isSelected()); 153 } 154 if (source.equals(reqSigConfChBox)) { 155 SecurityPolicyModelHelper.enableRequireSignatureConfirmation(SecurityPolicyModelHelper.getWss11(comp), reqSigConfChBox.isSelected()); 156 } 157 if (source.equals(layoutCombo)) { 158 SecurityPolicyModelHelper.setLayout(secBinding, (String ) layoutCombo.getSelectedItem()); 159 } 160 if (source.equals(algoSuiteCombo)) { 161 AlgoSuiteModelHelper.setAlgorithmSuite(secBinding, (String ) algoSuiteCombo.getSelectedItem()); 162 } 163 if (source.equals(wssVersionCombo)) { 164 boolean wss11 = ComboConstants.WSS11.equals(wssVersionCombo.getSelectedItem()); 165 WssElement wss = SecurityPolicyModelHelper.enableWss(comp, wss11); 166 if (wss11) { 167 SecurityPolicyModelHelper.enableRequireSignatureConfirmation(SecurityPolicyModelHelper.getWss11(comp), reqSigConfChBox.isSelected()); 168 } 169 SecurityPolicyModelHelper.enableMustSupportRefKeyIdentifier(wss, true); 170 } 171 if (source.equals(samlVersionCombo)) { 172 if (comp instanceof Binding) { 173 Collection <BindingOperation> ops = ((Binding)comp).getBindingOperations(); 174 for (BindingOperation o : ops) { 175 if (!SecurityPolicyModelHelper.isSecurityEnabled(o)) { 176 BindingInput input = o.getBindingInput(); 177 WSDLComponent tokenKind = SecurityTokensModelHelper.getSupportingToken(input, 178 SecurityTokensModelHelper.SIGNED_SUPPORTING); 179 WSDLComponent token = SecurityTokensModelHelper.getTokenTypeElement(tokenKind); 180 SecurityTokensModelHelper.setTokenProfileVersion(token, (String ) samlVersionCombo.getSelectedItem()); 181 } 182 } 183 } else { 184 BindingInput input = ((BindingOperation)comp).getBindingInput(); 185 WSDLComponent token = SecurityTokensModelHelper.getSupportingToken(input, 186 SecurityTokensModelHelper.SIGNED_SUPPORTING); 187 SecurityTokensModelHelper.setTokenProfileVersion(token, (String ) samlVersionCombo.getSelectedItem()); 188 } 189 } 190 198 enableDisable(); 199 } 200 201 private void setCombo(JComboBox combo, String item) { 202 if (item == null) { 203 combo.setSelectedIndex(0); 204 } else { 205 combo.setSelectedItem(item); 206 } 207 } 208 209 private void setCombo(JComboBox combo, boolean second) { 210 combo.setSelectedIndex(second ? 1 : 0); 211 } 212 213 private void setChBox(JCheckBox chBox, Boolean enable) { 214 if (enable == null) { 215 chBox.setSelected(false); 216 } else { 217 chBox.setSelected(enable); 218 } 219 } 220 221 226 private void initComponents() { 228 229 samlVersionLabel = new javax.swing.JLabel (); 230 samlVersionCombo = new javax.swing.JComboBox (); 231 reqSigConfChBox = new javax.swing.JCheckBox (); 232 reqClientCertChBox = new javax.swing.JCheckBox (); 233 wssVersionLabel = new javax.swing.JLabel (); 234 wssVersionCombo = new javax.swing.JComboBox (); 235 algoSuiteLabel = new javax.swing.JLabel (); 236 algoSuiteCombo = new javax.swing.JComboBox (); 237 layoutLabel = new javax.swing.JLabel (); 238 layoutCombo = new javax.swing.JComboBox (); 239 encryptSignatureChBox = new javax.swing.JCheckBox (); 240 241 samlVersionLabel.setLabelFor(samlVersionCombo); 242 org.openide.awt.Mnemonics.setLocalizedText(samlVersionLabel, org.openide.util.NbBundle.getMessage(SAMLAuthorizationOverSSL.class, "LBL_SamlVersion")); 244 samlVersionCombo.addActionListener(new java.awt.event.ActionListener () { 245 public void actionPerformed(java.awt.event.ActionEvent evt) { 246 samlVersionComboActionPerformed(evt); 247 } 248 }); 249 250 org.openide.awt.Mnemonics.setLocalizedText(reqSigConfChBox, org.openide.util.NbBundle.getMessage(SAMLAuthorizationOverSSL.class, "LBL_RequireSigConfirmation")); reqSigConfChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 252 reqSigConfChBox.setMargin(new java.awt.Insets (0, 0, 0, 0)); 253 reqSigConfChBox.addActionListener(new java.awt.event.ActionListener () { 254 public void actionPerformed(java.awt.event.ActionEvent evt) { 255 reqSigConfChBoxActionPerformed(evt); 256 } 257 }); 258 259 org.openide.awt.Mnemonics.setLocalizedText(reqClientCertChBox, org.openide.util.NbBundle.getMessage(SAMLAuthorizationOverSSL.class, "LBL_RequireClientCertificate")); reqClientCertChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 261 reqClientCertChBox.setMargin(new java.awt.Insets (0, 0, 0, 0)); 262 reqClientCertChBox.addActionListener(new java.awt.event.ActionListener () { 263 public void actionPerformed(java.awt.event.ActionEvent evt) { 264 reqClientCertChBoxActionPerformed(evt); 265 } 266 }); 267 268 wssVersionLabel.setLabelFor(wssVersionCombo); 269 org.openide.awt.Mnemonics.setLocalizedText(wssVersionLabel, org.openide.util.NbBundle.getMessage(SAMLAuthorizationOverSSL.class, "LBL_WSSVersionLabel")); 271 wssVersionCombo.addActionListener(new java.awt.event.ActionListener () { 272 public void actionPerformed(java.awt.event.ActionEvent evt) { 273 wssVersionComboActionPerformed(evt); 274 } 275 }); 276 277 algoSuiteLabel.setLabelFor(algoSuiteCombo); 278 org.openide.awt.Mnemonics.setLocalizedText(algoSuiteLabel, org.openide.util.NbBundle.getMessage(SAMLAuthorizationOverSSL.class, "LBL_AlgoSuiteLabel")); 280 algoSuiteCombo.addActionListener(new java.awt.event.ActionListener () { 281 public void actionPerformed(java.awt.event.ActionEvent evt) { 282 algoSuiteComboActionPerformed(evt); 283 } 284 }); 285 286 layoutLabel.setLabelFor(layoutCombo); 287 org.openide.awt.Mnemonics.setLocalizedText(layoutLabel, org.openide.util.NbBundle.getMessage(SAMLAuthorizationOverSSL.class, "LBL_LayoutLabel")); 289 layoutCombo.addActionListener(new java.awt.event.ActionListener () { 290 public void actionPerformed(java.awt.event.ActionEvent evt) { 291 layoutComboActionPerformed(evt); 292 } 293 }); 294 295 org.openide.awt.Mnemonics.setLocalizedText(encryptSignatureChBox, org.openide.util.NbBundle.getMessage(SAMLAuthorizationOverSSL.class, "LBL_EncryptSignatureLabel")); encryptSignatureChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 297 encryptSignatureChBox.setMargin(new java.awt.Insets (0, 0, 0, 0)); 298 encryptSignatureChBox.addActionListener(new java.awt.event.ActionListener () { 299 public void actionPerformed(java.awt.event.ActionEvent evt) { 300 encryptSignatureChBox(evt); 301 } 302 }); 303 304 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); 305 this.setLayout(layout); 306 layout.setHorizontalGroup( 307 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 308 .add(layout.createSequentialGroup() 309 .addContainerGap() 310 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) 311 .add(reqClientCertChBox) 312 .add(encryptSignatureChBox) 313 .add(reqSigConfChBox) 314 .add(layout.createSequentialGroup() 315 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 316 .add(samlVersionLabel) 317 .add(wssVersionLabel) 318 .add(algoSuiteLabel) 319 .add(layoutLabel)) 320 .add(12, 12, 12) 321 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false) 322 .add(samlVersionCombo, 0, 126, Short.MAX_VALUE) 323 .add(wssVersionCombo, 0, 126, Short.MAX_VALUE) 324 .add(org.jdesktop.layout.GroupLayout.LEADING, algoSuiteCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 126, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 325 .add(org.jdesktop.layout.GroupLayout.LEADING, layoutCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 126, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))) 326 .addContainerGap()) 327 ); 328 329 layout.linkSize(new java.awt.Component [] {algoSuiteCombo, layoutCombo, samlVersionCombo, wssVersionCombo}, org.jdesktop.layout.GroupLayout.HORIZONTAL); 330 331 layout.setVerticalGroup( 332 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 333 .add(layout.createSequentialGroup() 334 .addContainerGap() 335 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 336 .add(samlVersionLabel) 337 .add(samlVersionCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 338 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 339 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 340 .add(wssVersionLabel) 341 .add(wssVersionCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 22, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 342 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 343 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 344 .add(algoSuiteLabel) 345 .add(algoSuiteCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 346 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 347 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 348 .add(layoutLabel) 349 .add(layoutCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 350 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 351 .add(reqClientCertChBox) 352 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 353 .add(reqSigConfChBox) 354 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 355 .add(encryptSignatureChBox) 356 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 357 ); 358 359 layout.linkSize(new java.awt.Component [] {algoSuiteCombo, layoutCombo, samlVersionCombo, wssVersionCombo}, org.jdesktop.layout.GroupLayout.VERTICAL); 360 361 } 363 private void reqSigConfChBoxActionPerformed(java.awt.event.ActionEvent evt) { setValue(reqSigConfChBox); 365 } 367 private void reqClientCertChBoxActionPerformed(java.awt.event.ActionEvent evt) { setValue(reqClientCertChBox); 369 } 371 private void wssVersionComboActionPerformed(java.awt.event.ActionEvent evt) { setValue(wssVersionCombo); 373 } 375 private void samlVersionComboActionPerformed(java.awt.event.ActionEvent evt) { setValue(samlVersionCombo); 377 } 379 private void encryptSignatureChBox(java.awt.event.ActionEvent evt) { setValue(encryptSignatureChBox); 381 } 383 private void layoutComboActionPerformed(java.awt.event.ActionEvent evt) { setValue(layoutCombo); 385 } 387 private void algoSuiteComboActionPerformed(java.awt.event.ActionEvent evt) { setValue(algoSuiteCombo); 389 } 391 private javax.swing.JComboBox algoSuiteCombo; 393 private javax.swing.JLabel algoSuiteLabel; 394 private javax.swing.JCheckBox encryptSignatureChBox; 395 private javax.swing.JComboBox layoutCombo; 396 private javax.swing.JLabel layoutLabel; 397 private javax.swing.JCheckBox reqClientCertChBox; 398 private javax.swing.JCheckBox reqSigConfChBox; 399 private javax.swing.JComboBox samlVersionCombo; 400 private javax.swing.JLabel samlVersionLabel; 401 private javax.swing.JComboBox wssVersionCombo; 402 private javax.swing.JLabel wssVersionLabel; 403 405 } 406 | Popular Tags |