version 1.55, 2005/11/22 19:33:27
|
version 1.56, 2005/11/22 21:07:16
|
|
|
// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN _HTTP_HEADER_CONNECTION |
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
// | // |
//============================================================================== | //============================================================================== |
|
|
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
static const String _HTTP_VERSION_1_0 = "HTTP/1.0"; |
|
|
|
static const String _HTTP_METHOD_MPOST = "M-POST"; |
|
static const String _HTTP_METHOD = "POST"; |
|
|
|
static const String _HTTP_HEADER_CIMEXPORT = "CIMExport"; |
|
static const String _HTTP_HEADER_CONNECTION = "Connection"; |
|
static const String _HTTP_HEADER_CIMOPERATION = "CIMOperation"; |
|
static const String _HTTP_HEADER_ACCEPT_LANGUAGE = "Accept-Language"; |
|
static const String _HTTP_HEADER_CONTENT_LANGUAGE = "Content-Language"; |
|
static const String _HTTP_HEADER_AUTHORIZATION = "Authorization"; |
|
static const String _HTTP_HEADER_PEGASUSAUTHORIZATION = "PegasusAuthorization"; |
|
|
|
static const String _CONFIG_PARAM_ENABLEAUTHENTICATION = "enableAuthentication"; |
|
|
|
static const String _TRUE = "true"; |
| |
HTTPAuthenticatorDelegator::HTTPAuthenticatorDelegator( | HTTPAuthenticatorDelegator::HTTPAuthenticatorDelegator( |
Uint32 operationMessageQueueId, | Uint32 operationMessageQueueId, |
|
|
// | // |
// Check for Connection: Close | // Check for Connection: Close |
// | // |
if(HTTPMessage::lookupHeader(headers, "Connection", connectClose, false)) |
if(HTTPMessage::lookupHeader( |
|
headers, _HTTP_HEADER_CONNECTION, connectClose, false)) |
{ | { |
if (String::equalNoCase(connectClose, "Close")) | if (String::equalNoCase(connectClose, "Close")) |
{ | { |
|
|
String operation; | String operation; |
| |
if ( HTTPMessage::lookupHeader( | if ( HTTPMessage::lookupHeader( |
headers, "CIMOperation", operation, true) ) |
headers, _HTTP_HEADER_CIMOPERATION, operation, true) ) |
{ | { |
// | // |
// CIMOperation requests are not supported on the export connection | // CIMOperation requests are not supported on the export connection |
|
|
// is authenticated by client certificate verification. | // is authenticated by client certificate verification. |
// | // |
if ( HTTPMessage::lookupHeader( | if ( HTTPMessage::lookupHeader( |
headers, "CIMExport", operation, true) ) |
headers, _HTTP_HEADER_CIMEXPORT, operation, true) ) |
{ | { |
PEG_TRACE_STRING(TRC_HTTP, Tracer::LEVEL3, | PEG_TRACE_STRING(TRC_HTTP, Tracer::LEVEL3, |
"CIMExport request received on export connection"); | "CIMExport request received on export connection"); |
|
|
Boolean authenticated = false; | Boolean authenticated = false; |
| |
if (String::equal( | if (String::equal( |
configManager->getCurrentValue("enableAuthentication"), "true")) |
configManager->getCurrentValue( |
|
_CONFIG_PARAM_ENABLEAUTHENTICATION), _TRUE)) |
{ | { |
enableAuthentication = true; | enableAuthentication = true; |
| |
|
|
String acceptLanguageHeader; | String acceptLanguageHeader; |
if (HTTPMessage::lookupHeader( | if (HTTPMessage::lookupHeader( |
headers, | headers, |
"Accept-Language", |
_HTTP_HEADER_ACCEPT_LANGUAGE, |
acceptLanguageHeader, | acceptLanguageHeader, |
false) == true) | false) == true) |
{ | { |
|
|
String contentLanguageHeader; | String contentLanguageHeader; |
if (HTTPMessage::lookupHeader( | if (HTTPMessage::lookupHeader( |
headers, | headers, |
"Content-Language", |
_HTTP_HEADER_CONTENT_LANGUAGE, |
contentLanguageHeader, | contentLanguageHeader, |
false) == true) | false) == true) |
{ | { |
|
|
// | // |
// Set HTTP method for the request | // Set HTTP method for the request |
// | // |
if (methodName == "M-POST") |
if (methodName == _HTTP_METHOD_MPOST) |
{ | { |
httpMethod = HTTP_METHOD_M_POST; | httpMethod = HTTP_METHOD_M_POST; |
} | } |
| |
if (methodName != "M-POST" && methodName != "POST") |
if (methodName != _HTTP_METHOD_MPOST && methodName != _HTTP_METHOD) |
{ | { |
// Only POST and M-POST are implemented by this server | // Only POST and M-POST are implemented by this server |
_sendHttpError( | _sendHttpError( |
|
|
closeConnect); | closeConnect); |
} | } |
else if ((httpMethod == HTTP_METHOD_M_POST) && | else if ((httpMethod == HTTP_METHOD_M_POST) && |
(httpVersion == "HTTP/1.0")) |
(httpVersion == _HTTP_VERSION_1_0)) |
{ | { |
// | // |
// M-POST method is not valid with version 1.0 | // M-POST method is not valid with version 1.0 |
|
|
// | // |
// Process M-POST and POST messages: | // Process M-POST and POST messages: |
// | // |
Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE, |
|
"HTTPAuthenticatorDelegator - M-POST/POST processing start"); |
PEG_LOGGER_TRACE(( |
|
Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE, |
|
"HTTPAuthenticatorDelegator - M-POST/POST processing start")); |
| |
httpMessage->message.append('\0'); | httpMessage->message.append('\0'); |
| |
|
|
// | // |
String authorization = String::EMPTY; | String authorization = String::EMPTY; |
| |
if ( HTTPMessage::lookupHeader( |
if ( HTTPMessage::lookupHeader(headers, |
headers, "PegasusAuthorization", authorization, false) && |
_HTTP_HEADER_PEGASUSAUTHORIZATION, authorization, false) && |
enableAuthentication | enableAuthentication |
) | ) |
{ | { |
|
|
#endif | #endif |
| |
if ( HTTPMessage::lookupHeader( | if ( HTTPMessage::lookupHeader( |
headers, "Authorization", authorization, false) && |
headers, _HTTP_HEADER_AUTHORIZATION, authorization, false) && |
enableAuthentication | enableAuthentication |
) | ) |
{ | { |
|
|
String cimOperation; | String cimOperation; |
| |
if (HTTPMessage::lookupHeader( | if (HTTPMessage::lookupHeader( |
headers, "CIMOperation", cimOperation, true)) |
headers, _HTTP_HEADER_CIMOPERATION, cimOperation, true)) |
{ | { |
Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE, |
PEG_LOGGER_TRACE((Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE, |
"HTTPAuthenticatorDelegator - CIMOperation: $0 ",cimOperation); |
"HTTPAuthenticatorDelegator - CIMOperation: $0 ",cimOperation)); |
| |
MessageQueue* queue = | MessageQueue* queue = |
MessageQueue::lookup(_operationMessageQueueId); | MessageQueue::lookup(_operationMessageQueueId); |
|
|
} | } |
} | } |
else if (HTTPMessage::lookupHeader( | else if (HTTPMessage::lookupHeader( |
headers, "CIMExport", cimOperation, true)) |
headers, _HTTP_HEADER_CIMEXPORT, cimOperation, true)) |
{ | { |
Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE, | Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE, |
"HTTPAuthenticatorDelegator - CIMExport: $0 ",cimOperation); | "HTTPAuthenticatorDelegator - CIMExport: $0 ",cimOperation); |