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 #include <Pegasus/ExportClient/WSMANExportRequestEncoder.h>
38 #include <Pegasus/ExportClient/CIMExportRequestEncoder.h>
39 #include <Pegasus/Common/Config.h>
40 #include <Pegasus/Common/CIMName.h>
41 #include <Pegasus/Common/Monitor.h>
42 #include <Pegasus/Common/HTTPConnector.h>
43 anusha.kandepu 1.1 #include <Pegasus/Common/CIMMessage.h>
44 #include <Pegasus/Common/HTTPConnection.h>
45 #include <Pegasus/Common/CIMObject.h>
46 #include <Pegasus/Common/Exception.h>
47 #include <Pegasus/Common/ContentLanguageList.h>
48 #include <Pegasus/Common/AutoPtr.h>
49 #include <Pegasus/Client/ClientAuthenticator.h>
50 #include <Pegasus/ExportClient/Linkage.h>
51 #include <Pegasus/ExportClient/CIMExportResponseDecoder.h>
52
53
54 PEGASUS_NAMESPACE_BEGIN
55
56 class PEGASUS_EXPORT_CLIENT_LINKAGE ExportClient : public MessageQueue
57 {
58 public:
59 ExportClient(
60 const char* queueId,
61 HTTPConnector* httpConnector,
62 Uint32 timeoutMilliseconds);
63
64 anusha.kandepu 1.1 virtual ~ExportClient();
65
66 /**
67 Creates an HTTP connection with the server
68 defined by the host and portNumber.
69 @param host String defining the server to which the client should
70 connect.
71 @param portNumber Uint32 defining the port number for the server
72 to which the client should connect.
73 @exception AlreadyConnectedException
74 If a connection has already been established.
75 @exception InvalidLocatorException
76 If the specified address is improperly formed.
77 @exception CannotCreateSocketException
78 If a socket cannot be created.
79 @exception CannotConnectException
80 If the socket connection fails.
81 */
82 virtual void connect(
83 const String& host,
84 const Uint32 portNumber);
85 anusha.kandepu 1.1
86 /**
|
88 anusha.kandepu 1.1 the host and portNumber.
89 @param host String defining the hostname of the listener.
90 @param portNumber Uint32 defining the port number of the listener.
91 @param sslContext SSL context to use for this connection.
92 @exception AlreadyConnectedException
93 If a connection has already been established.
94 @exception InvalidLocatorException
95 If the specified address is improperly formed.
96 @exception CannotCreateSocketException
97 If a socket cannot be created.
98 @exception CannotConnectException
99 If the socket connection fails.
100 */
101 virtual void connect(
102 const String& host,
103 const Uint32 portNumber,
104 const SSLContext& sslContext);
105
106 /**
107 Closes the connection with the server if the connection
108 was open, simply returns if the connection was not open. Clients are
109 anusha.kandepu 1.1 expected to use this method to close the open connection before
110 opening a new connection.
111 */
112 virtual void disconnect();
113
114 /**
115 Gets the timeout in milliseconds for the CIMExportClient.
116 Default is 20 seconds (20000 milliseconds).
117 */
118 Uint32 getTimeout() const
119 {
120 return _timeoutMilliseconds;
121 }
122
123 /**
124 Sets the timeout in milliseconds for the CIMExportClient.
125 @param timeoutMilliseconds Defines the number of milliseconds the
126 CIMExportClient will wait for a response to an outstanding request.
127 If a request times out, the connection gets reset (disconnected and
128 reconnected). Default is 20 seconds (20000 milliseconds).
129 */
130 anusha.kandepu 1.1 void setTimeout(Uint32 timeoutMilliseconds)
131 {
132 _timeoutMilliseconds = timeoutMilliseconds;
133 if ((_connected) && (_httpConnection != 0))
134 {
135 _httpConnection->setSocketWriteTimeout(_timeoutMilliseconds/1000+1);
136 }
137 }
138
139
140 void _connect();
141 void _disconnect();
142
143 HTTPConnector* _httpConnector;
144 Uint32 _timeoutMilliseconds;
145 Boolean _connected;
146 HTTPConnection* _httpConnection;
147 WSMANExportRequestEncoder* _wsmanRequestEncoder;
148 CIMExportRequestEncoder* _cimRequestEncoder;
149 CIMExportResponseDecoder* _responseDecoder;
150 ClientAuthenticator _authenticator;
151 anusha.kandepu 1.1 String _connectHost;
152 Uint32 _connectPortNumber;
153 /**
154 The CIMExportClient uses a lazy reconnect algorithm. A reconnection
155 is necessary when the server (listener) sends a Connection: Close
156 header in the HTTP response or when a connection timeout occurs
157 while waiting for a response. In these cases, a disconnect is
158 performed immediately and the _doReconnect flag is set. The
159 connection is re-established only when required to perform another
160 operation. Note that in the case of a connection timeout, the
161 challenge status must be reset in the ClientAuthenticator to allow
162 authentication to be performed properly on the new connection.
163 */
164
165 Boolean _doReconnect;
166 AutoPtr<SSLContext> _connectSSLContext;
167 //This flag is to indicate whether this is WSMANExport indication request
168 // or CIMExportIndication request. If this falg is true it is WSMAN
169 // otherwise it is CIMExportIndication request.
170 Boolean isWSMANExportIndication;
171
172 anusha.kandepu 1.1
173 };
174
175 PEGASUS_NAMESPACE_END
176
177 #endif /* Pegasus_ExportClient_Interface_h */
178
|