diff options
author | Parth Chandra <pchandra@maprtech.com> | 2015-03-16 13:38:46 -0700 |
---|---|---|
committer | Parth Chandra <pchandra@maprtech.com> | 2015-03-24 12:12:19 -0700 |
commit | 2f2338f3f8b66921d6db223064bb23ff41894486 (patch) | |
tree | d0ab27aabeaedfdb0d12cb00b0a156c0753ac687 /contrib/native/client/src/include | |
parent | e796b91aa040795c0d3b813f7379fd3ce71c51fe (diff) |
DRILL-2442: Initial implementation of C++ client support for impersonation.
Diffstat (limited to 'contrib/native/client/src/include')
-rw-r--r-- | contrib/native/client/src/include/drill/common.hpp | 32 | ||||
-rw-r--r-- | contrib/native/client/src/include/drill/drillClient.hpp | 45 |
2 files changed, 75 insertions, 2 deletions
diff --git a/contrib/native/client/src/include/drill/common.hpp b/contrib/native/client/src/include/drill/common.hpp index e149ed11d..dbfa6fec6 100644 --- a/contrib/native/client/src/include/drill/common.hpp +++ b/contrib/native/client/src/include/drill/common.hpp @@ -58,6 +58,16 @@ #endif // _WIN32 && !_WIN64 +//DEPRECATED MACRO +#if defined(__GNUC__) || defined(__llvm__) +#define DEPRECATED __attribute__((deprecated)) +#elif defined(_MSC_VER) +#define DEPRECATED __declspec(deprecated) +#else +#pragma message("WARNING: DEPRECATED not available for this compiler") +#define DEPRECATED +#endif + namespace Drill { typedef std::vector<uint8_t> DataBuf; @@ -118,6 +128,28 @@ typedef enum{ RET_FAILURE=1 } ret_t; + +// User Property Names +#define USERPROP_USERNAME "userName" +#define USERPROP_PASSWORD "password" +#define USERPROP_SCHEMA "schema" +#define USERPROP_USESSL "useSSL" // Not implemented yet +#define USERPROP_FILEPATH "pemLocation" // Not implemented yet +#define USERPROP_FILENAME "pemFile" // Not implemented yet + +// Bitflags to describe user properties +// Used in DrillUserProperties::USER_PROPERTIES +#define USERPROP_FLAGS_SERVERPROP 0x00000001 +#define USERPROP_FLAGS_SSLPROP 0x00000002 +#define USERPROP_FLAGS_PASSWORD 0x00000004 +#define USERPROP_FLAGS_FILENAME 0x00000008 +#define USERPROP_FLAGS_FILEPATH 0x00000010 +#define USERPROP_FLAGS_STRING 0x00000020 +#define USERPROP_FLAGS_BOOLEAN 0x00000040 + +#define IS_BITSET(val, bit) \ + ((val&bit)==bit) + } // namespace Drill #endif diff --git a/contrib/native/client/src/include/drill/drillClient.hpp b/contrib/native/client/src/include/drill/drillClient.hpp index 71a5c800f..9289df3c7 100644 --- a/contrib/native/client/src/include/drill/drillClient.hpp +++ b/contrib/native/client/src/include/drill/drillClient.hpp @@ -135,6 +135,29 @@ class DECLSPEC_DRILL_CLIENT DrillClientConfig{ }; +class DECLSPEC_DRILL_CLIENT DrillUserProperties{ + public: + static const std::map<std::string, uint32_t> USER_PROPERTIES; + + DrillUserProperties(){}; + + void setProperty( std::string propName, std::string propValue){ + std::pair< std::string, std::string> in = make_pair(propName, propValue); + m_properties.push_back(in); + } + + size_t size() const { return m_properties.size(); } + + const std::string& keyAt(size_t i) const { return m_properties.at(i).first; } + + const std::string& valueAt(size_t i) const { return m_properties.at(i).second; } + + bool validate(std::string& err); + + private: + std::vector< std::pair< std::string, std::string> > m_properties; +}; + /* * Handle to the Query submitted for execution. * */ @@ -233,6 +256,15 @@ class DECLSPEC_DRILL_CLIENT DrillClient{ /** * Connect the client to a Drillbit using connection string and default schema. * + * @param[in] connectStr: connection string + * @param[in] defaultSchema: default schema (set to NULL and ignore it + * if not specified) + * @return connection status + */ + DEPRECATED connectionStatus_t connect(const char* connectStr, const char* defaultSchema=NULL); + + /* + * Connect the client to a Drillbit using connection string and a set of user properties. * The connection string format can be found in comments of * [DRILL-780](https://issues.apache.org/jira/browse/DRILL-780) * @@ -253,12 +285,21 @@ class DECLSPEC_DRILL_CLIENT DrillClient{ * local=127.0.0.1:31010 * ``` * + * User properties is a set of name value pairs. The following properties are recognized: + * schema + * userName + * password + * useSSL [true|false] + * pemLocation + * pemFile + * (see drill/common.hpp for friendly defines and the latest list of supported proeprties) + * * @param[in] connectStr: connection string - * @param[in] defaultSchema: default schema (set to NULL and ignore it + * @param[in] properties * if not specified) * @return connection status */ - connectionStatus_t connect(const char* connectStr, const char* defaultSchema=NULL); + connectionStatus_t connect(const char* connectStr, DrillUserProperties* properties); /* test whether the client is active */ bool isActive(); |