diff --git a/hbase-native-client/core/BUCK b/hbase-native-client/core/BUCK index e40236f..fd4c0dc 100644 --- a/hbase-native-client/core/BUCK +++ b/hbase-native-client/core/BUCK @@ -33,8 +33,6 @@ cxx_library( "meta-utils.h", "get.h", "time-range.h", - "configuration.h", - "hbase-configuration-loader.h", "scan.h", "result.h", "request-converter.h", @@ -52,8 +50,6 @@ cxx_library( "meta-utils.cc", "get.cc", "time-range.cc", - "configuration.cc", - "hbase-configuration-loader.cc", "scan.cc", "result.cc", "request-converter.cc", @@ -64,6 +60,7 @@ cxx_library( "//exceptions:exceptions", "//utils:utils", "//connection:connection", + "//core:conf", "//if:if", "//serde:serde", "//third-party:folly", @@ -74,6 +71,21 @@ cxx_library( visibility=[ 'PUBLIC', ],) +cxx_library( + name="conf", + exported_headers=[ + "configuration.h", + "hbase-configuration-loader.h", + ], + srcs=[ + "configuration.cc", + "hbase-configuration-loader.cc", + ], + deps=["//third-party:folly"], + compiler_flags=['-Weffc++', '-ggdb'], + visibility=[ + 'PUBLIC', + ],) cxx_test( name="location-cache-test", srcs=[ diff --git a/hbase-native-client/security/BUCK b/hbase-native-client/security/BUCK index d602ff3..1199797 100644 --- a/hbase-native-client/security/BUCK +++ b/hbase-native-client/security/BUCK @@ -23,6 +23,6 @@ cxx_library( "user.h", ], srcs=[], - deps=[], + deps=["//core:conf"], compiler_flags=['-Weffc++'], visibility=['//core/...', '//connection/...'],) diff --git a/hbase-native-client/security/user.h b/hbase-native-client/security/user.h index 8a15891..90fe277 100644 --- a/hbase-native-client/security/user.h +++ b/hbase-native-client/security/user.h @@ -18,10 +18,15 @@ */ #pragma once +#include #include +#include "core/configuration.h" +#include "core/hbase-configuration-loader.h" namespace hbase { namespace security { +static bool security_enabled_ = false; +static const std::string KERBEROS("kerberos"); class User { public: explicit User(const std::string& user_name) : user_name_(user_name) {} @@ -31,8 +36,17 @@ class User { static std::shared_ptr defaultUser() { return std::make_shared("__drwho"); } + static bool isSecurityEnabled() { + std::call_once(once_flag_, []() { + hbase::HBaseConfigurationLoader loader; + hbase::optional conf_ = loader.LoadDefaultResources(); + security_enabled_ = conf_->GetBool("hbase.security.authentication", false); + }); + return security_enabled_; + } private: std::string user_name_; + static std::once_flag once_flag_; }; } }