diff --git metastore/if/hive_metastore.thrift metastore/if/hive_metastore.thrift index 347aad9..4b92960 100755 --- metastore/if/hive_metastore.thrift +++ metastore/if/hive_metastore.thrift @@ -709,6 +709,9 @@ service ThriftHiveMetastore extends fb303.FacebookService list list_privileges(1:string principal_name, 2:PrincipalType principal_type, 3: HiveObjectRef hiveObject) throws(1:MetaException o1) + list list_privileges_for_auth(1:HiveObjectRef hiveObject, 2:string user_name, + 3: list group_names) throws(1:MetaException o1) + bool grant_privileges(1:PrivilegeBag privileges) throws(1:MetaException o1) bool revoke_privileges(1:PrivilegeBag privileges) throws(1:MetaException o1) diff --git metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp index 21a3bff..cecca86 100644 --- metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp +++ metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp @@ -20075,6 +20075,280 @@ uint32_t ThriftHiveMetastore_list_privileges_presult::read(::apache::thrift::pro return xfer; } +uint32_t ThriftHiveMetastore_list_privileges_for_auth_args::read(::apache::thrift::protocol::TProtocol* iprot) { + + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->hiveObject.read(iprot); + this->__isset.hiveObject = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 2: + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readString(this->user_name); + this->__isset.user_name = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 3: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + this->group_names.clear(); + uint32_t _size715; + ::apache::thrift::protocol::TType _etype718; + xfer += iprot->readListBegin(_etype718, _size715); + this->group_names.resize(_size715); + uint32_t _i719; + for (_i719 = 0; _i719 < _size715; ++_i719) + { + xfer += iprot->readString(this->group_names[_i719]); + } + xfer += iprot->readListEnd(); + } + this->__isset.group_names = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t ThriftHiveMetastore_list_privileges_for_auth_args::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + xfer += oprot->writeStructBegin("ThriftHiveMetastore_list_privileges_for_auth_args"); + + xfer += oprot->writeFieldBegin("hiveObject", ::apache::thrift::protocol::T_STRUCT, 1); + xfer += this->hiveObject.write(oprot); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("user_name", ::apache::thrift::protocol::T_STRING, 2); + xfer += oprot->writeString(this->user_name); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("group_names", ::apache::thrift::protocol::T_LIST, 3); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast(this->group_names.size())); + std::vector ::const_iterator _iter720; + for (_iter720 = this->group_names.begin(); _iter720 != this->group_names.end(); ++_iter720) + { + xfer += oprot->writeString((*_iter720)); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +uint32_t ThriftHiveMetastore_list_privileges_for_auth_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + xfer += oprot->writeStructBegin("ThriftHiveMetastore_list_privileges_for_auth_pargs"); + + xfer += oprot->writeFieldBegin("hiveObject", ::apache::thrift::protocol::T_STRUCT, 1); + xfer += (*(this->hiveObject)).write(oprot); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("user_name", ::apache::thrift::protocol::T_STRING, 2); + xfer += oprot->writeString((*(this->user_name))); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("group_names", ::apache::thrift::protocol::T_LIST, 3); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast((*(this->group_names)).size())); + std::vector ::const_iterator _iter721; + for (_iter721 = (*(this->group_names)).begin(); _iter721 != (*(this->group_names)).end(); ++_iter721) + { + xfer += oprot->writeString((*_iter721)); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +uint32_t ThriftHiveMetastore_list_privileges_for_auth_result::read(::apache::thrift::protocol::TProtocol* iprot) { + + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 0: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + this->success.clear(); + uint32_t _size722; + ::apache::thrift::protocol::TType _etype725; + xfer += iprot->readListBegin(_etype725, _size722); + this->success.resize(_size722); + uint32_t _i726; + for (_i726 = 0; _i726 < _size722; ++_i726) + { + xfer += iprot->readString(this->success[_i726]); + } + xfer += iprot->readListEnd(); + } + this->__isset.success = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->o1.read(iprot); + this->__isset.o1 = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t ThriftHiveMetastore_list_privileges_for_auth_result::write(::apache::thrift::protocol::TProtocol* oprot) const { + + uint32_t xfer = 0; + + xfer += oprot->writeStructBegin("ThriftHiveMetastore_list_privileges_for_auth_result"); + + if (this->__isset.success) { + xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast(this->success.size())); + std::vector ::const_iterator _iter727; + for (_iter727 = this->success.begin(); _iter727 != this->success.end(); ++_iter727) + { + xfer += oprot->writeString((*_iter727)); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + } else if (this->__isset.o1) { + xfer += oprot->writeFieldBegin("o1", ::apache::thrift::protocol::T_STRUCT, 1); + xfer += this->o1.write(oprot); + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +uint32_t ThriftHiveMetastore_list_privileges_for_auth_presult::read(::apache::thrift::protocol::TProtocol* iprot) { + + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 0: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + (*(this->success)).clear(); + uint32_t _size728; + ::apache::thrift::protocol::TType _etype731; + xfer += iprot->readListBegin(_etype731, _size728); + (*(this->success)).resize(_size728); + uint32_t _i732; + for (_i732 = 0; _i732 < _size728; ++_i732) + { + xfer += iprot->readString((*(this->success))[_i732]); + } + xfer += iprot->readListEnd(); + } + this->__isset.success = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->o1.read(iprot); + this->__isset.o1 = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + uint32_t ThriftHiveMetastore_grant_privileges_args::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; @@ -20471,14 +20745,14 @@ uint32_t ThriftHiveMetastore_set_ugi_args::read(::apache::thrift::protocol::TPro if (ftype == ::apache::thrift::protocol::T_LIST) { { this->group_names.clear(); - uint32_t _size715; - ::apache::thrift::protocol::TType _etype718; - xfer += iprot->readListBegin(_etype718, _size715); - this->group_names.resize(_size715); - uint32_t _i719; - for (_i719 = 0; _i719 < _size715; ++_i719) + uint32_t _size733; + ::apache::thrift::protocol::TType _etype736; + xfer += iprot->readListBegin(_etype736, _size733); + this->group_names.resize(_size733); + uint32_t _i737; + for (_i737 = 0; _i737 < _size733; ++_i737) { - xfer += iprot->readString(this->group_names[_i719]); + xfer += iprot->readString(this->group_names[_i737]); } xfer += iprot->readListEnd(); } @@ -20510,10 +20784,10 @@ uint32_t ThriftHiveMetastore_set_ugi_args::write(::apache::thrift::protocol::TPr xfer += oprot->writeFieldBegin("group_names", ::apache::thrift::protocol::T_LIST, 2); { xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast(this->group_names.size())); - std::vector ::const_iterator _iter720; - for (_iter720 = this->group_names.begin(); _iter720 != this->group_names.end(); ++_iter720) + std::vector ::const_iterator _iter738; + for (_iter738 = this->group_names.begin(); _iter738 != this->group_names.end(); ++_iter738) { - xfer += oprot->writeString((*_iter720)); + xfer += oprot->writeString((*_iter738)); } xfer += oprot->writeListEnd(); } @@ -20535,10 +20809,10 @@ uint32_t ThriftHiveMetastore_set_ugi_pargs::write(::apache::thrift::protocol::TP xfer += oprot->writeFieldBegin("group_names", ::apache::thrift::protocol::T_LIST, 2); { xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast((*(this->group_names)).size())); - std::vector ::const_iterator _iter721; - for (_iter721 = (*(this->group_names)).begin(); _iter721 != (*(this->group_names)).end(); ++_iter721) + std::vector ::const_iterator _iter739; + for (_iter739 = (*(this->group_names)).begin(); _iter739 != (*(this->group_names)).end(); ++_iter739) { - xfer += oprot->writeString((*_iter721)); + xfer += oprot->writeString((*_iter739)); } xfer += oprot->writeListEnd(); } @@ -20573,14 +20847,14 @@ uint32_t ThriftHiveMetastore_set_ugi_result::read(::apache::thrift::protocol::TP if (ftype == ::apache::thrift::protocol::T_LIST) { { this->success.clear(); - uint32_t _size722; - ::apache::thrift::protocol::TType _etype725; - xfer += iprot->readListBegin(_etype725, _size722); - this->success.resize(_size722); - uint32_t _i726; - for (_i726 = 0; _i726 < _size722; ++_i726) + uint32_t _size740; + ::apache::thrift::protocol::TType _etype743; + xfer += iprot->readListBegin(_etype743, _size740); + this->success.resize(_size740); + uint32_t _i744; + for (_i744 = 0; _i744 < _size740; ++_i744) { - xfer += iprot->readString(this->success[_i726]); + xfer += iprot->readString(this->success[_i744]); } xfer += iprot->readListEnd(); } @@ -20619,10 +20893,10 @@ uint32_t ThriftHiveMetastore_set_ugi_result::write(::apache::thrift::protocol::T xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0); { xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast(this->success.size())); - std::vector ::const_iterator _iter727; - for (_iter727 = this->success.begin(); _iter727 != this->success.end(); ++_iter727) + std::vector ::const_iterator _iter745; + for (_iter745 = this->success.begin(); _iter745 != this->success.end(); ++_iter745) { - xfer += oprot->writeString((*_iter727)); + xfer += oprot->writeString((*_iter745)); } xfer += oprot->writeListEnd(); } @@ -20661,14 +20935,14 @@ uint32_t ThriftHiveMetastore_set_ugi_presult::read(::apache::thrift::protocol::T if (ftype == ::apache::thrift::protocol::T_LIST) { { (*(this->success)).clear(); - uint32_t _size728; - ::apache::thrift::protocol::TType _etype731; - xfer += iprot->readListBegin(_etype731, _size728); - (*(this->success)).resize(_size728); - uint32_t _i732; - for (_i732 = 0; _i732 < _size728; ++_i732) + uint32_t _size746; + ::apache::thrift::protocol::TType _etype749; + xfer += iprot->readListBegin(_etype749, _size746); + (*(this->success)).resize(_size746); + uint32_t _i750; + for (_i750 = 0; _i750 < _size746; ++_i750) { - xfer += iprot->readString((*(this->success))[_i732]); + xfer += iprot->readString((*(this->success))[_i750]); } xfer += iprot->readListEnd(); } @@ -26550,6 +26824,69 @@ void ThriftHiveMetastoreClient::recv_list_privileges(std::vector & _return, const HiveObjectRef& hiveObject, const std::string& user_name, const std::vector & group_names) +{ + send_list_privileges_for_auth(hiveObject, user_name, group_names); + recv_list_privileges_for_auth(_return); +} + +void ThriftHiveMetastoreClient::send_list_privileges_for_auth(const HiveObjectRef& hiveObject, const std::string& user_name, const std::vector & group_names) +{ + int32_t cseqid = 0; + oprot_->writeMessageBegin("list_privileges_for_auth", ::apache::thrift::protocol::T_CALL, cseqid); + + ThriftHiveMetastore_list_privileges_for_auth_pargs args; + args.hiveObject = &hiveObject; + args.user_name = &user_name; + args.group_names = &group_names; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); +} + +void ThriftHiveMetastoreClient::recv_list_privileges_for_auth(std::vector & _return) +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + iprot_->readMessageBegin(fname, mtype, rseqid); + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + if (fname.compare("list_privileges_for_auth") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + ThriftHiveMetastore_list_privileges_for_auth_presult result; + result.success = &_return; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.success) { + // _return pointer has now been filled + return; + } + if (result.__isset.o1) { + throw result.o1; + } + throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "list_privileges_for_auth failed: unknown result"); +} + bool ThriftHiveMetastoreClient::grant_privileges(const PrivilegeBag& privileges) { send_grant_privileges(privileges); @@ -31837,6 +32174,63 @@ void ThriftHiveMetastoreProcessor::process_list_privileges(int32_t seqid, ::apac } } +void ThriftHiveMetastoreProcessor::process_list_privileges_for_auth(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) +{ + void* ctx = NULL; + if (this->eventHandler_.get() != NULL) { + ctx = this->eventHandler_->getContext("ThriftHiveMetastore.list_privileges_for_auth", callContext); + } + ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "ThriftHiveMetastore.list_privileges_for_auth"); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->preRead(ctx, "ThriftHiveMetastore.list_privileges_for_auth"); + } + + ThriftHiveMetastore_list_privileges_for_auth_args args; + args.read(iprot); + iprot->readMessageEnd(); + uint32_t bytes = iprot->getTransport()->readEnd(); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->postRead(ctx, "ThriftHiveMetastore.list_privileges_for_auth", bytes); + } + + ThriftHiveMetastore_list_privileges_for_auth_result result; + try { + iface_->list_privileges_for_auth(result.success, args.hiveObject, args.user_name, args.group_names); + result.__isset.success = true; + } catch (MetaException &o1) { + result.o1 = o1; + result.__isset.o1 = true; + } catch (const std::exception& e) { + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->handlerError(ctx, "ThriftHiveMetastore.list_privileges_for_auth"); + } + + ::apache::thrift::TApplicationException x(e.what()); + oprot->writeMessageBegin("list_privileges_for_auth", ::apache::thrift::protocol::T_EXCEPTION, seqid); + x.write(oprot); + oprot->writeMessageEnd(); + oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + return; + } + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->preWrite(ctx, "ThriftHiveMetastore.list_privileges_for_auth"); + } + + oprot->writeMessageBegin("list_privileges_for_auth", ::apache::thrift::protocol::T_REPLY, seqid); + result.write(oprot); + oprot->writeMessageEnd(); + bytes = oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->postWrite(ctx, "ThriftHiveMetastore.list_privileges_for_auth", bytes); + } +} + void ThriftHiveMetastoreProcessor::process_grant_privileges(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) { void* ctx = NULL; diff --git metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.h metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.h index af0abe7..04af8f1 100644 --- metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.h +++ metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.h @@ -97,6 +97,7 @@ class ThriftHiveMetastoreIf : virtual public ::facebook::fb303::FacebookService virtual void list_roles(std::vector & _return, const std::string& principal_name, const PrincipalType::type principal_type) = 0; virtual void get_privilege_set(PrincipalPrivilegeSet& _return, const HiveObjectRef& hiveObject, const std::string& user_name, const std::vector & group_names) = 0; virtual void list_privileges(std::vector & _return, const std::string& principal_name, const PrincipalType::type principal_type, const HiveObjectRef& hiveObject) = 0; + virtual void list_privileges_for_auth(std::vector & _return, const HiveObjectRef& hiveObject, const std::string& user_name, const std::vector & group_names) = 0; virtual bool grant_privileges(const PrivilegeBag& privileges) = 0; virtual bool revoke_privileges(const PrivilegeBag& privileges) = 0; virtual void set_ugi(std::vector & _return, const std::string& user_name, const std::vector & group_names) = 0; @@ -393,6 +394,9 @@ class ThriftHiveMetastoreNull : virtual public ThriftHiveMetastoreIf , virtual p void list_privileges(std::vector & /* _return */, const std::string& /* principal_name */, const PrincipalType::type /* principal_type */, const HiveObjectRef& /* hiveObject */) { return; } + void list_privileges_for_auth(std::vector & /* _return */, const HiveObjectRef& /* hiveObject */, const std::string& /* user_name */, const std::vector & /* group_names */) { + return; + } bool grant_privileges(const PrivilegeBag& /* privileges */) { bool _return = false; return _return; @@ -12051,6 +12055,142 @@ class ThriftHiveMetastore_list_privileges_presult { }; +typedef struct _ThriftHiveMetastore_list_privileges_for_auth_args__isset { + _ThriftHiveMetastore_list_privileges_for_auth_args__isset() : hiveObject(false), user_name(false), group_names(false) {} + bool hiveObject; + bool user_name; + bool group_names; +} _ThriftHiveMetastore_list_privileges_for_auth_args__isset; + +class ThriftHiveMetastore_list_privileges_for_auth_args { + public: + + ThriftHiveMetastore_list_privileges_for_auth_args() : user_name() { + } + + virtual ~ThriftHiveMetastore_list_privileges_for_auth_args() throw() {} + + HiveObjectRef hiveObject; + std::string user_name; + std::vector group_names; + + _ThriftHiveMetastore_list_privileges_for_auth_args__isset __isset; + + void __set_hiveObject(const HiveObjectRef& val) { + hiveObject = val; + } + + void __set_user_name(const std::string& val) { + user_name = val; + } + + void __set_group_names(const std::vector & val) { + group_names = val; + } + + bool operator == (const ThriftHiveMetastore_list_privileges_for_auth_args & rhs) const + { + if (!(hiveObject == rhs.hiveObject)) + return false; + if (!(user_name == rhs.user_name)) + return false; + if (!(group_names == rhs.group_names)) + return false; + return true; + } + bool operator != (const ThriftHiveMetastore_list_privileges_for_auth_args &rhs) const { + return !(*this == rhs); + } + + bool operator < (const ThriftHiveMetastore_list_privileges_for_auth_args & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + + +class ThriftHiveMetastore_list_privileges_for_auth_pargs { + public: + + + virtual ~ThriftHiveMetastore_list_privileges_for_auth_pargs() throw() {} + + const HiveObjectRef* hiveObject; + const std::string* user_name; + const std::vector * group_names; + + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _ThriftHiveMetastore_list_privileges_for_auth_result__isset { + _ThriftHiveMetastore_list_privileges_for_auth_result__isset() : success(false), o1(false) {} + bool success; + bool o1; +} _ThriftHiveMetastore_list_privileges_for_auth_result__isset; + +class ThriftHiveMetastore_list_privileges_for_auth_result { + public: + + ThriftHiveMetastore_list_privileges_for_auth_result() { + } + + virtual ~ThriftHiveMetastore_list_privileges_for_auth_result() throw() {} + + std::vector success; + MetaException o1; + + _ThriftHiveMetastore_list_privileges_for_auth_result__isset __isset; + + void __set_success(const std::vector & val) { + success = val; + } + + void __set_o1(const MetaException& val) { + o1 = val; + } + + bool operator == (const ThriftHiveMetastore_list_privileges_for_auth_result & rhs) const + { + if (!(success == rhs.success)) + return false; + if (!(o1 == rhs.o1)) + return false; + return true; + } + bool operator != (const ThriftHiveMetastore_list_privileges_for_auth_result &rhs) const { + return !(*this == rhs); + } + + bool operator < (const ThriftHiveMetastore_list_privileges_for_auth_result & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _ThriftHiveMetastore_list_privileges_for_auth_presult__isset { + _ThriftHiveMetastore_list_privileges_for_auth_presult__isset() : success(false), o1(false) {} + bool success; + bool o1; +} _ThriftHiveMetastore_list_privileges_for_auth_presult__isset; + +class ThriftHiveMetastore_list_privileges_for_auth_presult { + public: + + + virtual ~ThriftHiveMetastore_list_privileges_for_auth_presult() throw() {} + + std::vector * success; + MetaException o1; + + _ThriftHiveMetastore_list_privileges_for_auth_presult__isset __isset; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + +}; + typedef struct _ThriftHiveMetastore_grant_privileges_args__isset { _ThriftHiveMetastore_grant_privileges_args__isset() : privileges(false) {} bool privileges; @@ -13022,6 +13162,9 @@ class ThriftHiveMetastoreClient : virtual public ThriftHiveMetastoreIf, public void list_privileges(std::vector & _return, const std::string& principal_name, const PrincipalType::type principal_type, const HiveObjectRef& hiveObject); void send_list_privileges(const std::string& principal_name, const PrincipalType::type principal_type, const HiveObjectRef& hiveObject); void recv_list_privileges(std::vector & _return); + void list_privileges_for_auth(std::vector & _return, const HiveObjectRef& hiveObject, const std::string& user_name, const std::vector & group_names); + void send_list_privileges_for_auth(const HiveObjectRef& hiveObject, const std::string& user_name, const std::vector & group_names); + void recv_list_privileges_for_auth(std::vector & _return); bool grant_privileges(const PrivilegeBag& privileges); void send_grant_privileges(const PrivilegeBag& privileges); bool recv_grant_privileges(); @@ -13131,6 +13274,7 @@ class ThriftHiveMetastoreProcessor : public ::facebook::fb303::FacebookServiceP void process_list_roles(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); void process_get_privilege_set(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); void process_list_privileges(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); + void process_list_privileges_for_auth(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); void process_grant_privileges(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); void process_revoke_privileges(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); void process_set_ugi(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); @@ -13222,6 +13366,7 @@ class ThriftHiveMetastoreProcessor : public ::facebook::fb303::FacebookServiceP processMap_["list_roles"] = &ThriftHiveMetastoreProcessor::process_list_roles; processMap_["get_privilege_set"] = &ThriftHiveMetastoreProcessor::process_get_privilege_set; processMap_["list_privileges"] = &ThriftHiveMetastoreProcessor::process_list_privileges; + processMap_["list_privileges_for_auth"] = &ThriftHiveMetastoreProcessor::process_list_privileges_for_auth; processMap_["grant_privileges"] = &ThriftHiveMetastoreProcessor::process_grant_privileges; processMap_["revoke_privileges"] = &ThriftHiveMetastoreProcessor::process_revoke_privileges; processMap_["set_ugi"] = &ThriftHiveMetastoreProcessor::process_set_ugi; @@ -14038,6 +14183,16 @@ class ThriftHiveMetastoreMultiface : virtual public ThriftHiveMetastoreIf, publi return; } + void list_privileges_for_auth(std::vector & _return, const HiveObjectRef& hiveObject, const std::string& user_name, const std::vector & group_names) { + size_t sz = ifaces_.size(); + size_t i = 0; + for (; i < (sz - 1); ++i) { + ifaces_[i]->list_privileges_for_auth(_return, hiveObject, user_name, group_names); + } + ifaces_[i]->list_privileges_for_auth(_return, hiveObject, user_name, group_names); + return; + } + bool grant_privileges(const PrivilegeBag& privileges) { size_t sz = ifaces_.size(); size_t i = 0; diff --git metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore_server.skeleton.cpp metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore_server.skeleton.cpp index faa7951..b2ff185 100644 --- metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore_server.skeleton.cpp +++ metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore_server.skeleton.cpp @@ -427,6 +427,11 @@ class ThriftHiveMetastoreHandler : virtual public ThriftHiveMetastoreIf { printf("list_privileges\n"); } + void list_privileges_for_auth(std::vector & _return, const HiveObjectRef& hiveObject, const std::string& user_name, const std::vector & group_names) { + // Your implementation goes here + printf("list_privileges_for_auth\n"); + } + bool grant_privileges(const PrivilegeBag& privileges) { // Your implementation goes here printf("grant_privileges\n"); diff --git metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/ThriftHiveMetastore.java metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/ThriftHiveMetastore.java index acb7628..cb5aece 100644 --- metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/ThriftHiveMetastore.java +++ metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/ThriftHiveMetastore.java @@ -200,6 +200,8 @@ public List list_privileges(String principal_name, PrincipalType principal_type, HiveObjectRef hiveObject) throws MetaException, org.apache.thrift.TException; + public List list_privileges_for_auth(HiveObjectRef hiveObject, String user_name, List group_names) throws MetaException, org.apache.thrift.TException; + public boolean grant_privileges(PrivilegeBag privileges) throws MetaException, org.apache.thrift.TException; public boolean revoke_privileges(PrivilegeBag privileges) throws MetaException, org.apache.thrift.TException; @@ -378,6 +380,8 @@ public void list_privileges(String principal_name, PrincipalType principal_type, HiveObjectRef hiveObject, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + public void list_privileges_for_auth(HiveObjectRef hiveObject, String user_name, List group_names, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + public void grant_privileges(PrivilegeBag privileges, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; public void revoke_privileges(PrivilegeBag privileges, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; @@ -2918,6 +2922,34 @@ public void send_list_privileges(String principal_name, PrincipalType principal_ throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "list_privileges failed: unknown result"); } + public List list_privileges_for_auth(HiveObjectRef hiveObject, String user_name, List group_names) throws MetaException, org.apache.thrift.TException + { + send_list_privileges_for_auth(hiveObject, user_name, group_names); + return recv_list_privileges_for_auth(); + } + + public void send_list_privileges_for_auth(HiveObjectRef hiveObject, String user_name, List group_names) throws org.apache.thrift.TException + { + list_privileges_for_auth_args args = new list_privileges_for_auth_args(); + args.setHiveObject(hiveObject); + args.setUser_name(user_name); + args.setGroup_names(group_names); + sendBase("list_privileges_for_auth", args); + } + + public List recv_list_privileges_for_auth() throws MetaException, org.apache.thrift.TException + { + list_privileges_for_auth_result result = new list_privileges_for_auth_result(); + receiveBase(result, "list_privileges_for_auth"); + if (result.isSetSuccess()) { + return result.success; + } + if (result.o1 != null) { + throw result.o1; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "list_privileges_for_auth failed: unknown result"); + } + public boolean grant_privileges(PrivilegeBag privileges) throws MetaException, org.apache.thrift.TException { send_grant_privileges(privileges); @@ -6082,6 +6114,44 @@ public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apa } } + public void list_privileges_for_auth(HiveObjectRef hiveObject, String user_name, List group_names, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + list_privileges_for_auth_call method_call = new list_privileges_for_auth_call(hiveObject, user_name, group_names, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class list_privileges_for_auth_call extends org.apache.thrift.async.TAsyncMethodCall { + private HiveObjectRef hiveObject; + private String user_name; + private List group_names; + public list_privileges_for_auth_call(HiveObjectRef hiveObject, String user_name, List group_names, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.hiveObject = hiveObject; + this.user_name = user_name; + this.group_names = group_names; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("list_privileges_for_auth", org.apache.thrift.protocol.TMessageType.CALL, 0)); + list_privileges_for_auth_args args = new list_privileges_for_auth_args(); + args.setHiveObject(hiveObject); + args.setUser_name(user_name); + args.setGroup_names(group_names); + args.write(prot); + prot.writeMessageEnd(); + } + + public List getResult() throws MetaException, org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_list_privileges_for_auth(); + } + } + public void grant_privileges(PrivilegeBag privileges, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { checkReady(); grant_privileges_call method_call = new grant_privileges_call(privileges, resultHandler, this, ___protocolFactory, ___transport); @@ -6374,6 +6444,7 @@ protected Processor(I iface, Map extends org.apache.thrift.ProcessFunction { + public list_privileges_for_auth() { + super("list_privileges_for_auth"); + } + + public list_privileges_for_auth_args getEmptyArgsInstance() { + return new list_privileges_for_auth_args(); + } + + protected boolean isOneway() { + return false; + } + + public list_privileges_for_auth_result getResult(I iface, list_privileges_for_auth_args args) throws org.apache.thrift.TException { + list_privileges_for_auth_result result = new list_privileges_for_auth_result(); + try { + result.success = iface.list_privileges_for_auth(args.hiveObject, args.user_name, args.group_names); + } catch (MetaException o1) { + result.o1 = o1; + } + return result; + } + } + public static class grant_privileges extends org.apache.thrift.ProcessFunction { public grant_privileges() { super("grant_privileges"); @@ -99895,18 +99990,1071 @@ public String getFieldName() { static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, PrincipalPrivilegeSet.class))); + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, PrincipalPrivilegeSet.class))); + tmpMap.put(_Fields.O1, new org.apache.thrift.meta_data.FieldMetaData("o1", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(get_privilege_set_result.class, metaDataMap); + } + + public get_privilege_set_result() { + } + + public get_privilege_set_result( + PrincipalPrivilegeSet success, + MetaException o1) + { + this(); + this.success = success; + this.o1 = o1; + } + + /** + * Performs a deep copy on other. + */ + public get_privilege_set_result(get_privilege_set_result other) { + if (other.isSetSuccess()) { + this.success = new PrincipalPrivilegeSet(other.success); + } + if (other.isSetO1()) { + this.o1 = new MetaException(other.o1); + } + } + + public get_privilege_set_result deepCopy() { + return new get_privilege_set_result(this); + } + + @Override + public void clear() { + this.success = null; + this.o1 = null; + } + + public PrincipalPrivilegeSet getSuccess() { + return this.success; + } + + public void setSuccess(PrincipalPrivilegeSet success) { + this.success = success; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return this.success != null; + } + + public void setSuccessIsSet(boolean value) { + if (!value) { + this.success = null; + } + } + + public MetaException getO1() { + return this.o1; + } + + public void setO1(MetaException o1) { + this.o1 = o1; + } + + public void unsetO1() { + this.o1 = null; + } + + /** Returns true if field o1 is set (has been assigned a value) and false otherwise */ + public boolean isSetO1() { + return this.o1 != null; + } + + public void setO1IsSet(boolean value) { + if (!value) { + this.o1 = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((PrincipalPrivilegeSet)value); + } + break; + + case O1: + if (value == null) { + unsetO1(); + } else { + setO1((MetaException)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + case O1: + return getO1(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + case O1: + return isSetO1(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof get_privilege_set_result) + return this.equals((get_privilege_set_result)that); + return false; + } + + public boolean equals(get_privilege_set_result that) { + if (that == null) + return false; + + boolean this_present_success = true && this.isSetSuccess(); + boolean that_present_success = true && that.isSetSuccess(); + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (!this.success.equals(that.success)) + return false; + } + + boolean this_present_o1 = true && this.isSetO1(); + boolean that_present_o1 = true && that.isSetO1(); + if (this_present_o1 || that_present_o1) { + if (!(this_present_o1 && that_present_o1)) + return false; + if (!this.o1.equals(that.o1)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + + boolean present_success = true && (isSetSuccess()); + builder.append(present_success); + if (present_success) + builder.append(success); + + boolean present_o1 = true && (isSetO1()); + builder.append(present_o1); + if (present_o1) + builder.append(o1); + + return builder.toHashCode(); + } + + public int compareTo(get_privilege_set_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + get_privilege_set_result typedOther = (get_privilege_set_result)other; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(typedOther.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, typedOther.success); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetO1()).compareTo(typedOther.isSetO1()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetO1()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.o1, typedOther.o1); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("get_privilege_set_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + first = false; + if (!first) sb.append(", "); + sb.append("o1:"); + if (this.o1 == null) { + sb.append("null"); + } else { + sb.append(this.o1); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + if (success != null) { + success.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class get_privilege_set_resultStandardSchemeFactory implements SchemeFactory { + public get_privilege_set_resultStandardScheme getScheme() { + return new get_privilege_set_resultStandardScheme(); + } + } + + private static class get_privilege_set_resultStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, get_privilege_set_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 0: // SUCCESS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.success = new PrincipalPrivilegeSet(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 1: // O1 + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.o1 = new MetaException(); + struct.o1.read(iprot); + struct.setO1IsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, get_privilege_set_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.success != null) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + struct.success.write(oprot); + oprot.writeFieldEnd(); + } + if (struct.o1 != null) { + oprot.writeFieldBegin(O1_FIELD_DESC); + struct.o1.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class get_privilege_set_resultTupleSchemeFactory implements SchemeFactory { + public get_privilege_set_resultTupleScheme getScheme() { + return new get_privilege_set_resultTupleScheme(); + } + } + + private static class get_privilege_set_resultTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, get_privilege_set_result struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + if (struct.isSetO1()) { + optionals.set(1); + } + oprot.writeBitSet(optionals, 2); + if (struct.isSetSuccess()) { + struct.success.write(oprot); + } + if (struct.isSetO1()) { + struct.o1.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, get_privilege_set_result struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(2); + if (incoming.get(0)) { + struct.success = new PrincipalPrivilegeSet(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } + if (incoming.get(1)) { + struct.o1 = new MetaException(); + struct.o1.read(iprot); + struct.setO1IsSet(true); + } + } + } + + } + + public static class list_privileges_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("list_privileges_args"); + + private static final org.apache.thrift.protocol.TField PRINCIPAL_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("principal_name", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField PRINCIPAL_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("principal_type", org.apache.thrift.protocol.TType.I32, (short)2); + private static final org.apache.thrift.protocol.TField HIVE_OBJECT_FIELD_DESC = new org.apache.thrift.protocol.TField("hiveObject", org.apache.thrift.protocol.TType.STRUCT, (short)3); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new list_privileges_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new list_privileges_argsTupleSchemeFactory()); + } + + private String principal_name; // required + private PrincipalType principal_type; // required + private HiveObjectRef hiveObject; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + PRINCIPAL_NAME((short)1, "principal_name"), + /** + * + * @see PrincipalType + */ + PRINCIPAL_TYPE((short)2, "principal_type"), + HIVE_OBJECT((short)3, "hiveObject"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // PRINCIPAL_NAME + return PRINCIPAL_NAME; + case 2: // PRINCIPAL_TYPE + return PRINCIPAL_TYPE; + case 3: // HIVE_OBJECT + return HIVE_OBJECT; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.PRINCIPAL_NAME, new org.apache.thrift.meta_data.FieldMetaData("principal_name", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.PRINCIPAL_TYPE, new org.apache.thrift.meta_data.FieldMetaData("principal_type", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, PrincipalType.class))); + tmpMap.put(_Fields.HIVE_OBJECT, new org.apache.thrift.meta_data.FieldMetaData("hiveObject", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, HiveObjectRef.class))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(list_privileges_args.class, metaDataMap); + } + + public list_privileges_args() { + } + + public list_privileges_args( + String principal_name, + PrincipalType principal_type, + HiveObjectRef hiveObject) + { + this(); + this.principal_name = principal_name; + this.principal_type = principal_type; + this.hiveObject = hiveObject; + } + + /** + * Performs a deep copy on other. + */ + public list_privileges_args(list_privileges_args other) { + if (other.isSetPrincipal_name()) { + this.principal_name = other.principal_name; + } + if (other.isSetPrincipal_type()) { + this.principal_type = other.principal_type; + } + if (other.isSetHiveObject()) { + this.hiveObject = new HiveObjectRef(other.hiveObject); + } + } + + public list_privileges_args deepCopy() { + return new list_privileges_args(this); + } + + @Override + public void clear() { + this.principal_name = null; + this.principal_type = null; + this.hiveObject = null; + } + + public String getPrincipal_name() { + return this.principal_name; + } + + public void setPrincipal_name(String principal_name) { + this.principal_name = principal_name; + } + + public void unsetPrincipal_name() { + this.principal_name = null; + } + + /** Returns true if field principal_name is set (has been assigned a value) and false otherwise */ + public boolean isSetPrincipal_name() { + return this.principal_name != null; + } + + public void setPrincipal_nameIsSet(boolean value) { + if (!value) { + this.principal_name = null; + } + } + + /** + * + * @see PrincipalType + */ + public PrincipalType getPrincipal_type() { + return this.principal_type; + } + + /** + * + * @see PrincipalType + */ + public void setPrincipal_type(PrincipalType principal_type) { + this.principal_type = principal_type; + } + + public void unsetPrincipal_type() { + this.principal_type = null; + } + + /** Returns true if field principal_type is set (has been assigned a value) and false otherwise */ + public boolean isSetPrincipal_type() { + return this.principal_type != null; + } + + public void setPrincipal_typeIsSet(boolean value) { + if (!value) { + this.principal_type = null; + } + } + + public HiveObjectRef getHiveObject() { + return this.hiveObject; + } + + public void setHiveObject(HiveObjectRef hiveObject) { + this.hiveObject = hiveObject; + } + + public void unsetHiveObject() { + this.hiveObject = null; + } + + /** Returns true if field hiveObject is set (has been assigned a value) and false otherwise */ + public boolean isSetHiveObject() { + return this.hiveObject != null; + } + + public void setHiveObjectIsSet(boolean value) { + if (!value) { + this.hiveObject = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case PRINCIPAL_NAME: + if (value == null) { + unsetPrincipal_name(); + } else { + setPrincipal_name((String)value); + } + break; + + case PRINCIPAL_TYPE: + if (value == null) { + unsetPrincipal_type(); + } else { + setPrincipal_type((PrincipalType)value); + } + break; + + case HIVE_OBJECT: + if (value == null) { + unsetHiveObject(); + } else { + setHiveObject((HiveObjectRef)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case PRINCIPAL_NAME: + return getPrincipal_name(); + + case PRINCIPAL_TYPE: + return getPrincipal_type(); + + case HIVE_OBJECT: + return getHiveObject(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case PRINCIPAL_NAME: + return isSetPrincipal_name(); + case PRINCIPAL_TYPE: + return isSetPrincipal_type(); + case HIVE_OBJECT: + return isSetHiveObject(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof list_privileges_args) + return this.equals((list_privileges_args)that); + return false; + } + + public boolean equals(list_privileges_args that) { + if (that == null) + return false; + + boolean this_present_principal_name = true && this.isSetPrincipal_name(); + boolean that_present_principal_name = true && that.isSetPrincipal_name(); + if (this_present_principal_name || that_present_principal_name) { + if (!(this_present_principal_name && that_present_principal_name)) + return false; + if (!this.principal_name.equals(that.principal_name)) + return false; + } + + boolean this_present_principal_type = true && this.isSetPrincipal_type(); + boolean that_present_principal_type = true && that.isSetPrincipal_type(); + if (this_present_principal_type || that_present_principal_type) { + if (!(this_present_principal_type && that_present_principal_type)) + return false; + if (!this.principal_type.equals(that.principal_type)) + return false; + } + + boolean this_present_hiveObject = true && this.isSetHiveObject(); + boolean that_present_hiveObject = true && that.isSetHiveObject(); + if (this_present_hiveObject || that_present_hiveObject) { + if (!(this_present_hiveObject && that_present_hiveObject)) + return false; + if (!this.hiveObject.equals(that.hiveObject)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + + boolean present_principal_name = true && (isSetPrincipal_name()); + builder.append(present_principal_name); + if (present_principal_name) + builder.append(principal_name); + + boolean present_principal_type = true && (isSetPrincipal_type()); + builder.append(present_principal_type); + if (present_principal_type) + builder.append(principal_type.getValue()); + + boolean present_hiveObject = true && (isSetHiveObject()); + builder.append(present_hiveObject); + if (present_hiveObject) + builder.append(hiveObject); + + return builder.toHashCode(); + } + + public int compareTo(list_privileges_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + list_privileges_args typedOther = (list_privileges_args)other; + + lastComparison = Boolean.valueOf(isSetPrincipal_name()).compareTo(typedOther.isSetPrincipal_name()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetPrincipal_name()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.principal_name, typedOther.principal_name); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetPrincipal_type()).compareTo(typedOther.isSetPrincipal_type()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetPrincipal_type()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.principal_type, typedOther.principal_type); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetHiveObject()).compareTo(typedOther.isSetHiveObject()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetHiveObject()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.hiveObject, typedOther.hiveObject); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("list_privileges_args("); + boolean first = true; + + sb.append("principal_name:"); + if (this.principal_name == null) { + sb.append("null"); + } else { + sb.append(this.principal_name); + } + first = false; + if (!first) sb.append(", "); + sb.append("principal_type:"); + if (this.principal_type == null) { + sb.append("null"); + } else { + sb.append(this.principal_type); + } + first = false; + if (!first) sb.append(", "); + sb.append("hiveObject:"); + if (this.hiveObject == null) { + sb.append("null"); + } else { + sb.append(this.hiveObject); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + if (hiveObject != null) { + hiveObject.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class list_privileges_argsStandardSchemeFactory implements SchemeFactory { + public list_privileges_argsStandardScheme getScheme() { + return new list_privileges_argsStandardScheme(); + } + } + + private static class list_privileges_argsStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, list_privileges_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // PRINCIPAL_NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.principal_name = iprot.readString(); + struct.setPrincipal_nameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // PRINCIPAL_TYPE + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.principal_type = PrincipalType.findByValue(iprot.readI32()); + struct.setPrincipal_typeIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // HIVE_OBJECT + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.hiveObject = new HiveObjectRef(); + struct.hiveObject.read(iprot); + struct.setHiveObjectIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, list_privileges_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.principal_name != null) { + oprot.writeFieldBegin(PRINCIPAL_NAME_FIELD_DESC); + oprot.writeString(struct.principal_name); + oprot.writeFieldEnd(); + } + if (struct.principal_type != null) { + oprot.writeFieldBegin(PRINCIPAL_TYPE_FIELD_DESC); + oprot.writeI32(struct.principal_type.getValue()); + oprot.writeFieldEnd(); + } + if (struct.hiveObject != null) { + oprot.writeFieldBegin(HIVE_OBJECT_FIELD_DESC); + struct.hiveObject.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class list_privileges_argsTupleSchemeFactory implements SchemeFactory { + public list_privileges_argsTupleScheme getScheme() { + return new list_privileges_argsTupleScheme(); + } + } + + private static class list_privileges_argsTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, list_privileges_args struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetPrincipal_name()) { + optionals.set(0); + } + if (struct.isSetPrincipal_type()) { + optionals.set(1); + } + if (struct.isSetHiveObject()) { + optionals.set(2); + } + oprot.writeBitSet(optionals, 3); + if (struct.isSetPrincipal_name()) { + oprot.writeString(struct.principal_name); + } + if (struct.isSetPrincipal_type()) { + oprot.writeI32(struct.principal_type.getValue()); + } + if (struct.isSetHiveObject()) { + struct.hiveObject.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, list_privileges_args struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(3); + if (incoming.get(0)) { + struct.principal_name = iprot.readString(); + struct.setPrincipal_nameIsSet(true); + } + if (incoming.get(1)) { + struct.principal_type = PrincipalType.findByValue(iprot.readI32()); + struct.setPrincipal_typeIsSet(true); + } + if (incoming.get(2)) { + struct.hiveObject = new HiveObjectRef(); + struct.hiveObject.read(iprot); + struct.setHiveObjectIsSet(true); + } + } + } + + } + + public static class list_privileges_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("list_privileges_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.LIST, (short)0); + private static final org.apache.thrift.protocol.TField O1_FIELD_DESC = new org.apache.thrift.protocol.TField("o1", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new list_privileges_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new list_privileges_resultTupleSchemeFactory()); + } + + private List success; // required + private MetaException o1; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"), + O1((short)1, "o1"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + case 1: // O1 + return O1; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, HiveObjectPrivilege.class)))); tmpMap.put(_Fields.O1, new org.apache.thrift.meta_data.FieldMetaData("o1", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(get_privilege_set_result.class, metaDataMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(list_privileges_result.class, metaDataMap); } - public get_privilege_set_result() { + public list_privileges_result() { } - public get_privilege_set_result( - PrincipalPrivilegeSet success, + public list_privileges_result( + List success, MetaException o1) { this(); @@ -99917,17 +101065,21 @@ public get_privilege_set_result( /** * Performs a deep copy on other. */ - public get_privilege_set_result(get_privilege_set_result other) { + public list_privileges_result(list_privileges_result other) { if (other.isSetSuccess()) { - this.success = new PrincipalPrivilegeSet(other.success); + List __this__success = new ArrayList(); + for (HiveObjectPrivilege other_element : other.success) { + __this__success.add(new HiveObjectPrivilege(other_element)); + } + this.success = __this__success; } if (other.isSetO1()) { this.o1 = new MetaException(other.o1); } } - public get_privilege_set_result deepCopy() { - return new get_privilege_set_result(this); + public list_privileges_result deepCopy() { + return new list_privileges_result(this); } @Override @@ -99936,11 +101088,26 @@ public void clear() { this.o1 = null; } - public PrincipalPrivilegeSet getSuccess() { + public int getSuccessSize() { + return (this.success == null) ? 0 : this.success.size(); + } + + public java.util.Iterator getSuccessIterator() { + return (this.success == null) ? null : this.success.iterator(); + } + + public void addToSuccess(HiveObjectPrivilege elem) { + if (this.success == null) { + this.success = new ArrayList(); + } + this.success.add(elem); + } + + public List getSuccess() { return this.success; } - public void setSuccess(PrincipalPrivilegeSet success) { + public void setSuccess(List success) { this.success = success; } @@ -99988,7 +101155,7 @@ public void setFieldValue(_Fields field, Object value) { if (value == null) { unsetSuccess(); } else { - setSuccess((PrincipalPrivilegeSet)value); + setSuccess((List)value); } break; @@ -100034,12 +101201,12 @@ public boolean isSet(_Fields field) { public boolean equals(Object that) { if (that == null) return false; - if (that instanceof get_privilege_set_result) - return this.equals((get_privilege_set_result)that); + if (that instanceof list_privileges_result) + return this.equals((list_privileges_result)that); return false; } - public boolean equals(get_privilege_set_result that) { + public boolean equals(list_privileges_result that) { if (that == null) return false; @@ -100081,13 +101248,13 @@ public int hashCode() { return builder.toHashCode(); } - public int compareTo(get_privilege_set_result other) { + public int compareTo(list_privileges_result other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; - get_privilege_set_result typedOther = (get_privilege_set_result)other; + list_privileges_result typedOther = (list_privileges_result)other; lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(typedOther.isSetSuccess()); if (lastComparison != 0) { @@ -100126,7 +101293,7 @@ public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache. @Override public String toString() { - StringBuilder sb = new StringBuilder("get_privilege_set_result("); + StringBuilder sb = new StringBuilder("list_privileges_result("); boolean first = true; sb.append("success:"); @@ -100151,9 +101318,6 @@ public String toString() { public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity - if (success != null) { - success.validate(); - } } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { @@ -100172,15 +101336,15 @@ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException } } - private static class get_privilege_set_resultStandardSchemeFactory implements SchemeFactory { - public get_privilege_set_resultStandardScheme getScheme() { - return new get_privilege_set_resultStandardScheme(); + private static class list_privileges_resultStandardSchemeFactory implements SchemeFactory { + public list_privileges_resultStandardScheme getScheme() { + return new list_privileges_resultStandardScheme(); } } - private static class get_privilege_set_resultStandardScheme extends StandardScheme { + private static class list_privileges_resultStandardScheme extends StandardScheme { - public void read(org.apache.thrift.protocol.TProtocol iprot, get_privilege_set_result struct) throws org.apache.thrift.TException { + public void read(org.apache.thrift.protocol.TProtocol iprot, list_privileges_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) @@ -100191,9 +101355,19 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, get_privilege_set_r } switch (schemeField.id) { case 0: // SUCCESS - if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { - struct.success = new PrincipalPrivilegeSet(); - struct.success.read(iprot); + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list724 = iprot.readListBegin(); + struct.success = new ArrayList(_list724.size); + for (int _i725 = 0; _i725 < _list724.size; ++_i725) + { + HiveObjectPrivilege _elem726; // required + _elem726 = new HiveObjectPrivilege(); + _elem726.read(iprot); + struct.success.add(_elem726); + } + iprot.readListEnd(); + } struct.setSuccessIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); @@ -100217,13 +101391,20 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, get_privilege_set_r struct.validate(); } - public void write(org.apache.thrift.protocol.TProtocol oprot, get_privilege_set_result struct) throws org.apache.thrift.TException { + public void write(org.apache.thrift.protocol.TProtocol oprot, list_privileges_result struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.success != null) { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); - struct.success.write(oprot); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.success.size())); + for (HiveObjectPrivilege _iter727 : struct.success) + { + _iter727.write(oprot); + } + oprot.writeListEnd(); + } oprot.writeFieldEnd(); } if (struct.o1 != null) { @@ -100237,16 +101418,16 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, get_privilege_set_ } - private static class get_privilege_set_resultTupleSchemeFactory implements SchemeFactory { - public get_privilege_set_resultTupleScheme getScheme() { - return new get_privilege_set_resultTupleScheme(); + private static class list_privileges_resultTupleSchemeFactory implements SchemeFactory { + public list_privileges_resultTupleScheme getScheme() { + return new list_privileges_resultTupleScheme(); } } - private static class get_privilege_set_resultTupleScheme extends TupleScheme { + private static class list_privileges_resultTupleScheme extends TupleScheme { @Override - public void write(org.apache.thrift.protocol.TProtocol prot, get_privilege_set_result struct) throws org.apache.thrift.TException { + public void write(org.apache.thrift.protocol.TProtocol prot, list_privileges_result struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetSuccess()) { @@ -100257,7 +101438,13 @@ public void write(org.apache.thrift.protocol.TProtocol prot, get_privilege_set_r } oprot.writeBitSet(optionals, 2); if (struct.isSetSuccess()) { - struct.success.write(oprot); + { + oprot.writeI32(struct.success.size()); + for (HiveObjectPrivilege _iter728 : struct.success) + { + _iter728.write(oprot); + } + } } if (struct.isSetO1()) { struct.o1.write(oprot); @@ -100265,12 +101452,21 @@ public void write(org.apache.thrift.protocol.TProtocol prot, get_privilege_set_r } @Override - public void read(org.apache.thrift.protocol.TProtocol prot, get_privilege_set_result struct) throws org.apache.thrift.TException { + public void read(org.apache.thrift.protocol.TProtocol prot, list_privileges_result struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { - struct.success = new PrincipalPrivilegeSet(); - struct.success.read(iprot); + { + org.apache.thrift.protocol.TList _list729 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.success = new ArrayList(_list729.size); + for (int _i730 = 0; _i730 < _list729.size; ++_i730) + { + HiveObjectPrivilege _elem731; // required + _elem731 = new HiveObjectPrivilege(); + _elem731.read(iprot); + struct.success.add(_elem731); + } + } struct.setSuccessIsSet(true); } if (incoming.get(1)) { @@ -100283,32 +101479,28 @@ public void read(org.apache.thrift.protocol.TProtocol prot, get_privilege_set_re } - public static class list_privileges_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("list_privileges_args"); + public static class list_privileges_for_auth_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("list_privileges_for_auth_args"); - private static final org.apache.thrift.protocol.TField PRINCIPAL_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("principal_name", org.apache.thrift.protocol.TType.STRING, (short)1); - private static final org.apache.thrift.protocol.TField PRINCIPAL_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("principal_type", org.apache.thrift.protocol.TType.I32, (short)2); - private static final org.apache.thrift.protocol.TField HIVE_OBJECT_FIELD_DESC = new org.apache.thrift.protocol.TField("hiveObject", org.apache.thrift.protocol.TType.STRUCT, (short)3); + private static final org.apache.thrift.protocol.TField HIVE_OBJECT_FIELD_DESC = new org.apache.thrift.protocol.TField("hiveObject", org.apache.thrift.protocol.TType.STRUCT, (short)1); + private static final org.apache.thrift.protocol.TField USER_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("user_name", org.apache.thrift.protocol.TType.STRING, (short)2); + private static final org.apache.thrift.protocol.TField GROUP_NAMES_FIELD_DESC = new org.apache.thrift.protocol.TField("group_names", org.apache.thrift.protocol.TType.LIST, (short)3); private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); static { - schemes.put(StandardScheme.class, new list_privileges_argsStandardSchemeFactory()); - schemes.put(TupleScheme.class, new list_privileges_argsTupleSchemeFactory()); + schemes.put(StandardScheme.class, new list_privileges_for_auth_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new list_privileges_for_auth_argsTupleSchemeFactory()); } - private String principal_name; // required - private PrincipalType principal_type; // required private HiveObjectRef hiveObject; // required + private String user_name; // required + private List group_names; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { - PRINCIPAL_NAME((short)1, "principal_name"), - /** - * - * @see PrincipalType - */ - PRINCIPAL_TYPE((short)2, "principal_type"), - HIVE_OBJECT((short)3, "hiveObject"); + HIVE_OBJECT((short)1, "hiveObject"), + USER_NAME((short)2, "user_name"), + GROUP_NAMES((short)3, "group_names"); private static final Map byName = new HashMap(); @@ -100323,12 +101515,12 @@ public void read(org.apache.thrift.protocol.TProtocol prot, get_privilege_set_re */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { - case 1: // PRINCIPAL_NAME - return PRINCIPAL_NAME; - case 2: // PRINCIPAL_TYPE - return PRINCIPAL_TYPE; - case 3: // HIVE_OBJECT + case 1: // HIVE_OBJECT return HIVE_OBJECT; + case 2: // USER_NAME + return USER_NAME; + case 3: // GROUP_NAMES + return GROUP_NAMES; default: return null; } @@ -100372,156 +101564,168 @@ public String getFieldName() { public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.PRINCIPAL_NAME, new org.apache.thrift.meta_data.FieldMetaData("principal_name", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.PRINCIPAL_TYPE, new org.apache.thrift.meta_data.FieldMetaData("principal_type", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, PrincipalType.class))); tmpMap.put(_Fields.HIVE_OBJECT, new org.apache.thrift.meta_data.FieldMetaData("hiveObject", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, HiveObjectRef.class))); + tmpMap.put(_Fields.USER_NAME, new org.apache.thrift.meta_data.FieldMetaData("user_name", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.GROUP_NAMES, new org.apache.thrift.meta_data.FieldMetaData("group_names", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(list_privileges_args.class, metaDataMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(list_privileges_for_auth_args.class, metaDataMap); } - public list_privileges_args() { + public list_privileges_for_auth_args() { } - public list_privileges_args( - String principal_name, - PrincipalType principal_type, - HiveObjectRef hiveObject) + public list_privileges_for_auth_args( + HiveObjectRef hiveObject, + String user_name, + List group_names) { this(); - this.principal_name = principal_name; - this.principal_type = principal_type; this.hiveObject = hiveObject; + this.user_name = user_name; + this.group_names = group_names; } /** * Performs a deep copy on other. */ - public list_privileges_args(list_privileges_args other) { - if (other.isSetPrincipal_name()) { - this.principal_name = other.principal_name; - } - if (other.isSetPrincipal_type()) { - this.principal_type = other.principal_type; - } + public list_privileges_for_auth_args(list_privileges_for_auth_args other) { if (other.isSetHiveObject()) { this.hiveObject = new HiveObjectRef(other.hiveObject); } + if (other.isSetUser_name()) { + this.user_name = other.user_name; + } + if (other.isSetGroup_names()) { + List __this__group_names = new ArrayList(); + for (String other_element : other.group_names) { + __this__group_names.add(other_element); + } + this.group_names = __this__group_names; + } } - public list_privileges_args deepCopy() { - return new list_privileges_args(this); + public list_privileges_for_auth_args deepCopy() { + return new list_privileges_for_auth_args(this); } @Override public void clear() { - this.principal_name = null; - this.principal_type = null; this.hiveObject = null; + this.user_name = null; + this.group_names = null; } - public String getPrincipal_name() { - return this.principal_name; + public HiveObjectRef getHiveObject() { + return this.hiveObject; } - public void setPrincipal_name(String principal_name) { - this.principal_name = principal_name; + public void setHiveObject(HiveObjectRef hiveObject) { + this.hiveObject = hiveObject; } - public void unsetPrincipal_name() { - this.principal_name = null; + public void unsetHiveObject() { + this.hiveObject = null; } - /** Returns true if field principal_name is set (has been assigned a value) and false otherwise */ - public boolean isSetPrincipal_name() { - return this.principal_name != null; + /** Returns true if field hiveObject is set (has been assigned a value) and false otherwise */ + public boolean isSetHiveObject() { + return this.hiveObject != null; } - public void setPrincipal_nameIsSet(boolean value) { + public void setHiveObjectIsSet(boolean value) { if (!value) { - this.principal_name = null; + this.hiveObject = null; } } - /** - * - * @see PrincipalType - */ - public PrincipalType getPrincipal_type() { - return this.principal_type; + public String getUser_name() { + return this.user_name; } - /** - * - * @see PrincipalType - */ - public void setPrincipal_type(PrincipalType principal_type) { - this.principal_type = principal_type; + public void setUser_name(String user_name) { + this.user_name = user_name; } - public void unsetPrincipal_type() { - this.principal_type = null; + public void unsetUser_name() { + this.user_name = null; } - /** Returns true if field principal_type is set (has been assigned a value) and false otherwise */ - public boolean isSetPrincipal_type() { - return this.principal_type != null; + /** Returns true if field user_name is set (has been assigned a value) and false otherwise */ + public boolean isSetUser_name() { + return this.user_name != null; } - public void setPrincipal_typeIsSet(boolean value) { + public void setUser_nameIsSet(boolean value) { if (!value) { - this.principal_type = null; + this.user_name = null; } } - public HiveObjectRef getHiveObject() { - return this.hiveObject; + public int getGroup_namesSize() { + return (this.group_names == null) ? 0 : this.group_names.size(); } - public void setHiveObject(HiveObjectRef hiveObject) { - this.hiveObject = hiveObject; + public java.util.Iterator getGroup_namesIterator() { + return (this.group_names == null) ? null : this.group_names.iterator(); } - public void unsetHiveObject() { - this.hiveObject = null; + public void addToGroup_names(String elem) { + if (this.group_names == null) { + this.group_names = new ArrayList(); + } + this.group_names.add(elem); } - /** Returns true if field hiveObject is set (has been assigned a value) and false otherwise */ - public boolean isSetHiveObject() { - return this.hiveObject != null; + public List getGroup_names() { + return this.group_names; } - public void setHiveObjectIsSet(boolean value) { + public void setGroup_names(List group_names) { + this.group_names = group_names; + } + + public void unsetGroup_names() { + this.group_names = null; + } + + /** Returns true if field group_names is set (has been assigned a value) and false otherwise */ + public boolean isSetGroup_names() { + return this.group_names != null; + } + + public void setGroup_namesIsSet(boolean value) { if (!value) { - this.hiveObject = null; + this.group_names = null; } } public void setFieldValue(_Fields field, Object value) { switch (field) { - case PRINCIPAL_NAME: + case HIVE_OBJECT: if (value == null) { - unsetPrincipal_name(); + unsetHiveObject(); } else { - setPrincipal_name((String)value); + setHiveObject((HiveObjectRef)value); } break; - case PRINCIPAL_TYPE: + case USER_NAME: if (value == null) { - unsetPrincipal_type(); + unsetUser_name(); } else { - setPrincipal_type((PrincipalType)value); + setUser_name((String)value); } break; - case HIVE_OBJECT: + case GROUP_NAMES: if (value == null) { - unsetHiveObject(); + unsetGroup_names(); } else { - setHiveObject((HiveObjectRef)value); + setGroup_names((List)value); } break; @@ -100530,15 +101734,15 @@ public void setFieldValue(_Fields field, Object value) { public Object getFieldValue(_Fields field) { switch (field) { - case PRINCIPAL_NAME: - return getPrincipal_name(); - - case PRINCIPAL_TYPE: - return getPrincipal_type(); - case HIVE_OBJECT: return getHiveObject(); + case USER_NAME: + return getUser_name(); + + case GROUP_NAMES: + return getGroup_names(); + } throw new IllegalStateException(); } @@ -100550,12 +101754,12 @@ public boolean isSet(_Fields field) { } switch (field) { - case PRINCIPAL_NAME: - return isSetPrincipal_name(); - case PRINCIPAL_TYPE: - return isSetPrincipal_type(); case HIVE_OBJECT: return isSetHiveObject(); + case USER_NAME: + return isSetUser_name(); + case GROUP_NAMES: + return isSetGroup_names(); } throw new IllegalStateException(); } @@ -100564,39 +101768,39 @@ public boolean isSet(_Fields field) { public boolean equals(Object that) { if (that == null) return false; - if (that instanceof list_privileges_args) - return this.equals((list_privileges_args)that); + if (that instanceof list_privileges_for_auth_args) + return this.equals((list_privileges_for_auth_args)that); return false; } - public boolean equals(list_privileges_args that) { + public boolean equals(list_privileges_for_auth_args that) { if (that == null) return false; - boolean this_present_principal_name = true && this.isSetPrincipal_name(); - boolean that_present_principal_name = true && that.isSetPrincipal_name(); - if (this_present_principal_name || that_present_principal_name) { - if (!(this_present_principal_name && that_present_principal_name)) + boolean this_present_hiveObject = true && this.isSetHiveObject(); + boolean that_present_hiveObject = true && that.isSetHiveObject(); + if (this_present_hiveObject || that_present_hiveObject) { + if (!(this_present_hiveObject && that_present_hiveObject)) return false; - if (!this.principal_name.equals(that.principal_name)) + if (!this.hiveObject.equals(that.hiveObject)) return false; } - boolean this_present_principal_type = true && this.isSetPrincipal_type(); - boolean that_present_principal_type = true && that.isSetPrincipal_type(); - if (this_present_principal_type || that_present_principal_type) { - if (!(this_present_principal_type && that_present_principal_type)) + boolean this_present_user_name = true && this.isSetUser_name(); + boolean that_present_user_name = true && that.isSetUser_name(); + if (this_present_user_name || that_present_user_name) { + if (!(this_present_user_name && that_present_user_name)) return false; - if (!this.principal_type.equals(that.principal_type)) + if (!this.user_name.equals(that.user_name)) return false; } - boolean this_present_hiveObject = true && this.isSetHiveObject(); - boolean that_present_hiveObject = true && that.isSetHiveObject(); - if (this_present_hiveObject || that_present_hiveObject) { - if (!(this_present_hiveObject && that_present_hiveObject)) + boolean this_present_group_names = true && this.isSetGroup_names(); + boolean that_present_group_names = true && that.isSetGroup_names(); + if (this_present_group_names || that_present_group_names) { + if (!(this_present_group_names && that_present_group_names)) return false; - if (!this.hiveObject.equals(that.hiveObject)) + if (!this.group_names.equals(that.group_names)) return false; } @@ -100607,58 +101811,58 @@ public boolean equals(list_privileges_args that) { public int hashCode() { HashCodeBuilder builder = new HashCodeBuilder(); - boolean present_principal_name = true && (isSetPrincipal_name()); - builder.append(present_principal_name); - if (present_principal_name) - builder.append(principal_name); - - boolean present_principal_type = true && (isSetPrincipal_type()); - builder.append(present_principal_type); - if (present_principal_type) - builder.append(principal_type.getValue()); - boolean present_hiveObject = true && (isSetHiveObject()); builder.append(present_hiveObject); if (present_hiveObject) builder.append(hiveObject); + boolean present_user_name = true && (isSetUser_name()); + builder.append(present_user_name); + if (present_user_name) + builder.append(user_name); + + boolean present_group_names = true && (isSetGroup_names()); + builder.append(present_group_names); + if (present_group_names) + builder.append(group_names); + return builder.toHashCode(); } - public int compareTo(list_privileges_args other) { + public int compareTo(list_privileges_for_auth_args other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; - list_privileges_args typedOther = (list_privileges_args)other; + list_privileges_for_auth_args typedOther = (list_privileges_for_auth_args)other; - lastComparison = Boolean.valueOf(isSetPrincipal_name()).compareTo(typedOther.isSetPrincipal_name()); + lastComparison = Boolean.valueOf(isSetHiveObject()).compareTo(typedOther.isSetHiveObject()); if (lastComparison != 0) { return lastComparison; } - if (isSetPrincipal_name()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.principal_name, typedOther.principal_name); + if (isSetHiveObject()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.hiveObject, typedOther.hiveObject); if (lastComparison != 0) { return lastComparison; } } - lastComparison = Boolean.valueOf(isSetPrincipal_type()).compareTo(typedOther.isSetPrincipal_type()); + lastComparison = Boolean.valueOf(isSetUser_name()).compareTo(typedOther.isSetUser_name()); if (lastComparison != 0) { return lastComparison; } - if (isSetPrincipal_type()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.principal_type, typedOther.principal_type); + if (isSetUser_name()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.user_name, typedOther.user_name); if (lastComparison != 0) { return lastComparison; } } - lastComparison = Boolean.valueOf(isSetHiveObject()).compareTo(typedOther.isSetHiveObject()); + lastComparison = Boolean.valueOf(isSetGroup_names()).compareTo(typedOther.isSetGroup_names()); if (lastComparison != 0) { return lastComparison; } - if (isSetHiveObject()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.hiveObject, typedOther.hiveObject); + if (isSetGroup_names()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.group_names, typedOther.group_names); if (lastComparison != 0) { return lastComparison; } @@ -100680,30 +101884,30 @@ public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache. @Override public String toString() { - StringBuilder sb = new StringBuilder("list_privileges_args("); + StringBuilder sb = new StringBuilder("list_privileges_for_auth_args("); boolean first = true; - sb.append("principal_name:"); - if (this.principal_name == null) { + sb.append("hiveObject:"); + if (this.hiveObject == null) { sb.append("null"); } else { - sb.append(this.principal_name); + sb.append(this.hiveObject); } first = false; if (!first) sb.append(", "); - sb.append("principal_type:"); - if (this.principal_type == null) { + sb.append("user_name:"); + if (this.user_name == null) { sb.append("null"); } else { - sb.append(this.principal_type); + sb.append(this.user_name); } first = false; if (!first) sb.append(", "); - sb.append("hiveObject:"); - if (this.hiveObject == null) { + sb.append("group_names:"); + if (this.group_names == null) { sb.append("null"); } else { - sb.append(this.hiveObject); + sb.append(this.group_names); } first = false; sb.append(")"); @@ -100734,15 +101938,15 @@ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException } } - private static class list_privileges_argsStandardSchemeFactory implements SchemeFactory { - public list_privileges_argsStandardScheme getScheme() { - return new list_privileges_argsStandardScheme(); + private static class list_privileges_for_auth_argsStandardSchemeFactory implements SchemeFactory { + public list_privileges_for_auth_argsStandardScheme getScheme() { + return new list_privileges_for_auth_argsStandardScheme(); } } - private static class list_privileges_argsStandardScheme extends StandardScheme { + private static class list_privileges_for_auth_argsStandardScheme extends StandardScheme { - public void read(org.apache.thrift.protocol.TProtocol iprot, list_privileges_args struct) throws org.apache.thrift.TException { + public void read(org.apache.thrift.protocol.TProtocol iprot, list_privileges_for_auth_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) @@ -100752,27 +101956,37 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, list_privileges_arg break; } switch (schemeField.id) { - case 1: // PRINCIPAL_NAME - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.principal_name = iprot.readString(); - struct.setPrincipal_nameIsSet(true); + case 1: // HIVE_OBJECT + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.hiveObject = new HiveObjectRef(); + struct.hiveObject.read(iprot); + struct.setHiveObjectIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; - case 2: // PRINCIPAL_TYPE - if (schemeField.type == org.apache.thrift.protocol.TType.I32) { - struct.principal_type = PrincipalType.findByValue(iprot.readI32()); - struct.setPrincipal_typeIsSet(true); + case 2: // USER_NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.user_name = iprot.readString(); + struct.setUser_nameIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; - case 3: // HIVE_OBJECT - if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { - struct.hiveObject = new HiveObjectRef(); - struct.hiveObject.read(iprot); - struct.setHiveObjectIsSet(true); + case 3: // GROUP_NAMES + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list732 = iprot.readListBegin(); + struct.group_names = new ArrayList(_list732.size); + for (int _i733 = 0; _i733 < _list732.size; ++_i733) + { + String _elem734; // required + _elem734 = iprot.readString(); + struct.group_names.add(_elem734); + } + iprot.readListEnd(); + } + struct.setGroup_namesIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -100786,23 +102000,30 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, list_privileges_arg struct.validate(); } - public void write(org.apache.thrift.protocol.TProtocol oprot, list_privileges_args struct) throws org.apache.thrift.TException { + public void write(org.apache.thrift.protocol.TProtocol oprot, list_privileges_for_auth_args struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); - if (struct.principal_name != null) { - oprot.writeFieldBegin(PRINCIPAL_NAME_FIELD_DESC); - oprot.writeString(struct.principal_name); + if (struct.hiveObject != null) { + oprot.writeFieldBegin(HIVE_OBJECT_FIELD_DESC); + struct.hiveObject.write(oprot); oprot.writeFieldEnd(); } - if (struct.principal_type != null) { - oprot.writeFieldBegin(PRINCIPAL_TYPE_FIELD_DESC); - oprot.writeI32(struct.principal_type.getValue()); + if (struct.user_name != null) { + oprot.writeFieldBegin(USER_NAME_FIELD_DESC); + oprot.writeString(struct.user_name); oprot.writeFieldEnd(); } - if (struct.hiveObject != null) { - oprot.writeFieldBegin(HIVE_OBJECT_FIELD_DESC); - struct.hiveObject.write(oprot); + if (struct.group_names != null) { + oprot.writeFieldBegin(GROUP_NAMES_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.group_names.size())); + for (String _iter735 : struct.group_names) + { + oprot.writeString(_iter735); + } + oprot.writeListEnd(); + } oprot.writeFieldEnd(); } oprot.writeFieldStop(); @@ -100811,74 +102032,89 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, list_privileges_ar } - private static class list_privileges_argsTupleSchemeFactory implements SchemeFactory { - public list_privileges_argsTupleScheme getScheme() { - return new list_privileges_argsTupleScheme(); + private static class list_privileges_for_auth_argsTupleSchemeFactory implements SchemeFactory { + public list_privileges_for_auth_argsTupleScheme getScheme() { + return new list_privileges_for_auth_argsTupleScheme(); } } - private static class list_privileges_argsTupleScheme extends TupleScheme { + private static class list_privileges_for_auth_argsTupleScheme extends TupleScheme { @Override - public void write(org.apache.thrift.protocol.TProtocol prot, list_privileges_args struct) throws org.apache.thrift.TException { + public void write(org.apache.thrift.protocol.TProtocol prot, list_privileges_for_auth_args struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); - if (struct.isSetPrincipal_name()) { + if (struct.isSetHiveObject()) { optionals.set(0); } - if (struct.isSetPrincipal_type()) { + if (struct.isSetUser_name()) { optionals.set(1); } - if (struct.isSetHiveObject()) { + if (struct.isSetGroup_names()) { optionals.set(2); } oprot.writeBitSet(optionals, 3); - if (struct.isSetPrincipal_name()) { - oprot.writeString(struct.principal_name); - } - if (struct.isSetPrincipal_type()) { - oprot.writeI32(struct.principal_type.getValue()); - } if (struct.isSetHiveObject()) { struct.hiveObject.write(oprot); } + if (struct.isSetUser_name()) { + oprot.writeString(struct.user_name); + } + if (struct.isSetGroup_names()) { + { + oprot.writeI32(struct.group_names.size()); + for (String _iter736 : struct.group_names) + { + oprot.writeString(_iter736); + } + } + } } @Override - public void read(org.apache.thrift.protocol.TProtocol prot, list_privileges_args struct) throws org.apache.thrift.TException { + public void read(org.apache.thrift.protocol.TProtocol prot, list_privileges_for_auth_args struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(3); if (incoming.get(0)) { - struct.principal_name = iprot.readString(); - struct.setPrincipal_nameIsSet(true); + struct.hiveObject = new HiveObjectRef(); + struct.hiveObject.read(iprot); + struct.setHiveObjectIsSet(true); } if (incoming.get(1)) { - struct.principal_type = PrincipalType.findByValue(iprot.readI32()); - struct.setPrincipal_typeIsSet(true); + struct.user_name = iprot.readString(); + struct.setUser_nameIsSet(true); } if (incoming.get(2)) { - struct.hiveObject = new HiveObjectRef(); - struct.hiveObject.read(iprot); - struct.setHiveObjectIsSet(true); + { + org.apache.thrift.protocol.TList _list737 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.group_names = new ArrayList(_list737.size); + for (int _i738 = 0; _i738 < _list737.size; ++_i738) + { + String _elem739; // required + _elem739 = iprot.readString(); + struct.group_names.add(_elem739); + } + } + struct.setGroup_namesIsSet(true); } } } } - public static class list_privileges_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("list_privileges_result"); + public static class list_privileges_for_auth_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("list_privileges_for_auth_result"); private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.LIST, (short)0); private static final org.apache.thrift.protocol.TField O1_FIELD_DESC = new org.apache.thrift.protocol.TField("o1", org.apache.thrift.protocol.TType.STRUCT, (short)1); private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); static { - schemes.put(StandardScheme.class, new list_privileges_resultStandardSchemeFactory()); - schemes.put(TupleScheme.class, new list_privileges_resultTupleSchemeFactory()); + schemes.put(StandardScheme.class, new list_privileges_for_auth_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new list_privileges_for_auth_resultTupleSchemeFactory()); } - private List success; // required + private List success; // required private MetaException o1; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ @@ -100948,18 +102184,18 @@ public String getFieldName() { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, - new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, HiveObjectPrivilege.class)))); + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); tmpMap.put(_Fields.O1, new org.apache.thrift.meta_data.FieldMetaData("o1", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(list_privileges_result.class, metaDataMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(list_privileges_for_auth_result.class, metaDataMap); } - public list_privileges_result() { + public list_privileges_for_auth_result() { } - public list_privileges_result( - List success, + public list_privileges_for_auth_result( + List success, MetaException o1) { this(); @@ -100970,11 +102206,11 @@ public list_privileges_result( /** * Performs a deep copy on other. */ - public list_privileges_result(list_privileges_result other) { + public list_privileges_for_auth_result(list_privileges_for_auth_result other) { if (other.isSetSuccess()) { - List __this__success = new ArrayList(); - for (HiveObjectPrivilege other_element : other.success) { - __this__success.add(new HiveObjectPrivilege(other_element)); + List __this__success = new ArrayList(); + for (String other_element : other.success) { + __this__success.add(other_element); } this.success = __this__success; } @@ -100983,8 +102219,8 @@ public list_privileges_result(list_privileges_result other) { } } - public list_privileges_result deepCopy() { - return new list_privileges_result(this); + public list_privileges_for_auth_result deepCopy() { + return new list_privileges_for_auth_result(this); } @Override @@ -100997,22 +102233,22 @@ public int getSuccessSize() { return (this.success == null) ? 0 : this.success.size(); } - public java.util.Iterator getSuccessIterator() { + public java.util.Iterator getSuccessIterator() { return (this.success == null) ? null : this.success.iterator(); } - public void addToSuccess(HiveObjectPrivilege elem) { + public void addToSuccess(String elem) { if (this.success == null) { - this.success = new ArrayList(); + this.success = new ArrayList(); } this.success.add(elem); } - public List getSuccess() { + public List getSuccess() { return this.success; } - public void setSuccess(List success) { + public void setSuccess(List success) { this.success = success; } @@ -101060,7 +102296,7 @@ public void setFieldValue(_Fields field, Object value) { if (value == null) { unsetSuccess(); } else { - setSuccess((List)value); + setSuccess((List)value); } break; @@ -101106,12 +102342,12 @@ public boolean isSet(_Fields field) { public boolean equals(Object that) { if (that == null) return false; - if (that instanceof list_privileges_result) - return this.equals((list_privileges_result)that); + if (that instanceof list_privileges_for_auth_result) + return this.equals((list_privileges_for_auth_result)that); return false; } - public boolean equals(list_privileges_result that) { + public boolean equals(list_privileges_for_auth_result that) { if (that == null) return false; @@ -101153,13 +102389,13 @@ public int hashCode() { return builder.toHashCode(); } - public int compareTo(list_privileges_result other) { + public int compareTo(list_privileges_for_auth_result other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; - list_privileges_result typedOther = (list_privileges_result)other; + list_privileges_for_auth_result typedOther = (list_privileges_for_auth_result)other; lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(typedOther.isSetSuccess()); if (lastComparison != 0) { @@ -101198,7 +102434,7 @@ public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache. @Override public String toString() { - StringBuilder sb = new StringBuilder("list_privileges_result("); + StringBuilder sb = new StringBuilder("list_privileges_for_auth_result("); boolean first = true; sb.append("success:"); @@ -101241,15 +102477,15 @@ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException } } - private static class list_privileges_resultStandardSchemeFactory implements SchemeFactory { - public list_privileges_resultStandardScheme getScheme() { - return new list_privileges_resultStandardScheme(); + private static class list_privileges_for_auth_resultStandardSchemeFactory implements SchemeFactory { + public list_privileges_for_auth_resultStandardScheme getScheme() { + return new list_privileges_for_auth_resultStandardScheme(); } } - private static class list_privileges_resultStandardScheme extends StandardScheme { + private static class list_privileges_for_auth_resultStandardScheme extends StandardScheme { - public void read(org.apache.thrift.protocol.TProtocol iprot, list_privileges_result struct) throws org.apache.thrift.TException { + public void read(org.apache.thrift.protocol.TProtocol iprot, list_privileges_for_auth_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) @@ -101262,14 +102498,13 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, list_privileges_res case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list724 = iprot.readListBegin(); - struct.success = new ArrayList(_list724.size); - for (int _i725 = 0; _i725 < _list724.size; ++_i725) + org.apache.thrift.protocol.TList _list740 = iprot.readListBegin(); + struct.success = new ArrayList(_list740.size); + for (int _i741 = 0; _i741 < _list740.size; ++_i741) { - HiveObjectPrivilege _elem726; // required - _elem726 = new HiveObjectPrivilege(); - _elem726.read(iprot); - struct.success.add(_elem726); + String _elem742; // required + _elem742 = iprot.readString(); + struct.success.add(_elem742); } iprot.readListEnd(); } @@ -101296,17 +102531,17 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, list_privileges_res struct.validate(); } - public void write(org.apache.thrift.protocol.TProtocol oprot, list_privileges_result struct) throws org.apache.thrift.TException { + public void write(org.apache.thrift.protocol.TProtocol oprot, list_privileges_for_auth_result struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.success != null) { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { - oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.success.size())); - for (HiveObjectPrivilege _iter727 : struct.success) + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.success.size())); + for (String _iter743 : struct.success) { - _iter727.write(oprot); + oprot.writeString(_iter743); } oprot.writeListEnd(); } @@ -101323,16 +102558,16 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, list_privileges_re } - private static class list_privileges_resultTupleSchemeFactory implements SchemeFactory { - public list_privileges_resultTupleScheme getScheme() { - return new list_privileges_resultTupleScheme(); + private static class list_privileges_for_auth_resultTupleSchemeFactory implements SchemeFactory { + public list_privileges_for_auth_resultTupleScheme getScheme() { + return new list_privileges_for_auth_resultTupleScheme(); } } - private static class list_privileges_resultTupleScheme extends TupleScheme { + private static class list_privileges_for_auth_resultTupleScheme extends TupleScheme { @Override - public void write(org.apache.thrift.protocol.TProtocol prot, list_privileges_result struct) throws org.apache.thrift.TException { + public void write(org.apache.thrift.protocol.TProtocol prot, list_privileges_for_auth_result struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetSuccess()) { @@ -101345,9 +102580,9 @@ public void write(org.apache.thrift.protocol.TProtocol prot, list_privileges_res if (struct.isSetSuccess()) { { oprot.writeI32(struct.success.size()); - for (HiveObjectPrivilege _iter728 : struct.success) + for (String _iter744 : struct.success) { - _iter728.write(oprot); + oprot.writeString(_iter744); } } } @@ -101357,19 +102592,18 @@ public void write(org.apache.thrift.protocol.TProtocol prot, list_privileges_res } @Override - public void read(org.apache.thrift.protocol.TProtocol prot, list_privileges_result struct) throws org.apache.thrift.TException { + public void read(org.apache.thrift.protocol.TProtocol prot, list_privileges_for_auth_result struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { { - org.apache.thrift.protocol.TList _list729 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.success = new ArrayList(_list729.size); - for (int _i730 = 0; _i730 < _list729.size; ++_i730) + org.apache.thrift.protocol.TList _list745 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.success = new ArrayList(_list745.size); + for (int _i746 = 0; _i746 < _list745.size; ++_i746) { - HiveObjectPrivilege _elem731; // required - _elem731 = new HiveObjectPrivilege(); - _elem731.read(iprot); - struct.success.add(_elem731); + String _elem747; // required + _elem747 = iprot.readString(); + struct.success.add(_elem747); } } struct.setSuccessIsSet(true); @@ -103442,13 +104676,13 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, set_ugi_args struct case 2: // GROUP_NAMES if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list732 = iprot.readListBegin(); - struct.group_names = new ArrayList(_list732.size); - for (int _i733 = 0; _i733 < _list732.size; ++_i733) + org.apache.thrift.protocol.TList _list748 = iprot.readListBegin(); + struct.group_names = new ArrayList(_list748.size); + for (int _i749 = 0; _i749 < _list748.size; ++_i749) { - String _elem734; // required - _elem734 = iprot.readString(); - struct.group_names.add(_elem734); + String _elem750; // required + _elem750 = iprot.readString(); + struct.group_names.add(_elem750); } iprot.readListEnd(); } @@ -103479,9 +104713,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, set_ugi_args struc oprot.writeFieldBegin(GROUP_NAMES_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.group_names.size())); - for (String _iter735 : struct.group_names) + for (String _iter751 : struct.group_names) { - oprot.writeString(_iter735); + oprot.writeString(_iter751); } oprot.writeListEnd(); } @@ -103518,9 +104752,9 @@ public void write(org.apache.thrift.protocol.TProtocol prot, set_ugi_args struct if (struct.isSetGroup_names()) { { oprot.writeI32(struct.group_names.size()); - for (String _iter736 : struct.group_names) + for (String _iter752 : struct.group_names) { - oprot.writeString(_iter736); + oprot.writeString(_iter752); } } } @@ -103536,13 +104770,13 @@ public void read(org.apache.thrift.protocol.TProtocol prot, set_ugi_args struct) } if (incoming.get(1)) { { - org.apache.thrift.protocol.TList _list737 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); - struct.group_names = new ArrayList(_list737.size); - for (int _i738 = 0; _i738 < _list737.size; ++_i738) + org.apache.thrift.protocol.TList _list753 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.group_names = new ArrayList(_list753.size); + for (int _i754 = 0; _i754 < _list753.size; ++_i754) { - String _elem739; // required - _elem739 = iprot.readString(); - struct.group_names.add(_elem739); + String _elem755; // required + _elem755 = iprot.readString(); + struct.group_names.add(_elem755); } } struct.setGroup_namesIsSet(true); @@ -103948,13 +105182,13 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, set_ugi_result stru case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list740 = iprot.readListBegin(); - struct.success = new ArrayList(_list740.size); - for (int _i741 = 0; _i741 < _list740.size; ++_i741) + org.apache.thrift.protocol.TList _list756 = iprot.readListBegin(); + struct.success = new ArrayList(_list756.size); + for (int _i757 = 0; _i757 < _list756.size; ++_i757) { - String _elem742; // required - _elem742 = iprot.readString(); - struct.success.add(_elem742); + String _elem758; // required + _elem758 = iprot.readString(); + struct.success.add(_elem758); } iprot.readListEnd(); } @@ -103989,9 +105223,9 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, set_ugi_result str oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.success.size())); - for (String _iter743 : struct.success) + for (String _iter759 : struct.success) { - oprot.writeString(_iter743); + oprot.writeString(_iter759); } oprot.writeListEnd(); } @@ -104030,9 +105264,9 @@ public void write(org.apache.thrift.protocol.TProtocol prot, set_ugi_result stru if (struct.isSetSuccess()) { { oprot.writeI32(struct.success.size()); - for (String _iter744 : struct.success) + for (String _iter760 : struct.success) { - oprot.writeString(_iter744); + oprot.writeString(_iter760); } } } @@ -104047,13 +105281,13 @@ public void read(org.apache.thrift.protocol.TProtocol prot, set_ugi_result struc BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { { - org.apache.thrift.protocol.TList _list745 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); - struct.success = new ArrayList(_list745.size); - for (int _i746 = 0; _i746 < _list745.size; ++_i746) + org.apache.thrift.protocol.TList _list761 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.success = new ArrayList(_list761.size); + for (int _i762 = 0; _i762 < _list761.size; ++_i762) { - String _elem747; // required - _elem747 = iprot.readString(); - struct.success.add(_elem747); + String _elem763; // required + _elem763 = iprot.readString(); + struct.success.add(_elem763); } } struct.setSuccessIsSet(true); diff --git metastore/src/gen/thrift/gen-php/metastore/ThriftHiveMetastore.php metastore/src/gen/thrift/gen-php/metastore/ThriftHiveMetastore.php index a983724..1deecc1 100644 --- metastore/src/gen/thrift/gen-php/metastore/ThriftHiveMetastore.php +++ metastore/src/gen/thrift/gen-php/metastore/ThriftHiveMetastore.php @@ -97,6 +97,7 @@ interface ThriftHiveMetastoreIf extends \FacebookServiceIf { public function list_roles($principal_name, $principal_type); public function get_privilege_set(\metastore\HiveObjectRef $hiveObject, $user_name, $group_names); public function list_privileges($principal_name, $principal_type, \metastore\HiveObjectRef $hiveObject); + public function list_privileges_for_auth(\metastore\HiveObjectRef $hiveObject, $user_name, $group_names); public function grant_privileges(\metastore\PrivilegeBag $privileges); public function revoke_privileges(\metastore\PrivilegeBag $privileges); public function set_ugi($user_name, $group_names); @@ -4884,6 +4885,62 @@ class ThriftHiveMetastoreClient extends \FacebookServiceClient implements \metas throw new \Exception("list_privileges failed: unknown result"); } + public function list_privileges_for_auth(\metastore\HiveObjectRef $hiveObject, $user_name, $group_names) + { + $this->send_list_privileges_for_auth($hiveObject, $user_name, $group_names); + return $this->recv_list_privileges_for_auth(); + } + + public function send_list_privileges_for_auth(\metastore\HiveObjectRef $hiveObject, $user_name, $group_names) + { + $args = new \metastore\ThriftHiveMetastore_list_privileges_for_auth_args(); + $args->hiveObject = $hiveObject; + $args->user_name = $user_name; + $args->group_names = $group_names; + $bin_accel = ($this->output_ instanceof TProtocol::$TBINARYPROTOCOLACCELERATED) && function_exists('thrift_protocol_write_binary'); + if ($bin_accel) + { + thrift_protocol_write_binary($this->output_, 'list_privileges_for_auth', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); + } + else + { + $this->output_->writeMessageBegin('list_privileges_for_auth', TMessageType::CALL, $this->seqid_); + $args->write($this->output_); + $this->output_->writeMessageEnd(); + $this->output_->getTransport()->flush(); + } + } + + public function recv_list_privileges_for_auth() + { + $bin_accel = ($this->input_ instanceof TProtocol::$TBINARYPROTOCOLACCELERATED) && function_exists('thrift_protocol_read_binary'); + if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\metastore\ThriftHiveMetastore_list_privileges_for_auth_result', $this->input_->isStrictRead()); + else + { + $rseqid = 0; + $fname = null; + $mtype = 0; + + $this->input_->readMessageBegin($fname, $mtype, $rseqid); + if ($mtype == TMessageType::EXCEPTION) { + $x = new TApplicationException(); + $x->read($this->input_); + $this->input_->readMessageEnd(); + throw $x; + } + $result = new \metastore\ThriftHiveMetastore_list_privileges_for_auth_result(); + $result->read($this->input_); + $this->input_->readMessageEnd(); + } + if ($result->success !== null) { + return $result->success; + } + if ($result->o1 !== null) { + throw $result->o1; + } + throw new \Exception("list_privileges_for_auth failed: unknown result"); + } + public function grant_privileges(\metastore\PrivilegeBag $privileges) { $this->send_grant_privileges($privileges); @@ -24852,6 +24909,269 @@ class ThriftHiveMetastore_list_privileges_result { } +class ThriftHiveMetastore_list_privileges_for_auth_args { + static $_TSPEC; + + public $hiveObject = null; + public $user_name = null; + public $group_names = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'hiveObject', + 'type' => TType::STRUCT, + 'class' => '\metastore\HiveObjectRef', + ), + 2 => array( + 'var' => 'user_name', + 'type' => TType::STRING, + ), + 3 => array( + 'var' => 'group_names', + 'type' => TType::LST, + 'etype' => TType::STRING, + 'elem' => array( + 'type' => TType::STRING, + ), + ), + ); + } + if (is_array($vals)) { + if (isset($vals['hiveObject'])) { + $this->hiveObject = $vals['hiveObject']; + } + if (isset($vals['user_name'])) { + $this->user_name = $vals['user_name']; + } + if (isset($vals['group_names'])) { + $this->group_names = $vals['group_names']; + } + } + } + + public function getName() { + return 'ThriftHiveMetastore_list_privileges_for_auth_args'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::STRUCT) { + $this->hiveObject = new \metastore\HiveObjectRef(); + $xfer += $this->hiveObject->read($input); + } else { + $xfer += $input->skip($ftype); + } + break; + case 2: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->user_name); + } else { + $xfer += $input->skip($ftype); + } + break; + case 3: + if ($ftype == TType::LST) { + $this->group_names = array(); + $_size645 = 0; + $_etype648 = 0; + $xfer += $input->readListBegin($_etype648, $_size645); + for ($_i649 = 0; $_i649 < $_size645; ++$_i649) + { + $elem650 = null; + $xfer += $input->readString($elem650); + $this->group_names []= $elem650; + } + $xfer += $input->readListEnd(); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('ThriftHiveMetastore_list_privileges_for_auth_args'); + if ($this->hiveObject !== null) { + if (!is_object($this->hiveObject)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('hiveObject', TType::STRUCT, 1); + $xfer += $this->hiveObject->write($output); + $xfer += $output->writeFieldEnd(); + } + if ($this->user_name !== null) { + $xfer += $output->writeFieldBegin('user_name', TType::STRING, 2); + $xfer += $output->writeString($this->user_name); + $xfer += $output->writeFieldEnd(); + } + if ($this->group_names !== null) { + if (!is_array($this->group_names)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('group_names', TType::LST, 3); + { + $output->writeListBegin(TType::STRING, count($this->group_names)); + { + foreach ($this->group_names as $iter651) + { + $xfer += $output->writeString($iter651); + } + } + $output->writeListEnd(); + } + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class ThriftHiveMetastore_list_privileges_for_auth_result { + static $_TSPEC; + + public $success = null; + public $o1 = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 0 => array( + 'var' => 'success', + 'type' => TType::LST, + 'etype' => TType::STRING, + 'elem' => array( + 'type' => TType::STRING, + ), + ), + 1 => array( + 'var' => 'o1', + 'type' => TType::STRUCT, + 'class' => '\metastore\MetaException', + ), + ); + } + if (is_array($vals)) { + if (isset($vals['success'])) { + $this->success = $vals['success']; + } + if (isset($vals['o1'])) { + $this->o1 = $vals['o1']; + } + } + } + + public function getName() { + return 'ThriftHiveMetastore_list_privileges_for_auth_result'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 0: + if ($ftype == TType::LST) { + $this->success = array(); + $_size652 = 0; + $_etype655 = 0; + $xfer += $input->readListBegin($_etype655, $_size652); + for ($_i656 = 0; $_i656 < $_size652; ++$_i656) + { + $elem657 = null; + $xfer += $input->readString($elem657); + $this->success []= $elem657; + } + $xfer += $input->readListEnd(); + } else { + $xfer += $input->skip($ftype); + } + break; + case 1: + if ($ftype == TType::STRUCT) { + $this->o1 = new \metastore\MetaException(); + $xfer += $this->o1->read($input); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('ThriftHiveMetastore_list_privileges_for_auth_result'); + if ($this->success !== null) { + if (!is_array($this->success)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('success', TType::LST, 0); + { + $output->writeListBegin(TType::STRING, count($this->success)); + { + foreach ($this->success as $iter658) + { + $xfer += $output->writeString($iter658); + } + } + $output->writeListEnd(); + } + $xfer += $output->writeFieldEnd(); + } + if ($this->o1 !== null) { + $xfer += $output->writeFieldBegin('o1', TType::STRUCT, 1); + $xfer += $this->o1->write($output); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + class ThriftHiveMetastore_grant_privileges_args { static $_TSPEC; @@ -25256,14 +25576,14 @@ class ThriftHiveMetastore_set_ugi_args { case 2: if ($ftype == TType::LST) { $this->group_names = array(); - $_size645 = 0; - $_etype648 = 0; - $xfer += $input->readListBegin($_etype648, $_size645); - for ($_i649 = 0; $_i649 < $_size645; ++$_i649) + $_size659 = 0; + $_etype662 = 0; + $xfer += $input->readListBegin($_etype662, $_size659); + for ($_i663 = 0; $_i663 < $_size659; ++$_i663) { - $elem650 = null; - $xfer += $input->readString($elem650); - $this->group_names []= $elem650; + $elem664 = null; + $xfer += $input->readString($elem664); + $this->group_names []= $elem664; } $xfer += $input->readListEnd(); } else { @@ -25296,9 +25616,9 @@ class ThriftHiveMetastore_set_ugi_args { { $output->writeListBegin(TType::STRING, count($this->group_names)); { - foreach ($this->group_names as $iter651) + foreach ($this->group_names as $iter665) { - $xfer += $output->writeString($iter651); + $xfer += $output->writeString($iter665); } } $output->writeListEnd(); @@ -25368,14 +25688,14 @@ class ThriftHiveMetastore_set_ugi_result { case 0: if ($ftype == TType::LST) { $this->success = array(); - $_size652 = 0; - $_etype655 = 0; - $xfer += $input->readListBegin($_etype655, $_size652); - for ($_i656 = 0; $_i656 < $_size652; ++$_i656) + $_size666 = 0; + $_etype669 = 0; + $xfer += $input->readListBegin($_etype669, $_size666); + for ($_i670 = 0; $_i670 < $_size666; ++$_i670) { - $elem657 = null; - $xfer += $input->readString($elem657); - $this->success []= $elem657; + $elem671 = null; + $xfer += $input->readString($elem671); + $this->success []= $elem671; } $xfer += $input->readListEnd(); } else { @@ -25411,9 +25731,9 @@ class ThriftHiveMetastore_set_ugi_result { { $output->writeListBegin(TType::STRING, count($this->success)); { - foreach ($this->success as $iter658) + foreach ($this->success as $iter672) { - $xfer += $output->writeString($iter658); + $xfer += $output->writeString($iter672); } } $output->writeListEnd(); diff --git metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore-remote metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore-remote old mode 100644 new mode 100755 index 1986afa..1783ae4 --- metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore-remote +++ metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore-remote @@ -104,6 +104,7 @@ if len(sys.argv) <= 1 or sys.argv[1] == '--help': print ' list_roles(string principal_name, PrincipalType principal_type)' print ' PrincipalPrivilegeSet get_privilege_set(HiveObjectRef hiveObject, string user_name, group_names)' print ' list_privileges(string principal_name, PrincipalType principal_type, HiveObjectRef hiveObject)' + print ' list_privileges_for_auth(HiveObjectRef hiveObject, string user_name, group_names)' print ' bool grant_privileges(PrivilegeBag privileges)' print ' bool revoke_privileges(PrivilegeBag privileges)' print ' set_ugi(string user_name, group_names)' @@ -647,6 +648,12 @@ elif cmd == 'list_privileges': sys.exit(1) pp.pprint(client.list_privileges(args[0],eval(args[1]),eval(args[2]),)) +elif cmd == 'list_privileges_for_auth': + if len(args) != 3: + print 'list_privileges_for_auth requires 3 args' + sys.exit(1) + pp.pprint(client.list_privileges_for_auth(eval(args[0]),args[1],eval(args[2]),)) + elif cmd == 'grant_privileges': if len(args) != 1: print 'grant_privileges requires 1 args' diff --git metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore.py metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore.py index 523fbbd..51e11b1 100644 --- metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore.py +++ metastore/src/gen/thrift/gen-py/hive_metastore/ThriftHiveMetastore.py @@ -716,6 +716,15 @@ def list_privileges(self, principal_name, principal_type, hiveObject): """ pass + def list_privileges_for_auth(self, hiveObject, user_name, group_names): + """ + Parameters: + - hiveObject + - user_name + - group_names + """ + pass + def grant_privileges(self, privileges): """ Parameters: @@ -3798,6 +3807,42 @@ def recv_list_privileges(self, ): raise result.o1 raise TApplicationException(TApplicationException.MISSING_RESULT, "list_privileges failed: unknown result"); + def list_privileges_for_auth(self, hiveObject, user_name, group_names): + """ + Parameters: + - hiveObject + - user_name + - group_names + """ + self.send_list_privileges_for_auth(hiveObject, user_name, group_names) + return self.recv_list_privileges_for_auth() + + def send_list_privileges_for_auth(self, hiveObject, user_name, group_names): + self._oprot.writeMessageBegin('list_privileges_for_auth', TMessageType.CALL, self._seqid) + args = list_privileges_for_auth_args() + args.hiveObject = hiveObject + args.user_name = user_name + args.group_names = group_names + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_list_privileges_for_auth(self, ): + (fname, mtype, rseqid) = self._iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(self._iprot) + self._iprot.readMessageEnd() + raise x + result = list_privileges_for_auth_result() + result.read(self._iprot) + self._iprot.readMessageEnd() + if result.success is not None: + return result.success + if result.o1 is not None: + raise result.o1 + raise TApplicationException(TApplicationException.MISSING_RESULT, "list_privileges_for_auth failed: unknown result"); + def grant_privileges(self, privileges): """ Parameters: @@ -4077,6 +4122,7 @@ def __init__(self, handler): self._processMap["list_roles"] = Processor.process_list_roles self._processMap["get_privilege_set"] = Processor.process_get_privilege_set self._processMap["list_privileges"] = Processor.process_list_privileges + self._processMap["list_privileges_for_auth"] = Processor.process_list_privileges_for_auth self._processMap["grant_privileges"] = Processor.process_grant_privileges self._processMap["revoke_privileges"] = Processor.process_revoke_privileges self._processMap["set_ugi"] = Processor.process_set_ugi @@ -5441,6 +5487,20 @@ def process_list_privileges(self, seqid, iprot, oprot): oprot.writeMessageEnd() oprot.trans.flush() + def process_list_privileges_for_auth(self, seqid, iprot, oprot): + args = list_privileges_for_auth_args() + args.read(iprot) + iprot.readMessageEnd() + result = list_privileges_for_auth_result() + try: + result.success = self._handler.list_privileges_for_auth(args.hiveObject, args.user_name, args.group_names) + except MetaException as o1: + result.o1 = o1 + oprot.writeMessageBegin("list_privileges_for_auth", TMessageType.REPLY, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + def process_grant_privileges(self, seqid, iprot, oprot): args = grant_privileges_args() args.read(iprot) @@ -19441,6 +19501,179 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +class list_privileges_for_auth_args: + """ + Attributes: + - hiveObject + - user_name + - group_names + """ + + thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'hiveObject', (HiveObjectRef, HiveObjectRef.thrift_spec), None, ), # 1 + (2, TType.STRING, 'user_name', None, None, ), # 2 + (3, TType.LIST, 'group_names', (TType.STRING,None), None, ), # 3 + ) + + def __init__(self, hiveObject=None, user_name=None, group_names=None,): + self.hiveObject = hiveObject + self.user_name = user_name + self.group_names = group_names + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.hiveObject = HiveObjectRef() + self.hiveObject.read(iprot) + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRING: + self.user_name = iprot.readString(); + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.LIST: + self.group_names = [] + (_etype648, _size645) = iprot.readListBegin() + for _i649 in xrange(_size645): + _elem650 = iprot.readString(); + self.group_names.append(_elem650) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('list_privileges_for_auth_args') + if self.hiveObject is not None: + oprot.writeFieldBegin('hiveObject', TType.STRUCT, 1) + self.hiveObject.write(oprot) + oprot.writeFieldEnd() + if self.user_name is not None: + oprot.writeFieldBegin('user_name', TType.STRING, 2) + oprot.writeString(self.user_name) + oprot.writeFieldEnd() + if self.group_names is not None: + oprot.writeFieldBegin('group_names', TType.LIST, 3) + oprot.writeListBegin(TType.STRING, len(self.group_names)) + for iter651 in self.group_names: + oprot.writeString(iter651) + oprot.writeListEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + +class list_privileges_for_auth_result: + """ + Attributes: + - success + - o1 + """ + + thrift_spec = ( + (0, TType.LIST, 'success', (TType.STRING,None), None, ), # 0 + (1, TType.STRUCT, 'o1', (MetaException, MetaException.thrift_spec), None, ), # 1 + ) + + def __init__(self, success=None, o1=None,): + self.success = success + self.o1 = o1 + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.LIST: + self.success = [] + (_etype655, _size652) = iprot.readListBegin() + for _i656 in xrange(_size652): + _elem657 = iprot.readString(); + self.success.append(_elem657) + iprot.readListEnd() + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.o1 = MetaException() + self.o1.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('list_privileges_for_auth_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.LIST, 0) + oprot.writeListBegin(TType.STRING, len(self.success)) + for iter658 in self.success: + oprot.writeString(iter658) + oprot.writeListEnd() + oprot.writeFieldEnd() + if self.o1 is not None: + oprot.writeFieldBegin('o1', TType.STRUCT, 1) + self.o1.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + class grant_privileges_args: """ Attributes: @@ -19741,10 +19974,10 @@ def read(self, iprot): elif fid == 2: if ftype == TType.LIST: self.group_names = [] - (_etype648, _size645) = iprot.readListBegin() - for _i649 in xrange(_size645): - _elem650 = iprot.readString(); - self.group_names.append(_elem650) + (_etype662, _size659) = iprot.readListBegin() + for _i663 in xrange(_size659): + _elem664 = iprot.readString(); + self.group_names.append(_elem664) iprot.readListEnd() else: iprot.skip(ftype) @@ -19765,8 +19998,8 @@ def write(self, oprot): if self.group_names is not None: oprot.writeFieldBegin('group_names', TType.LIST, 2) oprot.writeListBegin(TType.STRING, len(self.group_names)) - for iter651 in self.group_names: - oprot.writeString(iter651) + for iter665 in self.group_names: + oprot.writeString(iter665) oprot.writeListEnd() oprot.writeFieldEnd() oprot.writeFieldStop() @@ -19815,10 +20048,10 @@ def read(self, iprot): if fid == 0: if ftype == TType.LIST: self.success = [] - (_etype655, _size652) = iprot.readListBegin() - for _i656 in xrange(_size652): - _elem657 = iprot.readString(); - self.success.append(_elem657) + (_etype669, _size666) = iprot.readListBegin() + for _i670 in xrange(_size666): + _elem671 = iprot.readString(); + self.success.append(_elem671) iprot.readListEnd() else: iprot.skip(ftype) @@ -19841,8 +20074,8 @@ def write(self, oprot): if self.success is not None: oprot.writeFieldBegin('success', TType.LIST, 0) oprot.writeListBegin(TType.STRING, len(self.success)) - for iter658 in self.success: - oprot.writeString(iter658) + for iter672 in self.success: + oprot.writeString(iter672) oprot.writeListEnd() oprot.writeFieldEnd() if self.o1 is not None: diff --git metastore/src/gen/thrift/gen-rb/thrift_hive_metastore.rb metastore/src/gen/thrift/gen-rb/thrift_hive_metastore.rb index a8a0a86..40f839b 100644 --- metastore/src/gen/thrift/gen-rb/thrift_hive_metastore.rb +++ metastore/src/gen/thrift/gen-rb/thrift_hive_metastore.rb @@ -1397,6 +1397,22 @@ module ThriftHiveMetastore raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'list_privileges failed: unknown result') end + def list_privileges_for_auth(hiveObject, user_name, group_names) + send_list_privileges_for_auth(hiveObject, user_name, group_names) + return recv_list_privileges_for_auth() + end + + def send_list_privileges_for_auth(hiveObject, user_name, group_names) + send_message('list_privileges_for_auth', List_privileges_for_auth_args, :hiveObject => hiveObject, :user_name => user_name, :group_names => group_names) + end + + def recv_list_privileges_for_auth() + result = receive_message(List_privileges_for_auth_result) + return result.success unless result.success.nil? + raise result.o1 unless result.o1.nil? + raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'list_privileges_for_auth failed: unknown result') + end + def grant_privileges(privileges) send_grant_privileges(privileges) return recv_grant_privileges() @@ -2596,6 +2612,17 @@ module ThriftHiveMetastore write_result(result, oprot, 'list_privileges', seqid) end + def process_list_privileges_for_auth(seqid, iprot, oprot) + args = read_args(iprot, List_privileges_for_auth_args) + result = List_privileges_for_auth_result.new() + begin + result.success = @handler.list_privileges_for_auth(args.hiveObject, args.user_name, args.group_names) + rescue ::MetaException => o1 + result.o1 = o1 + end + write_result(result, oprot, 'list_privileges_for_auth', seqid) + end + def process_grant_privileges(seqid, iprot, oprot) args = read_args(iprot, Grant_privileges_args) result = Grant_privileges_result.new() @@ -5887,6 +5914,44 @@ module ThriftHiveMetastore ::Thrift::Struct.generate_accessors self end + class List_privileges_for_auth_args + include ::Thrift::Struct, ::Thrift::Struct_Union + HIVEOBJECT = 1 + USER_NAME = 2 + GROUP_NAMES = 3 + + FIELDS = { + HIVEOBJECT => {:type => ::Thrift::Types::STRUCT, :name => 'hiveObject', :class => ::HiveObjectRef}, + USER_NAME => {:type => ::Thrift::Types::STRING, :name => 'user_name'}, + GROUP_NAMES => {:type => ::Thrift::Types::LIST, :name => 'group_names', :element => {:type => ::Thrift::Types::STRING}} + } + + def struct_fields; FIELDS; end + + def validate + end + + ::Thrift::Struct.generate_accessors self + end + + class List_privileges_for_auth_result + include ::Thrift::Struct, ::Thrift::Struct_Union + SUCCESS = 0 + O1 = 1 + + FIELDS = { + SUCCESS => {:type => ::Thrift::Types::LIST, :name => 'success', :element => {:type => ::Thrift::Types::STRING}}, + O1 => {:type => ::Thrift::Types::STRUCT, :name => 'o1', :class => ::MetaException} + } + + def struct_fields; FIELDS; end + + def validate + end + + ::Thrift::Struct.generate_accessors self + end + class Grant_privileges_args include ::Thrift::Struct, ::Thrift::Struct_Union PRIVILEGES = 1 diff --git metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java index bec21cf..51cc259 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java @@ -42,7 +42,6 @@ import java.util.Properties; import java.util.Set; import java.util.Timer; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.regex.Pattern; import org.apache.commons.cli.OptionBuilder; @@ -3785,6 +3784,46 @@ public PrincipalPrivilegeSet get_privilege_set(HiveObjectRef hiveObject, return null; } + public List list_privileges_for_auth(HiveObjectRef hiveObject, + String userName, List groupNames) throws MetaException, TException { + incrementCounter("list_privileges_for_auth"); + try { + String[] name = toStringName(hiveObject); + HiveObjectType type = hiveObject.getObjectType(); + return getMS().getPrivilegesForAuth(name, type, userName, groupNames); + } catch (MetaException e) { + throw e; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + private String[] toStringName(HiveObjectRef hiveObject) throws MetaException { + switch (hiveObject.getObjectType()) { + case GLOBAL: + return null; + case DATABASE: + return new String[] { hiveObject.getDbName().toLowerCase()}; + case TABLE: + return new String[] { + hiveObject.getDbName().toLowerCase(), + hiveObject.getObjectName().toLowerCase()}; + case PARTITION: + return new String[] { + hiveObject.getDbName().toLowerCase(), + hiveObject.getObjectName().toLowerCase(), + getPartName(hiveObject) + }; + case COLUMN: + return new String[] { + hiveObject.getDbName().toLowerCase(), + hiveObject.getObjectName().toLowerCase(), + getPartName(hiveObject), hiveObject.getColumnName() + }; + } + throw new IllegalArgumentException(hiveObject.toString()); + } + private String getPartName(HiveObjectRef hiveObject) throws MetaException { String partName = null; List partValue = hiveObject.getPartValues(); diff --git metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java index 6dce0aa..1f5d097 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java @@ -1398,6 +1398,12 @@ public PrincipalPrivilegeSet get_privilege_set(HiveObjectRef hiveObject, return client.list_privileges(principalName, principalType, hiveObject); } + @Override + public List list_privileges_for_auth(HiveObjectRef hiveObject, + String user_name, List group_names) throws MetaException, TException { + return client.list_privileges_for_auth(hiveObject, user_name, group_names); + } + public String getDelegationToken(String renewerKerberosPrincipalName) throws MetaException, TException, IOException { //a convenience method that makes the intended owner for the delegation diff --git metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java index 6bf1bf1..0bfb9d3 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java @@ -962,6 +962,18 @@ public PrincipalPrivilegeSet get_privilege_set(HiveObjectRef hiveObject, throws MetaException, TException; /** + * @param hiveObject + * @param user_name + * @param group_names + * @return + * @throws MetaException + * @throws TException + */ + public List list_privileges_for_auth(HiveObjectRef hiveObject, + String user_name, List group_names) + throws MetaException, TException; + + /** * @param privileges * @return true on success * @throws MetaException diff --git metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java index 16e189a..a002c85 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java @@ -28,6 +28,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -39,7 +40,6 @@ import java.util.concurrent.locks.ReentrantLock; import javax.jdo.JDODataStoreException; -import javax.jdo.JDOEnhanceException; import javax.jdo.JDOHelper; import javax.jdo.JDOObjectNotFoundException; import javax.jdo.PersistenceManager; @@ -49,7 +49,6 @@ import javax.jdo.datastore.DataStoreCache; import javax.jdo.identity.IntIdentity; -import org.antlr.runtime.CharStream; import org.antlr.runtime.CommonTokenStream; import org.antlr.runtime.RecognitionException; import org.apache.commons.logging.Log; @@ -62,14 +61,10 @@ import org.apache.hadoop.hive.common.classification.InterfaceStability; import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.hive.conf.HiveConf.ConfVars; -import org.apache.hadoop.hive.metastore.api.BinaryColumnStatsData; -import org.apache.hadoop.hive.metastore.api.BooleanColumnStatsData; import org.apache.hadoop.hive.metastore.api.ColumnStatistics; -import org.apache.hadoop.hive.metastore.api.ColumnStatisticsData; import org.apache.hadoop.hive.metastore.api.ColumnStatisticsDesc; import org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj; import org.apache.hadoop.hive.metastore.api.Database; -import org.apache.hadoop.hive.metastore.api.DoubleColumnStatsData; import org.apache.hadoop.hive.metastore.api.FieldSchema; import org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege; import org.apache.hadoop.hive.metastore.api.HiveObjectRef; @@ -78,7 +73,6 @@ import org.apache.hadoop.hive.metastore.api.InvalidInputException; import org.apache.hadoop.hive.metastore.api.InvalidObjectException; import org.apache.hadoop.hive.metastore.api.InvalidPartitionException; -import org.apache.hadoop.hive.metastore.api.LongColumnStatsData; import org.apache.hadoop.hive.metastore.api.MetaException; import org.apache.hadoop.hive.metastore.api.NoSuchObjectException; import org.apache.hadoop.hive.metastore.api.Order; @@ -92,7 +86,6 @@ import org.apache.hadoop.hive.metastore.api.SerDeInfo; import org.apache.hadoop.hive.metastore.api.SkewedInfo; import org.apache.hadoop.hive.metastore.api.StorageDescriptor; -import org.apache.hadoop.hive.metastore.api.StringColumnStatsData; import org.apache.hadoop.hive.metastore.api.Table; import org.apache.hadoop.hive.metastore.api.Type; import org.apache.hadoop.hive.metastore.api.UnknownDBException; @@ -112,6 +105,7 @@ import org.apache.hadoop.hive.metastore.model.MPartitionColumnStatistics; import org.apache.hadoop.hive.metastore.model.MPartitionEvent; import org.apache.hadoop.hive.metastore.model.MPartitionPrivilege; +import org.apache.hadoop.hive.metastore.model.MPrincipalDesc; import org.apache.hadoop.hive.metastore.model.MRole; import org.apache.hadoop.hive.metastore.model.MRoleMap; import org.apache.hadoop.hive.metastore.model.MSerDeInfo; @@ -134,8 +128,6 @@ import org.apache.thrift.TException; import org.datanucleus.store.rdbms.exceptions.MissingTableException; -import org.antlr.runtime.Token; - import com.google.common.collect.Lists; @@ -269,8 +261,7 @@ private static PartitionExpressionProxy createExpressionProxy(Configuration conf @SuppressWarnings("unchecked") Class clazz = (Class)MetaStoreUtils.getClass(className); - return MetaStoreUtils.newInstance( - clazz, new Class[0], new Object[0]); + return MetaStoreUtils.newInstance(clazz, new Class[0], new Object[0]); } catch (MetaException e) { LOG.error("Error loading PartitionExpressionProxy", e); throw new RuntimeException("Error loading PartitionExpressionProxy: " + e.getMessage()); @@ -3281,6 +3272,17 @@ private MRole getMRole(String roleName) { } } + public List getUserPrivileges(String principalName, PrincipalType principalType) + throws InvalidObjectException, MetaException { + List grantInfos = new ArrayList(); + for (MGlobalPrivilege privilege : listPrincipalGlobalGrants(principalName, principalType)) { + grantInfos.add(new PrivilegeGrantInfo(privilege.getPrivilege(), privilege + .getCreateTime(), privilege.getGrantor(), getPrincipalTypeFromStr(privilege + .getGrantorType()), privilege.getGrantOption())); + } + return grantInfos; + } + @Override public PrincipalPrivilegeSet getUserPrivilegeSet(String userName, List groupNames) throws InvalidObjectException, MetaException { @@ -3500,14 +3502,14 @@ public PrincipalPrivilegeSet getColumnPrivilegeSet(String dbName, if (userName != null) { Map> columnUserPriv = new HashMap>(); columnUserPriv.put(userName, getColumnPrivilege(dbName, tableName, - columnName, partitionName, userName, PrincipalType.USER)); + partitionName, columnName, userName, PrincipalType.USER)); ret.setUserPrivileges(columnUserPriv); } if (groupNames != null && groupNames.size() > 0) { Map> columnGroupPriv = new HashMap>(); for (String groupName : groupNames) { columnGroupPriv.put(groupName, getColumnPrivilege(dbName, tableName, - columnName, partitionName, groupName, PrincipalType.GROUP)); + partitionName, columnName, groupName, PrincipalType.GROUP)); } ret.setGroupPrivileges(columnGroupPriv); } @@ -3517,7 +3519,7 @@ public PrincipalPrivilegeSet getColumnPrivilegeSet(String dbName, for (MRoleMap role : roles) { String roleName = role.getRole().getRoleName(); columnRolePriv.put(roleName, getColumnPrivilege(dbName, tableName, - columnName, partitionName, roleName, PrincipalType.ROLE)); + partitionName, columnName, roleName, PrincipalType.ROLE)); } ret.setRolePrivileges(columnRolePriv); } @@ -3530,6 +3532,71 @@ public PrincipalPrivilegeSet getColumnPrivilegeSet(String dbName, return ret; } + private Set listPrincipals(String userName, List groupNames) { + Set visited = new LinkedHashSet(); + if (userName != null) { + visited.add(new MPrincipalDesc(userName, PrincipalType.USER.name())); + iterateRoles(listRoles(userName, PrincipalType.USER), visited); + } + if (groupNames != null) { + for (String groupName : groupNames) { + visited.add(new MPrincipalDesc(groupName, PrincipalType.GROUP.name())); + iterateRoles(listRoles(groupName, PrincipalType.GROUP), visited); + } + } + return visited; + } + + private Set iterateRoles(List roles, Set visited) { + for (MRoleMap roleMap : roles) { + MRole role = roleMap.getRole(); + if (visited.add(new MPrincipalDesc(role.getRoleName(), PrincipalType.ROLE.name()))) { + iterateRoles(listRoles(role.getRoleName(), PrincipalType.ROLE), visited); + } + } + return visited; + } + + @Override + public List getPrivilegesForAuth(String[] name, HiveObjectType type, + String userName, List groupNames) throws InvalidObjectException, MetaException { + boolean commited = false; + Set result = new HashSet(); + try { + openTransaction(); + for (MPrincipalDesc principal : listPrincipals(userName, groupNames)) { + for (PrivilegeGrantInfo grant : getPrivileges(name, type, principal)) { + result.add(grant.getPrivilege().toLowerCase()); + } + } + commited = commitTransaction(); + } finally { + if (!commited) { + rollbackTransaction(); + } + } + return new ArrayList(result); + } + + private List getPrivileges(String[] name, HiveObjectType type, + MPrincipalDesc principal) throws InvalidObjectException, MetaException { + String pname = principal.getName(); + PrincipalType ptype = PrincipalType.valueOf(principal.getType()); + switch (type) { + case GLOBAL: + return getUserPrivileges(pname, ptype); + case DATABASE: + return getDBPrivilege(name[0], pname, ptype); + case TABLE: + return getTablePrivilege(name[0], name[1], pname, ptype); + case PARTITION: + return getPartitionPrivilege(name[0], name[1], name[2], pname, ptype); + case COLUMN: + return getColumnPrivilege(name[0], name[1], name[2], name[3], pname, ptype); + } + throw new IllegalArgumentException("invalid type " + type); + } + private List getPartitionPrivilege(String dbName, String tableName, String partName, String principalName, PrincipalType principalType) { @@ -3586,7 +3653,7 @@ private PrincipalType getPrincipalTypeFromStr(String str) { } private List getColumnPrivilege(String dbName, - String tableName, String columnName, String partitionName, + String tableName, String partitionName, String columnName, String principalName, PrincipalType principalType) { tableName = tableName.toLowerCase().trim(); diff --git metastore/src/java/org/apache/hadoop/hive/metastore/RawStore.java metastore/src/java/org/apache/hadoop/hive/metastore/RawStore.java index 0a76cee..deebbe7 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/RawStore.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/RawStore.java @@ -30,6 +30,7 @@ import org.apache.hadoop.hive.metastore.api.ColumnStatistics; import org.apache.hadoop.hive.metastore.api.Database; import org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege; +import org.apache.hadoop.hive.metastore.api.HiveObjectType; import org.apache.hadoop.hive.metastore.api.Index; import org.apache.hadoop.hive.metastore.api.InvalidInputException; import org.apache.hadoop.hive.metastore.api.InvalidObjectException; @@ -248,6 +249,9 @@ public abstract PrincipalPrivilegeSet getPartitionPrivilegeSet (String dbName, S public abstract PrincipalPrivilegeSet getColumnPrivilegeSet (String dbName, String tableName, String partitionName, String columnName, String userName, List groupNames) throws InvalidObjectException, MetaException; + public abstract List getPrivilegesForAuth(String[] name, HiveObjectType type, + String userName, List groupNames) throws InvalidObjectException, MetaException; + public abstract List listPrincipalGlobalGrants(String principalName, PrincipalType principalType); diff --git metastore/src/test/org/apache/hadoop/hive/metastore/DummyRawStoreControlledCommit.java metastore/src/test/org/apache/hadoop/hive/metastore/DummyRawStoreControlledCommit.java index c53a412..88b0397 100644 --- metastore/src/test/org/apache/hadoop/hive/metastore/DummyRawStoreControlledCommit.java +++ metastore/src/test/org/apache/hadoop/hive/metastore/DummyRawStoreControlledCommit.java @@ -28,6 +28,7 @@ import org.apache.hadoop.hive.metastore.api.ColumnStatistics; import org.apache.hadoop.hive.metastore.api.Database; import org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege; +import org.apache.hadoop.hive.metastore.api.HiveObjectType; import org.apache.hadoop.hive.metastore.api.Index; import org.apache.hadoop.hive.metastore.api.InvalidInputException; import org.apache.hadoop.hive.metastore.api.InvalidObjectException; @@ -390,6 +391,12 @@ public PrincipalPrivilegeSet getColumnPrivilegeSet(String dbName, String tableNa } @Override + public List getPrivilegesForAuth(String[] name, HiveObjectType type, + String userName, List groupNames) throws InvalidObjectException, MetaException { + return objectStore.getPrivilegesForAuth(name, type, userName, groupNames); + } + + @Override public List listPrincipalGlobalGrants(String principalName, PrincipalType principalType) { return objectStore.listPrincipalGlobalGrants(principalName, principalType); diff --git metastore/src/test/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java metastore/src/test/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java index ed3d7ee..03895c9 100644 --- metastore/src/test/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java +++ metastore/src/test/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java @@ -29,6 +29,7 @@ import org.apache.hadoop.hive.metastore.api.ColumnStatistics; import org.apache.hadoop.hive.metastore.api.Database; import org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege; +import org.apache.hadoop.hive.metastore.api.HiveObjectType; import org.apache.hadoop.hive.metastore.api.Index; import org.apache.hadoop.hive.metastore.api.InvalidInputException; import org.apache.hadoop.hive.metastore.api.InvalidObjectException; @@ -412,6 +413,12 @@ public PrincipalPrivilegeSet getColumnPrivilegeSet(String dbName, String tableNa } @Override + public List getPrivilegesForAuth(String[] name, HiveObjectType type, + String userName, List groupNames) throws InvalidObjectException, MetaException { + return null; + } + + @Override public List listPrincipalGlobalGrants(String principalName, PrincipalType principalType) { diff --git ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java index 0b7c128..ea7a8fe 100644 --- ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java +++ ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java @@ -2074,6 +2074,19 @@ public PrincipalPrivilegeSet get_privilege_set(HiveObjectType objectType, } } + public List list_privileges_for_auth(HiveObjectType objectType, + String db_name, String table_name, List part_values, + String column_name, String user_name, List group_names) + throws HiveException { + try { + HiveObjectRef hiveObj = new HiveObjectRef(objectType, db_name, + table_name, part_values, column_name); + return getMSC().list_privileges_for_auth(hiveObj, user_name, group_names); + } catch (Exception e) { + throw new HiveException(e); + } + } + /** * @param objectType * hive object type diff --git ql/src/java/org/apache/hadoop/hive/ql/plan/PrincipalDesc.java ql/src/java/org/apache/hadoop/hive/ql/plan/PrincipalDesc.java index 7dc0ded..ee46652 100644 --- ql/src/java/org/apache/hadoop/hive/ql/plan/PrincipalDesc.java +++ ql/src/java/org/apache/hadoop/hive/ql/plan/PrincipalDesc.java @@ -59,4 +59,18 @@ public void setType(PrincipalType type) { this.type = type; } + @Override + public int hashCode() { + return name.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof PrincipalDesc)) { + return false; + } + PrincipalDesc other = (PrincipalDesc) obj; + return type == other.type && name.equals(other.name); + } + } diff --git ql/src/java/org/apache/hadoop/hive/ql/security/authorization/BitSetCheckedAuthorizationProvider.java ql/src/java/org/apache/hadoop/hive/ql/security/authorization/BitSetCheckedAuthorizationProvider.java index 2f2ceeb..26479d7 100644 --- ql/src/java/org/apache/hadoop/hive/ql/security/authorization/BitSetCheckedAuthorizationProvider.java +++ ql/src/java/org/apache/hadoop/hive/ql/security/authorization/BitSetCheckedAuthorizationProvider.java @@ -20,18 +20,16 @@ import java.util.ArrayList; import java.util.Collection; -import java.util.HashSet; import java.util.List; -import java.util.Set; import org.apache.hadoop.hive.metastore.api.Database; import org.apache.hadoop.hive.metastore.api.HiveObjectType; -import org.apache.hadoop.hive.metastore.api.PrincipalPrivilegeSet; import org.apache.hadoop.hive.metastore.api.PrivilegeGrantInfo; import org.apache.hadoop.hive.ql.metadata.AuthorizationException; import org.apache.hadoop.hive.ql.metadata.HiveException; import org.apache.hadoop.hive.ql.metadata.Partition; import org.apache.hadoop.hive.ql.metadata.Table; +import org.apache.hadoop.hive.ql.security.HiveAuthenticationProvider; public abstract class BitSetCheckedAuthorizationProvider extends HiveAuthorizationProviderBase { @@ -176,10 +174,10 @@ public void authorize(Table table, Partition part, List columns, boolean[] inputCheck2 = checker2.inputCheck; boolean[] outputCheck2 = checker2.outputCheck; - PrincipalPrivilegeSet partColumnPrivileges = hive_db - .get_privilege_set(HiveObjectType.COLUMN, table.getDbName(), table.getTableName(), + List partColumnPrivileges = hive_db + .list_privileges_for_auth(HiveObjectType.COLUMN, table.getDbName(), table.getTableName(), partValues, col, this.getAuthenticator().getUserName(), this - .getAuthenticator().getGroupNames()); + .getAuthenticator().getGroupNames()); authorizePrivileges(partColumnPrivileges, inputRequiredPriv, inputCheck2, outputRequiredPriv, outputCheck2); @@ -200,9 +198,9 @@ public void authorize(Table table, Partition part, List columns, protected boolean authorizeUserPriv(Privilege[] inputRequiredPriv, boolean[] inputCheck, Privilege[] outputRequiredPriv, boolean[] outputCheck) throws HiveException { - PrincipalPrivilegeSet privileges = hive_db.get_privilege_set( + List privileges = hive_db.list_privileges_for_auth( HiveObjectType.GLOBAL, null, null, null, null, this.getAuthenticator() - .getUserName(), this.getAuthenticator().getGroupNames()); + .getUserName(), this.getAuthenticator().getGroupNames()); return authorizePrivileges(privileges, inputRequiredPriv, inputCheck, outputRequiredPriv, outputCheck); } @@ -230,10 +228,10 @@ private boolean authorizeUserAndDBPriv(Database db, return true; } - PrincipalPrivilegeSet dbPrivileges = hive_db.get_privilege_set( + List dbPrivileges = hive_db.list_privileges_for_auth( HiveObjectType.DATABASE, db.getName(), null, null, null, this - .getAuthenticator().getUserName(), this.getAuthenticator() - .getGroupNames()); + .getAuthenticator().getUserName(), this.getAuthenticator() + .getGroupNames()); if (authorizePrivileges(dbPrivileges, inputRequiredPriv, inputCheck, outputRequiredPriv, outputCheck)) { @@ -263,10 +261,10 @@ private boolean authorizeUserDBAndTable(Table table, return true; } - PrincipalPrivilegeSet tablePrivileges = hive_db.get_privilege_set( + List tablePrivileges = hive_db.list_privileges_for_auth( HiveObjectType.TABLE, table.getDbName(), table.getTableName(), null, null, this.getAuthenticator().getUserName(), this.getAuthenticator() - .getGroupNames()); + .getGroupNames()); if (authorizePrivileges(tablePrivileges, inputRequiredPriv, inputCheck, outputRequiredPriv, outputCheck)) { @@ -291,19 +289,17 @@ private boolean authorizeUserDbAndPartition(Partition part, Privilege[] inputRequiredPriv, Privilege[] outputRequiredPriv, boolean[] inputCheck, boolean[] outputCheck) throws HiveException { + Table table = part.getTable(); if (authorizeUserAndDBPriv( - hive_db.getDatabase(part.getTable().getDbName()), inputRequiredPriv, + hive_db.getDatabase(table.getDbName()), inputRequiredPriv, outputRequiredPriv, inputCheck, outputCheck)) { return true; } - PrincipalPrivilegeSet partPrivileges = part.getTPartition().getPrivileges(); - if (partPrivileges == null) { - partPrivileges = hive_db.get_privilege_set(HiveObjectType.PARTITION, part - .getTable().getDbName(), part.getTable().getTableName(), part - .getValues(), null, this.getAuthenticator().getUserName(), this - .getAuthenticator().getGroupNames()); - } + HiveAuthenticationProvider authenticator = getAuthenticator(); + List partPrivileges = hive_db.list_privileges_for_auth( + HiveObjectType.PARTITION, table.getDbName(), table.getTableName(), part.getValues(), null, + authenticator.getUserName(), authenticator.getGroupNames()); if (authorizePrivileges(partPrivileges, inputRequiredPriv, inputCheck, outputRequiredPriv, outputCheck)) { @@ -313,7 +309,7 @@ private boolean authorizeUserDbAndPartition(Partition part, return false; } - protected boolean authorizePrivileges(PrincipalPrivilegeSet privileges, + protected boolean authorizePrivileges(List privileges, Privilege[] inputPriv, boolean[] inputCheck, Privilege[] outputPriv, boolean[] outputCheck) throws HiveException { @@ -332,8 +328,7 @@ protected boolean authorizePrivileges(PrincipalPrivilegeSet privileges, * * @param container */ - private boolean matchPrivs(Privilege[] inputPriv, - PrincipalPrivilegeSet privileges, boolean[] check) { + private boolean matchPrivs(Privilege[] inputPriv, List privileges, boolean[] check) { if (inputPriv == null) { return true; @@ -343,78 +338,17 @@ private boolean matchPrivs(Privilege[] inputPriv, return false; } - /* - * user grants - */ - Set privSet = new HashSet(); - if (privileges.getUserPrivileges() != null - && privileges.getUserPrivileges().size() > 0) { - Collection> privCollection = privileges.getUserPrivileges().values(); - - List userPrivs = getPrivilegeStringList(privCollection); - if (userPrivs != null && userPrivs.size() > 0) { - for (String priv : userPrivs) { - if (priv == null || priv.trim().equals("")) { - continue; - } - if (priv.equalsIgnoreCase(Privilege.ALL.toString())) { - setBooleanArray(check, true); - return true; - } - privSet.add(priv.toLowerCase()); - } - } - } - - /* - * group grants - */ - if (privileges.getGroupPrivileges() != null - && privileges.getGroupPrivileges().size() > 0) { - Collection> groupPrivCollection = privileges - .getGroupPrivileges().values(); - List groupPrivs = getPrivilegeStringList(groupPrivCollection); - if (groupPrivs != null && groupPrivs.size() > 0) { - for (String priv : groupPrivs) { - if (priv == null || priv.trim().equals("")) { - continue; - } - if (priv.equalsIgnoreCase(Privilege.ALL.toString())) { - setBooleanArray(check, true); - return true; - } - privSet.add(priv.toLowerCase()); - } - } - } - - /* - * roles grants - */ - if (privileges.getRolePrivileges() != null - && privileges.getRolePrivileges().size() > 0) { - Collection> rolePrivsCollection = privileges - .getRolePrivileges().values(); - ; - List rolePrivs = getPrivilegeStringList(rolePrivsCollection); - if (rolePrivs != null && rolePrivs.size() > 0) { - for (String priv : rolePrivs) { - if (priv == null || priv.trim().equals("")) { - continue; - } - if (priv.equalsIgnoreCase(Privilege.ALL.toString())) { - setBooleanArray(check, true); - return true; - } - privSet.add(priv.toLowerCase()); - } + for (String priv : privileges) { + if (priv.equalsIgnoreCase(Privilege.ALL.toString())) { + setBooleanArray(check, true); + return true; } } for (int i = 0; i < inputPriv.length; i++) { String toMatch = inputPriv[i].toString(); if (!check[i]) { - check[i] = privSet.contains(toMatch.toLowerCase()); + check[i] = privileges.contains(toMatch.toLowerCase()); } } diff --git ql/src/java/org/apache/hadoop/hive/ql/security/authorization/HiveAuthorizationProviderBase.java ql/src/java/org/apache/hadoop/hive/ql/security/authorization/HiveAuthorizationProviderBase.java index 18a1b25..4b7b2ed 100644 --- ql/src/java/org/apache/hadoop/hive/ql/security/authorization/HiveAuthorizationProviderBase.java +++ ql/src/java/org/apache/hadoop/hive/ql/security/authorization/HiveAuthorizationProviderBase.java @@ -80,6 +80,25 @@ public PrincipalPrivilegeSet get_privilege_set(HiveObjectType column, String dbN } } + public List list_privileges_for_auth(HiveObjectType column, String dbName, + String tableName, List partValues, String col, String userName, + List groupNames) throws HiveException { + if (!isRunFromMetaStore()) { + return hiveClient.list_privileges_for_auth( + column, dbName, tableName, partValues, col, userName, groupNames); + } else { + HiveObjectRef hiveObj = new HiveObjectRef(column, dbName, + tableName, partValues, col); + try { + return handler.list_privileges_for_auth(hiveObj, userName, groupNames); + } catch (MetaException e) { + throw new HiveException(e); + } catch (TException e) { + throw new HiveException(e); + } + } + } + public Database getDatabase(String dbName) throws HiveException { if (!isRunFromMetaStore()) { return hiveClient.getDatabase(dbName); diff --git ql/src/test/queries/clientpositive/authorization_10.q ql/src/test/queries/clientpositive/authorization_10.q new file mode 100644 index 0000000..ead7b47 --- /dev/null +++ ql/src/test/queries/clientpositive/authorization_10.q @@ -0,0 +1,14 @@ +-- SORT_BEFORE_DIFF + +create table dummy (key string, value string); + +create role role1; +create role role2; + +grant select on table dummy to role role1; +grant role role1 to role role2; +grant role role2 to user hive_test_user; + +set hive.security.authorization.enabled=true; + +select * from dummy; diff --git ql/src/test/results/clientpositive/authorization_10.q.out ql/src/test/results/clientpositive/authorization_10.q.out new file mode 100644 index 0000000..91e196f --- /dev/null +++ ql/src/test/results/clientpositive/authorization_10.q.out @@ -0,0 +1,39 @@ +PREHOOK: query: -- SORT_BEFORE_DIFF + +create table dummy (key string, value string) +PREHOOK: type: CREATETABLE +POSTHOOK: query: -- SORT_BEFORE_DIFF + +create table dummy (key string, value string) +POSTHOOK: type: CREATETABLE +POSTHOOK: Output: default@dummy +PREHOOK: query: create role role1 +PREHOOK: type: CREATEROLE +POSTHOOK: query: create role role1 +POSTHOOK: type: CREATEROLE +PREHOOK: query: create role role2 +PREHOOK: type: CREATEROLE +POSTHOOK: query: create role role2 +POSTHOOK: type: CREATEROLE +PREHOOK: query: grant select on table dummy to role role1 +PREHOOK: type: GRANT_PRIVILEGE +PREHOOK: Output: default@dummy +POSTHOOK: query: grant select on table dummy to role role1 +POSTHOOK: type: GRANT_PRIVILEGE +POSTHOOK: Output: default@dummy +PREHOOK: query: grant role role1 to role role2 +PREHOOK: type: GRANT_ROLE +POSTHOOK: query: grant role role1 to role role2 +POSTHOOK: type: GRANT_ROLE +PREHOOK: query: grant role role2 to user hive_test_user +PREHOOK: type: GRANT_ROLE +POSTHOOK: query: grant role role2 to user hive_test_user +POSTHOOK: type: GRANT_ROLE +PREHOOK: query: select * from dummy +PREHOOK: type: QUERY +PREHOOK: Input: default@dummy +#### A masked pattern was here #### +POSTHOOK: query: select * from dummy +POSTHOOK: type: QUERY +POSTHOOK: Input: default@dummy +#### A masked pattern was here #### diff --git ql/src/test/results/clientpositive/authorization_2.q.out ql/src/test/results/clientpositive/authorization_2.q.out index e21d5f5..6582551 100644 --- ql/src/test/results/clientpositive/authorization_2.q.out +++ ql/src/test/results/clientpositive/authorization_2.q.out @@ -53,8 +53,8 @@ PREHOOK: type: SHOW_GRANT POSTHOOK: query: show grant user hive_test_user on table authorization_part POSTHOOK: type: SHOW_GRANT default authorization_part hive_test_user USER Create false -1 hive_test_user -default authorization_part hive_test_user USER Update false -1 hive_test_user default authorization_part hive_test_user USER Drop false -1 hive_test_user +default authorization_part hive_test_user USER Update false -1 hive_test_user PREHOOK: query: alter table authorization_part add partition (ds='2010') PREHOOK: type: ALTERTABLE_ADDPARTS PREHOOK: Input: default@authorization_part @@ -225,8 +225,8 @@ POSTHOOK: type: SHOW_GRANT POSTHOOK: Lineage: authorization_part PARTITION(ds=2010).key EXPRESSION [(src_auth_tmp)src_auth_tmp.FieldSchema(name:key, type:string, comment:null), ] POSTHOOK: Lineage: authorization_part PARTITION(ds=2010).value SIMPLE [(src_auth_tmp)src_auth_tmp.FieldSchema(name:value, type:string, comment:null), ] default authorization_part hive_test_user USER Create false -1 hive_test_user -default authorization_part hive_test_user USER Update false -1 hive_test_user default authorization_part hive_test_user USER Drop false -1 hive_test_user +default authorization_part hive_test_user USER Update false -1 hive_test_user PREHOOK: query: alter table authorization_part add partition (ds='2010') PREHOOK: type: ALTERTABLE_ADDPARTS PREHOOK: Input: default@authorization_part @@ -296,8 +296,8 @@ POSTHOOK: Lineage: authorization_part PARTITION(ds=2010).value SIMPLE [(src_auth POSTHOOK: Lineage: authorization_part PARTITION(ds=2010).key EXPRESSION [(src_auth_tmp)src_auth_tmp.FieldSchema(name:key, type:string, comment:null), ] POSTHOOK: Lineage: authorization_part PARTITION(ds=2010).value SIMPLE [(src_auth_tmp)src_auth_tmp.FieldSchema(name:value, type:string, comment:null), ] default authorization_part hive_test_user USER Create false -1 hive_test_user -default authorization_part hive_test_user USER Update false -1 hive_test_user default authorization_part hive_test_user USER Drop false -1 hive_test_user +default authorization_part hive_test_user USER Update false -1 hive_test_user default authorization_part hive_test_user USER Select false -1 hive_test_user PREHOOK: query: select key from authorization_part where ds='2010' order by key limit 20 PREHOOK: type: QUERY @@ -352,8 +352,8 @@ POSTHOOK: Lineage: authorization_part PARTITION(ds=2010).value SIMPLE [(src_auth POSTHOOK: Lineage: authorization_part PARTITION(ds=2010).key EXPRESSION [(src_auth_tmp)src_auth_tmp.FieldSchema(name:key, type:string, comment:null), ] POSTHOOK: Lineage: authorization_part PARTITION(ds=2010).value SIMPLE [(src_auth_tmp)src_auth_tmp.FieldSchema(name:value, type:string, comment:null), ] default authorization_part hive_test_user USER Create false -1 hive_test_user -default authorization_part hive_test_user USER Update false -1 hive_test_user default authorization_part hive_test_user USER Drop false -1 hive_test_user +default authorization_part hive_test_user USER Update false -1 hive_test_user PREHOOK: query: show grant user hive_test_user on table authorization_part partition (ds='2010') PREHOOK: type: SHOW_GRANT POSTHOOK: query: show grant user hive_test_user on table authorization_part partition (ds='2010') diff --git serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/MegaStruct.java serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/MegaStruct.java index 386fef9..86a7cad 100644 --- serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/MegaStruct.java +++ serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/MegaStruct.java @@ -2192,7 +2192,7 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, MegaStruct struct) for (int _i1 = 0; _i1 < _map0.size; ++_i1) { String _key2; // required - String _val3; // required + String _val3; // optional _key2 = iprot.readString(); _val3 = iprot.readString(); struct.my_string_string_map.put(_key2, _val3); @@ -2212,7 +2212,7 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, MegaStruct struct) for (int _i5 = 0; _i5 < _map4.size; ++_i5) { String _key6; // required - MyEnum _val7; // required + MyEnum _val7; // optional _key6 = iprot.readString(); _val7 = MyEnum.findByValue(iprot.readI32()); struct.my_string_enum_map.put(_key6, _val7); @@ -2232,7 +2232,7 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, MegaStruct struct) for (int _i9 = 0; _i9 < _map8.size; ++_i9) { MyEnum _key10; // required - String _val11; // required + String _val11; // optional _key10 = MyEnum.findByValue(iprot.readI32()); _val11 = iprot.readString(); struct.my_enum_string_map.put(_key10, _val11); diff --git service/src/gen/thrift/gen-javabean/org/apache/hive/service/cli/thrift/TTypeQualifiers.java service/src/gen/thrift/gen-javabean/org/apache/hive/service/cli/thrift/TTypeQualifiers.java index 3935555..4c06c1a 100644 --- service/src/gen/thrift/gen-javabean/org/apache/hive/service/cli/thrift/TTypeQualifiers.java +++ service/src/gen/thrift/gen-javabean/org/apache/hive/service/cli/thrift/TTypeQualifiers.java @@ -360,7 +360,7 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, TTypeQualifiers str for (int _i1 = 0; _i1 < _map0.size; ++_i1) { String _key2; // required - TTypeQualifierValue _val3; // required + TTypeQualifierValue _val3; // optional _key2 = iprot.readString(); _val3 = new TTypeQualifierValue(); _val3.read(iprot); @@ -435,7 +435,7 @@ public void read(org.apache.thrift.protocol.TProtocol prot, TTypeQualifiers stru for (int _i7 = 0; _i7 < _map6.size; ++_i7) { String _key8; // required - TTypeQualifierValue _val9; // required + TTypeQualifierValue _val9; // optional _key8 = iprot.readString(); _val9 = new TTypeQualifierValue(); _val9.read(iprot); diff --git service/src/gen/thrift/gen-py/TCLIService/TCLIService-remote service/src/gen/thrift/gen-py/TCLIService/TCLIService-remote old mode 100644 new mode 100755 diff --git service/src/gen/thrift/gen-py/hive_service/ThriftHive-remote service/src/gen/thrift/gen-py/hive_service/ThriftHive-remote old mode 100644 new mode 100755