(file) Return to WbemExecClient.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Clients / wbemexec

File: [Pegasus] / pegasus / src / Clients / wbemexec / WbemExecClient.h (download)
Revision: 1.41, Tue Feb 24 11:42:25 2009 UTC (15 years, 3 months ago) by a.rachapudi
Branch: MAIN
CVS Tags: preBug9676, postBug9676, TASK_PEP317_1JUNE_2013, TASK-TASK_PEP362_RestfulService_branch-root, TASK-TASK_PEP362_RestfulService_branch-merged_out_from_trunk, TASK-TASK_PEP362_RestfulService_branch-merged_in_to_trunk, TASK-TASK_PEP362_RestfulService_branch-merged_in_from_branch, TASK-TASK_PEP362_RestfulService_branch-branch, TASK-PEP362_RestfulService-root, TASK-PEP362_RestfulService-merged_out_to_branch, TASK-PEP362_RestfulService-merged_out_from_trunk, TASK-PEP362_RestfulService-merged_in_to_trunk, TASK-PEP362_RestfulService-merged_in_from_branch, TASK-PEP362_RestfulService-branch, TASK-PEP348_SCMO-root, TASK-PEP348_SCMO-merged_out_to_branch, TASK-PEP348_SCMO-merged_out_from_trunk, TASK-PEP348_SCMO-merged_in_to_trunk, TASK-PEP348_SCMO-merged_in_from_branch, TASK-PEP348_SCMO-branch, TASK-PEP317_pullop-root, TASK-PEP317_pullop-merged_out_to_branch, TASK-PEP317_pullop-merged_out_from_trunk, TASK-PEP317_pullop-merged_in_to_trunk, TASK-PEP317_pullop-merged_in_from_branch, TASK-PEP317_pullop-branch, RELEASE_2_14_1, RELEASE_2_14_0-RC2, RELEASE_2_14_0-RC1, RELEASE_2_14_0, RELEASE_2_14-root, RELEASE_2_14-branch, RELEASE_2_13_0-RC2, RELEASE_2_13_0-RC1, RELEASE_2_13_0-FC, RELEASE_2_13_0, RELEASE_2_13-root, RELEASE_2_13-branch, RELEASE_2_12_1-RC1, RELEASE_2_12_1, RELEASE_2_12_0-RC1, RELEASE_2_12_0-FC, RELEASE_2_12_0, RELEASE_2_12-root, RELEASE_2_12-branch, RELEASE_2_11_2-RC1, RELEASE_2_11_2, RELEASE_2_11_1-RC1, RELEASE_2_11_1, RELEASE_2_11_0-RC1, RELEASE_2_11_0-FC, RELEASE_2_11_0, RELEASE_2_11-root, RELEASE_2_11-branch, RELEASE_2_10_1-RC1, RELEASE_2_10_1, RELEASE_2_10_0-RC2, RELEASE_2_10_0-RC1, RELEASE_2_10_0, RELEASE_2_10-root, RELEASE_2_10-branch, PREAUG25UPDATE, POSTAUG25UPDATE, HEAD, CIMRS_WORK_20130824, BeforeUpdateToHeadOct82011
Changes since 1.40: +16 -5 lines
BUG#: 8182
TITLE: Wbemexec handling of WMIMapper's localConnect functionality
DESCRIPTION: The Wbemexec is enhanced to handle the WMIMapper's localConnect functionality

//%LICENSE////////////////////////////////////////////////////////////////
//
// Licensed to The Open Group (TOG) under one or more contributor license
// agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
// this work for additional information regarding copyright ownership.
// Each contributor licenses this file to you under the OpenPegasus Open
// Source License; you may not use this file except in compliance with the
// License.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 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 WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////
//
//%/////////////////////////////////////////////////////////////////////////////

#ifndef Pegasus_WbemExecClient_h
#define Pegasus_WbemExecClient_h

#include <fstream>
#include <Pegasus/Common/Config.h>
#include <Pegasus/Common/String.h>
#include <Pegasus/Common/Monitor.h>
#include <Pegasus/Common/HTTPConnector.h>
#include <Pegasus/Common/HTTPConnection.h>
#include <Pegasus/Common/SSLContext.h>
#include <Pegasus/Common/Constants.h>
#include <Pegasus/Common/CIMMessage.h>
#include <Pegasus/Common/Exception.h>
#include <Pegasus/Common/AutoPtr.h>
#include <Pegasus/Client/ClientAuthenticator.h>

PEGASUS_NAMESPACE_BEGIN

/** This class provides the interface that a client uses to communicate
    with a CIMOM.
*/
class WbemExecClient : public MessageQueue
{
public:

    /** Constructor for a CIM Client object.
        @param timeoutMilliseconds Defines the number of milliseconds the
        WbemExecClient will wait for a response to an outstanding request.
        If a request times out, the connection gets reset (disconnected and
        reconnected).  Default is 20 seconds (20000 milliseconds).
    */
    WbemExecClient(Uint32 timeoutMilliseconds =
                        PEGASUS_DEFAULT_CLIENT_TIMEOUT_MILLISECONDS);

    ///
    virtual ~WbemExecClient();

    /**  TBD
    */
    // ATTN-RK-P3-20020416: This should be hidden from client apps
    virtual void handleEnqueue();

    /** TBD
    */
    Uint32 getTimeout() const
    {
      return _timeoutMilliseconds;
    }

    /** Sets the timeout in milliseconds for the WbemExecClient.
    */
    void setTimeout(Uint32 timeoutMilliseconds)
    {
      _timeoutMilliseconds = timeoutMilliseconds;
      if ((_connected) && (_httpConnection != 0))
        _httpConnection->setSocketWriteTimeout(_timeoutMilliseconds/1000+1);
    }

    /** connect - Creates an HTTP connection with the server
        defined by the URL in address.
        @param host - String defining the server to which the client should
        connect
        @param portNumber - Uint32 defining the port number for the server
        to which the client should connect
        @param userName - String containing the name of the user
        the client is connecting as.
        @param password - String containing the password of the user
        the client is connecting as.
        @return - No return defined. Failure to connect throws an exception
        @exception AlreadyConnectedException
            If a connection has already been established.
        @exception InvalidLocatorException
            If the specified address is improperly formed.
        @exception CannotCreateSocketException
            If a socket cannot be created.
        @exception CannotConnectException
            If the socket connection fails.
        <PRE>
            TBD
        </PRE>
    */
    inline void connect(
        const String& host,
        Uint32 portNumber,
        const String& userName,
        const String& password)
    {
        connect(host, portNumber, 0, userName, password);
    }

    /** connect - Creates an HTTP connection with the server
        defined by the URL in address.
        @param host - String defining the server to which the client should
        connect
        @param portNumber - Uint32 defining the port number for the server
        to which the client should connect
        @param sslContext - The SSL context to use for this connection
        @param userName - String containing the name of the user
        the client is connecting as.
        @param password - String containing the password of the user
        the client is connecting as.
        @return - No return defined. Failure to connect throws an exception
        @exception AlreadyConnectedException
            If a connection has already been established.
        @exception InvalidLocatorException
            If the specified address is improperly formed.
        @exception CannotCreateSocketException
            If a socket cannot be created.
        @exception CannotConnectException
            If the socket connection fails.
        <PRE>
            TBD
        </PRE>
    */
    void connect(
        const String& host,
        Uint32 portNumber,
        const SSLContext* sslContext,
        const String& userName,
        const String& password);

    /** connectLocal - Creates connection to the server for
        Local clients. The connectLocal connects to the CIM server
        running on the local system in the default location.  The
        connection is automatically authenticated for the current
        user.
        The connectLocal call is virtual because WMIMapper wbemexec 
        functionality defines a subclass to WbemExecClient and
        overrides this method.
        @return - No return defined. Failure to connect throws an exception.
        @see connect - The exceptions are defined in connect.
    */
    virtual void connectLocal();

    /** disconnect - Closes the connection with the server if the connection
        was open, simply returns if the connection was not open. Clients are
        expected to use this method to close the open connection before
        opening a new connection.
        The disconnect call is virtual because WMIMapper wbemexec 
        defines a subclass to WbemExecClient and overrides this method.
        @return - No return defined.
    */
    virtual void disconnect();


    /** ATTN TBD
        @exception NotConnectedException
        @exception ConnectionTimeoutException
        @exception UnauthorizedAccess
    */
    /* The WMIMapper wbemexec functionality defines a subclass to 
       WbemExecClient and overrides this method.
    */
    virtual Buffer issueRequest(const Buffer& request);

private:

    void _connect();

    /**
        The authentication challenge status is not changed by this method.
        It is designed to allow a reconnect after a challenge that contains
        a "Connection: Close" header, not for reconnecting after a connection
        timeout or after an operation response containing a "Connection: Close"
        header.  This design is sufficient because wbemexec only allows a
        single operation per invocation.
    */
    void _reconnect();

    Message* _doRequest(HTTPMessage* request);

    void _addAuthHeader(HTTPMessage*& httpMessage);

    Boolean _checkNeedToResend(const Array<HTTPHeader>& httpHeaders);

    String _promptForPassword();

    Monitor* _monitor;
    HTTPConnector* _httpConnector;
    HTTPConnection* _httpConnection;

    Uint32 _timeoutMilliseconds;
    ClientAuthenticator _authenticator;

    // Connection parameters
    String _connectHost;
    Uint32 _connectPortNumber;
    AutoPtr<SSLContext> _connectSSLContext;

    /**
        The password to be used for authorization of the operation.
     */
    String _password;

protected:
    /* The subclass can access these fields*/
    Boolean _connected;
    Boolean _isRemote;
};

PEGASUS_NAMESPACE_END

#endif /* Pegasus_WbemExecClient_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2