1 19 20 package org.netbeans.modules.websvc.wsitconf.ui.client; 21 22 import org.netbeans.modules.websvc.api.jaxws.project.config.JaxWsModel; 23 import org.netbeans.modules.websvc.wsitconf.spi.SecurityCheckerRegistry; 24 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.ProprietarySecurityPolicyModelHelper; 25 import org.netbeans.modules.xml.multiview.ui.SectionInnerPanel; 26 import org.netbeans.modules.xml.multiview.ui.SectionView; 27 import org.netbeans.modules.xml.multiview.ui.SectionVisualTheme; 28 import org.netbeans.modules.xml.wsdl.model.Binding; 29 import org.netbeans.modules.xml.wsdl.model.WSDLModel; 30 import org.openide.nodes.Node; 31 32 36 public class STSClientPanel extends SectionInnerPanel { 37 38 private WSDLModel model; 39 private Node node; 40 private Binding binding; 41 private boolean inSync = false; 42 private JaxWsModel jaxwsmodel; 43 44 public STSClientPanel(SectionView view, Node node, Binding binding, JaxWsModel jaxWsModel) { 45 super(view); 46 this.model = binding.getModel(); 47 this.node = node; 48 this.binding = binding; 49 this.jaxwsmodel = jaxWsModel; 50 51 initComponents(); 52 53 endpointLabel.setBackground(SectionVisualTheme.getDocumentBackgroundColor()); 54 endpointTextField.setBackground(SectionVisualTheme.getDocumentBackgroundColor()); 55 metadataLabel.setBackground(SectionVisualTheme.getDocumentBackgroundColor()); 56 metadataField.setBackground(SectionVisualTheme.getDocumentBackgroundColor()); 57 namespaceLabel.setBackground(SectionVisualTheme.getDocumentBackgroundColor()); 58 namespaceTextField.setBackground(SectionVisualTheme.getDocumentBackgroundColor()); 59 portNameLabel.setBackground(SectionVisualTheme.getDocumentBackgroundColor()); 60 portNameTextField.setBackground(SectionVisualTheme.getDocumentBackgroundColor()); 61 serviceNameLabel.setBackground(SectionVisualTheme.getDocumentBackgroundColor()); 62 serviceNameTextField.setBackground(SectionVisualTheme.getDocumentBackgroundColor()); 63 wsdlLocationLabel.setBackground(SectionVisualTheme.getDocumentBackgroundColor()); 64 wsdlLocationTextField.setBackground(SectionVisualTheme.getDocumentBackgroundColor()); 65 66 addImmediateModifier(endpointTextField); 67 addImmediateModifier(namespaceTextField); 68 addImmediateModifier(portNameTextField); 69 addImmediateModifier(serviceNameTextField); 70 addImmediateModifier(wsdlLocationTextField); 71 addImmediateModifier(metadataField); 72 73 sync(); 74 } 75 76 public void sync() { 77 inSync = true; 78 79 String endpoint = ProprietarySecurityPolicyModelHelper.getPreSTSEndpoint(binding); 80 if (endpoint != null) { 81 setEndpoint(endpoint); 82 } 83 84 String metadata = ProprietarySecurityPolicyModelHelper.getPreSTSMetadata(binding); 85 if (metadata != null) { 86 setMetadata(metadata); 87 } 88 89 String namespace = ProprietarySecurityPolicyModelHelper.getPreSTSNamespace(binding); 90 if (namespace != null) { 91 setNamespace(namespace); 92 } 93 94 String portName = ProprietarySecurityPolicyModelHelper.getPreSTSPortName(binding); 95 if (portName != null) { 96 setPortName(portName); 97 } 98 99 String serviceName = ProprietarySecurityPolicyModelHelper.getPreSTSServiceName(binding); 100 if (serviceName != null) { 101 setServiceName(serviceName); 102 } 103 104 String wsdlLocation = ProprietarySecurityPolicyModelHelper.getPreSTSWsdlLocation(binding); 105 if (wsdlLocation != null) { 106 setWsdlLocation(wsdlLocation); 107 } 108 109 inSync = false; 110 } 111 112 private String getEndpoint() { 113 return this.endpointTextField.getText(); 114 } 115 116 private void setEndpoint(String url) { 117 this.endpointTextField.setText(url); 118 } 119 120 private String getMetadata() { 121 return this.metadataField.getText(); 122 } 123 124 private void setMetadata(String url) { 125 this.metadataField.setText(url); 126 } 127 128 private String getNamespace() { 129 return this.namespaceTextField.getText(); 130 } 131 132 private void setNamespace(String ns) { 133 this.namespaceTextField.setText(ns); 134 } 135 136 private String getServiceName() { 137 return this.serviceNameTextField.getText(); 138 } 139 140 private void setServiceName(String sname) { 141 this.serviceNameTextField.setText(sname); 142 } 143 144 private String getPortName() { 145 return this.portNameTextField.getText(); 146 } 147 148 private void setPortName(String pname) { 149 this.portNameTextField.setText(pname); 150 } 151 152 private String getWsdlLocation() { 153 return this.wsdlLocationTextField.getText(); 154 } 155 156 private void setWsdlLocation(String wsdlLocation) { 157 this.wsdlLocationTextField.setText(wsdlLocation); 158 } 159 160 @Override 161 public void setValue(javax.swing.JComponent source, Object value) { 162 if (!inSync) { 163 if (source.equals(endpointTextField)) { 164 String endpoint = getEndpoint(); 165 if ((endpoint != null) && (endpoint.length() == 0)) { 166 ProprietarySecurityPolicyModelHelper.setPreSTSEndpoint(binding, null); 167 } else { 168 ProprietarySecurityPolicyModelHelper.setPreSTSEndpoint(binding, endpoint); 169 } 170 return; 171 } 172 173 if (source.equals(metadataField)) { 174 String metad = getMetadata(); 175 if ((metad != null) && (metad.length() == 0)) { 176 ProprietarySecurityPolicyModelHelper.setPreSTSMetadata(binding, null); 177 } else { 178 ProprietarySecurityPolicyModelHelper.setPreSTSMetadata(binding, metad); 179 } 180 return; 181 } 182 183 if (source.equals(namespaceTextField)) { 184 String ns = getNamespace(); 185 if ((ns != null) && (ns.length() == 0)) { 186 ProprietarySecurityPolicyModelHelper.setPreSTSNamespace(binding, null); 187 } else { 188 ProprietarySecurityPolicyModelHelper.setPreSTSNamespace(binding, ns); 189 } 190 return; 191 } 192 193 if (source.equals(serviceNameTextField)) { 194 String sname = getServiceName(); 195 if ((sname != null) && (sname.length() == 0)) { 196 ProprietarySecurityPolicyModelHelper.setPreSTSServiceName(binding, null); 197 } else { 198 ProprietarySecurityPolicyModelHelper.setPreSTSServiceName(binding, sname); 199 } 200 return; 201 } 202 203 if (source.equals(portNameTextField)) { 204 String pname = getPortName(); 205 if ((pname != null) && (pname.length() == 0)) { 206 ProprietarySecurityPolicyModelHelper.setPreSTSPortName(binding, null); 207 } else { 208 ProprietarySecurityPolicyModelHelper.setPreSTSPortName(binding, pname); 209 } 210 return; 211 } 212 213 if (source.equals(wsdlLocationTextField)) { 214 String wsdlLoc = getWsdlLocation(); 215 if ((wsdlLoc != null) && (wsdlLoc.length() == 0)) { 216 ProprietarySecurityPolicyModelHelper.setPreSTSWsdlLocation(binding, null); 217 } else { 218 ProprietarySecurityPolicyModelHelper.setPreSTSWsdlLocation(binding, wsdlLoc); 219 } 220 return; 221 } 222 enableDisable(); 223 } 224 } 225 226 @Override 227 public void documentChanged(javax.swing.text.JTextComponent comp, String value) { 228 enableDisable(); 229 } 230 231 @Override 232 public void rollbackValue(javax.swing.text.JTextComponent source) { 233 } 234 235 @Override 236 protected void endUIChange() { 237 } 238 239 public void linkButtonPressed(Object ddBean, String ddProperty) { 240 } 241 242 public javax.swing.JComponent getErrorComponent(String errorId) { 243 return null; 244 } 245 246 private void enableDisable() { 247 248 boolean amSec = SecurityCheckerRegistry.getDefault().isNonWsitSecurityEnabled(node, jaxwsmodel); 249 250 endpointLabel.setEnabled(!amSec); 251 endpointTextField.setEnabled(!amSec); 252 metadataField.setEnabled(!amSec); 253 metadataLabel.setEnabled(!amSec); 254 namespaceLabel.setEnabled(!amSec); 255 namespaceLabel.setEnabled(!amSec); 256 portNameLabel.setEnabled(!amSec); 257 portNameTextField.setEnabled(!amSec); 258 serviceNameLabel.setEnabled(!amSec); 259 serviceNameTextField.setEnabled(!amSec); 260 wsdlLocationLabel.setEnabled(!amSec); 261 wsdlLocationTextField.setEnabled(!amSec); 262 } 263 264 269 private void initComponents() { 271 272 endpointLabel = new javax.swing.JLabel (); 273 wsdlLocationLabel = new javax.swing.JLabel (); 274 endpointTextField = new javax.swing.JTextField (); 275 wsdlLocationTextField = new javax.swing.JTextField (); 276 serviceNameLabel = new javax.swing.JLabel (); 277 serviceNameTextField = new javax.swing.JTextField (); 278 portNameLabel = new javax.swing.JLabel (); 279 namespaceLabel = new javax.swing.JLabel (); 280 portNameTextField = new javax.swing.JTextField (); 281 namespaceTextField = new javax.swing.JTextField (); 282 metadataLabel = new javax.swing.JLabel (); 283 metadataField = new javax.swing.JTextField (); 284 285 addFocusListener(new java.awt.event.FocusAdapter () { 286 public void focusGained(java.awt.event.FocusEvent evt) { 287 formFocusGained(evt); 288 } 289 }); 290 addAncestorListener(new javax.swing.event.AncestorListener () { 291 public void ancestorMoved(javax.swing.event.AncestorEvent evt) { 292 } 293 public void ancestorAdded(javax.swing.event.AncestorEvent evt) { 294 formAncestorAdded(evt); 295 } 296 public void ancestorRemoved(javax.swing.event.AncestorEvent evt) { 297 } 298 }); 299 300 endpointLabel.setLabelFor(endpointTextField); 301 org.openide.awt.Mnemonics.setLocalizedText(endpointLabel, org.openide.util.NbBundle.getMessage(STSClientPanel.class, "LBL_STSPanel_Endpoint")); endpointLabel.setToolTipText("The maximum number of seconds the time stamp remains valid."); 303 304 wsdlLocationLabel.setLabelFor(wsdlLocationTextField); 305 org.openide.awt.Mnemonics.setLocalizedText(wsdlLocationLabel, org.openide.util.NbBundle.getMessage(STSClientPanel.class, "LBL_STSPanel_WsdlLocation")); wsdlLocationLabel.setToolTipText("The maximum number of seconds the sending clock can deviate from the receiving clock."); 307 308 endpointTextField.setHorizontalAlignment(javax.swing.JTextField.LEFT); 309 310 wsdlLocationTextField.setHorizontalAlignment(javax.swing.JTextField.LEFT); 311 312 serviceNameLabel.setLabelFor(serviceNameTextField); 313 org.openide.awt.Mnemonics.setLocalizedText(serviceNameLabel, org.openide.util.NbBundle.getMessage(STSClientPanel.class, "LBL_STSPanel_ServiceName")); 315 serviceNameTextField.setHorizontalAlignment(javax.swing.JTextField.LEFT); 316 317 portNameLabel.setLabelFor(portNameTextField); 318 org.openide.awt.Mnemonics.setLocalizedText(portNameLabel, org.openide.util.NbBundle.getMessage(STSClientPanel.class, "LBL_STSPanel_PortName")); 320 namespaceLabel.setLabelFor(namespaceTextField); 321 org.openide.awt.Mnemonics.setLocalizedText(namespaceLabel, org.openide.util.NbBundle.getMessage(STSClientPanel.class, "LBL_STSPanel_Namespace")); 323 portNameTextField.setHorizontalAlignment(javax.swing.JTextField.LEFT); 324 325 namespaceTextField.setHorizontalAlignment(javax.swing.JTextField.LEFT); 326 327 metadataLabel.setLabelFor(metadataField); 328 org.openide.awt.Mnemonics.setLocalizedText(metadataLabel, org.openide.util.NbBundle.getMessage(STSClientPanel.class, "LBL_STSPanel_Metadata")); 330 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); 331 this.setLayout(layout); 332 layout.setHorizontalGroup( 333 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 334 .add(layout.createSequentialGroup() 335 .addContainerGap() 336 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 337 .add(namespaceLabel) 338 .add(endpointLabel) 339 .add(wsdlLocationLabel) 340 .add(metadataLabel) 341 .add(serviceNameLabel) 342 .add(portNameLabel)) 343 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 344 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 345 .add(namespaceTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 383, Short.MAX_VALUE) 346 .add(portNameTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 383, Short.MAX_VALUE) 347 .add(serviceNameTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 383, Short.MAX_VALUE) 348 .add(wsdlLocationTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 383, Short.MAX_VALUE) 349 .add(endpointTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 383, Short.MAX_VALUE) 350 .add(metadataField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 383, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 351 .addContainerGap()) 352 ); 353 354 layout.linkSize(new java.awt.Component [] {endpointTextField, metadataField, namespaceTextField, portNameTextField, serviceNameTextField, wsdlLocationTextField}, org.jdesktop.layout.GroupLayout.HORIZONTAL); 355 356 layout.setVerticalGroup( 357 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 358 .add(layout.createSequentialGroup() 359 .addContainerGap() 360 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 361 .add(endpointLabel) 362 .add(endpointTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 363 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 364 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 365 .add(wsdlLocationLabel) 366 .add(wsdlLocationTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 367 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 368 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 369 .add(metadataLabel) 370 .add(metadataField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 371 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 372 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 373 .add(serviceNameLabel) 374 .add(serviceNameTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 375 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 376 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 377 .add(portNameLabel) 378 .add(portNameTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 379 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 380 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 381 .add(namespaceLabel) 382 .add(namespaceTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 383 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 384 ); 385 } 387 private void formFocusGained(java.awt.event.FocusEvent evt) { enableDisable(); 389 } 391 private void formAncestorAdded(javax.swing.event.AncestorEvent evt) { enableDisable(); 393 } 395 396 private javax.swing.JLabel endpointLabel; 398 private javax.swing.JTextField endpointTextField; 399 private javax.swing.JTextField metadataField; 400 private javax.swing.JLabel metadataLabel; 401 private javax.swing.JLabel namespaceLabel; 402 private javax.swing.JTextField namespaceTextField; 403 private javax.swing.JLabel portNameLabel; 404 private javax.swing.JTextField portNameTextField; 405 private javax.swing.JLabel serviceNameLabel; 406 private javax.swing.JTextField serviceNameTextField; 407 private javax.swing.JLabel wsdlLocationLabel; 408 private javax.swing.JTextField wsdlLocationTextField; 409 411 } 412 | Popular Tags |