1 anusha.kandepu 1.1 //%LICENSE////////////////////////////////////////////////////////////////
2 //
3 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 anusha.kandepu 1.1 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 //////////////////////////////////////////////////////////////////////////
29 //
30 //%/////////////////////////////////////////////////////////////////////////////
31 #ifndef Pegasus_ExportClient_Interface_h
32 #define Pegasus_ExportClient_Interface_h
33
34 #include <Pegasus/Common/String.h>
35 #include <Pegasus/Common/MessageQueue.h>
36 #include <Pegasus/Common/SSLContext.h>
|
37 anusha.kandepu 1.3 #ifdef PEGASUS_ENABLE_PROTOCOL_WSMAN
|
38 anusha.kandepu 1.1 #include <Pegasus/ExportClient/WSMANExportRequestEncoder.h>
|
39 anusha.kandepu 1.3 #include <Pegasus/ExportClient/WSMANExportResponseDecoder.h>
40 #endif
|
41 anusha.kandepu 1.1 #include <Pegasus/ExportClient/CIMExportRequestEncoder.h>
42 #include <Pegasus/Common/Config.h>
43 #include <Pegasus/Common/CIMName.h>
44 #include <Pegasus/Common/Monitor.h>
45 #include <Pegasus/Common/HTTPConnector.h>
46 #include <Pegasus/Common/CIMMessage.h>
47 #include <Pegasus/Common/HTTPConnection.h>
48 #include <Pegasus/Common/CIMObject.h>
49 #include <Pegasus/Common/Exception.h>
50 #include <Pegasus/Common/ContentLanguageList.h>
51 #include <Pegasus/Common/AutoPtr.h>
52 #include <Pegasus/Client/ClientAuthenticator.h>
53 #include <Pegasus/ExportClient/Linkage.h>
54 #include <Pegasus/ExportClient/CIMExportResponseDecoder.h>
55
56
57 PEGASUS_NAMESPACE_BEGIN
58
59 class PEGASUS_EXPORT_CLIENT_LINKAGE ExportClient : public MessageQueue
60 {
61 public:
62 anusha.kandepu 1.1 ExportClient(
63 const char* queueId,
64 HTTPConnector* httpConnector,
|
65 anusha.kandepu 1.3 Uint32 timeoutMilliseconds,
66 Monitor* monitor);
|
67 anusha.kandepu 1.1
68 virtual ~ExportClient();
69
70 /**
71 Creates an HTTP connection with the server
72 defined by the host and portNumber.
73 @param host String defining the server to which the client should
74 connect.
75 @param portNumber Uint32 defining the port number for the server
76 to which the client should connect.
77 @exception AlreadyConnectedException
78 If a connection has already been established.
79 @exception InvalidLocatorException
80 If the specified address is improperly formed.
81 @exception CannotCreateSocketException
82 If a socket cannot be created.
83 @exception CannotConnectException
84 If the socket connection fails.
85 */
86 virtual void connect(
87 const String& host,
88 anusha.kandepu 1.1 const Uint32 portNumber);
89
90 /**
|
91 dev.meetei 1.2 Creates an HTTPS connection with a Listener defined by
|
92 anusha.kandepu 1.1 the host and portNumber.
93 @param host String defining the hostname of the listener.
94 @param portNumber Uint32 defining the port number of the listener.
95 @param sslContext SSL context to use for this connection.
96 @exception AlreadyConnectedException
97 If a connection has already been established.
98 @exception InvalidLocatorException
99 If the specified address is improperly formed.
100 @exception CannotCreateSocketException
101 If a socket cannot be created.
102 @exception CannotConnectException
103 If the socket connection fails.
104 */
105 virtual void connect(
106 const String& host,
107 const Uint32 portNumber,
108 const SSLContext& sslContext);
109
110 /**
111 Closes the connection with the server if the connection
112 was open, simply returns if the connection was not open. Clients are
113 anusha.kandepu 1.1 expected to use this method to close the open connection before
114 opening a new connection.
115 */
116 virtual void disconnect();
117
118 /**
119 Gets the timeout in milliseconds for the CIMExportClient.
120 Default is 20 seconds (20000 milliseconds).
121 */
122 Uint32 getTimeout() const
123 {
124 return _timeoutMilliseconds;
125 }
126
127 /**
128 Sets the timeout in milliseconds for the CIMExportClient.
129 @param timeoutMilliseconds Defines the number of milliseconds the
130 CIMExportClient will wait for a response to an outstanding request.
131 If a request times out, the connection gets reset (disconnected and
132 reconnected). Default is 20 seconds (20000 milliseconds).
133 */
134 anusha.kandepu 1.1 void setTimeout(Uint32 timeoutMilliseconds)
135 {
136 _timeoutMilliseconds = timeoutMilliseconds;
137 if ((_connected) && (_httpConnection != 0))
138 {
139 _httpConnection->setSocketWriteTimeout(_timeoutMilliseconds/1000+1);
140 }
141 }
142
143
144 void _connect();
145 void _disconnect();
146
147 HTTPConnector* _httpConnector;
|
148 anusha.kandepu 1.3 Monitor* _monitor;
|
149 anusha.kandepu 1.1 Uint32 _timeoutMilliseconds;
150 Boolean _connected;
151 HTTPConnection* _httpConnection;
|
152 anusha.kandepu 1.3 #ifdef PEGASUS_ENABLE_PROTOCOL_WSMAN
|
153 anusha.kandepu 1.1 WSMANExportRequestEncoder* _wsmanRequestEncoder;
|
154 anusha.kandepu 1.3 WSMANExportResponseDecoder* _wsmanResponseDecoder;
155 #endif
|
156 anusha.kandepu 1.1 CIMExportRequestEncoder* _cimRequestEncoder;
|
157 anusha.kandepu 1.3 CIMExportResponseDecoder* _cimResponseDecoder;
|
158 anusha.kandepu 1.1 ClientAuthenticator _authenticator;
159 String _connectHost;
160 Uint32 _connectPortNumber;
161 /**
162 The CIMExportClient uses a lazy reconnect algorithm. A reconnection
163 is necessary when the server (listener) sends a Connection: Close
164 header in the HTTP response or when a connection timeout occurs
165 while waiting for a response. In these cases, a disconnect is
166 performed immediately and the _doReconnect flag is set. The
167 connection is re-established only when required to perform another
168 operation. Note that in the case of a connection timeout, the
169 challenge status must be reset in the ClientAuthenticator to allow
170 authentication to be performed properly on the new connection.
171 */
172
173 Boolean _doReconnect;
174 AutoPtr<SSLContext> _connectSSLContext;
175 //This flag is to indicate whether this is WSMANExport indication request
176 // or CIMExportIndication request. If this falg is true it is WSMAN
177 // otherwise it is CIMExportIndication request.
178 Boolean isWSMANExportIndication;
179 anusha.kandepu 1.1
180
181 };
182
183 PEGASUS_NAMESPACE_END
184
185 #endif /* Pegasus_ExportClient_Interface_h */
186
|