KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > WebServiceEndpoint


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.deployment;
25
26 /**
27  * This class represents information about a web service
28  * endpoint.
29  *
30  * @author Kenneth Saks
31  */

32
33
34 import com.sun.enterprise.deployment.runtime.common.MessageSecurityBindingDescriptor;
35 import com.sun.enterprise.deployment.web.SecurityConstraint;
36 import com.sun.enterprise.deployment.web.UserDataConstraint;
37 import java.io.File JavaDoc;
38 import java.net.MalformedURLException JavaDoc;
39 import java.net.URL JavaDoc;
40 import java.util.ArrayList JavaDoc;
41 import java.util.Collection JavaDoc;
42 import java.util.Iterator JavaDoc;
43 import java.util.LinkedList JavaDoc;
44 import java.util.List JavaDoc;
45 import java.util.Set JavaDoc;
46 import javax.servlet.http.HttpServletRequest JavaDoc;
47 import javax.xml.ws.soap.SOAPBinding;
48 import javax.xml.namespace.QName JavaDoc;
49
50 import com.sun.enterprise.deployment.types.HandlerChainContainer;
51
52
53 /**
54  * Represents a single port-component in a webservice in webservices.xml
55  */

56 public class WebServiceEndpoint extends Descriptor
57         implements HandlerChainContainer {
58
59     public static final String JavaDoc TRANSPORT_NONE = "NONE";
60     public static final String JavaDoc TRANSPORT_INTEGRAL = "INTEGRAL";
61     public static final String JavaDoc TRANSPORT_CONFIDENTIAL = "CONFIDENTIAL";
62     public static final String JavaDoc CLIENT_CERT = "CLIENT-CERT";
63
64     private static final String JavaDoc PUBLISHING_SUBCONTEXT =
65         "__container$publishing$subctx";
66
67     // Unique endpoint name within all the endpoints in the same module
68
private String JavaDoc endpointName;
69
70     private String JavaDoc serviceEndpointInterface;
71
72     private QName JavaDoc wsdlPort;
73     private String JavaDoc wsdlPortNamespacePrefix;
74
75     private QName JavaDoc wsdlService;
76     private String JavaDoc wsdlServiceNamespacePrefix;
77
78     private String JavaDoc mtomEnabled = null;
79     
80     private String JavaDoc protocolBinding = null;
81     
82     // Linkage to implementing component. Must be either stateless session
83
// ejb OR servlet.
84
private String JavaDoc ejbLink;
85     private EjbDescriptor ejbComponentImpl;
86     private String JavaDoc webComponentLink;
87     private WebComponentDescriptor webComponentImpl;
88
89     // List of handlers associated with this endpoint.
90
// Handler order is important and must be preserved.
91
// This list hols the handlers specified for JAXRPC based service
92
private LinkedList JavaDoc handlers;
93     
94     // This is the handlerchain defined for JAXWS based service
95
private LinkedList JavaDoc<WebServiceHandlerChain> handlerChains;
96
97     // The web service in which this endpoint lives
98
private WebService webService;
99     
100     //
101
// Runtime information.
102
//
103

104     //
105
// Endpoint address uri is used to compose the endpoint address url
106
// through which the endpoint can be accessed. It is required for
107
// ejb endpoints and optional for servlet endpoints. This is because
108
// web application's have a standard way of mapping servlets to uris.
109
//
110
// For ejb endpoints, the uri is relative to root of the
111
// public web server (i.e. the first portion of the uri is a context root).
112
//
113
// E.g. if the web server is listening at http://localhost:8000,
114
// an endpoint address URI of StockQuoteService/StockQuotePort would result
115
// in an endpoint address of :
116
//
117
// http://localhost:8000/StockQuoteService/StockQuotePort
118
//
119
// The context root portion should not conflict with the context root
120
// of any web application.
121
//
122
// For servlet endpoints, the uri is optional. If the uri is not specified,
123
// it will be derived from the url pattern for the servlet that is
124
// implementing this endpoint. The syntax of the servlet
125
// endpoint address uri is the same as the syntax for the url-pattern
126
// element in the web.xml servlet-mapping. Note that this makes it different
127
// than the syntax for ejb endpoint uris, since the servlet endpoint uri
128
// given here will be relative to the context root of the servlet's
129
// web application.
130
//
131
private String JavaDoc endpointAddressUri;
132
133     // Optional authentication method for EJB endpoints.
134
// Auth method holds an authorization type with one of the following
135
// values : BASIC, CLIENT-CERT
136
// The BASIC constant is defined on HttpServletRequest.
137
// If set to null (default), endpoint does not perform authentication
138
private String JavaDoc authMethod;
139
140     // Optional, used by ejb endpoint only.
141
// The realm info is in web.xml for servlet endpoint.
142
private String JavaDoc realm;
143
144     // Optional control over the level of security at the transport level.
145
private String JavaDoc transportGuarantee;
146
147     // The Service QName is derived during j2eec and stored as
148
// runtime information.
149
private String JavaDoc serviceNamespaceUri;
150     private String JavaDoc serviceLocalPart;
151
152     // Only used for web components to store the name of the
153
// application-written endpoint implementation class.
154
// Derived during deployment.
155
private String JavaDoc servletImplClass;
156
157     // Derived during tie generation.
158
private String JavaDoc tieClassName;
159
160     // message-security-binding
161
private MessageSecurityBindingDescriptor messageSecBindingDesc = null;
162     
163     // should debugging be allowed on this endpoint
164
private String JavaDoc debuggingEnabled = "true";
165
166     //jbi related properties
167
private List JavaDoc props = null;
168
169     // copy constructor
170
public WebServiceEndpoint(WebServiceEndpoint other) {
171     super(other);
172     endpointName = other.endpointName; // String
173
serviceEndpointInterface = other.serviceEndpointInterface; // String
174
wsdlPort = other.wsdlPort; // QName
175
wsdlPortNamespacePrefix = other.wsdlPortNamespacePrefix;
176         wsdlService = other.wsdlService;
177     wsdlServiceNamespacePrefix = other.wsdlServiceNamespacePrefix;
178         mtomEnabled = other.mtomEnabled;
179         protocolBinding = other.protocolBinding;
180     ejbLink = other.ejbLink; // String
181
ejbComponentImpl = other.ejbComponentImpl; // EjbDescriptor copy as-is
182
webComponentLink = other.webComponentLink; // String
183
webComponentImpl = other.webComponentImpl; // WebComponentDescriptorImpl copy as-is
184
handlers = other.handlers; // copy LinkedList(WebServiceHandler)
185
if (other.handlers != null) {
186             handlers = new LinkedList JavaDoc();
187         for (Iterator JavaDoc i = other.handlers.iterator(); i.hasNext();) {
188         WebServiceHandler wsh = (WebServiceHandler)i.next();
189         handlers.addLast(new WebServiceHandler(wsh));
190         }
191     } else {
192         handlers = null;
193     }
194         if (other.handlerChains!= null) {
195             handlerChains = new LinkedList JavaDoc();
196         for (Iterator JavaDoc i = other.handlerChains.iterator(); i.hasNext();) {
197         WebServiceHandlerChain wsh = (WebServiceHandlerChain)i.next();
198         handlerChains.addLast(new WebServiceHandlerChain(wsh));
199         }
200     } else {
201         handlers = null;
202     }
203
204     webService = other.webService; // WebService copy as-is
205
endpointAddressUri = other.endpointAddressUri; // String
206
authMethod = other.authMethod; // String
207
transportGuarantee = other.transportGuarantee; // String
208
serviceNamespaceUri = other.serviceNamespaceUri; // String
209
serviceLocalPart = other.serviceLocalPart; // String
210
servletImplClass = other.servletImplClass; // String
211
tieClassName = other.tieClassName; // String
212
}
213
214     public WebServiceEndpoint() {
215         handlers = new LinkedList JavaDoc();
216         handlerChains = new LinkedList JavaDoc();
217         authMethod = null;
218         wsdlPort = null;
219     }
220
221     public void setWebService(WebService service) {
222         webService = service;
223         super.changed();
224     }
225
226     public WebService getWebService() {
227         return webService;
228     }
229
230     public void setEndpointName(String JavaDoc name) {
231         endpointName = name;
232         super.changed();
233     }
234
235     public String JavaDoc getEndpointName() {
236         return endpointName;
237     }
238
239     public void setServiceEndpointInterface(String JavaDoc endpointInterface) {
240         serviceEndpointInterface = endpointInterface;
241         super.changed();
242     }
243
244     public String JavaDoc getServiceEndpointInterface() {
245         return serviceEndpointInterface;
246     }
247
248     public void setProtocolBinding(String JavaDoc value) {
249         protocolBinding = value;
250         super.changed();
251     }
252     
253     public String JavaDoc getProtocolBinding() {
254         return ((protocolBinding==null) ?
255             javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING : protocolBinding);
256     }
257     
258     public boolean hasUserSpecifiedProtocolBinding() {
259         return ((protocolBinding==null) ? false : true);
260     }
261
262     public void setMtomEnabled(String JavaDoc value) {
263         mtomEnabled =value;
264         super.changed();
265     }
266     
267     public String JavaDoc getMtomEnabled() {
268         return mtomEnabled;
269     }
270
271     public void setWsdlService(QName JavaDoc svc, String JavaDoc prefix) {
272         wsdlService = svc;
273         wsdlServiceNamespacePrefix = prefix;
274         serviceNamespaceUri = svc.getNamespaceURI();
275         serviceLocalPart = svc.getLocalPart();
276         super.changed();
277     }
278     
279     public void setWsdlService(QName JavaDoc service) {
280         wsdlService = service;
281         wsdlServiceNamespacePrefix = service.getPrefix();
282         serviceNamespaceUri = service.getNamespaceURI();
283         serviceLocalPart = service.getLocalPart();
284         super.changed();
285     }
286     
287     public String JavaDoc getWsdlServiceNamespacePrefix() {
288         return wsdlServiceNamespacePrefix;
289     }
290
291     public boolean hasWsdlServiceNamespacePrefix() {
292         return (wsdlServiceNamespacePrefix != null);
293     }
294
295     public QName JavaDoc getWsdlService() {
296         return wsdlService;
297     }
298
299     public void setWsdlPort(QName JavaDoc port, String JavaDoc prefix) {
300         wsdlPort = port;
301         wsdlPortNamespacePrefix = prefix;
302         super.changed();
303     }
304
305     public void setWsdlPort(QName JavaDoc port) {
306         wsdlPort = port;
307         wsdlPortNamespacePrefix = port.getPrefix();
308         super.changed();
309     }
310
311     public String JavaDoc getWsdlPortNamespacePrefix() {
312         return wsdlPortNamespacePrefix;
313     }
314
315     public boolean hasWsdlPortNamespacePrefix() {
316         return (wsdlPortNamespacePrefix != null);
317     }
318
319     public boolean hasWsdlPort() {
320         return (wsdlPort != null);
321     }
322
323     public QName JavaDoc getWsdlPort() {
324         return wsdlPort;
325     }
326
327     public void setMessageSecurityBinding(
328        MessageSecurityBindingDescriptor messageSecBindingDesc) {
329        this.messageSecBindingDesc = messageSecBindingDesc;
330     }
331     
332     public MessageSecurityBindingDescriptor getMessageSecurityBinding() {
333         return messageSecBindingDesc;
334     }
335
336
337     /**
338      * Convert the contents of the ejb-link or servlet-link element to
339      * an object representing the implementation component.
340      */

341     public boolean resolveComponentLink() {
342         boolean resolved = false;
343         if( ejbLink != null ) {
344             EjbBundleDescriptor ejbBundle = getEjbBundle();
345             if( ejbBundle.hasEjbByName(ejbLink) ) {
346                 resolved = true;
347                 EjbDescriptor ejb = ejbBundle.getEjbByName(ejbLink);
348                 setEjbComponentImpl(ejb);
349             }
350         } else if( webComponentLink != null ) {
351             WebBundleDescriptor webBundle = getWebBundle();
352             WebComponentDescriptor webComponent =
353                 (WebComponentDescriptor) webBundle.
354                   getWebComponentByCanonicalName(webComponentLink);
355             if( webComponent != null ) {
356                 resolved = true;
357                 setWebComponentImpl(webComponent);
358             }
359         }
360         super.changed();
361         return resolved;
362     }
363
364     public BundleDescriptor getBundleDescriptor() {
365         return getWebService().getBundleDescriptor();
366     }
367
368     private EjbBundleDescriptor getEjbBundle() {
369         return (EjbBundleDescriptor) getBundleDescriptor();
370     }
371
372     private WebBundleDescriptor getWebBundle() {
373         return (WebBundleDescriptor) getBundleDescriptor();
374     }
375     
376     /**
377      *@return true if this endpoint is implemented by any ejb
378      */

379     public boolean implementedByEjbComponent() {
380         return (ejbLink != null);
381     }
382
383     /**
384      *@return true if this endpoint is implemented by a specific ejb
385      */

386     public boolean implementedByEjbComponent(EjbDescriptor ejb) {
387         return (ejbLink != null) && ejbLink.equals(ejb.getName());
388     }
389
390     /**
391      *@return true if this endpoint is implemented by any web component
392      */

393     public boolean implementedByWebComponent() {
394         return (webComponentLink != null);
395     }
396
397     /**
398      *@return true if this endpoint is implemented by a specific web component
399      */

400     public boolean implementedByWebComponent(WebComponentDescriptor webComp) {
401         return ( (webComponentLink != null) &&
402                  (webComponentLink.equals(webComp.getCanonicalName())) );
403     }
404
405     public String JavaDoc getLinkName() {
406         String JavaDoc linkName = null;
407         if( implementedByEjbComponent() ) {
408             linkName = ejbLink;
409         } else if( implementedByWebComponent() ) {
410             linkName = webComponentLink;
411         }
412         return linkName;
413     }
414
415     public void setEjbLink(String JavaDoc link) {
416         ejbLink = link;
417         super.changed();
418     }
419
420     public String JavaDoc getEjbLink() {
421         return ejbLink;
422     }
423
424     public void setEjbComponentImpl(EjbDescriptor ejbComponent) {
425         webComponentImpl = null;
426         webComponentLink = null;
427
428         ejbLink = ejbComponent.getName();
429         ejbComponentImpl = ejbComponent;
430         super.changed();
431     }
432
433     public EjbDescriptor getEjbComponentImpl() {
434         return ejbComponentImpl;
435     }
436
437     public void setWebComponentLink(String JavaDoc link) {
438         webComponentLink = link;
439         super.changed();
440     }
441
442     public String JavaDoc getWebComponentLink() {
443         return webComponentLink;
444     }
445
446     public void setWebComponentImpl(WebComponentDescriptor webComponent) {
447         ejbComponentImpl = null;
448         ejbLink = null;
449         webComponentLink = webComponent.getCanonicalName();
450         webComponentImpl = webComponent;
451         super.changed();
452     }
453
454     public WebComponentDescriptor getWebComponentImpl() {
455         return webComponentImpl;
456     }
457
458     /**
459      *@return true if this endpoint has at least one handler in its
460      * handler chain.
461      */

462     public boolean hasHandlers() {
463         return ( handlers.size() > 0 );
464     }
465
466     /**
467      * Append handler to end of handler chain for this endpoint.
468      */

469     public void addHandler(WebServiceHandler handler) {
470         handlers.addLast(handler);
471         super.changed();
472     }
473
474     public void removeHandler(WebServiceHandler handler) {
475         handlers.remove(handler);
476         super.changed();
477     }
478
479     public void removeHandlerByName(String JavaDoc handlerName) {
480         for(Iterator JavaDoc iter = handlers.iterator(); iter.hasNext();) {
481             WebServiceHandler next = (WebServiceHandler) iter.next();
482             if( next.getHandlerName().equals(handlerName) ) {
483                 iter.remove();
484                 super.changed();
485                 break;
486             }
487         }
488     }
489
490     /**
491      * Get ordered list of WebServiceHandler handler for this endpoint.
492      */

493     public LinkedList JavaDoc getHandlers() {
494         return handlers;
495     }
496
497     /**
498      * Get ordered list of WebServiceHandler handler chains for this endpoint.
499      */

500     public LinkedList JavaDoc<WebServiceHandlerChain> getHandlerChain() {
501         return handlerChains;
502     }
503
504     /**
505      *@return true if this endpoint has at least one handler chain
506      */

507     public boolean hasHandlerChain() {
508         return ( handlerChains.size() > 0 );
509     }
510
511     /**
512      * Append handlerchain to end of handlerchain for this endpoint.
513      */

514     public void addHandlerChain(WebServiceHandlerChain handlerChain) {
515         handlerChains.addLast(handlerChain);
516         super.changed();
517     }
518
519     public void removeHandlerChain(WebServiceHandlerChain handlerChain) {
520         handlerChains.remove(handlerChain);
521         super.changed();
522     }
523
524     //
525
// Runtime information
526
//
527

528     public boolean hasEndpointAddressUri() {
529         return (endpointAddressUri != null);
530     }
531
532     public void setEndpointAddressUri(String JavaDoc uri) {
533         endpointAddressUri = uri;
534         super.changed();
535     }
536
537     public String JavaDoc getEndpointAddressUri() {
538         return endpointAddressUri;
539     }
540
541     public boolean isSecure() {
542         return ( hasTransportGuarantee() &&
543                  (transportGuarantee.equals(TRANSPORT_INTEGRAL) ||
544                   transportGuarantee.equals(TRANSPORT_CONFIDENTIAL)) );
545     }
546
547     /**
548      * Given the root portion of a URL representing the <protocol>:<host>:<port>
549      * of the webserver, return the endpoint address used to make web
550      * service invocations on this endpoint.
551      */

552     public URL JavaDoc composeEndpointAddress(URL JavaDoc root)
553         throws MalformedURLException JavaDoc {
554            
555         String JavaDoc uri = null;
556
557         // Compose file portion of URL depending on endpoint type.
558
// The file portion of the URL MUST have a single leading slash.
559
// Note that the context root and the endpoint address uri strings
560
// from the descriptors may or may not each have a leading slash.
561
if( implementedByWebComponent() ) {
562             if (endpointAddressUri == null) {
563                 updateServletEndpointRuntime();
564             }
565             
566             // for servlets, endpoint address uri is relative to
567
// web app context root.
568
WebBundleDescriptor webBundle =
569                 webComponentImpl.getWebBundleDescriptor();
570             String JavaDoc contextRoot = webBundle.getContextRoot();
571
572             if( contextRoot != null ) {
573                 if( !contextRoot.startsWith("/") ) {
574                     contextRoot = "/" + contextRoot;
575                 }
576             
577                 uri = contextRoot +
578                     (endpointAddressUri.startsWith("/") ?
579                      endpointAddressUri : ("/" + endpointAddressUri));
580             }
581         } else {
582             if( hasEndpointAddressUri() ) {
583                 uri = endpointAddressUri.startsWith("/") ?
584                     endpointAddressUri : ("/" + endpointAddressUri);
585             } else {
586                 // we need to define a standard endpoint address
587
uri = "/" + getWebService().getName() + "/" +
588                         getEndpointName();
589                 setEndpointAddressUri(uri);
590             }
591         }
592
593         URL JavaDoc endpointAddressURL =
594             new URL JavaDoc(root.getProtocol(), root.getHost(), root.getPort(), uri);
595
596         return endpointAddressURL;
597     }
598
599     /**
600      * Generate a URL pointing to the initial wsdl document for this
601      * endpoint's web service.
602      */

603     public URL JavaDoc composeFinalWsdlUrl(URL JavaDoc root) throws MalformedURLException JavaDoc {
604         
605         // WSDL for this webservice is published in a subcontext created
606
// under the endpoint address uri. The hierarchy under there mirrors
607
// the structure of the module file in which this endpoint's
608
// webservice is defined. This allows easy retrieval of the wsdl
609
// content using jar URLs.
610
URL JavaDoc context = composeEndpointAddress(root);
611         String JavaDoc mainFile = context.getFile() + "/" +
612             PUBLISHING_SUBCONTEXT + "/" + webService.getWsdlFileUri();
613         URL JavaDoc finalWsdlUrl = new URL JavaDoc(context.getProtocol(), context.getHost(),
614                                    context.getPort(), mainFile);
615         return finalWsdlUrl;
616     }
617
618     /**
619      * This is the logical equivalent to endpoint address uri, but for
620      * url publishing. Like endpoint address uri, it does not include the
621      * context root for servlet endpoints.
622      *
623      * @return publishing uri without a leading or trailing slash.
624      */

625     public String JavaDoc getPublishingUri() {
626
627         String JavaDoc uri = endpointAddressUri.startsWith("/") ?
628             endpointAddressUri.substring(1) : endpointAddressUri;
629
630         return uri + "/" + PUBLISHING_SUBCONTEXT;
631     }
632
633     /**
634      * Checks an ejb request uri to see if it represents a legal request
635      * for the wsdl content associated with this endpoint's web service.
636      * Equivalent matching for servlets is performed automatically by the
637      * web server. Should only be called for HTTP(S) GET.
638      */

639     public boolean matchesEjbPublishRequest(String JavaDoc requestUriRaw, String JavaDoc query)
640     {
641         // Strip off leading slash.
642
String JavaDoc requestUri = (requestUriRaw.charAt(0) == '/') ?
643             requestUriRaw.substring(1) : requestUriRaw;
644             
645         boolean matches = false;
646
647         // If request of form http<s>://<host>:<port>/<endpoint-address>?WSDL
648
if( query != null ) {
649             String JavaDoc toMatch = (endpointAddressUri.charAt(0) == '/') ?
650                 endpointAddressUri.substring(1) : endpointAddressUri;
651
652             matches = (query.equalsIgnoreCase("WSDL") &&
653                        requestUri.equals(toMatch));
654         } else {
655             // Add trailing slash to make sure sub context is an exact match.
656
String JavaDoc publishingUri = getPublishingUri() + "/";
657             matches = requestUri.startsWith(publishingUri);
658         }
659         
660         return matches;
661     }
662
663     /**
664      *@return the portion of a request uri that represents the location
665      * of wsdl content within a module or null if this request is invalid.
666      * Returned value does not have leading slash.
667      */

668     public String JavaDoc getWsdlContentPath(String JavaDoc requestUri) {
669         
670         // Strip off leading slash.
671
String JavaDoc uri = (requestUri.charAt(0) == '/') ? requestUri.substring(1) :
672             requestUri;
673
674         // get "raw" internal publishing uri. this value
675
// does NOT have a leading slash.
676
String JavaDoc publishingUriRaw = getPublishingUri();
677
678         // Construct the publishing root. This should NOT have a
679
// leading slash but SHOULD have a trailing slash.
680
String JavaDoc publishingRoot = null;
681
682         if( implementedByWebComponent() ) {
683             WebBundleDescriptor webBundle =
684                 webComponentImpl.getWebBundleDescriptor();
685             String JavaDoc contextRoot = webBundle.getContextRoot();
686             if( contextRoot.startsWith("/") ) {
687                 contextRoot = contextRoot.substring(1);
688             }
689             publishingRoot = contextRoot + "/" +
690                 publishingUriRaw + "/";
691         } else {
692             publishingRoot = publishingUriRaw + "/";
693         }
694
695         String JavaDoc wsdlPath = uri.startsWith(publishingRoot) ?
696             uri.substring(publishingRoot.length()) : null;
697
698         return wsdlPath;
699     }
700
701     // Set to null to indicate "no authentication"
702
public void setAuthMethod(String JavaDoc authType) {
703         authMethod = authType;
704         super.changed();
705     }
706
707     public String JavaDoc getAuthMethod() {
708         return authMethod;
709     }
710
711     public boolean hasAuthMethod() {
712         return (authMethod != null);
713     }
714
715     public boolean hasBasicAuth() {
716         return ( (authMethod != null) &&
717                  (authMethod.equals(HttpServletRequest.BASIC_AUTH)) );
718     }
719
720     public boolean hasClientCertAuth() {
721         return ( (authMethod != null) &&
722                  (authMethod.equals(CLIENT_CERT)) );
723     }
724
725     public void setRealm(String JavaDoc realm) {
726         this.realm = realm;
727     }
728
729     public String JavaDoc getRealm() {
730         return realm;
731     }
732
733     // Set to NONE or null to indicate no transport guarantee
734
public void setTransportGuarantee(String JavaDoc guarantee) {
735         transportGuarantee = guarantee;
736         super.changed();
737     }
738
739     public String JavaDoc getTransportGuarantee() {
740         return transportGuarantee;
741     }
742
743     public boolean hasTransportGuarantee() {
744         return (transportGuarantee != null);
745     }
746
747     public void setServiceNamespaceUri(String JavaDoc uri) {
748         serviceNamespaceUri = uri;
749         super.changed();
750     }
751
752     public void setServiceLocalPart(String JavaDoc localpart) {
753         serviceLocalPart = localpart;
754         super.changed();
755     }
756
757     public boolean hasServiceName() {
758         return ((serviceNamespaceUri != null) && (serviceLocalPart != null));
759     }
760
761     /**
762      * @return service QName or null if either part of qname is not set
763      */

764     public QName JavaDoc getServiceName() {
765         // NOTE : Here we do not return getWsdlService to maintain backward
766
// compatibility with JAXRPC 1.X
767
return hasServiceName() ?
768                 new QName JavaDoc(serviceNamespaceUri, serviceLocalPart) :
769                 null;
770     }
771
772     /**
773      * Store current contents of servlet impl class in a runtime descriptor
774      * element. The standard deployment descriptor element will be replaced at
775      * deployment time with a container-provided servlet impl, so we need
776      * to make a copy of this value in the runtime information.
777      */

778     public void saveServletImplClass() {
779         if( implementedByWebComponent() ) {
780             servletImplClass = ((WebComponentDescriptor) webComponentImpl).
781                 getWebComponentImplementation();
782         } else {
783             throw new IllegalStateException JavaDoc("requires ejb");
784         }
785         super.changed();
786     }
787
788     public boolean hasServletImplClass() {
789         return (servletImplClass != null);
790     }
791
792     public void setServletImplClass(String JavaDoc implClass) {
793         servletImplClass = implClass;
794         super.changed();
795     }
796
797     public String JavaDoc getServletImplClass() {
798         return servletImplClass;
799     }
800
801     public boolean hasTieClassName() {
802         return (tieClassName != null);
803     }
804
805     public void setTieClassName(String JavaDoc tieClass) {
806         tieClassName = tieClass;
807     }
808
809     public String JavaDoc getTieClassName() {
810         return tieClassName;
811     }
812    
813     public String JavaDoc getDebugging() {
814         return debuggingEnabled;
815     }
816     
817     public void setDebugging(String JavaDoc debuggingEnabled) {
818         this.debuggingEnabled = debuggingEnabled;
819     }
820
821     public void addProperty(NameValuePairDescriptor newProp) {
822         if (props==null) {
823             props = new ArrayList JavaDoc();
824         }
825         props.add(newProp);
826     }
827
828     public Iterator JavaDoc getProperties() {
829         if (props == null) {
830             return null;
831         }
832         return props.iterator();
833     }
834     
835    private void updateServletEndpointRuntime() {
836
837         // Copy the value of the servlet impl bean class into
838
// the runtime information. This way, we'll still
839
// remember it after the servlet-class element has been
840
// replaced with the name of the container's servlet class.
841
saveServletImplClass();
842
843         WebComponentDescriptor webComp =
844             (WebComponentDescriptor) getWebComponentImpl();
845
846         WebBundleDescriptor bundle = webComp.getWebBundleDescriptor();
847         WebServicesDescriptor webServices = bundle.getWebServices();
848         Collection JavaDoc endpoints =
849             webServices.getEndpointsImplementedBy(webComp);
850
851         if( endpoints.size() > 1 ) {
852             String JavaDoc msg = "Servlet " + getWebComponentLink() +
853                 " implements " + endpoints.size() + " web service endpoints " +
854                 " but must only implement 1";
855             throw new IllegalStateException JavaDoc(msg);
856         }
857
858         if( getEndpointAddressUri() == null ) {
859             Set JavaDoc urlPatterns = webComp.getUrlPatternsSet();
860             if( urlPatterns.size() == 1 ) {
861
862                 // Set endpoint-address-uri runtime info to uri.
863
// Final endpoint address will still be relative to context root
864
String JavaDoc uri = (String JavaDoc) urlPatterns.iterator().next();
865                 setEndpointAddressUri(uri);
866
867                 // Set transport guarantee in runtime info if transport
868
// guarantee is INTEGRAL or CONDIFIDENTIAL for any
869
// security constraint with this url-pattern.
870
Collection JavaDoc constraints =
871                     bundle.getSecurityConstraintsForUrlPattern(uri);
872                 for(Iterator JavaDoc i = constraints.iterator(); i.hasNext();) {
873                     SecurityConstraint next = (SecurityConstraint) i.next();
874                         
875                     UserDataConstraint dataConstraint =
876                         next.getUserDataConstraint();
877                     String JavaDoc guarantee = (dataConstraint != null) ?
878                         dataConstraint.getTransportGuarantee() : null;
879
880                     if( (guarantee != null) &&
881                         ( guarantee.equals
882                           (UserDataConstraint.INTEGRAL_TRANSPORT) ||
883                           guarantee.equals
884                           (UserDataConstraint.CONFIDENTIAL_TRANSPORT) ) ) {
885                         setTransportGuarantee(guarantee);
886                         break;
887                     }
888                 }
889             } else {
890                 String JavaDoc msg = "Endpoint " + getEndpointName() +
891                     " has not been assigned an endpoint address " +
892                     " and is associated with servlet " +
893                     webComp.getCanonicalName() + " , which has " +
894                     urlPatterns.size() + " url patterns";
895                 throw new IllegalStateException JavaDoc(msg);
896             }
897         }
898     }
899
900      public String JavaDoc getSoapAddressPrefix() {
901          if((SOAPBinding.SOAP12HTTP_BINDING.equals(protocolBinding)) ||
902             (SOAPBinding.SOAP12HTTP_MTOM_BINDING.equals(protocolBinding)) ||
903             ("##SOAP12_HTTP".equals(protocolBinding)) ||
904             ("##SOAP12_HTTP_MTOM".equals(protocolBinding))) {
905              return "soap12";
906          }
907          // anything else should be soap11
908
return "soap";
909      }
910    
911     public void print(StringBuffer JavaDoc toStringBuffer) {
912         super.print(toStringBuffer);
913         toStringBuffer.append("\n endpoint name = ").append(endpointName);
914         toStringBuffer.append( "\n endpoint intf = ").append(serviceEndpointInterface);
915         toStringBuffer.append( "\n wsdl Port = ").append(wsdlPort);
916         toStringBuffer.append( "\n ejb Link = ").append(ejbLink);
917         toStringBuffer.append( "\n web Link = ").append(webComponentLink);
918     }
919 }
920
Popular Tags