1 19 package org.netbeans.modules.websvc.wsitconf.api; 20 21 import java.util.Collection ; 22 import javax.swing.JComponent ; 23 import javax.swing.undo.UndoManager ; 24 import org.netbeans.api.project.FileOwnerQuery; 25 import org.netbeans.api.project.Project; 26 import org.netbeans.modules.websvc.api.jaxws.client.JAXWSClientSupport; 27 import org.netbeans.modules.websvc.api.jaxws.project.config.Client; 28 import org.netbeans.modules.websvc.api.jaxws.project.config.JaxWsModel; 29 import org.netbeans.modules.websvc.api.jaxws.project.config.Service; 30 import org.netbeans.modules.websvc.wsitconf.*; 31 import org.netbeans.modules.websvc.wsitconf.ui.service.ServiceTopComponent; 32 import org.netbeans.modules.websvc.wsitconf.util.Util; 33 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.SecurityPolicyModelHelper; 34 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.WSITModelSupport; 35 import org.netbeans.modules.xml.wsdl.model.Binding; 36 import org.netbeans.modules.xml.wsdl.model.WSDLModel; 37 import org.openide.ErrorManager; 38 import org.openide.nodes.Node; 39 40 44 public final class WSITConfigProvider extends Object { 45 46 private static WSITConfigProvider instance; 47 48 private WSITConfigProvider() { } 49 50 public static synchronized WSITConfigProvider getDefault() { 51 if (instance == null) { 52 instance = new WSITConfigProvider(); 53 } 54 return instance; 55 } 56 57 64 public final JComponent getWSITServiceConfig(WSDLModel wsdlModel, UndoManager undoManager, Collection <Binding> bindings) { 65 final ServiceTopComponent stc = new ServiceTopComponent(wsdlModel, undoManager, bindings); 66 return stc; 67 } 68 69 75 public final boolean isWsitSecurityEnabled(Node node, JaxWsModel jaxWsModel) { 76 77 Client client = (Client)node.getLookup().lookup(Client.class); 79 Service service = (Service)node.getLookup().lookup(Service.class); 81 82 Project p = null; 83 if (jaxWsModel != null) { 84 p = FileOwnerQuery.getOwner(jaxWsModel.getJaxWsFile()); 85 } 86 87 if (p != null) { 88 if (Util.isWsitSupported(p)) { 89 try { 90 WSDLModel wsdlModel = WSITModelSupport.getModel(node, jaxWsModel, null, false, null); 91 if (wsdlModel != null) { 92 if (client != null) { JAXWSClientSupport wscs = JAXWSClientSupport.getJaxWsClientSupport(p.getProjectDirectory()); 94 if (wscs != null) { 95 WSDLModel serviceWsdlModel = WSITModelSupport.getServiceModelForClient(wscs, client); 96 Collection <Binding> bindings = serviceWsdlModel.getDefinitions().getBindings(); 97 for (Binding b : bindings) { 98 if (SecurityPolicyModelHelper.isSecurityEnabled(b)) { 99 return true; 100 } 101 } 102 } 103 } else if (service != null) { 104 Collection <Binding> bindings = wsdlModel.getDefinitions().getBindings(); 105 for (Binding b : bindings) { 106 if (SecurityPolicyModelHelper.isSecurityEnabled(b)) { 107 return true; 108 } 109 } 110 } 111 } 112 } catch(Exception e) { 113 ErrorManager.getDefault().notify(e); 114 } 115 } 116 } 117 return false; 118 } 119 120 126 public final boolean isWsitEnabled(Node node, JaxWsModel jaxWsModel) { 127 128 Project p = null; 129 if (jaxWsModel != null) { 130 p = FileOwnerQuery.getOwner(jaxWsModel.getJaxWsFile()); 131 } 132 133 if (p != null) { 134 if (Util.isWsitSupported(p)) { 135 try { 136 WSDLModel wsdlModel = WSITModelSupport.getModel(node, jaxWsModel, null, false, null); 137 if (wsdlModel != null) { 138 return true; 139 } 140 } catch(Exception e) { 141 ErrorManager.getDefault().notify(e); 142 } 143 } 144 } 145 return false; 146 } 147 148 } 149 | Popular Tags |