SENTRY-2316: Rename any 'entity' word for 'principal' to be consistent with Hive principal name and type (Arjun Mishra reviewed by Sergio Pena and Kalyan Kumar Kalvagadda)
Change-Id: Ib89356952e98d58611e1c31e8f162d3666180bfb Project: http://git-wip-us.apache.org/repos/asf/sentry/repo Commit: http://git-wip-us.apache.org/repos/asf/sentry/commit/fb7bb7bc Tree: http://git-wip-us.apache.org/repos/asf/sentry/tree/fb7bb7bc Diff: http://git-wip-us.apache.org/repos/asf/sentry/diff/fb7bb7bc Branch: refs/heads/master Commit: fb7bb7bc6cdd5ea6f12e28c5e81001a0b5cce60b Parents: f3f238a Author: amishra <amis...@cloudera.com> Authored: Mon Aug 6 10:33:59 2018 -0500 Committer: amishra <amis...@cloudera.com> Committed: Mon Aug 6 10:42:41 2018 -0500 ---------------------------------------------------------------------- .../binding/metastore/SentryHmsEvent.java | 18 +- ...rySyncHMSNotificationsPostEventListener.java | 18 +- .../java/org/apache/sentry/SentryOwnerInfo.java | 10 +- .../sentry/service/common/ServiceConstants.java | 2 +- .../hdfs/service/thrift/TPrivilegeChanges.java | 80 +-- .../hdfs/service/thrift/TPrivilegeEntity.java | 502 ------------------- .../service/thrift/TPrivilegeEntityType.java | 48 -- .../service/thrift/TPrivilegePrincipal.java | 502 +++++++++++++++++++ .../service/thrift/TPrivilegePrincipalType.java | 48 ++ .../apache/sentry/hdfs/PermissionsUpdate.java | 4 +- .../main/resources/sentry_hdfs_service.thrift | 14 +- .../sentry/hdfs/TestPermissionUpdate.java | 8 +- .../apache/sentry/hdfs/SentryPermissions.java | 30 +- .../sentry/hdfs/UpdateableAuthzPermissions.java | 22 +- .../sentry/hdfs/TestSentryPermissions.java | 14 +- .../apache/sentry/hdfs/DBUpdateForwarder.java | 6 +- .../apache/sentry/hdfs/PermImageRetriever.java | 10 +- .../org/apache/sentry/hdfs/SentryPlugin.java | 28 +- .../apache/sentry/hdfs/TestDeltaRetriever.java | 14 +- .../apache/sentry/hdfs/TestImageRetriever.java | 14 +- .../hdfs/TestSentryHDFSServiceProcessor.java | 6 +- .../thrift/TListSentryPrivilegesRequest.java | 112 ++--- .../thrift/TSentryHmsEventNotification.java | 20 +- .../service/thrift/TSentryObjectOwnerType.java | 45 -- .../service/thrift/TSentryPrincipalType.java | 48 ++ .../thrift/SentryPolicyServiceClient.java | 2 +- .../SentryPolicyServiceClientDefaultImpl.java | 8 +- .../main/resources/sentry_policy_service.thrift | 11 +- ...estSentryPolicyServiceClientDefaultImpl.java | 4 +- .../thrift/SentryPolicyStoreProcessor.java | 36 +- .../db/service/model/MSentryPrivilege.java | 30 +- .../provider/db/service/model/MSentryRole.java | 16 +- .../provider/db/service/model/MSentryUser.java | 12 +- .../persistent/NotificationProcessor.java | 10 +- .../db/service/persistent/PermissionsImage.java | 8 +- .../db/service/persistent/PrivilegeEntity.java | 48 -- .../service/persistent/PrivilegePrincipal.java | 48 ++ .../db/service/persistent/SentryStore.java | 218 ++++---- .../persistent/SentryStoreInterface.java | 8 +- .../thrift/TestSentryPolicyStoreProcessor.java | 50 +- .../service/persistent/TestSentryRole.java | 16 +- .../TestHMSFollowerSentryStoreIntegration.java | 16 +- .../db/service/persistent/TestSentryStore.java | 386 +++++++------- 43 files changed, 1277 insertions(+), 1273 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/sentry/blob/fb7bb7bc/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/SentryHmsEvent.java ---------------------------------------------------------------------- diff --git a/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/SentryHmsEvent.java b/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/SentryHmsEvent.java index ef63a34..0dd8bf1 100644 --- a/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/SentryHmsEvent.java +++ b/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/SentryHmsEvent.java @@ -31,7 +31,7 @@ import org.apache.hadoop.hive.metastore.events.AlterTableEvent; import org.apache.hadoop.hive.metastore.events.ListenerEvent; import org.apache.hadoop.hive.metastore.messaging.EventMessage.EventType; import org.apache.sentry.api.service.thrift.TSentryAuthorizable; -import org.apache.sentry.api.service.thrift.TSentryObjectOwnerType; +import org.apache.sentry.api.service.thrift.TSentryPrincipalType; import java.util.Map; @@ -43,13 +43,13 @@ class SentryHmsEvent { private long eventId; private final EventType eventType; private String ownerName; - private TSentryObjectOwnerType ownerType; + private TSentryPrincipalType ownerType; private TSentryAuthorizable authorizable; private final Boolean isMetastoreTransactionActive; - private static final Map<PrincipalType, TSentryObjectOwnerType> mapOwnerType = ImmutableMap.of( - PrincipalType.ROLE, TSentryObjectOwnerType.ROLE, - PrincipalType.USER, TSentryObjectOwnerType.USER + private static final Map<PrincipalType, TSentryPrincipalType> mapOwnerType = ImmutableMap.of( + PrincipalType.ROLE, TSentryPrincipalType.ROLE, + PrincipalType.USER, TSentryPrincipalType.USER ); /** @@ -145,7 +145,7 @@ class SentryHmsEvent { return eventId; } - public TSentryObjectOwnerType getOwnerType() { + public TSentryPrincipalType getOwnerType() { return ownerType; } @@ -162,7 +162,7 @@ class SentryHmsEvent { // Hive 2.3.2 currently support owner type. Assuming user as the type for now. // TODO once sentry dependency is changed to a hive version that suppots user type for table this // hard coding should be rempved. - ownerType = TSentryObjectOwnerType.USER; + ownerType = TSentryPrincipalType.USER; } private void setOwnerInfo(Database database) { @@ -198,9 +198,9 @@ class SentryHmsEvent { * Converts Principle to Owner Type defined by sentry. * * @param principalType Hive Principle Type - * @return TSentryObjectOwnerType if the input is valid else null + * @return TSentryPrincipalType if the input is valid else null */ - private TSentryObjectOwnerType getTSentryHmsObjectOwnerType(PrincipalType principalType) { + private TSentryPrincipalType getTSentryHmsObjectOwnerType(PrincipalType principalType) { return mapOwnerType.get(principalType); } http://git-wip-us.apache.org/repos/asf/sentry/blob/fb7bb7bc/sentry-binding/sentry-binding-hive/src/test/java/org/apache/sentry/binding/metastore/TestSentrySyncHMSNotificationsPostEventListener.java ---------------------------------------------------------------------- diff --git a/sentry-binding/sentry-binding-hive/src/test/java/org/apache/sentry/binding/metastore/TestSentrySyncHMSNotificationsPostEventListener.java b/sentry-binding/sentry-binding-hive/src/test/java/org/apache/sentry/binding/metastore/TestSentrySyncHMSNotificationsPostEventListener.java index e261fc6..98de8e3 100644 --- a/sentry-binding/sentry-binding-hive/src/test/java/org/apache/sentry/binding/metastore/TestSentrySyncHMSNotificationsPostEventListener.java +++ b/sentry-binding/sentry-binding-hive/src/test/java/org/apache/sentry/binding/metastore/TestSentrySyncHMSNotificationsPostEventListener.java @@ -37,7 +37,7 @@ import org.apache.hadoop.hive.metastore.api.Table; import org.apache.hadoop.hive.metastore.api.Database; import org.apache.sentry.api.service.thrift.TSentryAuthorizable; import org.apache.sentry.api.service.thrift.TSentryHmsEventNotification; -import org.apache.sentry.api.service.thrift.TSentryObjectOwnerType; +import org.apache.sentry.api.service.thrift.TSentryPrincipalType; import org.apache.sentry.binding.hive.conf.HiveAuthzConf; import org.apache.sentry.binding.hive.conf.HiveAuthzConf.AuthzConfVars; import org.apache.sentry.core.common.exception.SentryUserException; @@ -125,13 +125,13 @@ public class TestSentrySyncHMSNotificationsPostEventListener { Mockito.verify( mockSentryClient, Mockito.times(1) ).notifyHmsEvent(anyString(), eq(eventId-1), eq(EventType.CREATE_TABLE.toString()), - eq(TSentryObjectOwnerType.USER), anyString(), eq(new TSentryAuthorizable(SERVER1))); + eq(TSentryPrincipalType.USER), anyString(), eq(new TSentryAuthorizable(SERVER1))); long latestEventId = callAllEventsThatSynchronize(EventType.DROP_TABLE, SUCCESSFUL_STATUS, eventId++); Mockito.verify( mockSentryClient, Mockito.times(1) ).notifyHmsEvent(anyString(), eq(eventId-1), eq(EventType.DROP_TABLE.toString()), - eq(TSentryObjectOwnerType.USER), anyString(), eq(new TSentryAuthorizable(SERVER1))); + eq(TSentryPrincipalType.USER), anyString(), eq(new TSentryAuthorizable(SERVER1))); Mockito.verify( @@ -174,7 +174,7 @@ public class TestSentrySyncHMSNotificationsPostEventListener { Mockito.verify( mockSentryClient, Mockito.times(1) ).notifyHmsEvent(anyString(), eq(eventId), eq(EventType.CREATE_TABLE.toString()), - eq(TSentryObjectOwnerType.USER), eq(OWNER), eq(toAuthorizable(DBNAME, TABLENAME))); + eq(TSentryPrincipalType.USER), eq(OWNER), eq(toAuthorizable(DBNAME, TABLENAME))); } @Test @@ -191,7 +191,7 @@ public class TestSentrySyncHMSNotificationsPostEventListener { Mockito.verify( mockSentryClient, Mockito.times(1) ).notifyHmsEvent(anyString(), eq(eventId), eq(EventType.DROP_TABLE.toString()), - eq(TSentryObjectOwnerType.USER), eq(OWNER), eq(toAuthorizable(DBNAME, TABLENAME))); + eq(TSentryPrincipalType.USER), eq(OWNER), eq(toAuthorizable(DBNAME, TABLENAME))); } @Test @@ -208,7 +208,7 @@ public class TestSentrySyncHMSNotificationsPostEventListener { Mockito.verify( mockSentryClient, Mockito.times(1) ).notifyHmsEvent(anyString(), eq(eventId), eq(EventType.CREATE_DATABASE.toString()), - eq(TSentryObjectOwnerType.USER), eq(OWNER), eq(toAuthorizable(DBNAME, ""))); + eq(TSentryPrincipalType.USER), eq(OWNER), eq(toAuthorizable(DBNAME, ""))); } @Test @@ -225,7 +225,7 @@ public class TestSentrySyncHMSNotificationsPostEventListener { Mockito.verify( mockSentryClient, Mockito.times(1) ).notifyHmsEvent(anyString(), eq(eventId), eq(EventType.DROP_DATABASE.toString()), - eq(TSentryObjectOwnerType.USER), eq(OWNER), eq(toAuthorizable(DBNAME, ""))); + eq(TSentryPrincipalType.USER), eq(OWNER), eq(toAuthorizable(DBNAME, ""))); } @@ -249,7 +249,7 @@ public class TestSentrySyncHMSNotificationsPostEventListener { Mockito.verify( mockSentryClient, Mockito.times(1) ).notifyHmsEvent(anyString(), eq(eventId), eq(EventType.ALTER_TABLE.toString()), - eq(TSentryObjectOwnerType.USER), eq(OWNER_NEW), eq(toAuthorizable(DBNAME, TABLENAME))); + eq(TSentryPrincipalType.USER), eq(OWNER_NEW), eq(toAuthorizable(DBNAME, TABLENAME))); } @Test @@ -361,7 +361,7 @@ public class TestSentrySyncHMSNotificationsPostEventListener { Mockito.verify( mockSentryClient, Mockito.times(1) ).notifyHmsEvent(anyString(), eq(i), eq(EventType.CREATE_TABLE.toString()), - eq(TSentryObjectOwnerType.USER), anyString(), anyObject()); + eq(TSentryPrincipalType.USER), anyString(), anyObject()); } private void setEventId(boolean eventIdSet, ListenerEvent eventListener, long eventId) { http://git-wip-us.apache.org/repos/asf/sentry/blob/fb7bb7bc/sentry-core/sentry-core-common/src/main/java/org/apache/sentry/SentryOwnerInfo.java ---------------------------------------------------------------------- diff --git a/sentry-core/sentry-core-common/src/main/java/org/apache/sentry/SentryOwnerInfo.java b/sentry-core/sentry-core-common/src/main/java/org/apache/sentry/SentryOwnerInfo.java index ee4fce5..51bf7b7 100644 --- a/sentry-core/sentry-core-common/src/main/java/org/apache/sentry/SentryOwnerInfo.java +++ b/sentry-core/sentry-core-common/src/main/java/org/apache/sentry/SentryOwnerInfo.java @@ -19,16 +19,16 @@ package org.apache.sentry; import org.apache.commons.lang.StringUtils; -import org.apache.sentry.service.common.ServiceConstants.SentryEntityType; +import org.apache.sentry.service.common.ServiceConstants.SentryPrincipalType; /** * This class holds the owner name and the Type */ public class SentryOwnerInfo { private String ownerName; - private SentryEntityType ownerType; + private SentryPrincipalType ownerType; - public SentryOwnerInfo (SentryEntityType type, String name) { + public SentryOwnerInfo (SentryPrincipalType type, String name) { ownerType = type; ownerName = name; } @@ -41,11 +41,11 @@ public class SentryOwnerInfo { return ownerName; } - public SentryEntityType getOwnerType() { + public SentryPrincipalType getOwnerType() { return ownerType; } - public void setOwnerType(SentryEntityType type) { + public void setOwnerType(SentryPrincipalType type) { ownerType = type; } http://git-wip-us.apache.org/repos/asf/sentry/blob/fb7bb7bc/sentry-core/sentry-core-common/src/main/java/org/apache/sentry/service/common/ServiceConstants.java ---------------------------------------------------------------------- diff --git a/sentry-core/sentry-core-common/src/main/java/org/apache/sentry/service/common/ServiceConstants.java b/sentry-core/sentry-core-common/src/main/java/org/apache/sentry/service/common/ServiceConstants.java index c1beaed..9a2091a 100644 --- a/sentry-core/sentry-core-common/src/main/java/org/apache/sentry/service/common/ServiceConstants.java +++ b/sentry-core/sentry-core-common/src/main/java/org/apache/sentry/service/common/ServiceConstants.java @@ -265,7 +265,7 @@ public class ServiceConstants { public static final String SENTRY_ZK_JAAS_NAME = "Sentry"; public static final String CURRENT_INCARNATION_ID_KEY = "current.incarnation.key"; - public enum SentryEntityType { + public enum SentryPrincipalType { ROLE, USER } http://git-wip-us.apache.org/repos/asf/sentry/blob/fb7bb7bc/sentry-hdfs/sentry-hdfs-common/src/gen/thrift/gen-javabean/org/apache/sentry/hdfs/service/thrift/TPrivilegeChanges.java ---------------------------------------------------------------------- diff --git a/sentry-hdfs/sentry-hdfs-common/src/gen/thrift/gen-javabean/org/apache/sentry/hdfs/service/thrift/TPrivilegeChanges.java b/sentry-hdfs/sentry-hdfs-common/src/gen/thrift/gen-javabean/org/apache/sentry/hdfs/service/thrift/TPrivilegeChanges.java index abcf3ca..456ca4d 100644 --- a/sentry-hdfs/sentry-hdfs-common/src/gen/thrift/gen-javabean/org/apache/sentry/hdfs/service/thrift/TPrivilegeChanges.java +++ b/sentry-hdfs/sentry-hdfs-common/src/gen/thrift/gen-javabean/org/apache/sentry/hdfs/service/thrift/TPrivilegeChanges.java @@ -49,8 +49,8 @@ public class TPrivilegeChanges implements org.apache.thrift.TBase<TPrivilegeChan } private String authzObj; // required - private Map<TPrivilegeEntity,String> addPrivileges; // required - private Map<TPrivilegeEntity,String> delPrivileges; // required + private Map<TPrivilegePrincipal,String> addPrivileges; // required + private Map<TPrivilegePrincipal,String> delPrivileges; // 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 { @@ -124,11 +124,11 @@ public class TPrivilegeChanges implements org.apache.thrift.TBase<TPrivilegeChan new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.ADD_PRIVILEGES, new org.apache.thrift.meta_data.FieldMetaData("addPrivileges", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, - new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TPrivilegeEntity.class), + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TPrivilegePrincipal.class), new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); tmpMap.put(_Fields.DEL_PRIVILEGES, new org.apache.thrift.meta_data.FieldMetaData("delPrivileges", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, - new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TPrivilegeEntity.class), + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TPrivilegePrincipal.class), new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TPrivilegeChanges.class, metaDataMap); @@ -139,8 +139,8 @@ public class TPrivilegeChanges implements org.apache.thrift.TBase<TPrivilegeChan public TPrivilegeChanges( String authzObj, - Map<TPrivilegeEntity,String> addPrivileges, - Map<TPrivilegeEntity,String> delPrivileges) + Map<TPrivilegePrincipal,String> addPrivileges, + Map<TPrivilegePrincipal,String> delPrivileges) { this(); this.authzObj = authzObj; @@ -156,13 +156,13 @@ public class TPrivilegeChanges implements org.apache.thrift.TBase<TPrivilegeChan this.authzObj = other.authzObj; } if (other.isSetAddPrivileges()) { - Map<TPrivilegeEntity,String> __this__addPrivileges = new HashMap<TPrivilegeEntity,String>(other.addPrivileges.size()); - for (Map.Entry<TPrivilegeEntity, String> other_element : other.addPrivileges.entrySet()) { + Map<TPrivilegePrincipal,String> __this__addPrivileges = new HashMap<TPrivilegePrincipal,String>(other.addPrivileges.size()); + for (Map.Entry<TPrivilegePrincipal, String> other_element : other.addPrivileges.entrySet()) { - TPrivilegeEntity other_element_key = other_element.getKey(); + TPrivilegePrincipal other_element_key = other_element.getKey(); String other_element_value = other_element.getValue(); - TPrivilegeEntity __this__addPrivileges_copy_key = new TPrivilegeEntity(other_element_key); + TPrivilegePrincipal __this__addPrivileges_copy_key = new TPrivilegePrincipal(other_element_key); String __this__addPrivileges_copy_value = other_element_value; @@ -171,13 +171,13 @@ public class TPrivilegeChanges implements org.apache.thrift.TBase<TPrivilegeChan this.addPrivileges = __this__addPrivileges; } if (other.isSetDelPrivileges()) { - Map<TPrivilegeEntity,String> __this__delPrivileges = new HashMap<TPrivilegeEntity,String>(other.delPrivileges.size()); - for (Map.Entry<TPrivilegeEntity, String> other_element : other.delPrivileges.entrySet()) { + Map<TPrivilegePrincipal,String> __this__delPrivileges = new HashMap<TPrivilegePrincipal,String>(other.delPrivileges.size()); + for (Map.Entry<TPrivilegePrincipal, String> other_element : other.delPrivileges.entrySet()) { - TPrivilegeEntity other_element_key = other_element.getKey(); + TPrivilegePrincipal other_element_key = other_element.getKey(); String other_element_value = other_element.getValue(); - TPrivilegeEntity __this__delPrivileges_copy_key = new TPrivilegeEntity(other_element_key); + TPrivilegePrincipal __this__delPrivileges_copy_key = new TPrivilegePrincipal(other_element_key); String __this__delPrivileges_copy_value = other_element_value; @@ -225,18 +225,18 @@ public class TPrivilegeChanges implements org.apache.thrift.TBase<TPrivilegeChan return (this.addPrivileges == null) ? 0 : this.addPrivileges.size(); } - public void putToAddPrivileges(TPrivilegeEntity key, String val) { + public void putToAddPrivileges(TPrivilegePrincipal key, String val) { if (this.addPrivileges == null) { - this.addPrivileges = new HashMap<TPrivilegeEntity,String>(); + this.addPrivileges = new HashMap<TPrivilegePrincipal,String>(); } this.addPrivileges.put(key, val); } - public Map<TPrivilegeEntity,String> getAddPrivileges() { + public Map<TPrivilegePrincipal,String> getAddPrivileges() { return this.addPrivileges; } - public void setAddPrivileges(Map<TPrivilegeEntity,String> addPrivileges) { + public void setAddPrivileges(Map<TPrivilegePrincipal,String> addPrivileges) { this.addPrivileges = addPrivileges; } @@ -259,18 +259,18 @@ public class TPrivilegeChanges implements org.apache.thrift.TBase<TPrivilegeChan return (this.delPrivileges == null) ? 0 : this.delPrivileges.size(); } - public void putToDelPrivileges(TPrivilegeEntity key, String val) { + public void putToDelPrivileges(TPrivilegePrincipal key, String val) { if (this.delPrivileges == null) { - this.delPrivileges = new HashMap<TPrivilegeEntity,String>(); + this.delPrivileges = new HashMap<TPrivilegePrincipal,String>(); } this.delPrivileges.put(key, val); } - public Map<TPrivilegeEntity,String> getDelPrivileges() { + public Map<TPrivilegePrincipal,String> getDelPrivileges() { return this.delPrivileges; } - public void setDelPrivileges(Map<TPrivilegeEntity,String> delPrivileges) { + public void setDelPrivileges(Map<TPrivilegePrincipal,String> delPrivileges) { this.delPrivileges = delPrivileges; } @@ -303,7 +303,7 @@ public class TPrivilegeChanges implements org.apache.thrift.TBase<TPrivilegeChan if (value == null) { unsetAddPrivileges(); } else { - setAddPrivileges((Map<TPrivilegeEntity,String>)value); + setAddPrivileges((Map<TPrivilegePrincipal,String>)value); } break; @@ -311,7 +311,7 @@ public class TPrivilegeChanges implements org.apache.thrift.TBase<TPrivilegeChan if (value == null) { unsetDelPrivileges(); } else { - setDelPrivileges((Map<TPrivilegeEntity,String>)value); + setDelPrivileges((Map<TPrivilegePrincipal,String>)value); } break; @@ -563,12 +563,12 @@ public class TPrivilegeChanges implements org.apache.thrift.TBase<TPrivilegeChan if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { { org.apache.thrift.protocol.TMap _map74 = iprot.readMapBegin(); - struct.addPrivileges = new HashMap<TPrivilegeEntity,String>(2*_map74.size); - TPrivilegeEntity _key75; + struct.addPrivileges = new HashMap<TPrivilegePrincipal,String>(2*_map74.size); + TPrivilegePrincipal _key75; String _val76; for (int _i77 = 0; _i77 < _map74.size; ++_i77) { - _key75 = new TPrivilegeEntity(); + _key75 = new TPrivilegePrincipal(); _key75.read(iprot); _val76 = iprot.readString(); struct.addPrivileges.put(_key75, _val76); @@ -584,12 +584,12 @@ public class TPrivilegeChanges implements org.apache.thrift.TBase<TPrivilegeChan if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { { org.apache.thrift.protocol.TMap _map78 = iprot.readMapBegin(); - struct.delPrivileges = new HashMap<TPrivilegeEntity,String>(2*_map78.size); - TPrivilegeEntity _key79; + struct.delPrivileges = new HashMap<TPrivilegePrincipal,String>(2*_map78.size); + TPrivilegePrincipal _key79; String _val80; for (int _i81 = 0; _i81 < _map78.size; ++_i81) { - _key79 = new TPrivilegeEntity(); + _key79 = new TPrivilegePrincipal(); _key79.read(iprot); _val80 = iprot.readString(); struct.delPrivileges.put(_key79, _val80); @@ -623,7 +623,7 @@ public class TPrivilegeChanges implements org.apache.thrift.TBase<TPrivilegeChan oprot.writeFieldBegin(ADD_PRIVILEGES_FIELD_DESC); { oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRUCT, org.apache.thrift.protocol.TType.STRING, struct.addPrivileges.size())); - for (Map.Entry<TPrivilegeEntity, String> _iter82 : struct.addPrivileges.entrySet()) + for (Map.Entry<TPrivilegePrincipal, String> _iter82 : struct.addPrivileges.entrySet()) { _iter82.getKey().write(oprot); oprot.writeString(_iter82.getValue()); @@ -636,7 +636,7 @@ public class TPrivilegeChanges implements org.apache.thrift.TBase<TPrivilegeChan oprot.writeFieldBegin(DEL_PRIVILEGES_FIELD_DESC); { oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRUCT, org.apache.thrift.protocol.TType.STRING, struct.delPrivileges.size())); - for (Map.Entry<TPrivilegeEntity, String> _iter83 : struct.delPrivileges.entrySet()) + for (Map.Entry<TPrivilegePrincipal, String> _iter83 : struct.delPrivileges.entrySet()) { _iter83.getKey().write(oprot); oprot.writeString(_iter83.getValue()); @@ -665,7 +665,7 @@ public class TPrivilegeChanges implements org.apache.thrift.TBase<TPrivilegeChan oprot.writeString(struct.authzObj); { oprot.writeI32(struct.addPrivileges.size()); - for (Map.Entry<TPrivilegeEntity, String> _iter84 : struct.addPrivileges.entrySet()) + for (Map.Entry<TPrivilegePrincipal, String> _iter84 : struct.addPrivileges.entrySet()) { _iter84.getKey().write(oprot); oprot.writeString(_iter84.getValue()); @@ -673,7 +673,7 @@ public class TPrivilegeChanges implements org.apache.thrift.TBase<TPrivilegeChan } { oprot.writeI32(struct.delPrivileges.size()); - for (Map.Entry<TPrivilegeEntity, String> _iter85 : struct.delPrivileges.entrySet()) + for (Map.Entry<TPrivilegePrincipal, String> _iter85 : struct.delPrivileges.entrySet()) { _iter85.getKey().write(oprot); oprot.writeString(_iter85.getValue()); @@ -688,12 +688,12 @@ public class TPrivilegeChanges implements org.apache.thrift.TBase<TPrivilegeChan struct.setAuthzObjIsSet(true); { org.apache.thrift.protocol.TMap _map86 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRUCT, org.apache.thrift.protocol.TType.STRING, iprot.readI32()); - struct.addPrivileges = new HashMap<TPrivilegeEntity,String>(2*_map86.size); - TPrivilegeEntity _key87; + struct.addPrivileges = new HashMap<TPrivilegePrincipal,String>(2*_map86.size); + TPrivilegePrincipal _key87; String _val88; for (int _i89 = 0; _i89 < _map86.size; ++_i89) { - _key87 = new TPrivilegeEntity(); + _key87 = new TPrivilegePrincipal(); _key87.read(iprot); _val88 = iprot.readString(); struct.addPrivileges.put(_key87, _val88); @@ -702,12 +702,12 @@ public class TPrivilegeChanges implements org.apache.thrift.TBase<TPrivilegeChan struct.setAddPrivilegesIsSet(true); { org.apache.thrift.protocol.TMap _map90 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRUCT, org.apache.thrift.protocol.TType.STRING, iprot.readI32()); - struct.delPrivileges = new HashMap<TPrivilegeEntity,String>(2*_map90.size); - TPrivilegeEntity _key91; + struct.delPrivileges = new HashMap<TPrivilegePrincipal,String>(2*_map90.size); + TPrivilegePrincipal _key91; String _val92; for (int _i93 = 0; _i93 < _map90.size; ++_i93) { - _key91 = new TPrivilegeEntity(); + _key91 = new TPrivilegePrincipal(); _key91.read(iprot); _val92 = iprot.readString(); struct.delPrivileges.put(_key91, _val92); http://git-wip-us.apache.org/repos/asf/sentry/blob/fb7bb7bc/sentry-hdfs/sentry-hdfs-common/src/gen/thrift/gen-javabean/org/apache/sentry/hdfs/service/thrift/TPrivilegeEntity.java ---------------------------------------------------------------------- diff --git a/sentry-hdfs/sentry-hdfs-common/src/gen/thrift/gen-javabean/org/apache/sentry/hdfs/service/thrift/TPrivilegeEntity.java b/sentry-hdfs/sentry-hdfs-common/src/gen/thrift/gen-javabean/org/apache/sentry/hdfs/service/thrift/TPrivilegeEntity.java deleted file mode 100644 index 85f8147..0000000 --- a/sentry-hdfs/sentry-hdfs-common/src/gen/thrift/gen-javabean/org/apache/sentry/hdfs/service/thrift/TPrivilegeEntity.java +++ /dev/null @@ -1,502 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.9.3) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -package org.apache.sentry.hdfs.service.thrift; - -import org.apache.thrift.scheme.IScheme; -import org.apache.thrift.scheme.SchemeFactory; -import org.apache.thrift.scheme.StandardScheme; - -import org.apache.thrift.scheme.TupleScheme; -import org.apache.thrift.protocol.TTupleProtocol; -import org.apache.thrift.protocol.TProtocolException; -import org.apache.thrift.EncodingUtils; -import org.apache.thrift.TException; -import org.apache.thrift.async.AsyncMethodCallback; -import org.apache.thrift.server.AbstractNonblockingServer.*; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.HashMap; -import java.util.EnumMap; -import java.util.Set; -import java.util.HashSet; -import java.util.EnumSet; -import java.util.Collections; -import java.util.BitSet; -import java.nio.ByteBuffer; -import java.util.Arrays; -import javax.annotation.Generated; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)") -public class TPrivilegeEntity implements org.apache.thrift.TBase<TPrivilegeEntity, TPrivilegeEntity._Fields>, java.io.Serializable, Cloneable, Comparable<TPrivilegeEntity> { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TPrivilegeEntity"); - - private static final org.apache.thrift.protocol.TField TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("type", org.apache.thrift.protocol.TType.I32, (short)1); - private static final org.apache.thrift.protocol.TField VALUE_FIELD_DESC = new org.apache.thrift.protocol.TField("value", org.apache.thrift.protocol.TType.STRING, (short)2); - - private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); - static { - schemes.put(StandardScheme.class, new TPrivilegeEntityStandardSchemeFactory()); - schemes.put(TupleScheme.class, new TPrivilegeEntityTupleSchemeFactory()); - } - - private TPrivilegeEntityType type; // required - private String value; // 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 { - /** - * - * @see TPrivilegeEntityType - */ - TYPE((short)1, "type"), - VALUE((short)2, "value"); - - private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); - - 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: // TYPE - return TYPE; - case 2: // VALUE - return VALUE; - 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.TYPE, new org.apache.thrift.meta_data.FieldMetaData("type", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TPrivilegeEntityType.class))); - tmpMap.put(_Fields.VALUE, new org.apache.thrift.meta_data.FieldMetaData("value", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TPrivilegeEntity.class, metaDataMap); - } - - public TPrivilegeEntity() { - } - - public TPrivilegeEntity( - TPrivilegeEntityType type, - String value) - { - this(); - this.type = type; - this.value = value; - } - - /** - * Performs a deep copy on <i>other</i>. - */ - public TPrivilegeEntity(TPrivilegeEntity other) { - if (other.isSetType()) { - this.type = other.type; - } - if (other.isSetValue()) { - this.value = other.value; - } - } - - public TPrivilegeEntity deepCopy() { - return new TPrivilegeEntity(this); - } - - @Override - public void clear() { - this.type = null; - this.value = null; - } - - /** - * - * @see TPrivilegeEntityType - */ - public TPrivilegeEntityType getType() { - return this.type; - } - - /** - * - * @see TPrivilegeEntityType - */ - public void setType(TPrivilegeEntityType type) { - this.type = type; - } - - public void unsetType() { - this.type = null; - } - - /** Returns true if field type is set (has been assigned a value) and false otherwise */ - public boolean isSetType() { - return this.type != null; - } - - public void setTypeIsSet(boolean value) { - if (!value) { - this.type = null; - } - } - - public String getValue() { - return this.value; - } - - public void setValue(String value) { - this.value = value; - } - - public void unsetValue() { - this.value = null; - } - - /** Returns true if field value is set (has been assigned a value) and false otherwise */ - public boolean isSetValue() { - return this.value != null; - } - - public void setValueIsSet(boolean value) { - if (!value) { - this.value = null; - } - } - - public void setFieldValue(_Fields field, Object value) { - switch (field) { - case TYPE: - if (value == null) { - unsetType(); - } else { - setType((TPrivilegeEntityType)value); - } - break; - - case VALUE: - if (value == null) { - unsetValue(); - } else { - setValue((String)value); - } - break; - - } - } - - public Object getFieldValue(_Fields field) { - switch (field) { - case TYPE: - return getType(); - - case VALUE: - return getValue(); - - } - 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 TYPE: - return isSetType(); - case VALUE: - return isSetValue(); - } - throw new IllegalStateException(); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof TPrivilegeEntity) - return this.equals((TPrivilegeEntity)that); - return false; - } - - public boolean equals(TPrivilegeEntity that) { - if (that == null) - return false; - - boolean this_present_type = true && this.isSetType(); - boolean that_present_type = true && that.isSetType(); - if (this_present_type || that_present_type) { - if (!(this_present_type && that_present_type)) - return false; - if (!this.type.equals(that.type)) - return false; - } - - boolean this_present_value = true && this.isSetValue(); - boolean that_present_value = true && that.isSetValue(); - if (this_present_value || that_present_value) { - if (!(this_present_value && that_present_value)) - return false; - if (!this.value.equals(that.value)) - return false; - } - - return true; - } - - @Override - public int hashCode() { - List<Object> list = new ArrayList<Object>(); - - boolean present_type = true && (isSetType()); - list.add(present_type); - if (present_type) - list.add(type.getValue()); - - boolean present_value = true && (isSetValue()); - list.add(present_value); - if (present_value) - list.add(value); - - return list.hashCode(); - } - - @Override - public int compareTo(TPrivilegeEntity other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - - lastComparison = Boolean.valueOf(isSetType()).compareTo(other.isSetType()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetType()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.type, other.type); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetValue()).compareTo(other.isSetValue()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetValue()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.value, other.value); - 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("TPrivilegeEntity("); - boolean first = true; - - sb.append("type:"); - if (this.type == null) { - sb.append("null"); - } else { - sb.append(this.type); - } - first = false; - if (!first) sb.append(", "); - sb.append("value:"); - if (this.value == null) { - sb.append("null"); - } else { - sb.append(this.value); - } - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws org.apache.thrift.TException { - // check for required fields - if (!isSetType()) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'type' is unset! Struct:" + toString()); - } - - if (!isSetValue()) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'value' is unset! Struct:" + toString()); - } - - // check for sub-struct validity - } - - 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 TPrivilegeEntityStandardSchemeFactory implements SchemeFactory { - public TPrivilegeEntityStandardScheme getScheme() { - return new TPrivilegeEntityStandardScheme(); - } - } - - private static class TPrivilegeEntityStandardScheme extends StandardScheme<TPrivilegeEntity> { - - public void read(org.apache.thrift.protocol.TProtocol iprot, TPrivilegeEntity 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: // TYPE - if (schemeField.type == org.apache.thrift.protocol.TType.I32) { - struct.type = org.apache.sentry.hdfs.service.thrift.TPrivilegeEntityType.findByValue(iprot.readI32()); - struct.setTypeIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 2: // VALUE - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.value = iprot.readString(); - struct.setValueIsSet(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, TPrivilegeEntity struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - if (struct.type != null) { - oprot.writeFieldBegin(TYPE_FIELD_DESC); - oprot.writeI32(struct.type.getValue()); - oprot.writeFieldEnd(); - } - if (struct.value != null) { - oprot.writeFieldBegin(VALUE_FIELD_DESC); - oprot.writeString(struct.value); - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class TPrivilegeEntityTupleSchemeFactory implements SchemeFactory { - public TPrivilegeEntityTupleScheme getScheme() { - return new TPrivilegeEntityTupleScheme(); - } - } - - private static class TPrivilegeEntityTupleScheme extends TupleScheme<TPrivilegeEntity> { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, TPrivilegeEntity struct) throws org.apache.thrift.TException { - TTupleProtocol oprot = (TTupleProtocol) prot; - oprot.writeI32(struct.type.getValue()); - oprot.writeString(struct.value); - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, TPrivilegeEntity struct) throws org.apache.thrift.TException { - TTupleProtocol iprot = (TTupleProtocol) prot; - struct.type = org.apache.sentry.hdfs.service.thrift.TPrivilegeEntityType.findByValue(iprot.readI32()); - struct.setTypeIsSet(true); - struct.value = iprot.readString(); - struct.setValueIsSet(true); - } - } - -} - http://git-wip-us.apache.org/repos/asf/sentry/blob/fb7bb7bc/sentry-hdfs/sentry-hdfs-common/src/gen/thrift/gen-javabean/org/apache/sentry/hdfs/service/thrift/TPrivilegeEntityType.java ---------------------------------------------------------------------- diff --git a/sentry-hdfs/sentry-hdfs-common/src/gen/thrift/gen-javabean/org/apache/sentry/hdfs/service/thrift/TPrivilegeEntityType.java b/sentry-hdfs/sentry-hdfs-common/src/gen/thrift/gen-javabean/org/apache/sentry/hdfs/service/thrift/TPrivilegeEntityType.java deleted file mode 100644 index ac44c1f..0000000 --- a/sentry-hdfs/sentry-hdfs-common/src/gen/thrift/gen-javabean/org/apache/sentry/hdfs/service/thrift/TPrivilegeEntityType.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.9.3) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -package org.apache.sentry.hdfs.service.thrift; - - -import java.util.Map; -import java.util.HashMap; -import org.apache.thrift.TEnum; - -public enum TPrivilegeEntityType implements org.apache.thrift.TEnum { - ROLE(0), - USER(1), - AUTHZ_OBJ(2); - - private final int value; - - private TPrivilegeEntityType(int value) { - this.value = value; - } - - /** - * Get the integer value of this enum value, as defined in the Thrift IDL. - */ - public int getValue() { - return value; - } - - /** - * Find a the enum type by its integer value, as defined in the Thrift IDL. - * @return null if the value is not found. - */ - public static TPrivilegeEntityType findByValue(int value) { - switch (value) { - case 0: - return ROLE; - case 1: - return USER; - case 2: - return AUTHZ_OBJ; - default: - return null; - } - } -} http://git-wip-us.apache.org/repos/asf/sentry/blob/fb7bb7bc/sentry-hdfs/sentry-hdfs-common/src/gen/thrift/gen-javabean/org/apache/sentry/hdfs/service/thrift/TPrivilegePrincipal.java ---------------------------------------------------------------------- diff --git a/sentry-hdfs/sentry-hdfs-common/src/gen/thrift/gen-javabean/org/apache/sentry/hdfs/service/thrift/TPrivilegePrincipal.java b/sentry-hdfs/sentry-hdfs-common/src/gen/thrift/gen-javabean/org/apache/sentry/hdfs/service/thrift/TPrivilegePrincipal.java new file mode 100644 index 0000000..8074840 --- /dev/null +++ b/sentry-hdfs/sentry-hdfs-common/src/gen/thrift/gen-javabean/org/apache/sentry/hdfs/service/thrift/TPrivilegePrincipal.java @@ -0,0 +1,502 @@ +/** + * Autogenerated by Thrift Compiler (0.9.3) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package org.apache.sentry.hdfs.service.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)") +public class TPrivilegePrincipal implements org.apache.thrift.TBase<TPrivilegePrincipal, TPrivilegePrincipal._Fields>, java.io.Serializable, Cloneable, Comparable<TPrivilegePrincipal> { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TPrivilegePrincipal"); + + private static final org.apache.thrift.protocol.TField TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("type", org.apache.thrift.protocol.TType.I32, (short)1); + private static final org.apache.thrift.protocol.TField VALUE_FIELD_DESC = new org.apache.thrift.protocol.TField("value", org.apache.thrift.protocol.TType.STRING, (short)2); + + private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TPrivilegePrincipalStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TPrivilegePrincipalTupleSchemeFactory()); + } + + private TPrivilegePrincipalType type; // required + private String value; // 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 { + /** + * + * @see TPrivilegePrincipalType + */ + TYPE((short)1, "type"), + VALUE((short)2, "value"); + + private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); + + 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: // TYPE + return TYPE; + case 2: // VALUE + return VALUE; + 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.TYPE, new org.apache.thrift.meta_data.FieldMetaData("type", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TPrivilegePrincipalType.class))); + tmpMap.put(_Fields.VALUE, new org.apache.thrift.meta_data.FieldMetaData("value", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TPrivilegePrincipal.class, metaDataMap); + } + + public TPrivilegePrincipal() { + } + + public TPrivilegePrincipal( + TPrivilegePrincipalType type, + String value) + { + this(); + this.type = type; + this.value = value; + } + + /** + * Performs a deep copy on <i>other</i>. + */ + public TPrivilegePrincipal(TPrivilegePrincipal other) { + if (other.isSetType()) { + this.type = other.type; + } + if (other.isSetValue()) { + this.value = other.value; + } + } + + public TPrivilegePrincipal deepCopy() { + return new TPrivilegePrincipal(this); + } + + @Override + public void clear() { + this.type = null; + this.value = null; + } + + /** + * + * @see TPrivilegePrincipalType + */ + public TPrivilegePrincipalType getType() { + return this.type; + } + + /** + * + * @see TPrivilegePrincipalType + */ + public void setType(TPrivilegePrincipalType type) { + this.type = type; + } + + public void unsetType() { + this.type = null; + } + + /** Returns true if field type is set (has been assigned a value) and false otherwise */ + public boolean isSetType() { + return this.type != null; + } + + public void setTypeIsSet(boolean value) { + if (!value) { + this.type = null; + } + } + + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + public void unsetValue() { + this.value = null; + } + + /** Returns true if field value is set (has been assigned a value) and false otherwise */ + public boolean isSetValue() { + return this.value != null; + } + + public void setValueIsSet(boolean value) { + if (!value) { + this.value = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case TYPE: + if (value == null) { + unsetType(); + } else { + setType((TPrivilegePrincipalType)value); + } + break; + + case VALUE: + if (value == null) { + unsetValue(); + } else { + setValue((String)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case TYPE: + return getType(); + + case VALUE: + return getValue(); + + } + 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 TYPE: + return isSetType(); + case VALUE: + return isSetValue(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof TPrivilegePrincipal) + return this.equals((TPrivilegePrincipal)that); + return false; + } + + public boolean equals(TPrivilegePrincipal that) { + if (that == null) + return false; + + boolean this_present_type = true && this.isSetType(); + boolean that_present_type = true && that.isSetType(); + if (this_present_type || that_present_type) { + if (!(this_present_type && that_present_type)) + return false; + if (!this.type.equals(that.type)) + return false; + } + + boolean this_present_value = true && this.isSetValue(); + boolean that_present_value = true && that.isSetValue(); + if (this_present_value || that_present_value) { + if (!(this_present_value && that_present_value)) + return false; + if (!this.value.equals(that.value)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List<Object> list = new ArrayList<Object>(); + + boolean present_type = true && (isSetType()); + list.add(present_type); + if (present_type) + list.add(type.getValue()); + + boolean present_value = true && (isSetValue()); + list.add(present_value); + if (present_value) + list.add(value); + + return list.hashCode(); + } + + @Override + public int compareTo(TPrivilegePrincipal other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetType()).compareTo(other.isSetType()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetType()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.type, other.type); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetValue()).compareTo(other.isSetValue()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetValue()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.value, other.value); + 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("TPrivilegePrincipal("); + boolean first = true; + + sb.append("type:"); + if (this.type == null) { + sb.append("null"); + } else { + sb.append(this.type); + } + first = false; + if (!first) sb.append(", "); + sb.append("value:"); + if (this.value == null) { + sb.append("null"); + } else { + sb.append(this.value); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (!isSetType()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'type' is unset! Struct:" + toString()); + } + + if (!isSetValue()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'value' is unset! Struct:" + toString()); + } + + // check for sub-struct validity + } + + 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 TPrivilegePrincipalStandardSchemeFactory implements SchemeFactory { + public TPrivilegePrincipalStandardScheme getScheme() { + return new TPrivilegePrincipalStandardScheme(); + } + } + + private static class TPrivilegePrincipalStandardScheme extends StandardScheme<TPrivilegePrincipal> { + + public void read(org.apache.thrift.protocol.TProtocol iprot, TPrivilegePrincipal 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: // TYPE + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.type = org.apache.sentry.hdfs.service.thrift.TPrivilegePrincipalType.findByValue(iprot.readI32()); + struct.setTypeIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // VALUE + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.value = iprot.readString(); + struct.setValueIsSet(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, TPrivilegePrincipal struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.type != null) { + oprot.writeFieldBegin(TYPE_FIELD_DESC); + oprot.writeI32(struct.type.getValue()); + oprot.writeFieldEnd(); + } + if (struct.value != null) { + oprot.writeFieldBegin(VALUE_FIELD_DESC); + oprot.writeString(struct.value); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class TPrivilegePrincipalTupleSchemeFactory implements SchemeFactory { + public TPrivilegePrincipalTupleScheme getScheme() { + return new TPrivilegePrincipalTupleScheme(); + } + } + + private static class TPrivilegePrincipalTupleScheme extends TupleScheme<TPrivilegePrincipal> { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, TPrivilegePrincipal struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + oprot.writeI32(struct.type.getValue()); + oprot.writeString(struct.value); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, TPrivilegePrincipal struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.type = org.apache.sentry.hdfs.service.thrift.TPrivilegePrincipalType.findByValue(iprot.readI32()); + struct.setTypeIsSet(true); + struct.value = iprot.readString(); + struct.setValueIsSet(true); + } + } + +} + http://git-wip-us.apache.org/repos/asf/sentry/blob/fb7bb7bc/sentry-hdfs/sentry-hdfs-common/src/gen/thrift/gen-javabean/org/apache/sentry/hdfs/service/thrift/TPrivilegePrincipalType.java ---------------------------------------------------------------------- diff --git a/sentry-hdfs/sentry-hdfs-common/src/gen/thrift/gen-javabean/org/apache/sentry/hdfs/service/thrift/TPrivilegePrincipalType.java b/sentry-hdfs/sentry-hdfs-common/src/gen/thrift/gen-javabean/org/apache/sentry/hdfs/service/thrift/TPrivilegePrincipalType.java new file mode 100644 index 0000000..6eb8521 --- /dev/null +++ b/sentry-hdfs/sentry-hdfs-common/src/gen/thrift/gen-javabean/org/apache/sentry/hdfs/service/thrift/TPrivilegePrincipalType.java @@ -0,0 +1,48 @@ +/** + * Autogenerated by Thrift Compiler (0.9.3) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package org.apache.sentry.hdfs.service.thrift; + + +import java.util.Map; +import java.util.HashMap; +import org.apache.thrift.TEnum; + +public enum TPrivilegePrincipalType implements org.apache.thrift.TEnum { + ROLE(0), + USER(1), + AUTHZ_OBJ(2); + + private final int value; + + private TPrivilegePrincipalType(int value) { + this.value = value; + } + + /** + * Get the integer value of this enum value, as defined in the Thrift IDL. + */ + public int getValue() { + return value; + } + + /** + * Find a the enum type by its integer value, as defined in the Thrift IDL. + * @return null if the value is not found. + */ + public static TPrivilegePrincipalType findByValue(int value) { + switch (value) { + case 0: + return ROLE; + case 1: + return USER; + case 2: + return AUTHZ_OBJ; + default: + return null; + } + } +} http://git-wip-us.apache.org/repos/asf/sentry/blob/fb7bb7bc/sentry-hdfs/sentry-hdfs-common/src/main/java/org/apache/sentry/hdfs/PermissionsUpdate.java ---------------------------------------------------------------------- diff --git a/sentry-hdfs/sentry-hdfs-common/src/main/java/org/apache/sentry/hdfs/PermissionsUpdate.java b/sentry-hdfs/sentry-hdfs-common/src/main/java/org/apache/sentry/hdfs/PermissionsUpdate.java index 5691933..b498555 100644 --- a/sentry-hdfs/sentry-hdfs-common/src/main/java/org/apache/sentry/hdfs/PermissionsUpdate.java +++ b/sentry-hdfs/sentry-hdfs-common/src/main/java/org/apache/sentry/hdfs/PermissionsUpdate.java @@ -22,7 +22,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; -import org.apache.sentry.hdfs.service.thrift.TPrivilegeEntity; +import org.apache.sentry.hdfs.service.thrift.TPrivilegePrincipal; import org.apache.sentry.hdfs.service.thrift.TPermissionsUpdate; import org.apache.sentry.hdfs.service.thrift.TPrivilegeChanges; import org.apache.sentry.hdfs.service.thrift.TRoleChanges; @@ -83,7 +83,7 @@ public class PermissionsUpdate implements Updateable.Update { return tPermUpdate.getPrivilegeChanges().get(authzObj); } TPrivilegeChanges privUpdate = new TPrivilegeChanges(authzObj, - new HashMap<TPrivilegeEntity, String>(), new HashMap<TPrivilegeEntity, String>()); + new HashMap<TPrivilegePrincipal, String>(), new HashMap<TPrivilegePrincipal, String>()); tPermUpdate.getPrivilegeChanges().put(authzObj, privUpdate); return privUpdate; } http://git-wip-us.apache.org/repos/asf/sentry/blob/fb7bb7bc/sentry-hdfs/sentry-hdfs-common/src/main/resources/sentry_hdfs_service.thrift ---------------------------------------------------------------------- diff --git a/sentry-hdfs/sentry-hdfs-common/src/main/resources/sentry_hdfs_service.thrift b/sentry-hdfs/sentry-hdfs-common/src/main/resources/sentry_hdfs_service.thrift index 61582cd..987bc32 100644 --- a/sentry-hdfs/sentry-hdfs-common/src/main/resources/sentry_hdfs_service.thrift +++ b/sentry-hdfs/sentry-hdfs-common/src/main/resources/sentry_hdfs_service.thrift @@ -26,18 +26,18 @@ namespace java org.apache.sentry.hdfs.service.thrift namespace php sentry.hdfs.thrift namespace cpp Apache.Sentry.HDFS.Thrift -enum TPrivilegeEntityType { +enum TPrivilegePrincipalType { ROLE, USER, AUTHZ_OBJ } -struct TPrivilegeEntity { +struct TPrivilegePrincipal { -# Type of the privilege entity -1: required TPrivilegeEntityType type; +# Type of the privilege principal +1: required TPrivilegePrincipalType type; -# Value of entity +# Value of principal 2: required string value; } @@ -94,11 +94,11 @@ struct TPrivilegeChanges { # The privileges that needs to be added to # the authorizable object. -2: required map<TPrivilegeEntity, string> addPrivileges; +2: required map<TPrivilegePrincipal, string> addPrivileges; # The privileges that needs to be deleted to # the authorizable object. -3: required map<TPrivilegeEntity, string> delPrivileges; +3: required map<TPrivilegePrincipal, string> delPrivileges; } struct TRoleChanges { http://git-wip-us.apache.org/repos/asf/sentry/blob/fb7bb7bc/sentry-hdfs/sentry-hdfs-common/src/test/java/org/apache/sentry/hdfs/TestPermissionUpdate.java ---------------------------------------------------------------------- diff --git a/sentry-hdfs/sentry-hdfs-common/src/test/java/org/apache/sentry/hdfs/TestPermissionUpdate.java b/sentry-hdfs/sentry-hdfs-common/src/test/java/org/apache/sentry/hdfs/TestPermissionUpdate.java index 8bd9d43..7c29225 100644 --- a/sentry-hdfs/sentry-hdfs-common/src/test/java/org/apache/sentry/hdfs/TestPermissionUpdate.java +++ b/sentry-hdfs/sentry-hdfs-common/src/test/java/org/apache/sentry/hdfs/TestPermissionUpdate.java @@ -21,8 +21,8 @@ package org.apache.sentry.hdfs; import junit.framework.Assert; import org.apache.sentry.hdfs.service.thrift.TPermissionsUpdate; import org.apache.sentry.hdfs.service.thrift.TPrivilegeChanges; -import org.apache.sentry.hdfs.service.thrift.TPrivilegeEntity; -import org.apache.sentry.hdfs.service.thrift.TPrivilegeEntityType; +import org.apache.sentry.hdfs.service.thrift.TPrivilegePrincipal; +import org.apache.sentry.hdfs.service.thrift.TPrivilegePrincipalType; import org.apache.thrift.TException; import org.junit.Test; @@ -32,8 +32,8 @@ public class TestPermissionUpdate { public void testSerializeDeserializeInJSON() throws TException { PermissionsUpdate update = new PermissionsUpdate(0, false); TPrivilegeChanges privUpdate = update.addPrivilegeUpdate(PermissionsUpdate.RENAME_PRIVS); - privUpdate.putToAddPrivileges(new TPrivilegeEntity(TPrivilegeEntityType.ROLE, "newAuthz"), "newAuthz"); - privUpdate.putToDelPrivileges(new TPrivilegeEntity(TPrivilegeEntityType.ROLE, "oldAuthz"), "oldAuthz"); + privUpdate.putToAddPrivileges(new TPrivilegePrincipal(TPrivilegePrincipalType.ROLE, "newAuthz"), "newAuthz"); + privUpdate.putToDelPrivileges(new TPrivilegePrincipal(TPrivilegePrincipalType.ROLE, "oldAuthz"), "oldAuthz"); // Serialize and deserialize the PermssionUpdate object should equals to the original one. TPermissionsUpdate before = update.toThrift(); http://git-wip-us.apache.org/repos/asf/sentry/blob/fb7bb7bc/sentry-hdfs/sentry-hdfs-namenode-plugin/src/main/java/org/apache/sentry/hdfs/SentryPermissions.java ---------------------------------------------------------------------- diff --git a/sentry-hdfs/sentry-hdfs-namenode-plugin/src/main/java/org/apache/sentry/hdfs/SentryPermissions.java b/sentry-hdfs/sentry-hdfs-namenode-plugin/src/main/java/org/apache/sentry/hdfs/SentryPermissions.java index c162ec1..caf9159 100644 --- a/sentry-hdfs/sentry-hdfs-namenode-plugin/src/main/java/org/apache/sentry/hdfs/SentryPermissions.java +++ b/sentry-hdfs/sentry-hdfs-namenode-plugin/src/main/java/org/apache/sentry/hdfs/SentryPermissions.java @@ -23,8 +23,8 @@ import org.apache.hadoop.fs.permission.AclEntry; import org.apache.hadoop.fs.permission.AclEntryScope; import org.apache.hadoop.fs.permission.AclEntryType; import org.apache.hadoop.fs.permission.FsAction; -import org.apache.sentry.hdfs.service.thrift.TPrivilegeEntity; -import org.apache.sentry.hdfs.service.thrift.TPrivilegeEntityType; +import org.apache.sentry.hdfs.service.thrift.TPrivilegePrincipal; +import org.apache.sentry.hdfs.service.thrift.TPrivilegePrincipalType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -32,24 +32,24 @@ public class SentryPermissions implements AuthzPermissions { public static class PrivilegeInfo { private final String authzObj; - // It is safe to use TPrivilegeEntity as key as it implements the hashCode and equals API's. + // It is safe to use TPrivilegePrincipal as key as it implements the hashCode and equals API's. // Equals() API would help in handling hash collisions. - private final Map<TPrivilegeEntity, FsAction> privilegeEntityFsActionMap = new HashMap<TPrivilegeEntity, FsAction>(); + private final Map<TPrivilegePrincipal, FsAction> privilegeEntityFsActionMap = new HashMap<TPrivilegePrincipal, FsAction>(); public PrivilegeInfo(String authzObj) { this.authzObj = authzObj; } - public PrivilegeInfo setPermission(TPrivilegeEntity privilegeEntity, FsAction perm) { + public PrivilegeInfo setPermission(TPrivilegePrincipal privilegeEntity, FsAction perm) { privilegeEntityFsActionMap.put(privilegeEntity, perm); return this; } - public PrivilegeInfo removePermission(TPrivilegeEntity privilegeEntity) { + public PrivilegeInfo removePermission(TPrivilegePrincipal privilegeEntity) { privilegeEntityFsActionMap.remove(privilegeEntity); return this; } - public FsAction getPermission(TPrivilegeEntity privilegeEntity) { + public FsAction getPermission(TPrivilegePrincipal privilegeEntity) { return privilegeEntityFsActionMap.get(privilegeEntity); } - public Map<TPrivilegeEntity, FsAction> getAllPermissions() { + public Map<TPrivilegePrincipal, FsAction> getAllPermissions() { return privilegeEntityFsActionMap; } public String getAuthzObj() { @@ -223,7 +223,7 @@ public class SentryPermissions implements AuthzPermissions { PrivilegeInfo privilegeInfo = privileges.get(authzObj); if (privilegeInfo != null) { - for (Map.Entry<TPrivilegeEntity, FsAction> privs : privilegeInfo + for (Map.Entry<TPrivilegePrincipal, FsAction> privs : privilegeInfo .getAllPermissions().entrySet()) { constructHdfsPermissions(privs.getKey(), privs.getValue(), perms); } @@ -268,16 +268,16 @@ public class SentryPermissions implements AuthzPermissions { /** * Constructs HDFS Permissions entry based on the privileges granted. - * @param privilegeEntity Privilege Entity + * @param privilegePrincipal Privilege Entity * @param permission Permission granted * @param perms */ - private void constructHdfsPermissions(TPrivilegeEntity privilegeEntity, FsAction permission, + private void constructHdfsPermissions(TPrivilegePrincipal privilegePrincipal, FsAction permission, Map<HdfsAclEntity, FsAction> perms) { HdfsAclEntity aclEntry; FsAction fsAction; - if(privilegeEntity.getType() == TPrivilegeEntityType.ROLE) { - RoleInfo roleInfo = roles.get(privilegeEntity.getValue()); + if(privilegePrincipal.getType() == TPrivilegePrincipalType.ROLE) { + RoleInfo roleInfo = roles.get(privilegePrincipal.getValue()); if (roleInfo != null) { for (String group : roleInfo.groups) { aclEntry = HdfsAclEntity.constructAclEntityForGroup(group); @@ -290,8 +290,8 @@ public class SentryPermissions implements AuthzPermissions { perms.put(aclEntry, fsAction.or(permission)); } } - } else if(privilegeEntity.getType() == TPrivilegeEntityType.USER) { - aclEntry = HdfsAclEntity.constructAclEntityForUser(privilegeEntity.getValue()); + } else if(privilegePrincipal.getType() == TPrivilegePrincipalType.USER) { + aclEntry = HdfsAclEntity.constructAclEntityForUser(privilegePrincipal.getValue()); // fsAction is an aggregate of permissions granted to // the user on the object and it's parents. fsAction = perms.get(aclEntry); http://git-wip-us.apache.org/repos/asf/sentry/blob/fb7bb7bc/sentry-hdfs/sentry-hdfs-namenode-plugin/src/main/java/org/apache/sentry/hdfs/UpdateableAuthzPermissions.java ---------------------------------------------------------------------- diff --git a/sentry-hdfs/sentry-hdfs-namenode-plugin/src/main/java/org/apache/sentry/hdfs/UpdateableAuthzPermissions.java b/sentry-hdfs/sentry-hdfs-namenode-plugin/src/main/java/org/apache/sentry/hdfs/UpdateableAuthzPermissions.java index 761c760..c87d205 100644 --- a/sentry-hdfs/sentry-hdfs-namenode-plugin/src/main/java/org/apache/sentry/hdfs/UpdateableAuthzPermissions.java +++ b/sentry-hdfs/sentry-hdfs-namenode-plugin/src/main/java/org/apache/sentry/hdfs/UpdateableAuthzPermissions.java @@ -29,8 +29,8 @@ import org.apache.hadoop.fs.permission.AclEntry; import org.apache.hadoop.fs.permission.FsAction; import org.apache.sentry.hdfs.SentryPermissions.PrivilegeInfo; import org.apache.sentry.hdfs.SentryPermissions.RoleInfo; -import org.apache.sentry.hdfs.service.thrift.TPrivilegeEntity; -import org.apache.sentry.hdfs.service.thrift.TPrivilegeEntityType; +import org.apache.sentry.hdfs.service.thrift.TPrivilegePrincipal; +import org.apache.sentry.hdfs.service.thrift.TPrivilegePrincipalType; import org.apache.sentry.hdfs.service.thrift.TPrivilegeChanges; import org.apache.sentry.hdfs.service.thrift.TRoleChanges; import org.apache.sentry.hdfs.service.thrift.sentry_hdfs_serviceConstants; @@ -124,13 +124,13 @@ public class UpdateableAuthzPermissions implements AuthzPermissions, Updateable< } private void applyPrivilegeUpdates(PermissionsUpdate update) { - TPrivilegeEntity addPrivEntity, delPrivEntity; + TPrivilegePrincipal addPrivEntity, delPrivEntity; for (TPrivilegeChanges pUpdate : update.getPrivilegeUpdates()) { if (pUpdate.getAuthzObj().equals(PermissionsUpdate.RENAME_PRIVS)) { addPrivEntity = pUpdate.getAddPrivileges().keySet().iterator().next(); delPrivEntity = pUpdate.getDelPrivileges().keySet().iterator().next(); - if(addPrivEntity.getType() != TPrivilegeEntityType.AUTHZ_OBJ || - delPrivEntity.getType() != TPrivilegeEntityType.AUTHZ_OBJ) { + if(addPrivEntity.getType() != TPrivilegePrincipalType.AUTHZ_OBJ || + delPrivEntity.getType() != TPrivilegePrincipalType.AUTHZ_OBJ) { LOG.warn("Invalid Permission Update, Received Rename update with wrong data, (Add) Type: {}, Value:{} " + "(Del) Type: {}, Value:{}", addPrivEntity.getType(), addPrivEntity.getValue(), delPrivEntity.getType(), delPrivEntity.getValue()); @@ -144,11 +144,11 @@ public class UpdateableAuthzPermissions implements AuthzPermissions, Updateable< // Db, but no explicit grants on Table.. then the authzObject associated // with the table will never exist. if (privilegeInfo != null) { - Map<TPrivilegeEntity, FsAction> allPermissions = privilegeInfo.getAllPermissions(); + Map<TPrivilegePrincipal, FsAction> allPermissions = privilegeInfo.getAllPermissions(); perms.delPrivilegeInfo(oldAuthzObj); perms.removeParentChildMappings(oldAuthzObj); PrivilegeInfo newPrivilegeInfo = new PrivilegeInfo(newAuthzObj); - for (Map.Entry<TPrivilegeEntity, FsAction> e : allPermissions.entrySet()) { + for (Map.Entry<TPrivilegePrincipal, FsAction> e : allPermissions.entrySet()) { newPrivilegeInfo.setPermission(e.getKey(), e.getValue()); } perms.addPrivilegeInfo(newPrivilegeInfo); @@ -164,7 +164,7 @@ public class UpdateableAuthzPermissions implements AuthzPermissions, Updateable< } } PrivilegeInfo pInfo = perms.getPrivilegeInfo(pUpdate.getAuthzObj()); - for (Map.Entry<TPrivilegeEntity, String> aMap : pUpdate.getAddPrivileges().entrySet()) { + for (Map.Entry<TPrivilegePrincipal, String> aMap : pUpdate.getAddPrivileges().entrySet()) { if (pInfo == null) { pInfo = new PrivilegeInfo(pUpdate.getAuthzObj()); } @@ -179,7 +179,7 @@ public class UpdateableAuthzPermissions implements AuthzPermissions, Updateable< if (pInfo != null) { perms.addPrivilegeInfo(pInfo); perms.addParentChildMappings(pUpdate.getAuthzObj()); - for (Map.Entry<TPrivilegeEntity, String> dMap : pUpdate.getDelPrivileges().entrySet()) { + for (Map.Entry<TPrivilegePrincipal, String> dMap : pUpdate.getDelPrivileges().entrySet()) { if (dMap.getKey().getValue().equals(PermissionsUpdate.ALL_ROLES)) { // Remove all privileges perms.delPrivilegeInfo(pUpdate.getAuthzObj()); @@ -243,8 +243,8 @@ public class UpdateableAuthzPermissions implements AuthzPermissions, Updateable< PermissionsUpdate retVal = new PermissionsUpdate(currSeqNum, true); for (PrivilegeInfo pInfo : perms.getAllPrivileges()) { TPrivilegeChanges pUpdate = retVal.addPrivilegeUpdate(pInfo.getAuthzObj()); - for (Map.Entry<TPrivilegeEntity, FsAction> ent : pInfo.getAllPermissions().entrySet()) { - pUpdate.putToAddPrivileges(new TPrivilegeEntity(ent.getKey()), + for (Map.Entry<TPrivilegePrincipal, FsAction> ent : pInfo.getAllPermissions().entrySet()) { + pUpdate.putToAddPrivileges(new TPrivilegePrincipal(ent.getKey()), ent.getValue().SYMBOL); } } http://git-wip-us.apache.org/repos/asf/sentry/blob/fb7bb7bc/sentry-hdfs/sentry-hdfs-namenode-plugin/src/test/java/org/apache/sentry/hdfs/TestSentryPermissions.java ---------------------------------------------------------------------- diff --git a/sentry-hdfs/sentry-hdfs-namenode-plugin/src/test/java/org/apache/sentry/hdfs/TestSentryPermissions.java b/sentry-hdfs/sentry-hdfs-namenode-plugin/src/test/java/org/apache/sentry/hdfs/TestSentryPermissions.java index f0ca787..a56892c 100644 --- a/sentry-hdfs/sentry-hdfs-namenode-plugin/src/test/java/org/apache/sentry/hdfs/TestSentryPermissions.java +++ b/sentry-hdfs/sentry-hdfs-namenode-plugin/src/test/java/org/apache/sentry/hdfs/TestSentryPermissions.java @@ -23,8 +23,8 @@ import java.util.List; import org.apache.hadoop.fs.permission.AclEntryType; import org.apache.hadoop.fs.permission.FsAction; -import org.apache.sentry.hdfs.service.thrift.TPrivilegeEntity; -import org.apache.sentry.hdfs.service.thrift.TPrivilegeEntityType; +import org.apache.sentry.hdfs.service.thrift.TPrivilegePrincipal; +import org.apache.sentry.hdfs.service.thrift.TPrivilegePrincipalType; import org.apache.hadoop.fs.permission.AclEntry; import org.junit.Assert; import org.junit.Test; @@ -56,7 +56,7 @@ public class TestSentryPermissions { SentryPermissions.RoleInfo roleInfo = new SentryPermissions.RoleInfo("role1"); roleInfo.addGroup("group1"); roleInfo.addGroup("group2"); - TPrivilegeEntity roleEntity = new TPrivilegeEntity(TPrivilegeEntityType.ROLE, "role1"); + TPrivilegePrincipal roleEntity = new TPrivilegePrincipal(TPrivilegePrincipalType.ROLE, "role1"); perms.addRoleInfo(roleInfo); @@ -77,7 +77,7 @@ public class TestSentryPermissions { public void testSentryUserPermissions() { String authorizable = "db1.tb1"; FsAction fsAction = FsAction.ALL; - TPrivilegeEntity userEntity = new TPrivilegeEntity(TPrivilegeEntityType.USER, "user1"); + TPrivilegePrincipal userEntity = new TPrivilegePrincipal(TPrivilegePrincipalType.USER, "user1"); SentryPermissions perms = new SentryPermissions(); SentryPermissions.PrivilegeInfo pInfo = new SentryPermissions.PrivilegeInfo(authorizable); @@ -98,7 +98,7 @@ public class TestSentryPermissions { String authorizable = null; // Add read permission for database authorizable = "db1"; - TPrivilegeEntity userEntity = new TPrivilegeEntity(TPrivilegeEntityType.USER, "user1"); + TPrivilegePrincipal userEntity = new TPrivilegePrincipal(TPrivilegePrincipalType.USER, "user1"); SentryPermissions perms = new SentryPermissions(); SentryPermissions.PrivilegeInfo pInfo = new SentryPermissions.PrivilegeInfo(authorizable); @@ -127,8 +127,8 @@ public class TestSentryPermissions { SentryPermissions.RoleInfo roleInfo = new SentryPermissions.RoleInfo("role1"); roleInfo.addGroup("group1"); roleInfo.addGroup("group2"); - TPrivilegeEntity roleEntity = new TPrivilegeEntity(TPrivilegeEntityType.ROLE, "role1"); - TPrivilegeEntity userEntity = new TPrivilegeEntity(TPrivilegeEntityType.USER, "user1"); + TPrivilegePrincipal roleEntity = new TPrivilegePrincipal(TPrivilegePrincipalType.ROLE, "role1"); + TPrivilegePrincipal userEntity = new TPrivilegePrincipal(TPrivilegePrincipalType.USER, "user1"); perms.addRoleInfo(roleInfo); http://git-wip-us.apache.org/repos/asf/sentry/blob/fb7bb7bc/sentry-hdfs/sentry-hdfs-service/src/main/java/org/apache/sentry/hdfs/DBUpdateForwarder.java ---------------------------------------------------------------------- diff --git a/sentry-hdfs/sentry-hdfs-service/src/main/java/org/apache/sentry/hdfs/DBUpdateForwarder.java b/sentry-hdfs/sentry-hdfs-service/src/main/java/org/apache/sentry/hdfs/DBUpdateForwarder.java index d47b9f7..08b16a4 100644 --- a/sentry-hdfs/sentry-hdfs-service/src/main/java/org/apache/sentry/hdfs/DBUpdateForwarder.java +++ b/sentry-hdfs/sentry-hdfs-service/src/main/java/org/apache/sentry/hdfs/DBUpdateForwarder.java @@ -27,7 +27,7 @@ import javax.annotation.concurrent.ThreadSafe; import org.apache.sentry.api.common.SentryServiceUtil; import org.apache.sentry.core.model.db.AccessConstants; -import org.apache.sentry.hdfs.service.thrift.TPrivilegeEntity; +import org.apache.sentry.hdfs.service.thrift.TPrivilegePrincipal; import org.apache.sentry.service.thrift.SentryServiceState; import org.apache.sentry.service.thrift.SentryStateBank; import org.slf4j.Logger; @@ -163,11 +163,11 @@ class DBUpdateForwarder<K extends Updateable.Update> { * Translate Owner Privilege * @param privMap Collection of privileges on an privilege entity. */ - public static void translateOwnerPrivileges(Map<TPrivilegeEntity,String> privMap) { + public static void translateOwnerPrivileges(Map<TPrivilegePrincipal,String> privMap) { if(privMap == null) { return; } - for (Map.Entry<TPrivilegeEntity, String> priv : privMap.entrySet()) { + for (Map.Entry<TPrivilegePrincipal, String> priv : privMap.entrySet()) { if (priv.getValue().equalsIgnoreCase(AccessConstants.OWNER)) { //Translate owner privilege priv.setValue(AccessConstants.ALL); http://git-wip-us.apache.org/repos/asf/sentry/blob/fb7bb7bc/sentry-hdfs/sentry-hdfs-service/src/main/java/org/apache/sentry/hdfs/PermImageRetriever.java ---------------------------------------------------------------------- diff --git a/sentry-hdfs/sentry-hdfs-service/src/main/java/org/apache/sentry/hdfs/PermImageRetriever.java b/sentry-hdfs/sentry-hdfs-service/src/main/java/org/apache/sentry/hdfs/PermImageRetriever.java index 2a67504..f3a2d50 100644 --- a/sentry-hdfs/sentry-hdfs-service/src/main/java/org/apache/sentry/hdfs/PermImageRetriever.java +++ b/sentry-hdfs/sentry-hdfs-service/src/main/java/org/apache/sentry/hdfs/PermImageRetriever.java @@ -18,7 +18,7 @@ package org.apache.sentry.hdfs; import sentry.com.codahale.metrics.Timer.Context; -import org.apache.sentry.hdfs.service.thrift.TPrivilegeEntity; +import org.apache.sentry.hdfs.service.thrift.TPrivilegePrincipal; import org.apache.sentry.hdfs.service.thrift.TPermissionsUpdate; import org.apache.sentry.hdfs.service.thrift.TPrivilegeChanges; import org.apache.sentry.hdfs.service.thrift.TRoleChanges; @@ -57,7 +57,7 @@ public class PermImageRetriever implements ImageRetriever<PermissionsUpdate> { // with a corresponding delta change sequence number. PermissionsImage permImage = sentryStore.retrieveFullPermssionsImage(); long curSeqNum = permImage.getCurSeqNum(); - Map<String, Map<TPrivilegeEntity, String>> privilegeImage = + Map<String, Map<TPrivilegePrincipal, String>> privilegeImage = permImage.getPrivilegeImage(); Map<String, List<String>> roleImage = permImage.getRoleImage(); @@ -71,12 +71,12 @@ public class PermImageRetriever implements ImageRetriever<PermissionsUpdate> { new HashMap<String, TPrivilegeChanges>(), new HashMap<String, TRoleChanges>()); - for (Map.Entry<String, Map<TPrivilegeEntity, String>> privEnt : privilegeImage.entrySet()) { + for (Map.Entry<String, Map<TPrivilegePrincipal, String>> privEnt : privilegeImage.entrySet()) { String authzObj = privEnt.getKey(); - Map<TPrivilegeEntity,String> privMap = privEnt.getValue(); + Map<TPrivilegePrincipal,String> privMap = privEnt.getValue(); DBUpdateForwarder.translateOwnerPrivileges(privMap); tPermUpdate.putToPrivilegeChanges(authzObj, new TPrivilegeChanges( - authzObj, privMap, new HashMap<TPrivilegeEntity, String>())); + authzObj, privMap, new HashMap<TPrivilegePrincipal, String>())); } for (Map.Entry<String, List<String>> privEnt : roleImage.entrySet()) {