2 * Copyright 2001-2006 Internet2
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @file xmltooling/soap/SOAPTransport.h
20 * Encapsulates a transport layer protocol for sending/receiving messages.
23 #ifndef __xmltooling_soaptrans_h__
24 #define __xmltooling_soaptrans_h__
26 #include <xmltooling/base.h>
29 namespace xmlsignature {
30 class XMLTOOL_API CredentialResolver;
31 class XMLTOOL_API KeyResolver;
34 namespace xmltooling {
36 class XMLTOOL_API X509TrustEngine;
39 * Encapsulates a transport layer protocol for sending/receiving messages.
41 * Most of the methods are const, meaning they don't affect the transport
42 * layer until the data is sent.
44 class XMLTOOL_API SOAPTransport
46 MAKE_NONCOPYABLE(SOAPTransport);
50 virtual ~SOAPTransport() {}
53 * Sets the connection timeout.
55 * @param timeout time to wait for connection to server in seconds, or -1 for no timeout
56 * @return true iff the transport supports connection timeouts
58 virtual bool setConnectTimeout(long timeout) const=0;
61 * Sets the request timeout.
63 * @param timeout time to wait for a response in seconds, or -1 for no timeout
64 * @return true iff the transport supports request/response timeouts
66 virtual bool setTimeout(long timeout) const=0;
69 * Common types of transport authentication that may be supported.
71 enum transport_auth_t {
72 transport_auth_none = 0,
73 transport_auth_basic = 1,
74 transport_auth_digest = 2,
75 transport_auth_ntlm = 3,
76 transport_auth_gss = 4
80 * Sets a particular form of transport authentication and credentials.
82 * @param authType type of transport authentication to use
83 * @param username username for transport authentication
84 * @param password simple password/credential for transport authentication
85 * @return true iff the transport supports the indicated form of authentication
87 virtual bool setAuth(transport_auth_t authType, const char* username=NULL, const char* password=NULL) const=0;
89 #ifndef XMLTOOLING_NO_XMLSEC
91 * Provides a CredentialResolver to the transport to supply transport credentials.
92 * The lifetime of the resolver must be longer than the lifetime of this object.
94 * <p>The CredentialResolver <strong>MUST</strong> be locked by the caller.
96 * @param credResolver a locked CredentialResolver instance, or NULL
97 * @return true iff the transport supports the use of a CredentialResolver
99 virtual bool setCredentialResolver(const xmlsignature::CredentialResolver* credResolver) const=0;
102 * Provides a TrustEngine to the transport to authenticate the transport peer.
103 * The lifetime of the engine must be longer than the lifetime of this object.
105 * @param trustEngine a TrustEngine instance, or NULL
106 * @param keyResolver optional externally supplied KeyResolver, or NULL
107 * @return true iff the transport supports the use of a TrustEngine
109 virtual bool setTrustEngine(const X509TrustEngine* trustEngine, const xmlsignature::KeyResolver* keyResolver=NULL) const=0;
113 * Sends a stream of data over the transport. The function may return without
114 * having received any data, depending on the nature of the transport.
116 * @param in input stream to send
118 virtual void send(std::istream& in)=0;
121 * Returns reference to response stream. The resulting stream must be
122 * checked directly to determine whether data is available.
124 * @return reference to a stream containing the response, if any
126 virtual std::istream& receive()=0;
129 * Returns the MIME type of the response, if any.
131 * @return MIME type of response, or an empty string
133 virtual std::string getContentType() const=0;
137 * Registers SOAPTransport classes into the runtime.
139 void XMLTOOL_API registerSOAPTransports();
142 * Notifies transport infrastructure to initialize.
144 void XMLTOOL_API initSOAPTransports();
147 * Notifies transport infrastructure to shutdown.
149 void XMLTOOL_API termSOAPTransports();
153 #endif /* __xmltooling_soaptrans_h__ */