109 lines
3.8 KiB
C++
109 lines
3.8 KiB
C++
//----------------------------------------------------------------------------
|
|
//
|
|
// Copyright (C) 2007 Intel Corporation
|
|
//
|
|
// File: WRMWsmanClient.h
|
|
//
|
|
// Contents: An implementation of the WsmanClient interface using Microsoft WinRM
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
#ifndef __WRM_WSMAN_CLIENT_H
|
|
#define __WRM_WSMAN_CLIENT_H
|
|
|
|
#include "WsmanClient.h"
|
|
#include <windows.h>
|
|
|
|
namespace WsmanClientNamespace
|
|
{
|
|
class WRMWsmanClient : public WsmanClient
|
|
{
|
|
private:
|
|
CLSID _wsmanOleClsid;
|
|
IDispatch * _pWsmanDispatch;
|
|
IDispatch * _pWsmanSessionDispatch;
|
|
IDispatch * _pWsmanConnectionOptions;
|
|
DISPID _dispPropertyPut;
|
|
DISPID _getDispid;
|
|
DISPID _putDispid;
|
|
DISPID _createDispid;
|
|
DISPID _enumerateDispid;
|
|
DISPID _invokeDispid;
|
|
DISPID _deleteDispid;
|
|
DISPID _createSessionDispid;
|
|
DISPID _createConnectionOptionsDispid;
|
|
DISPID _createResourceLocatorDispid;
|
|
long _connectionFlags;
|
|
string endpoint;
|
|
string user;
|
|
string pwd;
|
|
bool kerb;
|
|
bool Init();
|
|
void ReleaseDisps();
|
|
bool CreateSession();
|
|
bool SetConnectionOptions(wchar_t* fieldName, const string& fieldValue);
|
|
bool AddSessionFlag(wchar_t* flagName);
|
|
bool CreateConnectionOptions();
|
|
bool CreateSessionFlags();
|
|
bool GetFunctionIds();
|
|
bool GetDispId(IDispatch* disp, DISPID* id, wchar_t* name);
|
|
bool CreateResourceLocator(IDispatch** disp, const string& uri, const NameValuePairs *s) const;
|
|
bool GetEnumerationItems(IDispatch* disp, vector<string> &enumRes) const;
|
|
bool CheckForMoreItems(IDispatch* disp, DISPID& id, bool& hasItems) const;
|
|
bool AddSelectors(IDispatch* disp, const NameValuePairs *s) const;
|
|
bool AddSelector(IDispatch* disp, DISPID& selId, const string& name, const string& value) const;
|
|
// Copy constructor is declared private
|
|
WRMWsmanClient(const WRMWsmanClient& cl);
|
|
// operator = is declared private
|
|
WRMWsmanClient& operator =(const WRMWsmanClient& cl);
|
|
public:
|
|
// Construct WRMWsmanClient
|
|
// Note: The CoInitialize function must be called before calling the constructor
|
|
WRMWsmanClient(const string& endpoint,
|
|
const string& username,
|
|
const string& password,
|
|
const bool krb = false);
|
|
|
|
// Destructor.
|
|
virtual ~WRMWsmanClient();
|
|
|
|
// Identify.
|
|
virtual string Identify() const {throw exception("Function Not Supported");}
|
|
|
|
/// Creates a new instance of a resource.
|
|
string Create(const string &resourceUri, const string &data) const;
|
|
|
|
/// Delete a resource.
|
|
void Delete(const string &resourceUri, const NameValuePairs *s = NULL) const;
|
|
|
|
/// Enumerate resource.
|
|
void Enumerate(const string &resourceUri, vector<string> &enumRes, const NameValuePairs *s = NULL) const;
|
|
|
|
/// Retrieve a resource.
|
|
string Get(const string &resourceUri, const NameValuePairs *s = NULL) const;
|
|
|
|
/// Update a resource.
|
|
string Put(const string &resourceUri, const string &content, const NameValuePairs *s = NULL) const;
|
|
|
|
/// Invokes a method and returns the results of the method call.
|
|
string Invoke(const string &resourceUri, const string &methodName, const string &content, const NameValuePairs *s = NULL) const;
|
|
|
|
// Submit a subscription
|
|
string Subscribe(const string &resourceUri, const SubscribeInfo &info, string &identifier) const;
|
|
|
|
// Renew a subscription
|
|
string Renew(const string &identifier, float expire) const;
|
|
|
|
// Terminate a subscription
|
|
void Unsubscribe(const string &identifier) const;
|
|
|
|
// Renew a subscription
|
|
virtual string Renew(const string &resourceUri, const string &identifier, float expire, const NameValuePairs *s = NULL) const {throw exception("Function Not Supported");}
|
|
|
|
// Terminate a subscription
|
|
virtual void Unsubscribe(const string &resourceUri, const string &identifier, const NameValuePairs *s = NULL) const {throw exception("Function Not Supported");}
|
|
|
|
};
|
|
} // namespace WsmanClient
|
|
#endif
|