1 karl 1.41 //%2006////////////////////////////////////////////////////////////////////////
|
2 mike 1.2 //
|
3 karl 1.35 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 karl 1.25 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.35 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.37 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.41 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 mike 1.2 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
15 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
18 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
|
20 kumpf 1.15 //
|
21 mike 1.2 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 //%/////////////////////////////////////////////////////////////////////////////
33
34 #include <Pegasus/Common/Config.h>
35 #include <iostream>
|
36 kumpf 1.9 #include <Pegasus/Common/Constants.h>
|
37 mike 1.2 #include <Pegasus/Common/XmlParser.h>
38 #include <Pegasus/Common/XmlReader.h>
39 #include <Pegasus/Common/System.h>
40 #include <Pegasus/Common/XmlWriter.h>
41 #include <Pegasus/Common/HTTPMessage.h>
42 #include <Pegasus/Common/CIMMessage.h>
|
43 kumpf 1.19 #include <Pegasus/Common/Exception.h>
|
44 mike 1.2 #include "CIMExportResponseDecoder.h"
45
|
46 humberto 1.22 // l10n
47 #include <Pegasus/Common/MessageLoader.h>
48
|
49 mike 1.2 PEGASUS_USING_STD;
50
51 PEGASUS_NAMESPACE_BEGIN
52
53 CIMExportResponseDecoder::CIMExportResponseDecoder(
|
54 kumpf 1.49 MessageQueue* outputQueue,
55 MessageQueue* encoderQueue,
56 ClientAuthenticator* authenticator)
57 : MessageQueue(PEGASUS_QUEUENAME_EXPORTRESPDECODER),
58 _outputQueue(outputQueue),
59 _encoderQueue(encoderQueue),
60 _authenticator(authenticator)
|
61 mike 1.2 {
|
62 kumpf 1.49 PEG_METHOD_ENTER(TRC_EXPORT_CLIENT,
63 "CIMExportResponseDecoder::CIMExportResponseDecoder()");
|
64 kumpf 1.32 PEG_METHOD_EXIT();
|
65 mike 1.2 }
66
67 CIMExportResponseDecoder::~CIMExportResponseDecoder()
68 {
|
69 kumpf 1.49 PEG_METHOD_ENTER(TRC_EXPORT_CLIENT,
70 "CIMExportResponseDecoder::~CIMExportResponseDecoder()");
|
71 a.arora 1.31 _outputQueue.release();
72 _encoderQueue.release();
73 _authenticator.release();
|
74 kumpf 1.32 PEG_METHOD_EXIT();
|
75 mike 1.2 }
76
|
77 kumpf 1.49 void CIMExportResponseDecoder::setEncoderQueue(MessageQueue* encoderQueue)
|
78 mike 1.2 {
|
79 kumpf 1.49 PEG_METHOD_ENTER(TRC_EXPORT_CLIENT,
80 "CIMExportResponseDecoder::setEncoderQueue()");
81 _encoderQueue.release();
82 _encoderQueue.reset(encoderQueue);
83 PEG_METHOD_EXIT();
|
84 mike 1.2 }
85
|
86 kumpf 1.19 void CIMExportResponseDecoder::handleEnqueue()
|
87 mike 1.2 {
|
88 kumpf 1.49 PEG_METHOD_ENTER(TRC_EXPORT_CLIENT,
89 "CIMExportResponseDecoder::handleEnqueue()");
90 Message* message = dequeue();
91
92 PEGASUS_ASSERT(message != 0);
|
93 kumpf 1.19
|
94 kumpf 1.49 switch (message->getType())
95 {
96 case HTTP_MESSAGE:
97 {
98 HTTPMessage* httpMessage = (HTTPMessage*)message;
99 _handleHTTPMessage(httpMessage);
100 break;
101 }
102
103 default:
104 PEGASUS_ASSERT(0);
105 break;
106 }
|
107 mike 1.2
|
108 kumpf 1.49 delete message;
109 PEG_METHOD_EXIT();
|
110 mday 1.4 }
|
111 mike 1.2
112 void CIMExportResponseDecoder::_handleHTTPMessage(HTTPMessage* httpMessage)
113 {
|
114 kumpf 1.49 PEG_METHOD_ENTER(TRC_EXPORT_CLIENT,
|
115 carolann.graves 1.48 "CIMExportResponseDecoder::_handleHTTPMessage()");
|
116 mday 1.4
|
117 j.alex 1.38 //
|
118 carolann.graves 1.48 // Parse the HTTP CIM Export response message
|
119 j.alex 1.38 //
|
120 carolann.graves 1.48 ClientExceptionMessage* exceptionMessage;
121 char* content;
122 Array<HTTPHeader> headers;
123 Uint32 contentLength;
124 Uint32 statusCode;
125 String reasonPhrase;
126 Boolean cimReconnect;
127 Boolean valid;
128 HTTPExportResponseDecoder::parseHTTPHeaders(httpMessage, exceptionMessage,
129 headers, contentLength, statusCode, reasonPhrase, cimReconnect, valid);
|
130 mday 1.4
|
131 kumpf 1.19 //
|
132 carolann.graves 1.48 // Return exception on any parse errors from the HTTP export response
133 // message
|
134 kumpf 1.19 //
|
135 carolann.graves 1.48 if (!valid)
|
136 kumpf 1.19 {
|
137 carolann.graves 1.48 _outputQueue->enqueue(exceptionMessage);
138 PEG_METHOD_EXIT();
139 return;
|
140 kumpf 1.19 }
|
141 mday 1.4
|
142 kumpf 1.49 try
143 {
144 if (_authenticator->checkResponseHeaderForChallenge(headers))
145 {
146 //
147 // Get the original request, put that in the encoder's queue for
148 // re-sending with authentication challenge response.
149 //
150
151 Message* reqMessage = _authenticator->releaseRequestMessage();
152
153 if (cimReconnect == true)
154 {
155 reqMessage->setCloseConnect(cimReconnect);
156 _outputQueue->enqueue(reqMessage);
157 }
158 else
159 {
160 _encoderQueue->enqueue(reqMessage);
161 }
162
163 kumpf 1.49 PEG_METHOD_EXIT();
164 return;
165 }
166 else
167 {
168 //
169 // Received a valid/error response from the server.
170 // We do not need the original request message anymore, hence
171 // delete the request message by getting the handle from the
172 // ClientAuthenticator.
173 //
174 Message* reqMessage = _authenticator->releaseRequestMessage();
175 delete reqMessage;
176 }
|
177 kumpf 1.19 }
178 catch(InvalidAuthHeader& e)
179 {
|
180 a.arora 1.31 AutoPtr<CIMClientMalformedHTTPException> malformedHTTPException(
181 new CIMClientMalformedHTTPException(e.getMessage()));
182 AutoPtr<ClientExceptionMessage> response(
183 new ClientExceptionMessage(malformedHTTPException.get()));
184
185 malformedHTTPException.release();
|
186 kumpf 1.19
|
187 j.alex 1.38 response->setCloseConnect(cimReconnect);
|
188 a.arora 1.31 _outputQueue->enqueue(response.release());
|
189 kumpf 1.32 PEG_METHOD_EXIT();
|
190 kumpf 1.19 return;
191 }
192
|
193 carolann.graves 1.48 //
194 // Validate the HTTP headers in the export response message
195 //
196 HTTPExportResponseDecoder::validateHTTPHeaders(httpMessage, headers,
197 contentLength, statusCode, cimReconnect, reasonPhrase, content,
198 exceptionMessage, valid);
|
199 kumpf 1.19
200 //
|
201 carolann.graves 1.48 // Return exception on any errors in the HTTP headers in the export
202 // response message
|
203 kumpf 1.19 //
|
204 carolann.graves 1.48 if (!valid)
|
205 kumpf 1.19 {
|
206 carolann.graves 1.48 _outputQueue->enqueue(exceptionMessage);
|
207 kumpf 1.32 PEG_METHOD_EXIT();
|
208 kumpf 1.19 return;
209 }
|
210 mday 1.4
|
211 carolann.graves 1.48 //
212 // Decode the export response message
213 //
214 Message* responseMessage;
215 HTTPExportResponseDecoder::decodeExportResponse(content, cimReconnect,
216 responseMessage);
217 _outputQueue->enqueue(responseMessage);
|
218 mike 1.2
|
219 kumpf 1.32 PEG_METHOD_EXIT();
|
220 mike 1.2 }
221
222 PEGASUS_NAMESPACE_END
|