You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sentry.apache.org by sd...@apache.org on 2016/04/14 03:57:57 UTC

[1/6] sentry git commit: SENTRY-711: Implement grant user to role (Colin Ma, reviewed by Dapeng Sun)

Repository: sentry
Updated Branches:
  refs/heads/master 04881fa7a -> 68949951e


http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java
index 02f98e2..ddd42c5 100644
--- a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java
+++ b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java
@@ -22,6 +22,7 @@ import java.io.File;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
 
 import org.apache.commons.io.FileUtils;
@@ -40,17 +41,18 @@ import org.apache.sentry.provider.db.service.thrift.TSentryAuthorizable;
 import org.apache.sentry.provider.db.service.thrift.TSentryGrantOption;
 import org.apache.sentry.provider.db.service.thrift.TSentryGroup;
 import org.apache.sentry.provider.db.service.thrift.TSentryPrivilege;
+import org.apache.sentry.provider.db.service.thrift.TSentryRole;
 import org.apache.sentry.provider.file.PolicyFile;
 import org.apache.sentry.service.thrift.ServiceConstants.ServerConfig;
 import org.junit.After;
 import org.junit.AfterClass;
-import static org.junit.Assert.assertArrayEquals;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Ignore;
 import org.junit.Test;
 
 import com.google.common.collect.Iterables;
+import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 import com.google.common.io.Files;
 
@@ -135,12 +137,19 @@ public class TestSentryStore extends org.junit.Assert {
     privilege.setAction(AccessConstants.ALL);
     privilege.setCreateTime(System.currentTimeMillis());
 
+    Set<String> users = Sets.newHashSet("user1");
+
     long seqId = sentryStore.createSentryRole(roleName).getSequenceId();
     assertEquals(seqId + 1, sentryStore.alterSentryRoleAddGroups(grantor, roleName, groups).getSequenceId());
     assertEquals(seqId + 2, sentryStore.alterSentryRoleDeleteGroups(roleName, groups).getSequenceId());
-    assertEquals(seqId + 3, sentryStore.alterSentryRoleGrantPrivilege(grantor, roleName, privilege).getSequenceId());
-    assertEquals(seqId + 4, sentryStore.alterSentryRoleRevokePrivilege(grantor, roleName, privilege).getSequenceId());
+    assertEquals(seqId + 3, sentryStore.alterSentryRoleAddUsers(roleName, users).getSequenceId());
+    assertEquals(seqId + 4, sentryStore.alterSentryRoleDeleteUsers(roleName, users).getSequenceId());
+    assertEquals(seqId + 5, sentryStore.alterSentryRoleGrantPrivilege(grantor, roleName, privilege)
+        .getSequenceId());
+    assertEquals(seqId + 6, sentryStore
+        .alterSentryRoleRevokePrivilege(grantor, roleName, privilege).getSequenceId());
   }
+
   @Test
   public void testURI() throws Exception {
     String roleName = "test-dup-role";
@@ -163,14 +172,30 @@ public class TestSentryStore extends org.junit.Assert {
     Set<TSentryGroup> tSentryGroups = new HashSet<TSentryGroup>();
     tSentryGroups.add(new TSentryGroup("group1"));
     sentryStore.alterSentryRoleAddGroups(grantor, roleName, tSentryGroups);
+    sentryStore.alterSentryRoleAddUsers(roleName, Sets.newHashSet("user1"));
 
     TSentryActiveRoleSet thriftRoleSet = new TSentryActiveRoleSet(true, new HashSet<String>(Arrays.asList(roleName)));
 
-    Set<String> privs =
-        sentryStore.listSentryPrivilegesForProvider(new HashSet<String>(Arrays.asList("group1")), thriftRoleSet, tSentryAuthorizable);
+    // list privilege for group only
+    Set<String> privs = sentryStore.listSentryPrivilegesForProvider(
+        new HashSet<String>(Arrays.asList("group1")), Sets.newHashSet(""), thriftRoleSet,
+        tSentryAuthorizable);
 
     assertTrue(privs.size()==1);
     assertTrue(privs.contains("server=server1->uri=" + uri + "->action=all"));
+
+    // list privilege for user only
+    privs = sentryStore.listSentryPrivilegesForProvider(new HashSet<String>(Arrays.asList("")),
+        Sets.newHashSet("user1"), thriftRoleSet, tSentryAuthorizable);
+    assertTrue(privs.size() == 1);
+    assertTrue(privs.contains("server=server1->uri=" + uri + "->action=all"));
+
+    // list privilege for both user and group
+    privs = sentryStore.listSentryPrivilegesForProvider(
+        new HashSet<String>(Arrays.asList("group1")), Sets.newHashSet("user1"), thriftRoleSet,
+        tSentryAuthorizable);
+    assertTrue(privs.size() == 1);
+    assertTrue(privs.contains("server=server1->uri=" + uri + "->action=all"));
   }
 
   @Test
@@ -194,6 +219,7 @@ public class TestSentryStore extends org.junit.Assert {
     sentryPrivilege.setDbName("db1");
     assertEquals(seqId + 1, sentryStore.alterSentryRoleGrantPrivilege(grantor, roleName, sentryPrivilege).getSequenceId());
   }
+
   @Test
   public void testCreateDropRole() throws Exception {
     String roleName = "test-drop-role";
@@ -201,13 +227,25 @@ public class TestSentryStore extends org.junit.Assert {
     assertEquals(seqId + 1, sentryStore.dropSentryRole(roleName).getSequenceId());
   }
 
-  @Test(expected = SentryNoSuchObjectException.class)
+  @Test
   public void testAddDeleteGroupsNonExistantRole()
       throws Exception {
     String roleName = "non-existant-role";
     String grantor = "g1";
     Set<TSentryGroup> groups = Sets.newHashSet();
-    sentryStore.alterSentryRoleAddGroups(grantor, roleName, groups);
+    Set<String> users = Sets.newHashSet(grantor);
+    try {
+      sentryStore.alterSentryRoleAddGroups(grantor, roleName, groups);
+      fail("Expected SentryNoSuchObjectException exception");
+    } catch (SentryNoSuchObjectException e) {
+      // excepted exception
+    }
+    try {
+      sentryStore.alterSentryRoleAddUsers(roleName, users);
+      fail("Expected SentryNoSuchObjectException exception");
+    } catch (SentryNoSuchObjectException e) {
+      // excepted exception
+    }
   }
 
   @Test
@@ -231,6 +269,80 @@ public class TestSentryStore extends org.junit.Assert {
   }
 
   @Test
+  public void testAddDeleteUsers() throws Exception {
+    String roleName = "test-users";
+    long seqId = sentryStore.createSentryRole(roleName).getSequenceId();
+    Set<String> users = Sets.newHashSet("test-user-u1", "test-user-u2");
+    assertEquals(seqId + 1, sentryStore.alterSentryRoleAddUsers(roleName, users).getSequenceId());
+    MSentryRole role = sentryStore.getMSentryRoleByName(roleName);
+    assertEquals(2, role.getUsers().size());
+    assertEquals(seqId + 2, sentryStore.alterSentryRoleDeleteUsers(roleName, users).getSequenceId());
+    role = sentryStore.getMSentryRoleByName(roleName);
+    assertEquals(0, role.getUsers().size());
+  }
+
+  @Test
+  public void testGetTSentryRolesForUser() throws Exception {
+    // Test the method GetTSentryRolesForUser according to the following test data:
+    // user1->group1
+    // user2->group1
+    // user3->group1, group2
+    // user4->group2, group3
+    // group1->r1
+    // group2->r2
+    // group3->r2
+    // user2->r3
+    // user4->r3
+    String roleName1 = "r1";
+    String roleName2 = "r2";
+    String roleName3 = "r3";
+    String user1 = "u1";
+    String user2 = "u2";
+    String user3 = "u3";
+    String user4 = "u4";
+    String group1 = "group1";
+    String group2 = "group2";
+    String group3 = "group3";
+    Map<String, Set<String>> userToGroups = Maps.newHashMap();
+    userToGroups.put(user1, Sets.newHashSet(group1));
+    userToGroups.put(user2, Sets.newHashSet(group1));
+    userToGroups.put(user3, Sets.newHashSet(group1, group2));
+    userToGroups.put(user4, Sets.newHashSet(group2, group3));
+
+    sentryStore.createSentryRole(roleName1);
+    sentryStore.createSentryRole(roleName2);
+    sentryStore.createSentryRole(roleName3);
+    sentryStore.alterSentryRoleAddUsers(roleName1, Sets.newHashSet(user1));
+    sentryStore.alterSentryRoleAddUsers(roleName2, Sets.newHashSet(user2));
+    sentryStore.alterSentryRoleAddUsers(roleName2, Sets.newHashSet(user3));
+    sentryStore.alterSentryRoleAddUsers(roleName3, Sets.newHashSet(user2, user4));
+
+    Set<TSentryRole> roles = sentryStore.getTSentryRolesByUserNames(Sets.newHashSet(user1));
+    assertEquals(1, roles.size());
+    for (TSentryRole role : roles) {
+      assertTrue(roleName1.equals(role.getRoleName()));
+    }
+
+    roles = sentryStore.getTSentryRolesByUserNames(Sets.newHashSet(user2));
+    assertEquals(2, roles.size());
+    for (TSentryRole role : roles) {
+      assertTrue(roleName2.equals(role.getRoleName()) || roleName3.equals(role.getRoleName()));
+    }
+
+    roles = sentryStore.getTSentryRolesByUserNames(Sets.newHashSet(user3));
+    assertEquals(1, roles.size());
+    for (TSentryRole role : roles) {
+      assertTrue(roleName2.equals(role.getRoleName()));
+    }
+
+    roles = sentryStore.getTSentryRolesByUserNames(Sets.newHashSet(user4));
+    assertEquals(1, roles.size());
+    for (TSentryRole role : roles) {
+      assertTrue(roleName3.equals(role.getRoleName()));
+    }
+  }
+
+  @Test
   public void testGrantRevokePrivilege() throws Exception {
     String roleName = "test-privilege";
     String grantor = "g1";
@@ -678,6 +790,7 @@ public class TestSentryStore extends org.junit.Assert {
     String table = "tbl1";
     TSentryGrantOption grantOption = TSentryGrantOption.TRUE;
     long seqId = sentryStore.createSentryRole(roleName).getSequenceId();
+
     TSentryPrivilege privilege = new TSentryPrivilege();
     privilege.setPrivilegeScope("TABLE");
     privilege.setServerName(server);
@@ -727,6 +840,157 @@ public class TestSentryStore extends org.junit.Assert {
   }
 
   @Test
+  public void testGrantCheckWithGroupAndUser() throws Exception {
+    // 1. set local group mapping and group-role, user-role mapping
+    // user0_0->group0
+    // user0_1->group0
+    // user1_0->group1
+    // user1_1->group1
+    // group0->roleG0
+    // group1->roleG1
+    // user0_0->roleU00
+    // user0_1->roleU01
+    // user1_0->roleU10
+    // user1_1->roleU11
+    String grantor = "g1";
+    String[][] users = { { "user0_0", "user0_1" }, { "user1_0", "user1_1" } };
+    String[] groups = { "group0", "group1" };
+    String[] rolesForGroup = { "roleG0", "roleG1" };
+    String[] rolesForUser = { "roleU0", "roleU1", "roleU2", "roleU3" };
+    for (int i = 0; i < groups.length; i++) {
+      for (int j = 0; j < users[i].length; j++) {
+        addGroupsToUser(users[i][j], groups[i]);
+        sentryStore.createSentryRole(rolesForUser[i * 2 + j]);
+        sentryStore.alterSentryRoleAddUsers(rolesForUser[i * 2 + j], Sets.newHashSet(users[i][j]));
+      }
+      sentryStore.createSentryRole(rolesForGroup[i]);
+      Set<TSentryGroup> tGroups = Sets.newHashSet();
+      TSentryGroup tGroup = new TSentryGroup(groups[i]);
+      tGroups.add(tGroup);
+      sentryStore.alterSentryRoleAddGroups(grantor, rolesForGroup[i], tGroups);
+    }
+    writePolicyFile();
+
+    // 2. g1 grant all on database db1 to roleG0, roleU0 without grant option
+    String server = "server1";
+    String db = "db1";
+    grantor = "g1";
+    TSentryPrivilege privilege1 = new TSentryPrivilege();
+    privilege1.setPrivilegeScope("DATABASE");
+    privilege1.setServerName(server);
+    privilege1.setDbName(db);
+    privilege1.setAction(AccessConstants.ALL);
+    privilege1.setCreateTime(System.currentTimeMillis());
+    privilege1.setGrantOption(TSentryGrantOption.FALSE);
+    // user0_0 has the privilege without grant option
+    sentryStore.alterSentryRoleGrantPrivilege(grantor, "roleG0", privilege1);
+    sentryStore.alterSentryRoleGrantPrivilege(grantor, "roleU0", privilege1);
+    try {
+      sentryStore.alterSentryRoleGrantPrivilege("user0_0", "roleG1", privilege1);
+      fail("Expected SentryGrantDeniedException exception");
+    } catch (SentryGrantDeniedException e) {
+      // excepted exception
+    }
+    try {
+      sentryStore.alterSentryRoleRevokePrivilege("user0_0", "roleG1", privilege1);
+      fail("Expected SentryGrantDeniedException exception");
+    } catch (SentryGrantDeniedException e) {
+      // excepted exception
+    }
+
+    // 3. g1 grant all on database db1 to roleG0 with grant option
+    TSentryPrivilege privilege2 = new TSentryPrivilege();
+    privilege2.setPrivilegeScope("DATABASE");
+    privilege2.setServerName(server);
+    privilege2.setDbName(db);
+    privilege2.setAction(AccessConstants.ALL);
+    privilege2.setCreateTime(System.currentTimeMillis());
+    privilege2.setGrantOption(TSentryGrantOption.TRUE);
+    // user0_0, user0_1 can grant the same privilege to other roles
+    sentryStore.alterSentryRoleGrantPrivilege(grantor, "roleG0", privilege2);
+    sentryStore.alterSentryRoleGrantPrivilege("user0_0", "roleG1", privilege2);
+    validatePrivilegeByRoleName("roleG1", privilege2);
+    sentryStore.alterSentryRoleRevokePrivilege("user0_0", "roleG1", privilege2);
+    validateEmptyPrivilegeByRoleName("roleG1");
+    sentryStore.alterSentryRoleGrantPrivilege("user0_1", "roleG1", privilege2);
+    validatePrivilegeByRoleName("roleG1", privilege2);
+    sentryStore.alterSentryRoleRevokePrivilege("user0_1", "roleG1", privilege2);
+    validateEmptyPrivilegeByRoleName("roleG1");
+    // clear privilege for roleG0
+    sentryStore.alterSentryRoleRevokePrivilege(grantor, "roleG0", privilege2);
+
+    // 4. g1 grant all on database db1 to roleU0 with grant option
+    sentryStore.alterSentryRoleGrantPrivilege(grantor, "roleU0", privilege2);
+    sentryStore.alterSentryRoleGrantPrivilege("user0_0", "roleG1", privilege2);
+    validatePrivilegeByRoleName("roleG1", privilege2);
+    sentryStore.alterSentryRoleRevokePrivilege("user0_0", "roleG1", privilege2);
+    validateEmptyPrivilegeByRoleName("roleG1");
+    try {
+      sentryStore.alterSentryRoleGrantPrivilege("user0_1", "roleG1", privilege2);
+      fail("Expected SentryGrantDeniedException exception");
+    } catch (SentryGrantDeniedException e) {
+      // excepted exception
+    }
+    try {
+      sentryStore.alterSentryRoleRevokePrivilege("user0_1", "roleG1", privilege2);
+      fail("Expected SentryGrantDeniedException exception");
+    } catch (SentryGrantDeniedException e) {
+      // excepted exception
+    }
+    // clear privilege for roleG0
+    sentryStore.alterSentryRoleRevokePrivilege(grantor, "roleU0", privilege2);
+
+    // 5. g1 grant all on database db1 to roleU2, roleG0 with grant option
+    sentryStore.alterSentryRoleGrantPrivilege(grantor, "roleU2", privilege2);
+    sentryStore.alterSentryRoleGrantPrivilege(grantor, "roleG0", privilege2);
+    sentryStore.alterSentryRoleGrantPrivilege("user0_0", "roleG1", privilege2);
+    validatePrivilegeByRoleName("roleG1", privilege2);
+    sentryStore.alterSentryRoleRevokePrivilege("user0_0", "roleG1", privilege2);
+    validateEmptyPrivilegeByRoleName("roleG1");
+    sentryStore.alterSentryRoleGrantPrivilege("user0_1", "roleG1", privilege2);
+    validatePrivilegeByRoleName("roleG1", privilege2);
+    sentryStore.alterSentryRoleRevokePrivilege("user0_1", "roleG1", privilege2);
+    validateEmptyPrivilegeByRoleName("roleG1");
+
+    sentryStore.alterSentryRoleGrantPrivilege("user1_0", "roleG1", privilege2);
+    validatePrivilegeByRoleName("roleG1", privilege2);
+    sentryStore.alterSentryRoleRevokePrivilege("user1_0", "roleG1", privilege2);
+    validateEmptyPrivilegeByRoleName("roleG1");
+    try {
+      sentryStore.alterSentryRoleGrantPrivilege("user1_1", "roleG1", privilege2);
+      fail("Expected SentryGrantDeniedException exception");
+    } catch (SentryGrantDeniedException e) {
+      // excepted exception
+    }
+    try {
+      sentryStore.alterSentryRoleRevokePrivilege("user1_1", "roleG1", privilege2);
+      fail("Expected SentryGrantDeniedException exception");
+    } catch (SentryGrantDeniedException e) {
+      // excepted exception
+    }
+    // clear privilege for roleG0
+    sentryStore.alterSentryRoleRevokePrivilege(grantor, "roleG0", privilege2);
+    sentryStore.alterSentryRoleRevokePrivilege(grantor, "roleU2", privilege2);
+  }
+
+  private void validatePrivilegeByRoleName(String roleName, TSentryPrivilege exceptedTPrivelege)
+      throws Exception {
+    MSentryRole role = sentryStore.getMSentryRoleByName(roleName);
+    Set<MSentryPrivilege> privileges = role.getPrivileges();
+    assertEquals(privileges.toString(), 1, privileges.size());
+    MSentryPrivilege mPrivilege = Iterables.get(privileges, 0);
+    assertEquals(exceptedTPrivelege.getServerName(), mPrivilege.getServerName());
+    assertEquals(exceptedTPrivelege.getDbName(), mPrivilege.getDbName());
+    assertEquals(AccessConstants.ALL, mPrivilege.getAction());
+  }
+
+  private void validateEmptyPrivilegeByRoleName(String roleName) throws Exception {
+    MSentryRole role = sentryStore.getMSentryRoleByName(roleName);
+    Set<MSentryPrivilege> privileges = role.getPrivileges();
+    assertEquals(privileges.toString(), 0, privileges.size());
+  }
+
+  @Test
   public void testGrantCheckWithGrantOption() throws Exception {
     // 1. set local group mapping
     // user0->group0->role0
@@ -736,8 +1000,8 @@ public class TestSentryStore extends org.junit.Assert {
     // user4->group4->role4
     String grantor = "g1";
     String[] users = {"user0","user1","user2","user3","user4"};
+    String[] groups = { "group0", "group1", "group2", "group3", "group4" };
     String[] roles = {"role0","role1","role2","role3","role4"};
-    String[] groups = {"group0","group1","group2","group3","group4"};
     for (int i = 0; i < users.length; i++) {
       addGroupsToUser(users[i], groups[i]);
       sentryStore.createSentryRole(roles[i]);
@@ -802,14 +1066,12 @@ public class TestSentryStore extends org.junit.Assert {
     privilege4.setAction(AccessConstants.INSERT);
     privilege4.setCreateTime(System.currentTimeMillis());
     privilege4.setGrantOption(TSentryGrantOption.FALSE);
-    boolean isGrantOptionException = false;
     try {
       sentryStore.alterSentryRoleGrantPrivilege(grantor, roleName, privilege4);
+      fail("Expected SentryGrantDeniedException exception");
     } catch (SentryGrantDeniedException e) {
-      isGrantOptionException = true;
-      System.err.println(e.getMessage());
+      // excepted exception
     }
-    assertTrue(isGrantOptionException);
 
     // 6. user2 has role2, no grant option,
     // grant insert to role4, will throw no grant exception
@@ -823,14 +1085,12 @@ public class TestSentryStore extends org.junit.Assert {
     privilege5.setAction(AccessConstants.INSERT);
     privilege5.setCreateTime(System.currentTimeMillis());
     privilege5.setGrantOption(TSentryGrantOption.FALSE);
-    isGrantOptionException = false;
     try {
       sentryStore.alterSentryRoleGrantPrivilege(grantor, roleName, privilege5);
+      fail("Expected SentryGrantDeniedException exception");
     } catch (SentryGrantDeniedException e) {
-      isGrantOptionException = true;
-      System.err.println(e.getMessage());
+      // excepted exception
     }
-    assertTrue(isGrantOptionException);
   }
 
   @Test
@@ -850,6 +1110,7 @@ public class TestSentryStore extends org.junit.Assert {
       TSentryGroup tGroup = new TSentryGroup(groups[i]);
       tGroups.add(tGroup);
       sentryStore.alterSentryRoleAddGroups(grantor, roles[i], tGroups);
+      sentryStore.alterSentryRoleAddUsers(roles[i], Sets.newHashSet(users[i]));
     }
     writePolicyFile();
 
@@ -901,14 +1162,12 @@ public class TestSentryStore extends org.junit.Assert {
     // revoke from role2 will throw no grant exception
     roleName = roles[2];
     grantor = users[1];
-    boolean isGrantOptionException = false;
     try {
       sentryStore.alterSentryRoleRevokePrivilege(grantor, roleName, privilege3);
+      fail("Expected SentryGrantDeniedException exception");
     } catch (SentryGrantDeniedException e) {
-      isGrantOptionException = true;
-      System.err.println(e.getMessage());
+      // excepted exception
     }
-    assertTrue(isGrantOptionException);
 
     // 6. user0 has role0, only have select,
     // revoke all from role1 will throw no grant exception
@@ -916,11 +1175,10 @@ public class TestSentryStore extends org.junit.Assert {
     grantor = users[0];
     try {
       sentryStore.alterSentryRoleRevokePrivilege(grantor, roleName, privilege2);
+      fail("Expected SentryGrantDeniedException exception");
     } catch (SentryGrantDeniedException e) {
-      isGrantOptionException = true;
-      System.err.println(e.getMessage());
+      // excepted exception
     }
-    assertTrue(isGrantOptionException);
 
     // 7. user0 has role0, has select and grant option,
     // revoke select from role2
@@ -1038,14 +1296,12 @@ public class TestSentryStore extends org.junit.Assert {
     // 4. user1 revoke table level privilege from user0, will throw grant denied exception
     roleName = roles[0];
     grantor = users[1];
-    boolean isGrantOptionException = false;
     try {
       sentryStore.alterSentryRoleRevokePrivilege(grantor, roleName, privilege1);
+      fail("Expected SentryGrantDeniedException exception");
     } catch (SentryGrantDeniedException e) {
-      isGrantOptionException = true;
-      System.err.println(e.getMessage());
+      // excepted exception
     }
-    assertTrue(isGrantOptionException);
 
     // 5. user0 revoke column level privilege from user1
     roleName = roles[1];
@@ -1089,6 +1345,9 @@ public class TestSentryStore extends org.junit.Assert {
   public void testListSentryPrivilegesForProvider() throws Exception {
     String roleName1 = "list-privs-r1", roleName2 = "list-privs-r2";
     String groupName1 = "list-privs-g1", groupName2 = "list-privs-g2";
+    String userName1 = "list-privs-u1", userName2 = "list-privs-u2";
+    String userWithoutRole = "user-no-privs";
+    Set<String> noRoleUsers = Sets.newHashSet(userWithoutRole);
     String grantor = "g1";
     long seqId = sentryStore.createSentryRole(roleName1).getSequenceId();
     assertEquals(seqId + 1, sentryStore.createSentryRole(roleName2).getSequenceId());
@@ -1110,82 +1369,124 @@ public class TestSentryStore extends org.junit.Assert {
     assertEquals(seqId + 4, sentryStore.alterSentryRoleGrantPrivilege(grantor, roleName2, privilege2)
         .getSequenceId());
     Set<TSentryGroup> groups = Sets.newHashSet();
+    Set<String> users = Sets.newHashSet();
     TSentryGroup group = new TSentryGroup();
     group.setGroupName(groupName1);
     groups.add(group);
+    users.add(userName1);
     assertEquals(seqId + 5, sentryStore.alterSentryRoleAddGroups(grantor,
         roleName1, groups).getSequenceId());
+    assertEquals(seqId + 6, sentryStore.alterSentryRoleAddUsers(roleName1, users).getSequenceId());
     groups.clear();
+    users.clear();
     group = new TSentryGroup();
     group.setGroupName(groupName2);
     groups.add(group);
-    // group 2 has both roles 1 and 2
-    assertEquals(seqId + 6, sentryStore.alterSentryRoleAddGroups(grantor,
-        roleName1, groups).getSequenceId());
-    assertEquals(seqId + 7, sentryStore.alterSentryRoleAddGroups(grantor,
-        roleName2, groups).getSequenceId());
+    users.add(userName2);
+    // group 2 and user2 has both roles 1 and 2
+    assertEquals(seqId + 7, sentryStore.alterSentryRoleAddGroups(grantor, roleName1, groups)
+        .getSequenceId());
+    assertEquals(seqId + 8, sentryStore.alterSentryRoleAddGroups(grantor, roleName2, groups)
+        .getSequenceId());
+    assertEquals(seqId + 9, sentryStore.alterSentryRoleAddUsers(roleName1, users).getSequenceId());
+    assertEquals(seqId + 10, sentryStore.alterSentryRoleAddUsers(roleName2, users).getSequenceId());
     // group1 all roles
     assertEquals(Sets.newHashSet("server=server1->db=db1->table=tbl1->action=select"),
-        SentryStore.toTrimedLower(sentryStore.listAllSentryPrivilegesForProvider(Sets.newHashSet(groupName1),
-            new TSentryActiveRoleSet(true, new HashSet<String>()))));
-    // one active role
+        SentryStore.toTrimedLower(sentryStore.listAllSentryPrivilegesForProvider(Sets
+            .newHashSet(groupName1), noRoleUsers, new TSentryActiveRoleSet(true,
+            new HashSet<String>()))));
+    // user1 all roles
     assertEquals(Sets.newHashSet("server=server1->db=db1->table=tbl1->action=select"),
-        SentryStore.toTrimedLower(sentryStore.listAllSentryPrivilegesForProvider(Sets.newHashSet(groupName1),
+        SentryStore.toTrimedLower(sentryStore.listAllSentryPrivilegesForProvider(Sets
+            .newHashSet(""), Sets.newHashSet(userName1), new TSentryActiveRoleSet(true,
+            new HashSet<String>()))));
+    // group1 and user1 all roles
+    assertEquals(Sets.newHashSet("server=server1->db=db1->table=tbl1->action=select"),
+        SentryStore.toTrimedLower(sentryStore.listAllSentryPrivilegesForProvider(Sets
+            .newHashSet(groupName1), Sets.newHashSet(userName1), new TSentryActiveRoleSet(true,
+            new HashSet<String>()))));
+    // one active role
+    assertEquals(
+        Sets.newHashSet("server=server1->db=db1->table=tbl1->action=select"),
+        SentryStore.toTrimedLower(sentryStore.listAllSentryPrivilegesForProvider(
+            Sets.newHashSet(groupName1), noRoleUsers,
             new TSentryActiveRoleSet(false, Sets.newHashSet(roleName1)))));
     // unknown active role
-    assertEquals(Sets.newHashSet(),
-        SentryStore.toTrimedLower(sentryStore.listAllSentryPrivilegesForProvider(Sets.newHashSet(groupName1),
+    assertEquals(
+        Sets.newHashSet(),
+        SentryStore.toTrimedLower(sentryStore.listAllSentryPrivilegesForProvider(
+            Sets.newHashSet(groupName1), noRoleUsers,
             new TSentryActiveRoleSet(false, Sets.newHashSet("not a role")))));
     // no active roles
-    assertEquals(Sets.newHashSet(),
-        SentryStore.toTrimedLower(sentryStore.listAllSentryPrivilegesForProvider(Sets.newHashSet(groupName1),
+    assertEquals(Sets.newHashSet(), SentryStore.toTrimedLower(sentryStore
+        .listAllSentryPrivilegesForProvider(Sets.newHashSet(groupName1), noRoleUsers,
             new TSentryActiveRoleSet(false, new HashSet<String>()))));
 
     // group2 all roles
-    assertEquals(Sets.newHashSet("server=server1->db=db1->table=tbl1->action=select", "server=server1"),
-        SentryStore.toTrimedLower(sentryStore.listAllSentryPrivilegesForProvider(Sets.newHashSet(groupName2),
+    assertEquals(Sets.newHashSet("server=server1->db=db1->table=tbl1->action=select",
+        "server=server1"), SentryStore.toTrimedLower(sentryStore
+        .listAllSentryPrivilegesForProvider(Sets.newHashSet(groupName2), Sets.newHashSet(""),
             new TSentryActiveRoleSet(true, new HashSet<String>()))));
+    // user2 all roles
+    assertEquals(Sets.newHashSet("server=server1->db=db1->table=tbl1->action=select",
+        "server=server1"), SentryStore.toTrimedLower(sentryStore
+        .listAllSentryPrivilegesForProvider(Sets.newHashSet(""), Sets.newHashSet(userName2),
+            new TSentryActiveRoleSet(true, new HashSet<String>()))));
+    // user2 and group2 all roles
+    assertEquals(Sets.newHashSet("server=server1->db=db1->table=tbl1->action=select",
+        "server=server1"), SentryStore.toTrimedLower(sentryStore
+        .listAllSentryPrivilegesForProvider(Sets.newHashSet(groupName2),
+            Sets.newHashSet(userName2), new TSentryActiveRoleSet(true, new HashSet<String>()))));
+
     // one active role
-    assertEquals(Sets.newHashSet("server=server1->db=db1->table=tbl1->action=select"),
-        SentryStore.toTrimedLower(sentryStore.listAllSentryPrivilegesForProvider(Sets.newHashSet(groupName2),
+    assertEquals(
+        Sets.newHashSet("server=server1->db=db1->table=tbl1->action=select"),
+        SentryStore.toTrimedLower(sentryStore.listAllSentryPrivilegesForProvider(
+            Sets.newHashSet(groupName2), noRoleUsers,
             new TSentryActiveRoleSet(false, Sets.newHashSet(roleName1)))));
-    assertEquals(Sets.newHashSet(
-        "server=server1->db=db1->table=tbl1->action=select", "server=server1"),
-        SentryStore.toTrimedLower(sentryStore.listAllSentryPrivilegesForProvider(Sets.newHashSet(groupName2),
+    assertEquals(
+        Sets.newHashSet("server=server1->db=db1->table=tbl1->action=select", "server=server1"),
+        SentryStore.toTrimedLower(sentryStore.listAllSentryPrivilegesForProvider(
+            Sets.newHashSet(groupName2), noRoleUsers,
             new TSentryActiveRoleSet(false, Sets.newHashSet(roleName2)))));
     // unknown active role
-    assertEquals(Sets.newHashSet(),
-        SentryStore.toTrimedLower(sentryStore.listAllSentryPrivilegesForProvider(Sets.newHashSet(groupName2),
+    assertEquals(
+        Sets.newHashSet(),
+        SentryStore.toTrimedLower(sentryStore.listAllSentryPrivilegesForProvider(
+            Sets.newHashSet(groupName2), noRoleUsers,
             new TSentryActiveRoleSet(false, Sets.newHashSet("not a role")))));
     // no active roles
-    assertEquals(Sets.newHashSet(),
-        SentryStore.toTrimedLower(sentryStore.listAllSentryPrivilegesForProvider(Sets.newHashSet(groupName2),
+    assertEquals(Sets.newHashSet(), SentryStore.toTrimedLower(sentryStore
+        .listAllSentryPrivilegesForProvider(Sets.newHashSet(groupName2), noRoleUsers,
             new TSentryActiveRoleSet(false, new HashSet<String>()))));
 
     // both groups, all active roles
-    assertEquals(Sets.newHashSet("server=server1->db=db1->table=tbl1->action=select", "server=server1"),
-        SentryStore.toTrimedLower(sentryStore.listAllSentryPrivilegesForProvider(Sets.
-            newHashSet(groupName1, groupName2),
+    assertEquals(Sets.newHashSet("server=server1->db=db1->table=tbl1->action=select",
+        "server=server1"), SentryStore.toTrimedLower(sentryStore
+        .listAllSentryPrivilegesForProvider(Sets.newHashSet(groupName1, groupName2), noRoleUsers,
+            new TSentryActiveRoleSet(true, new HashSet<String>()))));
+    // both users and groups, all active roles
+    assertEquals(Sets.newHashSet("server=server1->db=db1->table=tbl1->action=select",
+        "server=server1"), SentryStore.toTrimedLower(sentryStore
+        .listAllSentryPrivilegesForProvider(Sets.newHashSet(groupName1, groupName2), Sets
+            .newHashSet(userName1, userName2),
             new TSentryActiveRoleSet(true, new HashSet<String>()))));
     // one active role
     assertEquals(Sets.newHashSet("server=server1->db=db1->table=tbl1->action=select"),
-        SentryStore.toTrimedLower(sentryStore.listAllSentryPrivilegesForProvider(Sets.
-            newHashSet(groupName1, groupName2),
+        SentryStore.toTrimedLower(sentryStore.listAllSentryPrivilegesForProvider(Sets.newHashSet(
+            groupName1, groupName2), noRoleUsers,
             new TSentryActiveRoleSet(false, Sets.newHashSet(roleName1)))));
-    assertEquals(Sets.newHashSet(
-        "server=server1->db=db1->table=tbl1->action=select", "server=server1"),
-        SentryStore.toTrimedLower(sentryStore.listAllSentryPrivilegesForProvider(Sets.
-            newHashSet(groupName1, groupName2),
+    assertEquals(Sets.newHashSet("server=server1->db=db1->table=tbl1->action=select",
+        "server=server1"), SentryStore.toTrimedLower(sentryStore
+        .listAllSentryPrivilegesForProvider(Sets.newHashSet(groupName1, groupName2), noRoleUsers,
             new TSentryActiveRoleSet(false, Sets.newHashSet(roleName2)))));
     // unknown active role
-    assertEquals(Sets.newHashSet(),
-        SentryStore.toTrimedLower(sentryStore.listAllSentryPrivilegesForProvider(Sets.
-            newHashSet(groupName1, groupName2),
+    assertEquals(Sets.newHashSet(), SentryStore.toTrimedLower(sentryStore
+        .listAllSentryPrivilegesForProvider(Sets.newHashSet(groupName1, groupName2), noRoleUsers,
             new TSentryActiveRoleSet(false, Sets.newHashSet("not a role")))));
     // no active roles
-    assertEquals(Sets.newHashSet(),
-        SentryStore.toTrimedLower(sentryStore.listAllSentryPrivilegesForProvider(Sets.
-            newHashSet(groupName1, groupName2),
+    assertEquals(Sets.newHashSet(), SentryStore.toTrimedLower(sentryStore
+        .listAllSentryPrivilegesForProvider(Sets.newHashSet(groupName1, groupName2), noRoleUsers,
             new TSentryActiveRoleSet(false, new HashSet<String>()))));
   }
 
@@ -1601,6 +1902,28 @@ public class TestSentryStore extends org.junit.Assert {
   }
 
   @Test
+  public void testSentryUsersSize() throws Exception {
+    String role1 = "role1";
+    String role2 = "role2";
+
+    sentryStore.createSentryRole(role1);
+    sentryStore.createSentryRole(role2);
+
+    Set<String> users = Sets.newHashSet("user1");
+
+    sentryStore.alterSentryRoleAddUsers(role1, users);
+    assertEquals(Long.valueOf(1), sentryStore.getUserCountGauge().getValue());
+
+    sentryStore.alterSentryRoleAddUsers(role2, users);
+    assertEquals(Long.valueOf(1), sentryStore.getUserCountGauge().getValue());
+
+    users.add("user2");
+    sentryStore.alterSentryRoleAddUsers(role2, users);
+    assertEquals(Long.valueOf(2), sentryStore.getUserCountGauge().getValue());
+
+  }
+
+  @Test
   public void testRenameTableWithColumn() throws Exception {
     String roleName1 = "role1", roleName2 = "role2";
     String grantor = "g1";
@@ -1684,7 +2007,8 @@ public class TestSentryStore extends org.junit.Assert {
     TSentryActiveRoleSet thriftRoleSet = new TSentryActiveRoleSet(true, new HashSet<String>(Arrays.asList(roleName)));
 
     Set<String> privs =
-        sentryStore.listSentryPrivilegesForProvider(new HashSet<String>(Arrays.asList("group1")), thriftRoleSet, tSentryAuthorizable);
+        sentryStore.listSentryPrivilegesForProvider(new HashSet<String>(Arrays.asList("group1")),
+            Sets.newHashSet(grantor), thriftRoleSet, tSentryAuthorizable);
 
     assertTrue(privs.size()==1);
     assertTrue(privs.contains("server=server1->db=" + dbName + "->table=" + table + "->action=all"));
@@ -1724,7 +2048,8 @@ public class TestSentryStore extends org.junit.Assert {
     TSentryActiveRoleSet thriftRoleSet = new TSentryActiveRoleSet(true, new HashSet<String>(Arrays.asList(roleName)));
 
     Set<String> privs =
-        sentryStore.listSentryPrivilegesForProvider(new HashSet<String>(Arrays.asList("group1")), thriftRoleSet, tSentryAuthorizable);
+        sentryStore.listSentryPrivilegesForProvider(new HashSet<String>(Arrays.asList("group1")), Sets.newHashSet(grantor),
+                thriftRoleSet, tSentryAuthorizable);
 
     assertTrue(privs.size() == 1);
     assertTrue(privs.contains("server=server1->db=" + dbName + "->table=" + table + "->column="

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/thrift/TestSentryServerForHaWithoutKerberos.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/thrift/TestSentryServerForHaWithoutKerberos.java b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/thrift/TestSentryServerForHaWithoutKerberos.java
index ac4df77..6c78942 100644
--- a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/thrift/TestSentryServerForHaWithoutKerberos.java
+++ b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/thrift/TestSentryServerForHaWithoutKerberos.java
@@ -104,18 +104,18 @@ public class TestSentryServerForHaWithoutKerberos extends SentryServiceIntegrati
     listPrivilegesByRoleName = client.listPrivilegesByRoleName(requestorUserName, roleName2, Lists.newArrayList(new Server("server"), new Database("db3")));
     assertEquals("Privilege not assigned to role2 !!", 1, listPrivilegesByRoleName.size());
 
-    Set<String> listPrivilegesForProvider = client.listPrivilegesForProvider(Sets.newHashSet(group1, group2), ActiveRoleSet.ALL, new Server("server"), new Database("db2"));
+    Set<String> listPrivilegesForProvider = client.listPrivilegesForProvider(Sets.newHashSet(group1, group2), null, ActiveRoleSet.ALL, new Server("server"), new Database("db2"));
     assertEquals("Privilege not correctly assigned to roles !!",
         Sets.newHashSet("server=server->db=db2->table=table4->action=all", "server=server->db=db2->table=table3->action=all"),
         listPrivilegesForProvider);
 
-    listPrivilegesForProvider = client.listPrivilegesForProvider(Sets.newHashSet(group1, group2), ActiveRoleSet.ALL, new Server("server"), new Database("db3"));
+    listPrivilegesForProvider = client.listPrivilegesForProvider(Sets.newHashSet(group1, group2), null, ActiveRoleSet.ALL, new Server("server"), new Database("db3"));
     assertEquals("Privilege not correctly assigned to roles !!", Sets.newHashSet("server=server->db=db3->table=table5->action=all"), listPrivilegesForProvider);
 
-    listPrivilegesForProvider = client.listPrivilegesForProvider(Sets.newHashSet(group1, group2), new ActiveRoleSet(Sets.newHashSet(roleName1)), new Server("server"), new Database("db3"));
+    listPrivilegesForProvider = client.listPrivilegesForProvider(Sets.newHashSet(group1, group2), null, new ActiveRoleSet(Sets.newHashSet(roleName1)), new Server("server"), new Database("db3"));
     assertEquals("Privilege not correctly assigned to roles !!", Sets.newHashSet("server=+"), listPrivilegesForProvider);
 
-    listPrivilegesForProvider = client.listPrivilegesForProvider(Sets.newHashSet(group1, group2), new ActiveRoleSet(Sets.newHashSet(roleName1)), new Server("server1"));
+    listPrivilegesForProvider = client.listPrivilegesForProvider(Sets.newHashSet(group1, group2), null, new ActiveRoleSet(Sets.newHashSet(roleName1)), new Server("server1"));
     assertEquals("Privilege not correctly assigned to roles !!", new HashSet<String>(), listPrivilegesForProvider);
   }
 
@@ -141,28 +141,68 @@ public class TestSentryServerForHaWithoutKerberos extends SentryServiceIntegrati
     client.grantRoleToGroup(requestorUserName, ADMIN_GROUP, roleName);
     client.grantDatabasePrivilege(requestorUserName, roleName, "server1", "db2", AccessConstants.ALL);
     client.grantTablePrivilege(requestorUserName, roleName, "server1", "db3", "tab3", "ALL");
-    assertEquals(2, client.listPrivilegesForProvider(requestorUserGroupNames,
+    assertEquals(2, client.listPrivilegesForProvider(requestorUserGroupNames, null,
             ActiveRoleSet.ALL).size());
 
     // drop role and verify privileges
     client.dropRole(requestorUserName, roleName);
-    assertEquals(0, client.listPrivilegesForProvider(requestorUserGroupNames,
+    assertEquals(0, client.listPrivilegesForProvider(requestorUserGroupNames, null,
             ActiveRoleSet.ALL).size());
 
     // recreate the role
     client.createRole(requestorUserName, roleName);
     client.grantRoleToGroup(requestorUserName, ADMIN_GROUP, roleName);
-    assertEquals(0, client.listPrivilegesForProvider(requestorUserGroupNames,
+    assertEquals(0, client.listPrivilegesForProvider(requestorUserGroupNames, null,
             ActiveRoleSet.ALL).size());
 
     // grant different privileges and verify
     client.grantDatabasePrivilege(requestorUserName, roleName, "server1", "db2", AccessConstants.ALL);
-    assertEquals(1, client.listPrivilegesForProvider(requestorUserGroupNames,
+    assertEquals(1, client.listPrivilegesForProvider(requestorUserGroupNames, null,
             ActiveRoleSet.ALL).size());
     client.dropRole(requestorUserName, roleName);
-    assertEquals(0, client.listPrivilegesForProvider(requestorUserGroupNames,
+    assertEquals(0, client.listPrivilegesForProvider(requestorUserGroupNames, null,
             ActiveRoleSet.ALL).size());
-    assertEquals(0, client.listPrivilegesForProvider(requestorUserGroupNames,
+    assertEquals(0, client.listPrivilegesForProvider(requestorUserGroupNames, null,
+            ActiveRoleSet.ALL).size());
+  }
+
+  @Test
+  public void testDropRoleOnUser() throws Exception {
+    String requestorUserName = ADMIN_USER;
+    Set<String> requestorUserGroupNames = Sets.newHashSet(ADMIN_GROUP);
+    Set<String> requestorUserNames = Sets.newHashSet(ADMIN_USER);
+    setLocalGroupMapping(requestorUserName, requestorUserGroupNames);
+    writePolicyFile();
+    String roleName = "admin_r";
+
+    // create role and add privileges
+    client.dropRoleIfExists(requestorUserName, roleName);
+    client.createRole(requestorUserName, roleName);
+    client.grantRoleToUser(requestorUserName, ADMIN_USER, roleName);
+    client.grantDatabasePrivilege(requestorUserName, roleName, "server1", "db2", AccessConstants.ALL);
+    client.grantTablePrivilege(requestorUserName, roleName, "server1", "db3", "tab3", "ALL");
+    assertEquals(2, client.listPrivilegesForProvider(requestorUserGroupNames, requestorUserNames,
+            ActiveRoleSet.ALL).size());
+
+    // drop role and verify privileges
+    client.dropRole(requestorUserName, roleName);
+    assertEquals(0, client.listPrivilegesForProvider(requestorUserGroupNames, requestorUserNames,
+            ActiveRoleSet.ALL).size());
+
+    // recreate the role
+    client.createRole(requestorUserName, roleName);
+    client.grantRoleToGroup(requestorUserName, ADMIN_GROUP, roleName);
+    assertEquals(0, client.listPrivilegesForProvider(requestorUserGroupNames, requestorUserNames,
+            ActiveRoleSet.ALL).size());
+
+    // grant different privileges and verify
+    client.grantDatabasePrivilege(requestorUserName, roleName, "server1", "db2", AccessConstants.ALL);
+    assertEquals(1, client.listPrivilegesForProvider(requestorUserGroupNames, requestorUserNames,
+            ActiveRoleSet.ALL).size());
+    client.dropRole(requestorUserName, roleName);
+    assertEquals(0, client.listPrivilegesForProvider(requestorUserGroupNames, requestorUserNames,
+            ActiveRoleSet.ALL).size());
+    assertEquals(0, client.listPrivilegesForProvider(requestorUserGroupNames, requestorUserNames,
             ActiveRoleSet.ALL).size());
   }
 

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/thrift/TestSentryServerWithoutKerberos.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/thrift/TestSentryServerWithoutKerberos.java b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/thrift/TestSentryServerWithoutKerberos.java
index 0792eb6..b37f057 100644
--- a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/thrift/TestSentryServerWithoutKerberos.java
+++ b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/thrift/TestSentryServerWithoutKerberos.java
@@ -110,18 +110,18 @@ public class TestSentryServerWithoutKerberos extends SentryServiceIntegrationBas
     listPrivilegesByRoleName = client.listPrivilegesByRoleName(requestorUserName, roleName2, Lists.newArrayList(new Server("server"), new Database("db3")));
     assertEquals("Privilege not assigned to role2 !!", 1, listPrivilegesByRoleName.size());
 
-    Set<String> listPrivilegesForProvider = client.listPrivilegesForProvider(Sets.newHashSet(group1, group2), ActiveRoleSet.ALL, new Server("server"), new Database("db2"));
+    Set<String> listPrivilegesForProvider = client.listPrivilegesForProvider(Sets.newHashSet(group1, group2), null, ActiveRoleSet.ALL, new Server("server"), new Database("db2"));
     assertEquals("Privilege not correctly assigned to roles !!",
         Sets.newHashSet("server=server->db=db2->table=table4->action=all", "server=server->db=db2->table=table3->action=all"),
         listPrivilegesForProvider);
 
-    listPrivilegesForProvider = client.listPrivilegesForProvider(Sets.newHashSet(group1, group2), ActiveRoleSet.ALL, new Server("server"), new Database("db3"));
+    listPrivilegesForProvider = client.listPrivilegesForProvider(Sets.newHashSet(group1, group2), null, ActiveRoleSet.ALL, new Server("server"), new Database("db3"));
     assertEquals("Privilege not correctly assigned to roles !!", Sets.newHashSet("server=server->db=db3->table=table5->action=all"), listPrivilegesForProvider);
 
-    listPrivilegesForProvider = client.listPrivilegesForProvider(Sets.newHashSet(group1, group2), new ActiveRoleSet(Sets.newHashSet(roleName1)), new Server("server"), new Database("db3"));
+    listPrivilegesForProvider = client.listPrivilegesForProvider(Sets.newHashSet(group1, group2), null, new ActiveRoleSet(Sets.newHashSet(roleName1)), new Server("server"), new Database("db3"));
     assertEquals("Privilege not correctly assigned to roles !!", Sets.newHashSet("server=+"), listPrivilegesForProvider);
 
-    listPrivilegesForProvider = client.listPrivilegesForProvider(Sets.newHashSet(group1, group2), new ActiveRoleSet(Sets.newHashSet(roleName1)), new Server("server1"));
+    listPrivilegesForProvider = client.listPrivilegesForProvider(Sets.newHashSet(group1, group2), null, new ActiveRoleSet(Sets.newHashSet(roleName1)), new Server("server1"));
     assertEquals("Privilege not correctly assigned to roles !!", new HashSet<String>(), listPrivilegesForProvider);
   }
 
@@ -147,29 +147,68 @@ public class TestSentryServerWithoutKerberos extends SentryServiceIntegrationBas
     client.grantRoleToGroup(requestorUserName, ADMIN_GROUP, roleName);
     client.grantDatabasePrivilege(requestorUserName, roleName, "server1", "db2", AccessConstants.ALL);
     client.grantTablePrivilege(requestorUserName, roleName, "server1", "db3", "tab3", "ALL");
-    assertEquals(2, client.listPrivilegesForProvider(requestorUserGroupNames,
+    assertEquals(2, client.listPrivilegesForProvider(requestorUserGroupNames, null,
             ActiveRoleSet.ALL).size());
 
     // drop role and verify privileges
     client.dropRole(requestorUserName, roleName);
-    assertEquals(0, client.listPrivilegesForProvider(requestorUserGroupNames,
+    assertEquals(0, client.listPrivilegesForProvider(requestorUserGroupNames, null,
             ActiveRoleSet.ALL).size());
 
     // recreate the role
     client.createRole(requestorUserName, roleName);
     client.grantRoleToGroup(requestorUserName, ADMIN_GROUP, roleName);
-    assertEquals(0, client.listPrivilegesForProvider(requestorUserGroupNames,
+    assertEquals(0, client.listPrivilegesForProvider(requestorUserGroupNames, null,
             ActiveRoleSet.ALL).size());
 
     // grant different privileges and verify
     client.grantDatabasePrivilege(requestorUserName, roleName, "server1", "db2", AccessConstants.ALL);
-    assertEquals(1, client.listPrivilegesForProvider(requestorUserGroupNames,
+    assertEquals(1, client.listPrivilegesForProvider(requestorUserGroupNames, null,
             ActiveRoleSet.ALL).size());
     client.dropRole(requestorUserName, roleName);
-    assertEquals(0, client.listPrivilegesForProvider(requestorUserGroupNames,
+    assertEquals(0, client.listPrivilegesForProvider(requestorUserGroupNames, null,
             ActiveRoleSet.ALL).size());
-    assertEquals(0, client.listPrivilegesForProvider(requestorUserGroupNames,
+    assertEquals(0, client.listPrivilegesForProvider(requestorUserGroupNames, null,
             ActiveRoleSet.ALL).size());
   }
 
+  @Test
+  public void testDropRoleOnUser() throws Exception {
+    String requestorUserName = ADMIN_USER;
+    Set<String> requestorUserGroupNames = Sets.newHashSet(ADMIN_GROUP);
+    Set<String> requestorUserNames = Sets.newHashSet(ADMIN_USER);
+    setLocalGroupMapping(requestorUserName, requestorUserGroupNames);
+    writePolicyFile();
+    String roleName = "admin_r";
+
+    // create role and add privileges
+    client.dropRoleIfExists(requestorUserName, roleName);
+    client.createRole(requestorUserName, roleName);
+    client.grantRoleToUser(requestorUserName, ADMIN_USER, roleName);
+    client.grantDatabasePrivilege(requestorUserName, roleName, "server1", "db2", AccessConstants.ALL);
+    client.grantTablePrivilege(requestorUserName, roleName, "server1", "db3", "tab3", "ALL");
+    assertEquals(2, client.listPrivilegesForProvider(requestorUserGroupNames, requestorUserNames,
+            ActiveRoleSet.ALL).size());
+
+    // drop role and verify privileges
+    client.dropRole(requestorUserName, roleName);
+    assertEquals(0, client.listPrivilegesForProvider(requestorUserGroupNames, requestorUserNames,
+            ActiveRoleSet.ALL).size());
+
+    // recreate the role
+    client.createRole(requestorUserName, roleName);
+    client.grantRoleToGroup(requestorUserName, ADMIN_GROUP, roleName);
+    assertEquals(0, client.listPrivilegesForProvider(requestorUserGroupNames, requestorUserNames,
+            ActiveRoleSet.ALL).size());
+
+    // grant different privileges and verify
+    client.grantDatabasePrivilege(requestorUserName, roleName, "server1", "db2", AccessConstants.ALL);
+    assertEquals(1, client.listPrivilegesForProvider(requestorUserGroupNames, requestorUserNames,
+            ActiveRoleSet.ALL).size());
+    client.dropRole(requestorUserName, roleName);
+    assertEquals(0, client.listPrivilegesForProvider(requestorUserGroupNames, requestorUserNames,
+            ActiveRoleSet.ALL).size());
+    assertEquals(0, client.listPrivilegesForProvider(requestorUserGroupNames, requestorUserNames,
+            ActiveRoleSet.ALL).size());
+  }
 }

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/thrift/TestSentryServiceIntegration.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/thrift/TestSentryServiceIntegration.java b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/thrift/TestSentryServiceIntegration.java
index 07c7f7a..a076475 100644
--- a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/thrift/TestSentryServiceIntegration.java
+++ b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/thrift/TestSentryServiceIntegration.java
@@ -135,6 +135,232 @@ public class TestSentryServiceIntegration extends SentryServiceIntegrationBase {
   }
 
   @Test
+  public void testAddDeleteRolesForUser() throws Exception {
+    runTestAsSubject(new TestOperation() {
+      @Override
+      public void runTestAsSubject() throws Exception {
+        String requestorUserName = ADMIN_USER;
+        Set<String> requestorUserGroupNames = Sets.newHashSet(ADMIN_GROUP);
+        setLocalGroupMapping(requestorUserName, requestorUserGroupNames);
+
+        // user1->group1
+        // user2->group1
+        // user3->group1, group2
+        // user4->group2, group3
+        // group1->r1
+        // group2->r2
+        // group3->r2
+        // user2->r3
+        // user4->r3
+        String roleName1 = "r1";
+        String roleName2 = "r2";
+        String roleName3 = "r3";
+        String user1 = "u1";
+        String user2 = "u2";
+        String user3 = "u3";
+        String user4 = "u4";
+        String group1 = "g1";
+        String group2 = "g2";
+        String group3 = "g3";
+        Map<String, Set<String>> userToGroups = Maps.newHashMap();
+        userToGroups.put(user1, Sets.newHashSet(group1));
+        userToGroups.put(user2, Sets.newHashSet(group1));
+        userToGroups.put(user3, Sets.newHashSet(group1, group2));
+        userToGroups.put(user4, Sets.newHashSet(group2, group3));
+
+        setLocalGroupMapping(user1, Sets.newHashSet(group1));
+        setLocalGroupMapping(user2, Sets.newHashSet(group1));
+        setLocalGroupMapping(user3, Sets.newHashSet(group1, group2));
+        setLocalGroupMapping(user4, Sets.newHashSet(group2, group3));
+        writePolicyFile();
+
+        client.dropRoleIfExists(requestorUserName, roleName1);
+        client.dropRoleIfExists(requestorUserName, roleName2);
+        client.dropRoleIfExists(requestorUserName, roleName3);
+        client.createRole(requestorUserName, roleName1);
+        client.createRole(requestorUserName, roleName2);
+        client.createRole(requestorUserName, roleName3);
+
+        client.grantRoleToGroup(requestorUserName, group1, roleName1);
+        client.grantRoleToUser(requestorUserName, user2, roleName2);
+        client.grantRoleToUser(requestorUserName, user3, roleName2);
+        client.grantRoleToUser(requestorUserName, user2, roleName3);
+        client.grantRoleToUsers(requestorUserName, roleName3, Sets.newHashSet(user4));
+        // following test cases also test the grantRoleToUser() and grantRoleToUsers() implicity
+        // admin always can get the role list
+        Set<TSentryRole> roles = client.listRolesByUserName(requestorUserName, user1);
+        assertEquals(0, roles.size());
+        // the role list includes the role for user and the role for user's group
+        roles = client.listRolesByUserName(requestorUserName, user2);
+        assertEquals(2, roles.size());
+        for (TSentryRole role : roles) {
+          assertTrue(roleName2.equals(role.getRoleName()) || roleName3.equals(role.getRoleName()));
+        }
+        // user has 2 groups whose role list are different
+        roles = client.listRolesByUserName(requestorUserName, user3);
+        assertEquals(1, roles.size());
+        for (TSentryRole role : roles) {
+          assertTrue(roleName2.equals(role.getRoleName()));
+        }
+        // user has 2 groups whose role list are the same
+        roles = client.listRolesByUserName(requestorUserName, user4);
+        assertEquals(1, roles.size());
+        for (TSentryRole role : roles) {
+          assertTrue(roleName3.equals(role.getRoleName()));
+        }
+        // user can get his own role list if he isn't an admin
+        roles = client.listRolesByUserName(user3, user3);
+        assertEquals(1, roles.size());
+        // user can't get other's role list if he isn't an admin
+        try {
+          client.listRolesByUserName(user3, user2);
+          fail("SentryAccessDeniedException should be caught.");
+        } catch (SentryAccessDeniedException e) {
+          // excepted exception
+        }
+        // the user's name can't be empty
+        try {
+          client.listRolesByUserName(user3, "");
+          fail("SentryAccessDeniedException should be caught.");
+        } catch (SentryAccessDeniedException e) {
+          // excepted exception
+        }
+        client.revokeRoleFromUser(requestorUserName, user2, roleName3);
+        client.revokeRoleFromUsers(requestorUserName, roleName3, Sets.newHashSet(user4));
+        // test the result of revokeRoleFromUser() and revokeRoleFromUsers()
+        roles = client.listRolesByUserName(requestorUserName, user2);
+        assertEquals(1, roles.size());
+        for (TSentryRole role : roles) {
+          assertTrue(roleName2.equals(role.getRoleName()));
+        }
+        roles = client.listRolesByUserName(requestorUserName, user4);
+        assertEquals(0, roles.size());
+      }
+    });
+  }
+
+  @Test
+  public void testGranRevokePrivilegeForRoleWithUG() throws Exception {
+    runTestAsSubject(new TestOperation() {
+      @Override
+      public void runTestAsSubject() throws Exception {
+        String requestorUserName = ADMIN_USER;
+        Set<String> requestorUserGroupNames = Sets.newHashSet(ADMIN_GROUP);
+        setLocalGroupMapping(requestorUserName, requestorUserGroupNames);
+
+        // user1_1->group1
+        // user1_2->group1
+        // user2_1->group2
+        // user2_2->group2
+        // group1->r1
+        // group2->r2
+        // user1_1->r3
+        // user2_1->r4
+        String roleName1 = "r1";
+        String roleName2 = "r2";
+        String roleName3 = "r3";
+        String roleName4 = "r4";
+        String user1_1 = "u1_1";
+        String user1_2 = "u1_2";
+        String user2_1 = "u2_1";
+        String user2_2 = "u2_2";
+        String group1 = "g1";
+        String group2 = "g2";
+        Map<String, String> userToGroup = Maps.newHashMap();
+        userToGroup.put(user1_1, group1);
+        userToGroup.put(user1_2, group1);
+        userToGroup.put(user2_1, group2);
+        userToGroup.put(user2_2, user2_1);
+
+        Set<String> groupSet = Sets.newHashSet(group1);
+        setLocalGroupMapping(user1_1, groupSet);
+        setLocalGroupMapping(user1_2, groupSet);
+        groupSet = Sets.newHashSet(group2);
+        setLocalGroupMapping(user2_1, groupSet);
+        setLocalGroupMapping(user2_2, groupSet);
+        writePolicyFile();
+
+        client.dropRoleIfExists(requestorUserName, roleName1);
+        client.dropRoleIfExists(requestorUserName, roleName2);
+        client.dropRoleIfExists(requestorUserName, roleName3);
+        client.dropRoleIfExists(requestorUserName, roleName4);
+        client.createRole(requestorUserName, roleName1);
+        client.createRole(requestorUserName, roleName2);
+        client.createRole(requestorUserName, roleName3);
+        client.createRole(requestorUserName, roleName4);
+
+        client.grantRoleToGroup(requestorUserName, group1, roleName1);
+        client.grantRoleToGroup(requestorUserName, group2, roleName2);
+        client.grantRoleToUser(requestorUserName, user1_1, roleName3);
+        client.grantRoleToUsers(requestorUserName, roleName4, Sets.newHashSet(user2_1));
+
+        client
+            .grantTablePrivilege(requestorUserName, roleName1, "server", "db1", "table1_1", "ALL");
+        client
+            .grantTablePrivilege(requestorUserName, roleName1, "server", "db1", "table1_2", "ALL");
+        client
+            .grantTablePrivilege(requestorUserName, roleName2, "server", "db1", "table2_1", "ALL");
+        client
+            .grantTablePrivilege(requestorUserName, roleName2, "server", "db1", "table2_2", "ALL");
+        client
+            .grantTablePrivilege(requestorUserName, roleName3, "server", "db1", "table3_1", "ALL");
+        client
+            .grantTablePrivilege(requestorUserName, roleName3, "server", "db1", "table3_2", "ALL");
+        client
+            .grantTablePrivilege(requestorUserName, roleName4, "server", "db1", "table4_1", "ALL");
+        client
+            .grantTablePrivilege(requestorUserName, roleName4, "server", "db1", "table4_2", "ALL");
+
+        Set<String> listPrivilegesForProvider = client.listPrivilegesForProvider(
+            Sets.newHashSet(group1), Sets.newHashSet(""), ActiveRoleSet.ALL, (Authorizable[]) null);
+        assertEquals("Privilege not correctly assigned to roles !!", Sets.newHashSet(
+            "server=server->db=db1->table=table1_1->action=all",
+            "server=server->db=db1->table=table1_2->action=all"), listPrivilegesForProvider);
+
+        listPrivilegesForProvider = client.listPrivilegesForProvider(
+            Sets.newHashSet(userToGroup.get(user1_2)),
+            Sets.newHashSet(user1_2), ActiveRoleSet.ALL, (Authorizable[]) null);
+        assertEquals("Privilege not correctly assigned to roles !!", Sets.newHashSet(
+            "server=server->db=db1->table=table1_1->action=all",
+            "server=server->db=db1->table=table1_2->action=all"), listPrivilegesForProvider);
+
+        listPrivilegesForProvider = client.listPrivilegesForProvider(
+            Sets.newHashSet(userToGroup.get(user1_1)),
+            Sets.newHashSet(user1_1), ActiveRoleSet.ALL, (Authorizable[]) null);
+        assertEquals("Privilege not correctly assigned to roles !!", Sets.newHashSet(
+            "server=server->db=db1->table=table1_1->action=all",
+            "server=server->db=db1->table=table1_2->action=all",
+            "server=server->db=db1->table=table3_1->action=all",
+            "server=server->db=db1->table=table3_2->action=all"), listPrivilegesForProvider);
+
+        listPrivilegesForProvider = client.listPrivilegesForProvider(Sets.newHashSet(group1),
+            Sets.newHashSet(user1_1, user1_2), ActiveRoleSet.ALL, (Authorizable[]) null);
+        assertEquals("Privilege not correctly assigned to roles !!", Sets.newHashSet(
+            "server=server->db=db1->table=table1_1->action=all",
+            "server=server->db=db1->table=table1_2->action=all",
+            "server=server->db=db1->table=table3_1->action=all",
+            "server=server->db=db1->table=table3_2->action=all"), listPrivilegesForProvider);
+
+        listPrivilegesForProvider = client.listPrivilegesForProvider(
+            Sets.newHashSet(group1, group2), Sets.newHashSet(user1_1, user1_2, user2_1, user2_2),
+            ActiveRoleSet.ALL, (Authorizable[]) null);
+        assertEquals("Privilege not correctly assigned to roles !!", Sets.newHashSet(
+            "server=server->db=db1->table=table1_1->action=all",
+            "server=server->db=db1->table=table1_2->action=all",
+            "server=server->db=db1->table=table2_1->action=all",
+            "server=server->db=db1->table=table2_2->action=all",
+            "server=server->db=db1->table=table3_1->action=all",
+            "server=server->db=db1->table=table3_2->action=all",
+            "server=server->db=db1->table=table4_1->action=all",
+            "server=server->db=db1->table=table4_2->action=all"), listPrivilegesForProvider);
+
+        client.revokeRoleFromUser(requestorUserName, user1_1, roleName3);
+        client.revokeRoleFromUsers(requestorUserName, roleName4, Sets.newHashSet(user2_1));
+      }
+    });
+  }
+
+  @Test
   public void testMultipleRolesSamePrivilege() throws Exception {
     runTestAsSubject(new TestOperation(){
       @Override

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-file/src/main/java/org/apache/sentry/provider/file/SimpleFileProviderBackend.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-file/src/main/java/org/apache/sentry/provider/file/SimpleFileProviderBackend.java b/sentry-provider/sentry-provider-file/src/main/java/org/apache/sentry/provider/file/SimpleFileProviderBackend.java
index 884de16..8924657 100644
--- a/sentry-provider/sentry-provider-file/src/main/java/org/apache/sentry/provider/file/SimpleFileProviderBackend.java
+++ b/sentry-provider/sentry-provider-file/src/main/java/org/apache/sentry/provider/file/SimpleFileProviderBackend.java
@@ -156,6 +156,13 @@ public class SimpleFileProviderBackend implements ProviderBackend {
     return resultBuilder.build();
   }
 
+  @Override
+  public ImmutableSet<String> getPrivileges(Set<String> groups, Set<String> users,
+      ActiveRoleSet roleSet, Authorizable... authorizableHierarchy) {
+    // SimpleFileProviderBackend doesn't support getPrivileges for user now.
+    return getPrivileges(groups, roleSet, authorizableHierarchy);
+  }
+
   /**
    * {@inheritDoc}
    */

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbDDLAuditLog.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbDDLAuditLog.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbDDLAuditLog.java
index 3afd6b2..e105f00 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbDDLAuditLog.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbDDLAuditLog.java
@@ -61,6 +61,7 @@ public class TestDbDDLAuditLog extends AbstractTestWithStaticConfiguration {
   public void testBasic() throws Exception {
     String roleName = "testRole";
     String groupName = "testGroup";
+    String userName = "testUser";
     String dbName = "dbTest";
     String tableName = "tableTest";
     Connection connection = context.createConnection(ADMIN1);
@@ -84,9 +85,18 @@ public class TestDbDDLAuditLog extends AbstractTestWithStaticConfiguration {
     fieldValueMap.put(Constants.LOG_FIELD_IP_ADDRESS, null);
     assertAuditLog(fieldValueMap);
 
+    statement.execute("GRANT ROLE " + roleName + " TO USER " + userName);
+    fieldValueMap.clear();
+    fieldValueMap.put(Constants.LOG_FIELD_OPERATION, Constants.OPERATION_ADD_ROLE_USER);
+    fieldValueMap.put(Constants.LOG_FIELD_OPERATION_TEXT, "GRANT ROLE " + roleName + " TO USER "
+        + userName);
+    fieldValueMap.put(Constants.LOG_FIELD_ALLOWED, Constants.TRUE);
+    assertAuditLog(fieldValueMap);
+
     statement.execute("create database " + dbName);
     statement.execute("use " + dbName);
     statement.execute("CREATE TABLE " + tableName + " (c1 string)");
+
     statement.execute("GRANT ALL ON DATABASE " + dbName + " TO ROLE " + roleName);
     fieldValueMap.clear();
     fieldValueMap.put(Constants.LOG_FIELD_OPERATION, Constants.OPERATION_GRANT_PRIVILEGE);
@@ -210,6 +220,14 @@ public class TestDbDDLAuditLog extends AbstractTestWithStaticConfiguration {
     fieldValueMap.put(Constants.LOG_FIELD_IP_ADDRESS, null);
     assertAuditLog(fieldValueMap);
 
+    statement.execute("REVOKE ROLE " + roleName + " FROM USER " + userName);
+    fieldValueMap.clear();
+    fieldValueMap.put(Constants.LOG_FIELD_OPERATION, Constants.OPERATION_DELETE_ROLE_USER);
+    fieldValueMap.put(Constants.LOG_FIELD_OPERATION_TEXT, "REVOKE ROLE " + roleName + " FROM USER "
+        + userName);
+    fieldValueMap.put(Constants.LOG_FIELD_ALLOWED, Constants.TRUE);
+    assertAuditLog(fieldValueMap);
+
     statement.execute("DROP ROLE " + roleName);
     fieldValueMap.clear();
     fieldValueMap.put(Constants.LOG_FIELD_OPERATION, Constants.OPERATION_DROP_ROLE);

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestGrantUserToRole.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestGrantUserToRole.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestGrantUserToRole.java
new file mode 100644
index 0000000..4ce30c1
--- /dev/null
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestGrantUserToRole.java
@@ -0,0 +1,237 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.sentry.tests.e2e.dbprovider;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.Set;
+
+import org.apache.sentry.tests.e2e.hive.AbstractTestWithStaticConfiguration;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Sets;
+
+public class TestGrantUserToRole extends AbstractTestWithStaticConfiguration {
+
+  private static final Logger LOGGER = LoggerFactory.getLogger(TestGrantUserToRole.class);
+
+  private static String ROLENAME1 = "testGrantUserToRole_r1";
+  private static String ROLENAME2 = "testGrantUserToRole_r2";
+  private static String ROLENAME3 = "testGrantUserToRole_r3";
+
+  @BeforeClass
+  public static void setupTestStaticConfiguration() throws Exception {
+    useSentryService = true;
+    AbstractTestWithStaticConfiguration.setupTestStaticConfiguration();
+  }
+
+  @Override
+  @Before
+  public void setup() throws Exception {
+    super.setupAdmin();
+    super.setup();
+    prepareTestData();
+  }
+
+  private void prepareTestData() throws Exception {
+    Connection connection = context.createConnection(ADMIN1);
+    Statement statement = context.createStatement(connection);
+    statement.execute("CREATE ROLE " + ROLENAME1);
+    statement.execute("CREATE ROLE " + ROLENAME2);
+    statement.execute("CREATE ROLE " + ROLENAME3);
+    // grant role to groups and users as the following:
+    statement.execute("GRANT ROLE " + ROLENAME1 + " TO GROUP " + USERGROUP1);
+    statement.execute("GRANT ROLE " + ROLENAME2 + " TO GROUP " + USERGROUP2);
+    statement.execute("GRANT ROLE " + ROLENAME3 + " TO USER " + USER2_1);
+    statement.execute("GRANT ROLE " + ROLENAME2 + " TO USER " + USER3_1);
+    statement.execute("GRANT ROLE " + ROLENAME2 + " TO USER " + USER4_1);
+    statement.execute("GRANT ROLE " + ROLENAME3 + " TO USER " + USER4_1);
+    statement.close();
+    connection.close();
+  }
+
+  @Test
+  public void testAddDeleteRolesForUser() throws Exception {
+    Connection connection = context.createConnection(ADMIN1);
+    Statement statement = context.createStatement(connection);
+    Set<String> emptyRoleSet = Sets.newHashSet();
+    // admin can get all roles for users
+    // user1 get the role1 for group1
+    ResultSet resultSet = statement.executeQuery("SHOW ROLE GRANT USER " + USER1_1);
+    verifyResultRoles(resultSet, emptyRoleSet);
+
+    // user2 get the role1 for group1 and role2 for user2
+    resultSet = statement.executeQuery("SHOW ROLE GRANT USER " + USER2_1);
+    verifyResultRoles(resultSet, Sets.newHashSet(ROLENAME3.toLowerCase()));
+
+    // user3 get the role1 for group1 and role2 for group2
+    resultSet = statement.executeQuery("SHOW ROLE GRANT USER " + USER3_1);
+    verifyResultRoles(resultSet, Sets.newHashSet(ROLENAME2.toLowerCase()));
+
+    // user4 get the role2 for group2 and group3, role3 for user4
+    resultSet = statement.executeQuery("SHOW ROLE GRANT USER " + USER4_1);
+    verifyResultRoles(resultSet, Sets.newHashSet(ROLENAME2.toLowerCase(), ROLENAME3.toLowerCase()));
+    statement.close();
+    connection.close();
+
+    connection = context.createConnection(USER1_1);
+    statement = context.createStatement(connection);
+    // user1 can show his own roles
+    resultSet = statement.executeQuery("SHOW ROLE GRANT USER " + USER1_1);
+    verifyResultRoles(resultSet, emptyRoleSet);
+    // test the command : show current roles
+    resultSet = statement.executeQuery("SHOW CURRENT ROLES");
+    verifyResultRoles(resultSet, Sets.newHashSet(ROLENAME1.toLowerCase()));
+
+    try {
+      // user1 can't show other's roles if he isn't an admin
+      resultSet = statement.executeQuery("SHOW ROLE GRANT USER " + USER2_1);
+      fail("Can't show other's role if the user is not an admin.");
+    } catch (Exception e) {
+      // excepted exception
+    }
+    statement.close();
+    connection.close();
+
+    connection = context.createConnection(USER2_1);
+    statement = context.createStatement(connection);
+    // user2 can show his own roles
+    resultSet = statement.executeQuery("SHOW ROLE GRANT USER " + USER2_1);
+    verifyResultRoles(resultSet, Sets.newHashSet(ROLENAME3.toLowerCase()));
+    // test the command : show current roles
+    resultSet = statement.executeQuery("SHOW CURRENT ROLES");
+    verifyResultRoles(resultSet, Sets.newHashSet(ROLENAME2.toLowerCase(), ROLENAME3.toLowerCase()));
+    statement.close();
+    connection.close();
+
+    connection = context.createConnection(ADMIN1);
+    statement = context.createStatement(connection);
+    // revoke the role from user
+    statement.execute("REVOKE ROLE " + ROLENAME3 + " FROM USER " + USER2_1);
+    statement.execute("REVOKE ROLE " + ROLENAME3 + " FROM USER " + USER4_1);
+
+    resultSet = statement.executeQuery("SHOW ROLE GRANT USER " + USER2_1);
+    verifyResultRoles(resultSet, emptyRoleSet);
+
+    resultSet = statement.executeQuery("SHOW ROLE GRANT USER " + USER4_1);
+    verifyResultRoles(resultSet, Sets.newHashSet(ROLENAME2.toLowerCase()));
+    statement.close();
+    connection.close();
+  }
+
+  @Test
+  public void testAuthorizationForUsersWithRoles() throws Exception {
+    Connection connection = context.createConnection(ADMIN1);
+    Statement statement = context.createStatement(connection);
+    statement.execute("CREATE TABLE t1 (c1 string)");
+    statement.execute("CREATE TABLE t2 (c1 string)");
+    statement.execute("CREATE TABLE t3 (c1 string)");
+    statement.execute("GRANT SELECT ON TABLE t1 TO ROLE " + ROLENAME1);
+    statement.execute("GRANT SELECT ON TABLE t2 TO ROLE " + ROLENAME2);
+    statement.execute("GRANT SELECT ON TABLE t3 TO ROLE " + ROLENAME3);
+    statement.close();
+    connection.close();
+
+    // user1 can access the t1
+    connection = context.createConnection(USER1_1);
+    statement = context.createStatement(connection);
+    statement.execute("select c1 from t1");
+    try {
+      statement.execute("select c1 from t2");
+      fail("Can't access the table t2");
+    } catch (Exception e) {
+      // excepted exception
+    }
+    try {
+      statement.execute("select c1 from t3");
+      fail("Can't access the table t3");
+    } catch (Exception e) {
+      // excepted exception
+    }
+    statement.close();
+    connection.close();
+
+    // user2 can access the t2, t3
+    connection = context.createConnection(USER2_1);
+    statement = context.createStatement(connection);
+    try {
+      statement.execute("select c1 from t1");
+      fail("Can't access the table t1");
+    } catch (Exception e) {
+      // excepted exception
+    }
+    statement.execute("select c1 from t2");
+    statement.execute("select c1 from t3");
+    statement.close();
+    connection.close();
+
+    // user3 can access the t2
+    connection = context.createConnection(USER3_1);
+    statement = context.createStatement(connection);
+    try {
+      statement.execute("select c1 from t1");
+      fail("Can't access the table t1");
+    } catch (Exception e) {
+      // excepted exception
+    }
+    statement.execute("select c1 from t2");
+    try {
+      statement.execute("select c1 from t3");
+      fail("Can't access the table t3");
+    } catch (Exception e) {
+      // excepted exception
+    }
+    statement.close();
+    connection.close();
+
+    // user4 can access the t2,t3
+    connection = context.createConnection(USER4_1);
+    statement = context.createStatement(connection);
+    try {
+      statement.execute("select c1 from t1");
+      fail("Can't access the table t1");
+    } catch (Exception e) {
+      // excepted exception
+    }
+    statement.execute("select c1 from t2");
+    statement.execute("select c1 from t3");
+    statement.close();
+    connection.close();
+  }
+
+  private void verifyResultRoles(ResultSet resultSet, Set<String> exceptedRoles) throws Exception {
+    int size = 0;
+    while (resultSet.next()) {
+      String tempRole = resultSet.getString(1);
+      LOGGER.debug("tempRole:" + tempRole);
+      assertTrue(exceptedRoles.contains(tempRole));
+      size++;
+    }
+    assertEquals(exceptedRoles.size(), size);
+    resultSet.close();
+  }
+}


[3/6] sentry git commit: SENTRY-711: Implement grant user to role (Colin Ma, reviewed by Dapeng Sun)

Posted by sd...@apache.org.
http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleGrantPrivilegeResponse.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleGrantPrivilegeResponse.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleGrantPrivilegeResponse.java
index 0cadf16..825abe4 100644
--- a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleGrantPrivilegeResponse.java
+++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleGrantPrivilegeResponse.java
@@ -537,14 +537,14 @@ public class TAlterSentryRoleGrantPrivilegeResponse implements org.apache.thrift
           case 3: // PRIVILEGES
             if (schemeField.type == org.apache.thrift.protocol.TType.SET) {
               {
-                org.apache.thrift.protocol.TSet _set24 = iprot.readSetBegin();
-                struct.privileges = new HashSet<TSentryPrivilege>(2*_set24.size);
-                for (int _i25 = 0; _i25 < _set24.size; ++_i25)
+                org.apache.thrift.protocol.TSet _set40 = iprot.readSetBegin();
+                struct.privileges = new HashSet<TSentryPrivilege>(2*_set40.size);
+                for (int _i41 = 0; _i41 < _set40.size; ++_i41)
                 {
-                  TSentryPrivilege _elem26; // required
-                  _elem26 = new TSentryPrivilege();
-                  _elem26.read(iprot);
-                  struct.privileges.add(_elem26);
+                  TSentryPrivilege _elem42; // required
+                  _elem42 = new TSentryPrivilege();
+                  _elem42.read(iprot);
+                  struct.privileges.add(_elem42);
                 }
                 iprot.readSetEnd();
               }
@@ -583,9 +583,9 @@ public class TAlterSentryRoleGrantPrivilegeResponse implements org.apache.thrift
           oprot.writeFieldBegin(PRIVILEGES_FIELD_DESC);
           {
             oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, struct.privileges.size()));
-            for (TSentryPrivilege _iter27 : struct.privileges)
+            for (TSentryPrivilege _iter43 : struct.privileges)
             {
-              _iter27.write(oprot);
+              _iter43.write(oprot);
             }
             oprot.writeSetEnd();
           }
@@ -624,9 +624,9 @@ public class TAlterSentryRoleGrantPrivilegeResponse implements org.apache.thrift
       if (struct.isSetPrivileges()) {
         {
           oprot.writeI32(struct.privileges.size());
-          for (TSentryPrivilege _iter28 : struct.privileges)
+          for (TSentryPrivilege _iter44 : struct.privileges)
           {
-            _iter28.write(oprot);
+            _iter44.write(oprot);
           }
         }
       }
@@ -646,14 +646,14 @@ public class TAlterSentryRoleGrantPrivilegeResponse implements org.apache.thrift
       }
       if (incoming.get(1)) {
         {
-          org.apache.thrift.protocol.TSet _set29 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
-          struct.privileges = new HashSet<TSentryPrivilege>(2*_set29.size);
-          for (int _i30 = 0; _i30 < _set29.size; ++_i30)
+          org.apache.thrift.protocol.TSet _set45 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
+          struct.privileges = new HashSet<TSentryPrivilege>(2*_set45.size);
+          for (int _i46 = 0; _i46 < _set45.size; ++_i46)
           {
-            TSentryPrivilege _elem31; // required
-            _elem31 = new TSentryPrivilege();
-            _elem31.read(iprot);
-            struct.privileges.add(_elem31);
+            TSentryPrivilege _elem47; // required
+            _elem47 = new TSentryPrivilege();
+            _elem47.read(iprot);
+            struct.privileges.add(_elem47);
           }
         }
         struct.setPrivilegesIsSet(true);

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleRevokePrivilegeRequest.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleRevokePrivilegeRequest.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleRevokePrivilegeRequest.java
index 034a061..57f2722 100644
--- a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleRevokePrivilegeRequest.java
+++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleRevokePrivilegeRequest.java
@@ -721,14 +721,14 @@ public class TAlterSentryRoleRevokePrivilegeRequest implements org.apache.thrift
           case 6: // PRIVILEGES
             if (schemeField.type == org.apache.thrift.protocol.TType.SET) {
               {
-                org.apache.thrift.protocol.TSet _set32 = iprot.readSetBegin();
-                struct.privileges = new HashSet<TSentryPrivilege>(2*_set32.size);
-                for (int _i33 = 0; _i33 < _set32.size; ++_i33)
+                org.apache.thrift.protocol.TSet _set48 = iprot.readSetBegin();
+                struct.privileges = new HashSet<TSentryPrivilege>(2*_set48.size);
+                for (int _i49 = 0; _i49 < _set48.size; ++_i49)
                 {
-                  TSentryPrivilege _elem34; // required
-                  _elem34 = new TSentryPrivilege();
-                  _elem34.read(iprot);
-                  struct.privileges.add(_elem34);
+                  TSentryPrivilege _elem50; // required
+                  _elem50 = new TSentryPrivilege();
+                  _elem50.read(iprot);
+                  struct.privileges.add(_elem50);
                 }
                 iprot.readSetEnd();
               }
@@ -775,9 +775,9 @@ public class TAlterSentryRoleRevokePrivilegeRequest implements org.apache.thrift
           oprot.writeFieldBegin(PRIVILEGES_FIELD_DESC);
           {
             oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, struct.privileges.size()));
-            for (TSentryPrivilege _iter35 : struct.privileges)
+            for (TSentryPrivilege _iter51 : struct.privileges)
             {
-              _iter35.write(oprot);
+              _iter51.write(oprot);
             }
             oprot.writeSetEnd();
           }
@@ -818,9 +818,9 @@ public class TAlterSentryRoleRevokePrivilegeRequest implements org.apache.thrift
       if (struct.isSetPrivileges()) {
         {
           oprot.writeI32(struct.privileges.size());
-          for (TSentryPrivilege _iter36 : struct.privileges)
+          for (TSentryPrivilege _iter52 : struct.privileges)
           {
-            _iter36.write(oprot);
+            _iter52.write(oprot);
           }
         }
       }
@@ -843,14 +843,14 @@ public class TAlterSentryRoleRevokePrivilegeRequest implements org.apache.thrift
       }
       if (incoming.get(1)) {
         {
-          org.apache.thrift.protocol.TSet _set37 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
-          struct.privileges = new HashSet<TSentryPrivilege>(2*_set37.size);
-          for (int _i38 = 0; _i38 < _set37.size; ++_i38)
+          org.apache.thrift.protocol.TSet _set53 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
+          struct.privileges = new HashSet<TSentryPrivilege>(2*_set53.size);
+          for (int _i54 = 0; _i54 < _set53.size; ++_i54)
           {
-            TSentryPrivilege _elem39; // required
-            _elem39 = new TSentryPrivilege();
-            _elem39.read(iprot);
-            struct.privileges.add(_elem39);
+            TSentryPrivilege _elem55; // required
+            _elem55 = new TSentryPrivilege();
+            _elem55.read(iprot);
+            struct.privileges.add(_elem55);
           }
         }
         struct.setPrivilegesIsSet(true);

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryPrivilegesByAuthRequest.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryPrivilegesByAuthRequest.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryPrivilegesByAuthRequest.java
index 0f3c6d8..f1188b2 100644
--- a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryPrivilegesByAuthRequest.java
+++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryPrivilegesByAuthRequest.java
@@ -724,14 +724,14 @@ public class TListSentryPrivilegesByAuthRequest implements org.apache.thrift.TBa
           case 3: // AUTHORIZABLE_SET
             if (schemeField.type == org.apache.thrift.protocol.TType.SET) {
               {
-                org.apache.thrift.protocol.TSet _set106 = iprot.readSetBegin();
-                struct.authorizableSet = new HashSet<TSentryAuthorizable>(2*_set106.size);
-                for (int _i107 = 0; _i107 < _set106.size; ++_i107)
+                org.apache.thrift.protocol.TSet _set130 = iprot.readSetBegin();
+                struct.authorizableSet = new HashSet<TSentryAuthorizable>(2*_set130.size);
+                for (int _i131 = 0; _i131 < _set130.size; ++_i131)
                 {
-                  TSentryAuthorizable _elem108; // required
-                  _elem108 = new TSentryAuthorizable();
-                  _elem108.read(iprot);
-                  struct.authorizableSet.add(_elem108);
+                  TSentryAuthorizable _elem132; // required
+                  _elem132 = new TSentryAuthorizable();
+                  _elem132.read(iprot);
+                  struct.authorizableSet.add(_elem132);
                 }
                 iprot.readSetEnd();
               }
@@ -743,13 +743,13 @@ public class TListSentryPrivilegesByAuthRequest implements org.apache.thrift.TBa
           case 4: // GROUPS
             if (schemeField.type == org.apache.thrift.protocol.TType.SET) {
               {
-                org.apache.thrift.protocol.TSet _set109 = iprot.readSetBegin();
-                struct.groups = new HashSet<String>(2*_set109.size);
-                for (int _i110 = 0; _i110 < _set109.size; ++_i110)
+                org.apache.thrift.protocol.TSet _set133 = iprot.readSetBegin();
+                struct.groups = new HashSet<String>(2*_set133.size);
+                for (int _i134 = 0; _i134 < _set133.size; ++_i134)
                 {
-                  String _elem111; // required
-                  _elem111 = iprot.readString();
-                  struct.groups.add(_elem111);
+                  String _elem135; // required
+                  _elem135 = iprot.readString();
+                  struct.groups.add(_elem135);
                 }
                 iprot.readSetEnd();
               }
@@ -792,9 +792,9 @@ public class TListSentryPrivilegesByAuthRequest implements org.apache.thrift.TBa
         oprot.writeFieldBegin(AUTHORIZABLE_SET_FIELD_DESC);
         {
           oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, struct.authorizableSet.size()));
-          for (TSentryAuthorizable _iter112 : struct.authorizableSet)
+          for (TSentryAuthorizable _iter136 : struct.authorizableSet)
           {
-            _iter112.write(oprot);
+            _iter136.write(oprot);
           }
           oprot.writeSetEnd();
         }
@@ -805,9 +805,9 @@ public class TListSentryPrivilegesByAuthRequest implements org.apache.thrift.TBa
           oprot.writeFieldBegin(GROUPS_FIELD_DESC);
           {
             oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, struct.groups.size()));
-            for (String _iter113 : struct.groups)
+            for (String _iter137 : struct.groups)
             {
-              oprot.writeString(_iter113);
+              oprot.writeString(_iter137);
             }
             oprot.writeSetEnd();
           }
@@ -842,9 +842,9 @@ public class TListSentryPrivilegesByAuthRequest implements org.apache.thrift.TBa
       oprot.writeString(struct.requestorUserName);
       {
         oprot.writeI32(struct.authorizableSet.size());
-        for (TSentryAuthorizable _iter114 : struct.authorizableSet)
+        for (TSentryAuthorizable _iter138 : struct.authorizableSet)
         {
-          _iter114.write(oprot);
+          _iter138.write(oprot);
         }
       }
       BitSet optionals = new BitSet();
@@ -858,9 +858,9 @@ public class TListSentryPrivilegesByAuthRequest implements org.apache.thrift.TBa
       if (struct.isSetGroups()) {
         {
           oprot.writeI32(struct.groups.size());
-          for (String _iter115 : struct.groups)
+          for (String _iter139 : struct.groups)
           {
-            oprot.writeString(_iter115);
+            oprot.writeString(_iter139);
           }
         }
       }
@@ -877,27 +877,27 @@ public class TListSentryPrivilegesByAuthRequest implements org.apache.thrift.TBa
       struct.requestorUserName = iprot.readString();
       struct.setRequestorUserNameIsSet(true);
       {
-        org.apache.thrift.protocol.TSet _set116 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
-        struct.authorizableSet = new HashSet<TSentryAuthorizable>(2*_set116.size);
-        for (int _i117 = 0; _i117 < _set116.size; ++_i117)
+        org.apache.thrift.protocol.TSet _set140 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
+        struct.authorizableSet = new HashSet<TSentryAuthorizable>(2*_set140.size);
+        for (int _i141 = 0; _i141 < _set140.size; ++_i141)
         {
-          TSentryAuthorizable _elem118; // required
-          _elem118 = new TSentryAuthorizable();
-          _elem118.read(iprot);
-          struct.authorizableSet.add(_elem118);
+          TSentryAuthorizable _elem142; // required
+          _elem142 = new TSentryAuthorizable();
+          _elem142.read(iprot);
+          struct.authorizableSet.add(_elem142);
         }
       }
       struct.setAuthorizableSetIsSet(true);
       BitSet incoming = iprot.readBitSet(2);
       if (incoming.get(0)) {
         {
-          org.apache.thrift.protocol.TSet _set119 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
-          struct.groups = new HashSet<String>(2*_set119.size);
-          for (int _i120 = 0; _i120 < _set119.size; ++_i120)
+          org.apache.thrift.protocol.TSet _set143 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
+          struct.groups = new HashSet<String>(2*_set143.size);
+          for (int _i144 = 0; _i144 < _set143.size; ++_i144)
           {
-            String _elem121; // required
-            _elem121 = iprot.readString();
-            struct.groups.add(_elem121);
+            String _elem145; // required
+            _elem145 = iprot.readString();
+            struct.groups.add(_elem145);
           }
         }
         struct.setGroupsIsSet(true);

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryPrivilegesByAuthResponse.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryPrivilegesByAuthResponse.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryPrivilegesByAuthResponse.java
index 870f94b..513f88a 100644
--- a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryPrivilegesByAuthResponse.java
+++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryPrivilegesByAuthResponse.java
@@ -449,17 +449,17 @@ public class TListSentryPrivilegesByAuthResponse implements org.apache.thrift.TB
           case 2: // PRIVILEGES_MAP_BY_AUTH
             if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
               {
-                org.apache.thrift.protocol.TMap _map122 = iprot.readMapBegin();
-                struct.privilegesMapByAuth = new HashMap<TSentryAuthorizable,TSentryPrivilegeMap>(2*_map122.size);
-                for (int _i123 = 0; _i123 < _map122.size; ++_i123)
+                org.apache.thrift.protocol.TMap _map146 = iprot.readMapBegin();
+                struct.privilegesMapByAuth = new HashMap<TSentryAuthorizable,TSentryPrivilegeMap>(2*_map146.size);
+                for (int _i147 = 0; _i147 < _map146.size; ++_i147)
                 {
-                  TSentryAuthorizable _key124; // required
-                  TSentryPrivilegeMap _val125; // required
-                  _key124 = new TSentryAuthorizable();
-                  _key124.read(iprot);
-                  _val125 = new TSentryPrivilegeMap();
-                  _val125.read(iprot);
-                  struct.privilegesMapByAuth.put(_key124, _val125);
+                  TSentryAuthorizable _key148; // required
+                  TSentryPrivilegeMap _val149; // required
+                  _key148 = new TSentryAuthorizable();
+                  _key148.read(iprot);
+                  _val149 = new TSentryPrivilegeMap();
+                  _val149.read(iprot);
+                  struct.privilegesMapByAuth.put(_key148, _val149);
                 }
                 iprot.readMapEnd();
               }
@@ -491,10 +491,10 @@ public class TListSentryPrivilegesByAuthResponse implements org.apache.thrift.TB
           oprot.writeFieldBegin(PRIVILEGES_MAP_BY_AUTH_FIELD_DESC);
           {
             oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRUCT, org.apache.thrift.protocol.TType.STRUCT, struct.privilegesMapByAuth.size()));
-            for (Map.Entry<TSentryAuthorizable, TSentryPrivilegeMap> _iter126 : struct.privilegesMapByAuth.entrySet())
+            for (Map.Entry<TSentryAuthorizable, TSentryPrivilegeMap> _iter150 : struct.privilegesMapByAuth.entrySet())
             {
-              _iter126.getKey().write(oprot);
-              _iter126.getValue().write(oprot);
+              _iter150.getKey().write(oprot);
+              _iter150.getValue().write(oprot);
             }
             oprot.writeMapEnd();
           }
@@ -527,10 +527,10 @@ public class TListSentryPrivilegesByAuthResponse implements org.apache.thrift.TB
       if (struct.isSetPrivilegesMapByAuth()) {
         {
           oprot.writeI32(struct.privilegesMapByAuth.size());
-          for (Map.Entry<TSentryAuthorizable, TSentryPrivilegeMap> _iter127 : struct.privilegesMapByAuth.entrySet())
+          for (Map.Entry<TSentryAuthorizable, TSentryPrivilegeMap> _iter151 : struct.privilegesMapByAuth.entrySet())
           {
-            _iter127.getKey().write(oprot);
-            _iter127.getValue().write(oprot);
+            _iter151.getKey().write(oprot);
+            _iter151.getValue().write(oprot);
           }
         }
       }
@@ -545,17 +545,17 @@ public class TListSentryPrivilegesByAuthResponse implements org.apache.thrift.TB
       BitSet incoming = iprot.readBitSet(1);
       if (incoming.get(0)) {
         {
-          org.apache.thrift.protocol.TMap _map128 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRUCT, org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
-          struct.privilegesMapByAuth = new HashMap<TSentryAuthorizable,TSentryPrivilegeMap>(2*_map128.size);
-          for (int _i129 = 0; _i129 < _map128.size; ++_i129)
+          org.apache.thrift.protocol.TMap _map152 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRUCT, org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
+          struct.privilegesMapByAuth = new HashMap<TSentryAuthorizable,TSentryPrivilegeMap>(2*_map152.size);
+          for (int _i153 = 0; _i153 < _map152.size; ++_i153)
           {
-            TSentryAuthorizable _key130; // required
-            TSentryPrivilegeMap _val131; // required
-            _key130 = new TSentryAuthorizable();
-            _key130.read(iprot);
-            _val131 = new TSentryPrivilegeMap();
-            _val131.read(iprot);
-            struct.privilegesMapByAuth.put(_key130, _val131);
+            TSentryAuthorizable _key154; // required
+            TSentryPrivilegeMap _val155; // required
+            _key154 = new TSentryAuthorizable();
+            _key154.read(iprot);
+            _val155 = new TSentryPrivilegeMap();
+            _val155.read(iprot);
+            struct.privilegesMapByAuth.put(_key154, _val155);
           }
         }
         struct.setPrivilegesMapByAuthIsSet(true);

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryPrivilegesForProviderRequest.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryPrivilegesForProviderRequest.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryPrivilegesForProviderRequest.java
index 51fa953..e695eb0 100644
--- a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryPrivilegesForProviderRequest.java
+++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryPrivilegesForProviderRequest.java
@@ -38,6 +38,7 @@ public class TListSentryPrivilegesForProviderRequest implements org.apache.thrif
   private static final org.apache.thrift.protocol.TField GROUPS_FIELD_DESC = new org.apache.thrift.protocol.TField("groups", org.apache.thrift.protocol.TType.SET, (short)2);
   private static final org.apache.thrift.protocol.TField ROLE_SET_FIELD_DESC = new org.apache.thrift.protocol.TField("roleSet", org.apache.thrift.protocol.TType.STRUCT, (short)3);
   private static final org.apache.thrift.protocol.TField AUTHORIZABLE_HIERARCHY_FIELD_DESC = new org.apache.thrift.protocol.TField("authorizableHierarchy", org.apache.thrift.protocol.TType.STRUCT, (short)4);
+  private static final org.apache.thrift.protocol.TField USERS_FIELD_DESC = new org.apache.thrift.protocol.TField("users", org.apache.thrift.protocol.TType.SET, (short)5);
 
   private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
   static {
@@ -49,13 +50,15 @@ public class TListSentryPrivilegesForProviderRequest implements org.apache.thrif
   private Set<String> groups; // required
   private TSentryActiveRoleSet roleSet; // required
   private TSentryAuthorizable authorizableHierarchy; // optional
+  private Set<String> users; // optional
 
   /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
   public enum _Fields implements org.apache.thrift.TFieldIdEnum {
     PROTOCOL_VERSION((short)1, "protocol_version"),
     GROUPS((short)2, "groups"),
     ROLE_SET((short)3, "roleSet"),
-    AUTHORIZABLE_HIERARCHY((short)4, "authorizableHierarchy");
+    AUTHORIZABLE_HIERARCHY((short)4, "authorizableHierarchy"),
+    USERS((short)5, "users");
 
     private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
 
@@ -78,6 +81,8 @@ public class TListSentryPrivilegesForProviderRequest implements org.apache.thrif
           return ROLE_SET;
         case 4: // AUTHORIZABLE_HIERARCHY
           return AUTHORIZABLE_HIERARCHY;
+        case 5: // USERS
+          return USERS;
         default:
           return null;
       }
@@ -120,7 +125,7 @@ public class TListSentryPrivilegesForProviderRequest implements org.apache.thrif
   // isset id assignments
   private static final int __PROTOCOL_VERSION_ISSET_ID = 0;
   private byte __isset_bitfield = 0;
-  private _Fields optionals[] = {_Fields.AUTHORIZABLE_HIERARCHY};
+  private _Fields optionals[] = {_Fields.AUTHORIZABLE_HIERARCHY,_Fields.USERS};
   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);
@@ -133,6 +138,9 @@ public class TListSentryPrivilegesForProviderRequest implements org.apache.thrif
         new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TSentryActiveRoleSet.class)));
     tmpMap.put(_Fields.AUTHORIZABLE_HIERARCHY, new org.apache.thrift.meta_data.FieldMetaData("authorizableHierarchy", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
         new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TSentryAuthorizable.class)));
+    tmpMap.put(_Fields.USERS, new org.apache.thrift.meta_data.FieldMetaData("users", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        new org.apache.thrift.meta_data.SetMetaData(org.apache.thrift.protocol.TType.SET, 
+            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
     metaDataMap = Collections.unmodifiableMap(tmpMap);
     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TListSentryPrivilegesForProviderRequest.class, metaDataMap);
   }
@@ -173,6 +181,13 @@ public class TListSentryPrivilegesForProviderRequest implements org.apache.thrif
     if (other.isSetAuthorizableHierarchy()) {
       this.authorizableHierarchy = new TSentryAuthorizable(other.authorizableHierarchy);
     }
+    if (other.isSetUsers()) {
+      Set<String> __this__users = new HashSet<String>();
+      for (String other_element : other.users) {
+        __this__users.add(other_element);
+      }
+      this.users = __this__users;
+    }
   }
 
   public TListSentryPrivilegesForProviderRequest deepCopy() {
@@ -186,6 +201,7 @@ public class TListSentryPrivilegesForProviderRequest implements org.apache.thrif
     this.groups = null;
     this.roleSet = null;
     this.authorizableHierarchy = null;
+    this.users = null;
   }
 
   public int getProtocol_version() {
@@ -294,6 +310,44 @@ public class TListSentryPrivilegesForProviderRequest implements org.apache.thrif
     }
   }
 
+  public int getUsersSize() {
+    return (this.users == null) ? 0 : this.users.size();
+  }
+
+  public java.util.Iterator<String> getUsersIterator() {
+    return (this.users == null) ? null : this.users.iterator();
+  }
+
+  public void addToUsers(String elem) {
+    if (this.users == null) {
+      this.users = new HashSet<String>();
+    }
+    this.users.add(elem);
+  }
+
+  public Set<String> getUsers() {
+    return this.users;
+  }
+
+  public void setUsers(Set<String> users) {
+    this.users = users;
+  }
+
+  public void unsetUsers() {
+    this.users = null;
+  }
+
+  /** Returns true if field users is set (has been assigned a value) and false otherwise */
+  public boolean isSetUsers() {
+    return this.users != null;
+  }
+
+  public void setUsersIsSet(boolean value) {
+    if (!value) {
+      this.users = null;
+    }
+  }
+
   public void setFieldValue(_Fields field, Object value) {
     switch (field) {
     case PROTOCOL_VERSION:
@@ -328,6 +382,14 @@ public class TListSentryPrivilegesForProviderRequest implements org.apache.thrif
       }
       break;
 
+    case USERS:
+      if (value == null) {
+        unsetUsers();
+      } else {
+        setUsers((Set<String>)value);
+      }
+      break;
+
     }
   }
 
@@ -345,6 +407,9 @@ public class TListSentryPrivilegesForProviderRequest implements org.apache.thrif
     case AUTHORIZABLE_HIERARCHY:
       return getAuthorizableHierarchy();
 
+    case USERS:
+      return getUsers();
+
     }
     throw new IllegalStateException();
   }
@@ -364,6 +429,8 @@ public class TListSentryPrivilegesForProviderRequest implements org.apache.thrif
       return isSetRoleSet();
     case AUTHORIZABLE_HIERARCHY:
       return isSetAuthorizableHierarchy();
+    case USERS:
+      return isSetUsers();
     }
     throw new IllegalStateException();
   }
@@ -417,6 +484,15 @@ public class TListSentryPrivilegesForProviderRequest implements org.apache.thrif
         return false;
     }
 
+    boolean this_present_users = true && this.isSetUsers();
+    boolean that_present_users = true && that.isSetUsers();
+    if (this_present_users || that_present_users) {
+      if (!(this_present_users && that_present_users))
+        return false;
+      if (!this.users.equals(that.users))
+        return false;
+    }
+
     return true;
   }
 
@@ -444,6 +520,11 @@ public class TListSentryPrivilegesForProviderRequest implements org.apache.thrif
     if (present_authorizableHierarchy)
       builder.append(authorizableHierarchy);
 
+    boolean present_users = true && (isSetUsers());
+    builder.append(present_users);
+    if (present_users)
+      builder.append(users);
+
     return builder.toHashCode();
   }
 
@@ -495,6 +576,16 @@ public class TListSentryPrivilegesForProviderRequest implements org.apache.thrif
         return lastComparison;
       }
     }
+    lastComparison = Boolean.valueOf(isSetUsers()).compareTo(typedOther.isSetUsers());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetUsers()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.users, typedOther.users);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
     return 0;
   }
 
@@ -544,6 +635,16 @@ public class TListSentryPrivilegesForProviderRequest implements org.apache.thrif
       }
       first = false;
     }
+    if (isSetUsers()) {
+      if (!first) sb.append(", ");
+      sb.append("users:");
+      if (this.users == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.users);
+      }
+      first = false;
+    }
     sb.append(")");
     return sb.toString();
   }
@@ -618,13 +719,13 @@ public class TListSentryPrivilegesForProviderRequest implements org.apache.thrif
           case 2: // GROUPS
             if (schemeField.type == org.apache.thrift.protocol.TType.SET) {
               {
-                org.apache.thrift.protocol.TSet _set72 = iprot.readSetBegin();
-                struct.groups = new HashSet<String>(2*_set72.size);
-                for (int _i73 = 0; _i73 < _set72.size; ++_i73)
+                org.apache.thrift.protocol.TSet _set88 = iprot.readSetBegin();
+                struct.groups = new HashSet<String>(2*_set88.size);
+                for (int _i89 = 0; _i89 < _set88.size; ++_i89)
                 {
-                  String _elem74; // required
-                  _elem74 = iprot.readString();
-                  struct.groups.add(_elem74);
+                  String _elem90; // required
+                  _elem90 = iprot.readString();
+                  struct.groups.add(_elem90);
                 }
                 iprot.readSetEnd();
               }
@@ -651,6 +752,24 @@ public class TListSentryPrivilegesForProviderRequest implements org.apache.thrif
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
+          case 5: // USERS
+            if (schemeField.type == org.apache.thrift.protocol.TType.SET) {
+              {
+                org.apache.thrift.protocol.TSet _set91 = iprot.readSetBegin();
+                struct.users = new HashSet<String>(2*_set91.size);
+                for (int _i92 = 0; _i92 < _set91.size; ++_i92)
+                {
+                  String _elem93; // required
+                  _elem93 = iprot.readString();
+                  struct.users.add(_elem93);
+                }
+                iprot.readSetEnd();
+              }
+              struct.setUsersIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
           default:
             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
         }
@@ -671,9 +790,9 @@ public class TListSentryPrivilegesForProviderRequest implements org.apache.thrif
         oprot.writeFieldBegin(GROUPS_FIELD_DESC);
         {
           oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, struct.groups.size()));
-          for (String _iter75 : struct.groups)
+          for (String _iter94 : struct.groups)
           {
-            oprot.writeString(_iter75);
+            oprot.writeString(_iter94);
           }
           oprot.writeSetEnd();
         }
@@ -691,6 +810,20 @@ public class TListSentryPrivilegesForProviderRequest implements org.apache.thrif
           oprot.writeFieldEnd();
         }
       }
+      if (struct.users != null) {
+        if (struct.isSetUsers()) {
+          oprot.writeFieldBegin(USERS_FIELD_DESC);
+          {
+            oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, struct.users.size()));
+            for (String _iter95 : struct.users)
+            {
+              oprot.writeString(_iter95);
+            }
+            oprot.writeSetEnd();
+          }
+          oprot.writeFieldEnd();
+        }
+      }
       oprot.writeFieldStop();
       oprot.writeStructEnd();
     }
@@ -711,9 +844,9 @@ public class TListSentryPrivilegesForProviderRequest implements org.apache.thrif
       oprot.writeI32(struct.protocol_version);
       {
         oprot.writeI32(struct.groups.size());
-        for (String _iter76 : struct.groups)
+        for (String _iter96 : struct.groups)
         {
-          oprot.writeString(_iter76);
+          oprot.writeString(_iter96);
         }
       }
       struct.roleSet.write(oprot);
@@ -721,10 +854,22 @@ public class TListSentryPrivilegesForProviderRequest implements org.apache.thrif
       if (struct.isSetAuthorizableHierarchy()) {
         optionals.set(0);
       }
-      oprot.writeBitSet(optionals, 1);
+      if (struct.isSetUsers()) {
+        optionals.set(1);
+      }
+      oprot.writeBitSet(optionals, 2);
       if (struct.isSetAuthorizableHierarchy()) {
         struct.authorizableHierarchy.write(oprot);
       }
+      if (struct.isSetUsers()) {
+        {
+          oprot.writeI32(struct.users.size());
+          for (String _iter97 : struct.users)
+          {
+            oprot.writeString(_iter97);
+          }
+        }
+      }
     }
 
     @Override
@@ -733,25 +878,38 @@ public class TListSentryPrivilegesForProviderRequest implements org.apache.thrif
       struct.protocol_version = iprot.readI32();
       struct.setProtocol_versionIsSet(true);
       {
-        org.apache.thrift.protocol.TSet _set77 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
-        struct.groups = new HashSet<String>(2*_set77.size);
-        for (int _i78 = 0; _i78 < _set77.size; ++_i78)
+        org.apache.thrift.protocol.TSet _set98 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
+        struct.groups = new HashSet<String>(2*_set98.size);
+        for (int _i99 = 0; _i99 < _set98.size; ++_i99)
         {
-          String _elem79; // required
-          _elem79 = iprot.readString();
-          struct.groups.add(_elem79);
+          String _elem100; // required
+          _elem100 = iprot.readString();
+          struct.groups.add(_elem100);
         }
       }
       struct.setGroupsIsSet(true);
       struct.roleSet = new TSentryActiveRoleSet();
       struct.roleSet.read(iprot);
       struct.setRoleSetIsSet(true);
-      BitSet incoming = iprot.readBitSet(1);
+      BitSet incoming = iprot.readBitSet(2);
       if (incoming.get(0)) {
         struct.authorizableHierarchy = new TSentryAuthorizable();
         struct.authorizableHierarchy.read(iprot);
         struct.setAuthorizableHierarchyIsSet(true);
       }
+      if (incoming.get(1)) {
+        {
+          org.apache.thrift.protocol.TSet _set101 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
+          struct.users = new HashSet<String>(2*_set101.size);
+          for (int _i102 = 0; _i102 < _set101.size; ++_i102)
+          {
+            String _elem103; // required
+            _elem103 = iprot.readString();
+            struct.users.add(_elem103);
+          }
+        }
+        struct.setUsersIsSet(true);
+      }
     }
   }
 

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryPrivilegesForProviderResponse.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryPrivilegesForProviderResponse.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryPrivilegesForProviderResponse.java
index b900dec..aa6594b 100644
--- a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryPrivilegesForProviderResponse.java
+++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryPrivilegesForProviderResponse.java
@@ -447,13 +447,13 @@ public class TListSentryPrivilegesForProviderResponse implements org.apache.thri
           case 2: // PRIVILEGES
             if (schemeField.type == org.apache.thrift.protocol.TType.SET) {
               {
-                org.apache.thrift.protocol.TSet _set80 = iprot.readSetBegin();
-                struct.privileges = new HashSet<String>(2*_set80.size);
-                for (int _i81 = 0; _i81 < _set80.size; ++_i81)
+                org.apache.thrift.protocol.TSet _set104 = iprot.readSetBegin();
+                struct.privileges = new HashSet<String>(2*_set104.size);
+                for (int _i105 = 0; _i105 < _set104.size; ++_i105)
                 {
-                  String _elem82; // required
-                  _elem82 = iprot.readString();
-                  struct.privileges.add(_elem82);
+                  String _elem106; // required
+                  _elem106 = iprot.readString();
+                  struct.privileges.add(_elem106);
                 }
                 iprot.readSetEnd();
               }
@@ -484,9 +484,9 @@ public class TListSentryPrivilegesForProviderResponse implements org.apache.thri
         oprot.writeFieldBegin(PRIVILEGES_FIELD_DESC);
         {
           oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, struct.privileges.size()));
-          for (String _iter83 : struct.privileges)
+          for (String _iter107 : struct.privileges)
           {
-            oprot.writeString(_iter83);
+            oprot.writeString(_iter107);
           }
           oprot.writeSetEnd();
         }
@@ -512,9 +512,9 @@ public class TListSentryPrivilegesForProviderResponse implements org.apache.thri
       struct.status.write(oprot);
       {
         oprot.writeI32(struct.privileges.size());
-        for (String _iter84 : struct.privileges)
+        for (String _iter108 : struct.privileges)
         {
-          oprot.writeString(_iter84);
+          oprot.writeString(_iter108);
         }
       }
     }
@@ -526,13 +526,13 @@ public class TListSentryPrivilegesForProviderResponse implements org.apache.thri
       struct.status.read(iprot);
       struct.setStatusIsSet(true);
       {
-        org.apache.thrift.protocol.TSet _set85 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
-        struct.privileges = new HashSet<String>(2*_set85.size);
-        for (int _i86 = 0; _i86 < _set85.size; ++_i86)
+        org.apache.thrift.protocol.TSet _set109 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
+        struct.privileges = new HashSet<String>(2*_set109.size);
+        for (int _i110 = 0; _i110 < _set109.size; ++_i110)
         {
-          String _elem87; // required
-          _elem87 = iprot.readString();
-          struct.privileges.add(_elem87);
+          String _elem111; // required
+          _elem111 = iprot.readString();
+          struct.privileges.add(_elem111);
         }
       }
       struct.setPrivilegesIsSet(true);

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryPrivilegesResponse.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryPrivilegesResponse.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryPrivilegesResponse.java
index 7540519..ad46067 100644
--- a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryPrivilegesResponse.java
+++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryPrivilegesResponse.java
@@ -444,14 +444,14 @@ public class TListSentryPrivilegesResponse implements org.apache.thrift.TBase<TL
           case 2: // PRIVILEGES
             if (schemeField.type == org.apache.thrift.protocol.TType.SET) {
               {
-                org.apache.thrift.protocol.TSet _set56 = iprot.readSetBegin();
-                struct.privileges = new HashSet<TSentryPrivilege>(2*_set56.size);
-                for (int _i57 = 0; _i57 < _set56.size; ++_i57)
+                org.apache.thrift.protocol.TSet _set72 = iprot.readSetBegin();
+                struct.privileges = new HashSet<TSentryPrivilege>(2*_set72.size);
+                for (int _i73 = 0; _i73 < _set72.size; ++_i73)
                 {
-                  TSentryPrivilege _elem58; // required
-                  _elem58 = new TSentryPrivilege();
-                  _elem58.read(iprot);
-                  struct.privileges.add(_elem58);
+                  TSentryPrivilege _elem74; // required
+                  _elem74 = new TSentryPrivilege();
+                  _elem74.read(iprot);
+                  struct.privileges.add(_elem74);
                 }
                 iprot.readSetEnd();
               }
@@ -483,9 +483,9 @@ public class TListSentryPrivilegesResponse implements org.apache.thrift.TBase<TL
           oprot.writeFieldBegin(PRIVILEGES_FIELD_DESC);
           {
             oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, struct.privileges.size()));
-            for (TSentryPrivilege _iter59 : struct.privileges)
+            for (TSentryPrivilege _iter75 : struct.privileges)
             {
-              _iter59.write(oprot);
+              _iter75.write(oprot);
             }
             oprot.writeSetEnd();
           }
@@ -518,9 +518,9 @@ public class TListSentryPrivilegesResponse implements org.apache.thrift.TBase<TL
       if (struct.isSetPrivileges()) {
         {
           oprot.writeI32(struct.privileges.size());
-          for (TSentryPrivilege _iter60 : struct.privileges)
+          for (TSentryPrivilege _iter76 : struct.privileges)
           {
-            _iter60.write(oprot);
+            _iter76.write(oprot);
           }
         }
       }
@@ -535,14 +535,14 @@ public class TListSentryPrivilegesResponse implements org.apache.thrift.TBase<TL
       BitSet incoming = iprot.readBitSet(1);
       if (incoming.get(0)) {
         {
-          org.apache.thrift.protocol.TSet _set61 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
-          struct.privileges = new HashSet<TSentryPrivilege>(2*_set61.size);
-          for (int _i62 = 0; _i62 < _set61.size; ++_i62)
+          org.apache.thrift.protocol.TSet _set77 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
+          struct.privileges = new HashSet<TSentryPrivilege>(2*_set77.size);
+          for (int _i78 = 0; _i78 < _set77.size; ++_i78)
           {
-            TSentryPrivilege _elem63; // required
-            _elem63 = new TSentryPrivilege();
-            _elem63.read(iprot);
-            struct.privileges.add(_elem63);
+            TSentryPrivilege _elem79; // required
+            _elem79 = new TSentryPrivilege();
+            _elem79.read(iprot);
+            struct.privileges.add(_elem79);
           }
         }
         struct.setPrivilegesIsSet(true);

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryRolesForUserRequest.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryRolesForUserRequest.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryRolesForUserRequest.java
new file mode 100644
index 0000000..f58775f
--- /dev/null
+++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryRolesForUserRequest.java
@@ -0,0 +1,587 @@
+/**
+ * Autogenerated by Thrift Compiler (0.9.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ *  @generated
+ */
+package org.apache.sentry.provider.db.service.thrift;
+
+import org.apache.commons.lang.builder.HashCodeBuilder;
+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 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 org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TListSentryRolesForUserRequest implements org.apache.thrift.TBase<TListSentryRolesForUserRequest, TListSentryRolesForUserRequest._Fields>, java.io.Serializable, Cloneable {
+  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TListSentryRolesForUserRequest");
+
+  private static final org.apache.thrift.protocol.TField PROTOCOL_VERSION_FIELD_DESC = new org.apache.thrift.protocol.TField("protocol_version", org.apache.thrift.protocol.TType.I32, (short)1);
+  private static final org.apache.thrift.protocol.TField REQUESTOR_USER_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("requestorUserName", org.apache.thrift.protocol.TType.STRING, (short)2);
+  private static final org.apache.thrift.protocol.TField USER_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("userName", org.apache.thrift.protocol.TType.STRING, (short)3);
+
+  private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+  static {
+    schemes.put(StandardScheme.class, new TListSentryRolesForUserRequestStandardSchemeFactory());
+    schemes.put(TupleScheme.class, new TListSentryRolesForUserRequestTupleSchemeFactory());
+  }
+
+  private int protocol_version; // required
+  private String requestorUserName; // required
+  private String userName; // 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 {
+    PROTOCOL_VERSION((short)1, "protocol_version"),
+    REQUESTOR_USER_NAME((short)2, "requestorUserName"),
+    USER_NAME((short)3, "userName");
+
+    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: // PROTOCOL_VERSION
+          return PROTOCOL_VERSION;
+        case 2: // REQUESTOR_USER_NAME
+          return REQUESTOR_USER_NAME;
+        case 3: // USER_NAME
+          return USER_NAME;
+        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
+  private static final int __PROTOCOL_VERSION_ISSET_ID = 0;
+  private byte __isset_bitfield = 0;
+  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.PROTOCOL_VERSION, new org.apache.thrift.meta_data.FieldMetaData("protocol_version", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
+    tmpMap.put(_Fields.REQUESTOR_USER_NAME, new org.apache.thrift.meta_data.FieldMetaData("requestorUserName", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.USER_NAME, new org.apache.thrift.meta_data.FieldMetaData("userName", 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(TListSentryRolesForUserRequest.class, metaDataMap);
+  }
+
+  public TListSentryRolesForUserRequest() {
+    this.protocol_version = 1;
+
+  }
+
+  public TListSentryRolesForUserRequest(
+    int protocol_version,
+    String requestorUserName,
+    String userName)
+  {
+    this();
+    this.protocol_version = protocol_version;
+    setProtocol_versionIsSet(true);
+    this.requestorUserName = requestorUserName;
+    this.userName = userName;
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public TListSentryRolesForUserRequest(TListSentryRolesForUserRequest other) {
+    __isset_bitfield = other.__isset_bitfield;
+    this.protocol_version = other.protocol_version;
+    if (other.isSetRequestorUserName()) {
+      this.requestorUserName = other.requestorUserName;
+    }
+    if (other.isSetUserName()) {
+      this.userName = other.userName;
+    }
+  }
+
+  public TListSentryRolesForUserRequest deepCopy() {
+    return new TListSentryRolesForUserRequest(this);
+  }
+
+  @Override
+  public void clear() {
+    this.protocol_version = 1;
+
+    this.requestorUserName = null;
+    this.userName = null;
+  }
+
+  public int getProtocol_version() {
+    return this.protocol_version;
+  }
+
+  public void setProtocol_version(int protocol_version) {
+    this.protocol_version = protocol_version;
+    setProtocol_versionIsSet(true);
+  }
+
+  public void unsetProtocol_version() {
+    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __PROTOCOL_VERSION_ISSET_ID);
+  }
+
+  /** Returns true if field protocol_version is set (has been assigned a value) and false otherwise */
+  public boolean isSetProtocol_version() {
+    return EncodingUtils.testBit(__isset_bitfield, __PROTOCOL_VERSION_ISSET_ID);
+  }
+
+  public void setProtocol_versionIsSet(boolean value) {
+    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __PROTOCOL_VERSION_ISSET_ID, value);
+  }
+
+  public String getRequestorUserName() {
+    return this.requestorUserName;
+  }
+
+  public void setRequestorUserName(String requestorUserName) {
+    this.requestorUserName = requestorUserName;
+  }
+
+  public void unsetRequestorUserName() {
+    this.requestorUserName = null;
+  }
+
+  /** Returns true if field requestorUserName is set (has been assigned a value) and false otherwise */
+  public boolean isSetRequestorUserName() {
+    return this.requestorUserName != null;
+  }
+
+  public void setRequestorUserNameIsSet(boolean value) {
+    if (!value) {
+      this.requestorUserName = null;
+    }
+  }
+
+  public String getUserName() {
+    return this.userName;
+  }
+
+  public void setUserName(String userName) {
+    this.userName = userName;
+  }
+
+  public void unsetUserName() {
+    this.userName = null;
+  }
+
+  /** Returns true if field userName is set (has been assigned a value) and false otherwise */
+  public boolean isSetUserName() {
+    return this.userName != null;
+  }
+
+  public void setUserNameIsSet(boolean value) {
+    if (!value) {
+      this.userName = null;
+    }
+  }
+
+  public void setFieldValue(_Fields field, Object value) {
+    switch (field) {
+    case PROTOCOL_VERSION:
+      if (value == null) {
+        unsetProtocol_version();
+      } else {
+        setProtocol_version((Integer)value);
+      }
+      break;
+
+    case REQUESTOR_USER_NAME:
+      if (value == null) {
+        unsetRequestorUserName();
+      } else {
+        setRequestorUserName((String)value);
+      }
+      break;
+
+    case USER_NAME:
+      if (value == null) {
+        unsetUserName();
+      } else {
+        setUserName((String)value);
+      }
+      break;
+
+    }
+  }
+
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
+    case PROTOCOL_VERSION:
+      return Integer.valueOf(getProtocol_version());
+
+    case REQUESTOR_USER_NAME:
+      return getRequestorUserName();
+
+    case USER_NAME:
+      return getUserName();
+
+    }
+    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 PROTOCOL_VERSION:
+      return isSetProtocol_version();
+    case REQUESTOR_USER_NAME:
+      return isSetRequestorUserName();
+    case USER_NAME:
+      return isSetUserName();
+    }
+    throw new IllegalStateException();
+  }
+
+  @Override
+  public boolean equals(Object that) {
+    if (that == null)
+      return false;
+    if (that instanceof TListSentryRolesForUserRequest)
+      return this.equals((TListSentryRolesForUserRequest)that);
+    return false;
+  }
+
+  public boolean equals(TListSentryRolesForUserRequest that) {
+    if (that == null)
+      return false;
+
+    boolean this_present_protocol_version = true;
+    boolean that_present_protocol_version = true;
+    if (this_present_protocol_version || that_present_protocol_version) {
+      if (!(this_present_protocol_version && that_present_protocol_version))
+        return false;
+      if (this.protocol_version != that.protocol_version)
+        return false;
+    }
+
+    boolean this_present_requestorUserName = true && this.isSetRequestorUserName();
+    boolean that_present_requestorUserName = true && that.isSetRequestorUserName();
+    if (this_present_requestorUserName || that_present_requestorUserName) {
+      if (!(this_present_requestorUserName && that_present_requestorUserName))
+        return false;
+      if (!this.requestorUserName.equals(that.requestorUserName))
+        return false;
+    }
+
+    boolean this_present_userName = true && this.isSetUserName();
+    boolean that_present_userName = true && that.isSetUserName();
+    if (this_present_userName || that_present_userName) {
+      if (!(this_present_userName && that_present_userName))
+        return false;
+      if (!this.userName.equals(that.userName))
+        return false;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    HashCodeBuilder builder = new HashCodeBuilder();
+
+    boolean present_protocol_version = true;
+    builder.append(present_protocol_version);
+    if (present_protocol_version)
+      builder.append(protocol_version);
+
+    boolean present_requestorUserName = true && (isSetRequestorUserName());
+    builder.append(present_requestorUserName);
+    if (present_requestorUserName)
+      builder.append(requestorUserName);
+
+    boolean present_userName = true && (isSetUserName());
+    builder.append(present_userName);
+    if (present_userName)
+      builder.append(userName);
+
+    return builder.toHashCode();
+  }
+
+  public int compareTo(TListSentryRolesForUserRequest other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+    TListSentryRolesForUserRequest typedOther = (TListSentryRolesForUserRequest)other;
+
+    lastComparison = Boolean.valueOf(isSetProtocol_version()).compareTo(typedOther.isSetProtocol_version());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetProtocol_version()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.protocol_version, typedOther.protocol_version);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetRequestorUserName()).compareTo(typedOther.isSetRequestorUserName());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetRequestorUserName()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.requestorUserName, typedOther.requestorUserName);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetUserName()).compareTo(typedOther.isSetUserName());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetUserName()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.userName, typedOther.userName);
+      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("TListSentryRolesForUserRequest(");
+    boolean first = true;
+
+    sb.append("protocol_version:");
+    sb.append(this.protocol_version);
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("requestorUserName:");
+    if (this.requestorUserName == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.requestorUserName);
+    }
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("userName:");
+    if (this.userName == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.userName);
+    }
+    first = false;
+    sb.append(")");
+    return sb.toString();
+  }
+
+  public void validate() throws org.apache.thrift.TException {
+    // check for required fields
+    if (!isSetProtocol_version()) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'protocol_version' is unset! Struct:" + toString());
+    }
+
+    if (!isSetRequestorUserName()) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'requestorUserName' is unset! Struct:" + toString());
+    }
+
+    if (!isSetUserName()) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'userName' 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 {
+      // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
+      __isset_bitfield = 0;
+      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 TListSentryRolesForUserRequestStandardSchemeFactory implements SchemeFactory {
+    public TListSentryRolesForUserRequestStandardScheme getScheme() {
+      return new TListSentryRolesForUserRequestStandardScheme();
+    }
+  }
+
+  private static class TListSentryRolesForUserRequestStandardScheme extends StandardScheme<TListSentryRolesForUserRequest> {
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot, TListSentryRolesForUserRequest 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: // PROTOCOL_VERSION
+            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
+              struct.protocol_version = iprot.readI32();
+              struct.setProtocol_versionIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 2: // REQUESTOR_USER_NAME
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.requestorUserName = iprot.readString();
+              struct.setRequestorUserNameIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 3: // USER_NAME
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.userName = iprot.readString();
+              struct.setUserNameIsSet(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, TListSentryRolesForUserRequest struct) throws org.apache.thrift.TException {
+      struct.validate();
+
+      oprot.writeStructBegin(STRUCT_DESC);
+      oprot.writeFieldBegin(PROTOCOL_VERSION_FIELD_DESC);
+      oprot.writeI32(struct.protocol_version);
+      oprot.writeFieldEnd();
+      if (struct.requestorUserName != null) {
+        oprot.writeFieldBegin(REQUESTOR_USER_NAME_FIELD_DESC);
+        oprot.writeString(struct.requestorUserName);
+        oprot.writeFieldEnd();
+      }
+      if (struct.userName != null) {
+        oprot.writeFieldBegin(USER_NAME_FIELD_DESC);
+        oprot.writeString(struct.userName);
+        oprot.writeFieldEnd();
+      }
+      oprot.writeFieldStop();
+      oprot.writeStructEnd();
+    }
+
+  }
+
+  private static class TListSentryRolesForUserRequestTupleSchemeFactory implements SchemeFactory {
+    public TListSentryRolesForUserRequestTupleScheme getScheme() {
+      return new TListSentryRolesForUserRequestTupleScheme();
+    }
+  }
+
+  private static class TListSentryRolesForUserRequestTupleScheme extends TupleScheme<TListSentryRolesForUserRequest> {
+
+    @Override
+    public void write(org.apache.thrift.protocol.TProtocol prot, TListSentryRolesForUserRequest struct) throws org.apache.thrift.TException {
+      TTupleProtocol oprot = (TTupleProtocol) prot;
+      oprot.writeI32(struct.protocol_version);
+      oprot.writeString(struct.requestorUserName);
+      oprot.writeString(struct.userName);
+    }
+
+    @Override
+    public void read(org.apache.thrift.protocol.TProtocol prot, TListSentryRolesForUserRequest struct) throws org.apache.thrift.TException {
+      TTupleProtocol iprot = (TTupleProtocol) prot;
+      struct.protocol_version = iprot.readI32();
+      struct.setProtocol_versionIsSet(true);
+      struct.requestorUserName = iprot.readString();
+      struct.setRequestorUserNameIsSet(true);
+      struct.userName = iprot.readString();
+      struct.setUserNameIsSet(true);
+    }
+  }
+
+}
+

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryRolesResponse.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryRolesResponse.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryRolesResponse.java
index 2439645..5a8cff4 100644
--- a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryRolesResponse.java
+++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TListSentryRolesResponse.java
@@ -444,14 +444,14 @@ public class TListSentryRolesResponse implements org.apache.thrift.TBase<TListSe
           case 2: // ROLES
             if (schemeField.type == org.apache.thrift.protocol.TType.SET) {
               {
-                org.apache.thrift.protocol.TSet _set48 = iprot.readSetBegin();
-                struct.roles = new HashSet<TSentryRole>(2*_set48.size);
-                for (int _i49 = 0; _i49 < _set48.size; ++_i49)
+                org.apache.thrift.protocol.TSet _set64 = iprot.readSetBegin();
+                struct.roles = new HashSet<TSentryRole>(2*_set64.size);
+                for (int _i65 = 0; _i65 < _set64.size; ++_i65)
                 {
-                  TSentryRole _elem50; // required
-                  _elem50 = new TSentryRole();
-                  _elem50.read(iprot);
-                  struct.roles.add(_elem50);
+                  TSentryRole _elem66; // required
+                  _elem66 = new TSentryRole();
+                  _elem66.read(iprot);
+                  struct.roles.add(_elem66);
                 }
                 iprot.readSetEnd();
               }
@@ -483,9 +483,9 @@ public class TListSentryRolesResponse implements org.apache.thrift.TBase<TListSe
           oprot.writeFieldBegin(ROLES_FIELD_DESC);
           {
             oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, struct.roles.size()));
-            for (TSentryRole _iter51 : struct.roles)
+            for (TSentryRole _iter67 : struct.roles)
             {
-              _iter51.write(oprot);
+              _iter67.write(oprot);
             }
             oprot.writeSetEnd();
           }
@@ -518,9 +518,9 @@ public class TListSentryRolesResponse implements org.apache.thrift.TBase<TListSe
       if (struct.isSetRoles()) {
         {
           oprot.writeI32(struct.roles.size());
-          for (TSentryRole _iter52 : struct.roles)
+          for (TSentryRole _iter68 : struct.roles)
           {
-            _iter52.write(oprot);
+            _iter68.write(oprot);
           }
         }
       }
@@ -535,14 +535,14 @@ public class TListSentryRolesResponse implements org.apache.thrift.TBase<TListSe
       BitSet incoming = iprot.readBitSet(1);
       if (incoming.get(0)) {
         {
-          org.apache.thrift.protocol.TSet _set53 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
-          struct.roles = new HashSet<TSentryRole>(2*_set53.size);
-          for (int _i54 = 0; _i54 < _set53.size; ++_i54)
+          org.apache.thrift.protocol.TSet _set69 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
+          struct.roles = new HashSet<TSentryRole>(2*_set69.size);
+          for (int _i70 = 0; _i70 < _set69.size; ++_i70)
           {
-            TSentryRole _elem55; // required
-            _elem55 = new TSentryRole();
-            _elem55.read(iprot);
-            struct.roles.add(_elem55);
+            TSentryRole _elem71; // required
+            _elem71 = new TSentryRole();
+            _elem71.read(iprot);
+            struct.roles.add(_elem71);
           }
         }
         struct.setRolesIsSet(true);

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryActiveRoleSet.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryActiveRoleSet.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryActiveRoleSet.java
index 10b421d..9d96139 100644
--- a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryActiveRoleSet.java
+++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryActiveRoleSet.java
@@ -443,13 +443,13 @@ public class TSentryActiveRoleSet implements org.apache.thrift.TBase<TSentryActi
           case 2: // ROLES
             if (schemeField.type == org.apache.thrift.protocol.TType.SET) {
               {
-                org.apache.thrift.protocol.TSet _set64 = iprot.readSetBegin();
-                struct.roles = new HashSet<String>(2*_set64.size);
-                for (int _i65 = 0; _i65 < _set64.size; ++_i65)
+                org.apache.thrift.protocol.TSet _set80 = iprot.readSetBegin();
+                struct.roles = new HashSet<String>(2*_set80.size);
+                for (int _i81 = 0; _i81 < _set80.size; ++_i81)
                 {
-                  String _elem66; // required
-                  _elem66 = iprot.readString();
-                  struct.roles.add(_elem66);
+                  String _elem82; // required
+                  _elem82 = iprot.readString();
+                  struct.roles.add(_elem82);
                 }
                 iprot.readSetEnd();
               }
@@ -478,9 +478,9 @@ public class TSentryActiveRoleSet implements org.apache.thrift.TBase<TSentryActi
         oprot.writeFieldBegin(ROLES_FIELD_DESC);
         {
           oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, struct.roles.size()));
-          for (String _iter67 : struct.roles)
+          for (String _iter83 : struct.roles)
           {
-            oprot.writeString(_iter67);
+            oprot.writeString(_iter83);
           }
           oprot.writeSetEnd();
         }
@@ -506,9 +506,9 @@ public class TSentryActiveRoleSet implements org.apache.thrift.TBase<TSentryActi
       oprot.writeBool(struct.all);
       {
         oprot.writeI32(struct.roles.size());
-        for (String _iter68 : struct.roles)
+        for (String _iter84 : struct.roles)
         {
-          oprot.writeString(_iter68);
+          oprot.writeString(_iter84);
         }
       }
     }
@@ -519,13 +519,13 @@ public class TSentryActiveRoleSet implements org.apache.thrift.TBase<TSentryActi
       struct.all = iprot.readBool();
       struct.setAllIsSet(true);
       {
-        org.apache.thrift.protocol.TSet _set69 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
-        struct.roles = new HashSet<String>(2*_set69.size);
-        for (int _i70 = 0; _i70 < _set69.size; ++_i70)
+        org.apache.thrift.protocol.TSet _set85 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
+        struct.roles = new HashSet<String>(2*_set85.size);
+        for (int _i86 = 0; _i86 < _set85.size; ++_i86)
         {
-          String _elem71; // required
-          _elem71 = iprot.readString();
-          struct.roles.add(_elem71);
+          String _elem87; // required
+          _elem87 = iprot.readString();
+          struct.roles.add(_elem87);
         }
       }
       struct.setRolesIsSet(true);

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryMappingData.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryMappingData.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryMappingData.java
index 05d1dd4..9b70abd 100644
--- a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryMappingData.java
+++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryMappingData.java
@@ -461,25 +461,25 @@ public class TSentryMappingData implements org.apache.thrift.TBase<TSentryMappin
           case 1: // GROUP_ROLES_MAP
             if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
               {
-                org.apache.thrift.protocol.TMap _map132 = iprot.readMapBegin();
-                struct.groupRolesMap = new HashMap<String,Set<String>>(2*_map132.size);
-                for (int _i133 = 0; _i133 < _map132.size; ++_i133)
+                org.apache.thrift.protocol.TMap _map156 = iprot.readMapBegin();
+                struct.groupRolesMap = new HashMap<String,Set<String>>(2*_map156.size);
+                for (int _i157 = 0; _i157 < _map156.size; ++_i157)
                 {
-                  String _key134; // required
-                  Set<String> _val135; // required
-                  _key134 = iprot.readString();
+                  String _key158; // required
+                  Set<String> _val159; // required
+                  _key158 = iprot.readString();
                   {
-                    org.apache.thrift.protocol.TSet _set136 = iprot.readSetBegin();
-                    _val135 = new HashSet<String>(2*_set136.size);
-                    for (int _i137 = 0; _i137 < _set136.size; ++_i137)
+                    org.apache.thrift.protocol.TSet _set160 = iprot.readSetBegin();
+                    _val159 = new HashSet<String>(2*_set160.size);
+                    for (int _i161 = 0; _i161 < _set160.size; ++_i161)
                     {
-                      String _elem138; // required
-                      _elem138 = iprot.readString();
-                      _val135.add(_elem138);
+                      String _elem162; // required
+                      _elem162 = iprot.readString();
+                      _val159.add(_elem162);
                     }
                     iprot.readSetEnd();
                   }
-                  struct.groupRolesMap.put(_key134, _val135);
+                  struct.groupRolesMap.put(_key158, _val159);
                 }
                 iprot.readMapEnd();
               }
@@ -491,26 +491,26 @@ public class TSentryMappingData implements org.apache.thrift.TBase<TSentryMappin
           case 2: // ROLE_PRIVILEGES_MAP
             if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
               {
-                org.apache.thrift.protocol.TMap _map139 = iprot.readMapBegin();
-                struct.rolePrivilegesMap = new HashMap<String,Set<TSentryPrivilege>>(2*_map139.size);
-                for (int _i140 = 0; _i140 < _map139.size; ++_i140)
+                org.apache.thrift.protocol.TMap _map163 = iprot.readMapBegin();
+                struct.rolePrivilegesMap = new HashMap<String,Set<TSentryPrivilege>>(2*_map163.size);
+                for (int _i164 = 0; _i164 < _map163.size; ++_i164)
                 {
-                  String _key141; // required
-                  Set<TSentryPrivilege> _val142; // required
-                  _key141 = iprot.readString();
+                  String _key165; // required
+                  Set<TSentryPrivilege> _val166; // required
+                  _key165 = iprot.readString();
                   {
-                    org.apache.thrift.protocol.TSet _set143 = iprot.readSetBegin();
-                    _val142 = new HashSet<TSentryPrivilege>(2*_set143.size);
-                    for (int _i144 = 0; _i144 < _set143.size; ++_i144)
+                    org.apache.thrift.protocol.TSet _set167 = iprot.readSetBegin();
+                    _val166 = new HashSet<TSentryPrivilege>(2*_set167.size);
+                    for (int _i168 = 0; _i168 < _set167.size; ++_i168)
                     {
-                      TSentryPrivilege _elem145; // required
-                      _elem145 = new TSentryPrivilege();
-                      _elem145.read(iprot);
-                      _val142.add(_elem145);
+                      TSentryPrivilege _elem169; // required
+                      _elem169 = new TSentryPrivilege();
+                      _elem169.read(iprot);
+                      _val166.add(_elem169);
                     }
                     iprot.readSetEnd();
                   }
-                  struct.rolePrivilegesMap.put(_key141, _val142);
+                  struct.rolePrivilegesMap.put(_key165, _val166);
                 }
                 iprot.readMapEnd();
               }
@@ -537,14 +537,14 @@ public class TSentryMappingData implements org.apache.thrift.TBase<TSentryMappin
           oprot.writeFieldBegin(GROUP_ROLES_MAP_FIELD_DESC);
           {
             oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.SET, struct.groupRolesMap.size()));
-            for (Map.Entry<String, Set<String>> _iter146 : struct.groupRolesMap.entrySet())
+            for (Map.Entry<String, Set<String>> _iter170 : struct.groupRolesMap.entrySet())
             {
-              oprot.writeString(_iter146.getKey());
+              oprot.writeString(_iter170.getKey());
               {
-                oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, _iter146.getValue().size()));
-                for (String _iter147 : _iter146.getValue())
+                oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, _iter170.getValue().size()));
+                for (String _iter171 : _iter170.getValue())
                 {
-                  oprot.writeString(_iter147);
+                  oprot.writeString(_iter171);
                 }
                 oprot.writeSetEnd();
               }
@@ -559,14 +559,14 @@ public class TSentryMappingData implements org.apache.thrift.TBase<TSentryMappin
           oprot.writeFieldBegin(ROLE_PRIVILEGES_MAP_FIELD_DESC);
           {
             oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.SET, struct.rolePrivilegesMap.size()));
-            for (Map.Entry<String, Set<TSentryPrivilege>> _iter148 : struct.rolePrivilegesMap.entrySet())
+            for (Map.Entry<String, Set<TSentryPrivilege>> _iter172 : struct.rolePrivilegesMap.entrySet())
             {
-              oprot.writeString(_iter148.getKey());
+              oprot.writeString(_iter172.getKey());
               {
-                oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, _iter148.getValue().size()));
-                for (TSentryPrivilege _iter149 : _iter148.getValue())
+                oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, _iter172.getValue().size()));
+                for (TSentryPrivilege _iter173 : _iter172.getValue())
                 {
-                  _iter149.write(oprot);
+                  _iter173.write(oprot);
                 }
                 oprot.writeSetEnd();
               }
@@ -604,14 +604,14 @@ public class TSentryMappingData implements org.apache.thrift.TBase<TSentryMappin
       if (struct.isSetGroupRolesMap()) {
         {
           oprot.writeI32(struct.groupRolesMap.size());
-          for (Map.Entry<String, Set<String>> _iter150 : struct.groupRolesMap.entrySet())
+          for (Map.Entry<String, Set<String>> _iter174 : struct.groupRolesMap.entrySet())
           {
-            oprot.writeString(_iter150.getKey());
+            oprot.writeString(_iter174.getKey());
             {
-              oprot.writeI32(_iter150.getValue().size());
-              for (String _iter151 : _iter150.getValue())
+              oprot.writeI32(_iter174.getValue().size());
+              for (String _iter175 : _iter174.getValue())
               {
-                oprot.writeString(_iter151);
+                oprot.writeString(_iter175);
               }
             }
           }
@@ -620,14 +620,14 @@ public class TSentryMappingData implements org.apache.thrift.TBase<TSentryMappin
       if (struct.isSetRolePrivilegesMap()) {
         {
           oprot.writeI32(struct.rolePrivilegesMap.size());
-          for (Map.Entry<String, Set<TSentryPrivilege>> _iter152 : struct.rolePrivilegesMap.entrySet())
+          for (Map.Entry<String, Set<TSentryPrivilege>> _iter176 : struct.rolePrivilegesMap.entrySet())
           {
-            oprot.writeString(_iter152.getKey());
+            oprot.writeString(_iter176.getKey());
             {
-              oprot.writeI32(_iter152.getValue().size());
-              for (TSentryPrivilege _iter153 : _iter152.getValue())
+              oprot.writeI32(_iter176.getValue().size());
+              for (TSentryPrivilege _iter177 : _iter176.getValue())
               {
-                _iter153.write(oprot);
+                _iter177.write(oprot);
               }
             }
           }
@@ -641,49 +641,49 @@ public class TSentryMappingData implements org.apache.thrift.TBase<TSentryMappin
       BitSet incoming = iprot.readBitSet(2);
       if (incoming.get(0)) {
         {
-          org.apache.thrift.protocol.TMap _map154 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.SET, iprot.readI32());
-          struct.groupRolesMap = new HashMap<String,Set<String>>(2*_map154.size);
-          for (int _i155 = 0; _i155 < _map154.size; ++_i155)
+          org.apache.thrift.protocol.TMap _map178 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.SET, iprot.readI32());
+          struct.groupRolesMap = new HashMap<String,Set<String>>(2*_map178.size);
+          for (int _i179 = 0; _i179 < _map178.size; ++_i179)
           {
-            String _key156; // required
-            Set<String> _val157; // required
-            _key156 = iprot.readString();
+            String _key180; // required
+            Set<String> _val181; // required
+            _key180 = iprot.readString();
             {
-              org.apache.thrift.protocol.TSet _set158 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
-              _val157 = new HashSet<String>(2*_set158.size);
-              for (int _i159 = 0; _i159 < _set158.size; ++_i159)
+              org.apache.thrift.protocol.TSet _set182 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
+              _val181 = new HashSet<String>(2*_set182.size);
+              for (int _i183 = 0; _i183 < _set182.size; ++_i183)
               {
-                String _elem160; // required
-                _elem160 = iprot.readString();
-                _val157.add(_elem160);
+                String _elem184; // required
+                _elem184 = iprot.readString();
+                _val181.add(_elem184);
               }
             }
-            struct.groupRolesMap.put(_key156, _val157);
+            struct.groupRolesMap.put(_key180, _val181);
           }
         }
         struct.setGroupRolesMapIsSet(true);
       }
       if (incoming.get(1)) {
         {
-          org.apache.thrift.protocol.TMap _map161 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.SET, iprot.readI32());
-          struct.rolePrivilegesMap = new HashMap<String,Set<TSentryPrivilege>>(2*_map161.size);
-          for (int _i162 = 0; _i162 < _map161.size; ++_i162)
+          org.apache.thrift.protocol.TMap _map185 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.SET, iprot.readI32());
+          struct.rolePrivilegesMap = new HashMap<String,Set<TSentryPrivilege>>(2*_map185.size);
+          for (int _i186 = 0; _i186 < _map185.size; ++_i186)
           {
-            String _key163; // required
-            Set<TSentryPrivilege> _val164; // required
-            _key163 = iprot.readString();
+            String _key187; // required
+            Set<TSentryPrivilege> _val188; // required
+            _key187 = iprot.readString();
             {
-              org.apache.thrift.protocol.TSet _set165 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
-              _val164 = new HashSet<TSentryPrivilege>(2*_set165.size);
-              for (int _i166 = 0; _i166 < _set165.size; ++_i166)
+              org.apache.thrift.protocol.TSet _set189 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
+              _val188 = new HashSet<TSentryPrivilege>(2*_set189.size);
+              for (int _i190 = 0; _i190 < _set189.size; ++_i190)
               {
-                TSentryPrivilege _elem167; // required
-                _elem167 = new TSentryPrivilege();
-                _elem167.read(iprot);
-                _val164.add(_elem167);
+                TSentryPrivilege _elem191; // required
+                _elem191 = new TSentryPrivilege();
+                _elem191.read(iprot);
+                _val188.add(_elem191);
               }
             }
-            struct.rolePrivilegesMap.put(_key163, _val164);
+            struct.rolePrivilegesMap.put(_key187, _val188);
           }
         }
         struct.setRolePrivilegesMapIsSet(true);


[5/6] sentry git commit: SENTRY-711: Implement grant user to role (Colin Ma, reviewed by Dapeng Sun)

Posted by sd...@apache.org.
http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/SentryPolicyService.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/SentryPolicyService.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/SentryPolicyService.java
index 0c24449..054ae05 100644
--- a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/SentryPolicyService.java
+++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/SentryPolicyService.java
@@ -47,8 +47,14 @@ public class SentryPolicyService {
 
     public TAlterSentryRoleDeleteGroupsResponse alter_sentry_role_delete_groups(TAlterSentryRoleDeleteGroupsRequest request) throws org.apache.thrift.TException;
 
+    public TAlterSentryRoleAddUsersResponse alter_sentry_role_add_users(TAlterSentryRoleAddUsersRequest request) throws org.apache.thrift.TException;
+
+    public TAlterSentryRoleDeleteUsersResponse alter_sentry_role_delete_users(TAlterSentryRoleDeleteUsersRequest request) throws org.apache.thrift.TException;
+
     public TListSentryRolesResponse list_sentry_roles_by_group(TListSentryRolesRequest request) throws org.apache.thrift.TException;
 
+    public TListSentryRolesResponse list_sentry_roles_by_user(TListSentryRolesForUserRequest request) throws org.apache.thrift.TException;
+
     public TListSentryPrivilegesResponse list_sentry_privileges_by_role(TListSentryPrivilegesRequest request) throws org.apache.thrift.TException;
 
     public TListSentryPrivilegesForProviderResponse list_sentry_privileges_for_provider(TListSentryPrivilegesForProviderRequest request) throws org.apache.thrift.TException;
@@ -81,8 +87,14 @@ public class SentryPolicyService {
 
     public void alter_sentry_role_delete_groups(TAlterSentryRoleDeleteGroupsRequest request, org.apache.thrift.async.AsyncMethodCallback<AsyncClient.alter_sentry_role_delete_groups_call> resultHandler) throws org.apache.thrift.TException;
 
+    public void alter_sentry_role_add_users(TAlterSentryRoleAddUsersRequest request, org.apache.thrift.async.AsyncMethodCallback<AsyncClient.alter_sentry_role_add_users_call> resultHandler) throws org.apache.thrift.TException;
+
+    public void alter_sentry_role_delete_users(TAlterSentryRoleDeleteUsersRequest request, org.apache.thrift.async.AsyncMethodCallback<AsyncClient.alter_sentry_role_delete_users_call> resultHandler) throws org.apache.thrift.TException;
+
     public void list_sentry_roles_by_group(TListSentryRolesRequest request, org.apache.thrift.async.AsyncMethodCallback<AsyncClient.list_sentry_roles_by_group_call> resultHandler) throws org.apache.thrift.TException;
 
+    public void list_sentry_roles_by_user(TListSentryRolesForUserRequest request, org.apache.thrift.async.AsyncMethodCallback<AsyncClient.list_sentry_roles_by_user_call> resultHandler) throws org.apache.thrift.TException;
+
     public void list_sentry_privileges_by_role(TListSentryPrivilegesRequest request, org.apache.thrift.async.AsyncMethodCallback<AsyncClient.list_sentry_privileges_by_role_call> resultHandler) throws org.apache.thrift.TException;
 
     public void list_sentry_privileges_for_provider(TListSentryPrivilegesForProviderRequest request, org.apache.thrift.async.AsyncMethodCallback<AsyncClient.list_sentry_privileges_for_provider_call> resultHandler) throws org.apache.thrift.TException;
@@ -259,6 +271,52 @@ public class SentryPolicyService {
       throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "alter_sentry_role_delete_groups failed: unknown result");
     }
 
+    public TAlterSentryRoleAddUsersResponse alter_sentry_role_add_users(TAlterSentryRoleAddUsersRequest request) throws org.apache.thrift.TException
+    {
+      send_alter_sentry_role_add_users(request);
+      return recv_alter_sentry_role_add_users();
+    }
+
+    public void send_alter_sentry_role_add_users(TAlterSentryRoleAddUsersRequest request) throws org.apache.thrift.TException
+    {
+      alter_sentry_role_add_users_args args = new alter_sentry_role_add_users_args();
+      args.setRequest(request);
+      sendBase("alter_sentry_role_add_users", args);
+    }
+
+    public TAlterSentryRoleAddUsersResponse recv_alter_sentry_role_add_users() throws org.apache.thrift.TException
+    {
+      alter_sentry_role_add_users_result result = new alter_sentry_role_add_users_result();
+      receiveBase(result, "alter_sentry_role_add_users");
+      if (result.isSetSuccess()) {
+        return result.success;
+      }
+      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "alter_sentry_role_add_users failed: unknown result");
+    }
+
+    public TAlterSentryRoleDeleteUsersResponse alter_sentry_role_delete_users(TAlterSentryRoleDeleteUsersRequest request) throws org.apache.thrift.TException
+    {
+      send_alter_sentry_role_delete_users(request);
+      return recv_alter_sentry_role_delete_users();
+    }
+
+    public void send_alter_sentry_role_delete_users(TAlterSentryRoleDeleteUsersRequest request) throws org.apache.thrift.TException
+    {
+      alter_sentry_role_delete_users_args args = new alter_sentry_role_delete_users_args();
+      args.setRequest(request);
+      sendBase("alter_sentry_role_delete_users", args);
+    }
+
+    public TAlterSentryRoleDeleteUsersResponse recv_alter_sentry_role_delete_users() throws org.apache.thrift.TException
+    {
+      alter_sentry_role_delete_users_result result = new alter_sentry_role_delete_users_result();
+      receiveBase(result, "alter_sentry_role_delete_users");
+      if (result.isSetSuccess()) {
+        return result.success;
+      }
+      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "alter_sentry_role_delete_users failed: unknown result");
+    }
+
     public TListSentryRolesResponse list_sentry_roles_by_group(TListSentryRolesRequest request) throws org.apache.thrift.TException
     {
       send_list_sentry_roles_by_group(request);
@@ -282,6 +340,29 @@ public class SentryPolicyService {
       throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "list_sentry_roles_by_group failed: unknown result");
     }
 
+    public TListSentryRolesResponse list_sentry_roles_by_user(TListSentryRolesForUserRequest request) throws org.apache.thrift.TException
+    {
+      send_list_sentry_roles_by_user(request);
+      return recv_list_sentry_roles_by_user();
+    }
+
+    public void send_list_sentry_roles_by_user(TListSentryRolesForUserRequest request) throws org.apache.thrift.TException
+    {
+      list_sentry_roles_by_user_args args = new list_sentry_roles_by_user_args();
+      args.setRequest(request);
+      sendBase("list_sentry_roles_by_user", args);
+    }
+
+    public TListSentryRolesResponse recv_list_sentry_roles_by_user() throws org.apache.thrift.TException
+    {
+      list_sentry_roles_by_user_result result = new list_sentry_roles_by_user_result();
+      receiveBase(result, "list_sentry_roles_by_user");
+      if (result.isSetSuccess()) {
+        return result.success;
+      }
+      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "list_sentry_roles_by_user failed: unknown result");
+    }
+
     public TListSentryPrivilegesResponse list_sentry_privileges_by_role(TListSentryPrivilegesRequest request) throws org.apache.thrift.TException
     {
       send_list_sentry_privileges_by_role(request);
@@ -676,6 +757,70 @@ public class SentryPolicyService {
       }
     }
 
+    public void alter_sentry_role_add_users(TAlterSentryRoleAddUsersRequest request, org.apache.thrift.async.AsyncMethodCallback<alter_sentry_role_add_users_call> resultHandler) throws org.apache.thrift.TException {
+      checkReady();
+      alter_sentry_role_add_users_call method_call = new alter_sentry_role_add_users_call(request, resultHandler, this, ___protocolFactory, ___transport);
+      this.___currentMethod = method_call;
+      ___manager.call(method_call);
+    }
+
+    public static class alter_sentry_role_add_users_call extends org.apache.thrift.async.TAsyncMethodCall {
+      private TAlterSentryRoleAddUsersRequest request;
+      public alter_sentry_role_add_users_call(TAlterSentryRoleAddUsersRequest request, org.apache.thrift.async.AsyncMethodCallback<alter_sentry_role_add_users_call> 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.request = request;
+      }
+
+      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
+        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("alter_sentry_role_add_users", org.apache.thrift.protocol.TMessageType.CALL, 0));
+        alter_sentry_role_add_users_args args = new alter_sentry_role_add_users_args();
+        args.setRequest(request);
+        args.write(prot);
+        prot.writeMessageEnd();
+      }
+
+      public TAlterSentryRoleAddUsersResponse getResult() throws 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_alter_sentry_role_add_users();
+      }
+    }
+
+    public void alter_sentry_role_delete_users(TAlterSentryRoleDeleteUsersRequest request, org.apache.thrift.async.AsyncMethodCallback<alter_sentry_role_delete_users_call> resultHandler) throws org.apache.thrift.TException {
+      checkReady();
+      alter_sentry_role_delete_users_call method_call = new alter_sentry_role_delete_users_call(request, resultHandler, this, ___protocolFactory, ___transport);
+      this.___currentMethod = method_call;
+      ___manager.call(method_call);
+    }
+
+    public static class alter_sentry_role_delete_users_call extends org.apache.thrift.async.TAsyncMethodCall {
+      private TAlterSentryRoleDeleteUsersRequest request;
+      public alter_sentry_role_delete_users_call(TAlterSentryRoleDeleteUsersRequest request, org.apache.thrift.async.AsyncMethodCallback<alter_sentry_role_delete_users_call> 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.request = request;
+      }
+
+      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
+        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("alter_sentry_role_delete_users", org.apache.thrift.protocol.TMessageType.CALL, 0));
+        alter_sentry_role_delete_users_args args = new alter_sentry_role_delete_users_args();
+        args.setRequest(request);
+        args.write(prot);
+        prot.writeMessageEnd();
+      }
+
+      public TAlterSentryRoleDeleteUsersResponse getResult() throws 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_alter_sentry_role_delete_users();
+      }
+    }
+
     public void list_sentry_roles_by_group(TListSentryRolesRequest request, org.apache.thrift.async.AsyncMethodCallback<list_sentry_roles_by_group_call> resultHandler) throws org.apache.thrift.TException {
       checkReady();
       list_sentry_roles_by_group_call method_call = new list_sentry_roles_by_group_call(request, resultHandler, this, ___protocolFactory, ___transport);
@@ -708,6 +853,38 @@ public class SentryPolicyService {
       }
     }
 
+    public void list_sentry_roles_by_user(TListSentryRolesForUserRequest request, org.apache.thrift.async.AsyncMethodCallback<list_sentry_roles_by_user_call> resultHandler) throws org.apache.thrift.TException {
+      checkReady();
+      list_sentry_roles_by_user_call method_call = new list_sentry_roles_by_user_call(request, resultHandler, this, ___protocolFactory, ___transport);
+      this.___currentMethod = method_call;
+      ___manager.call(method_call);
+    }
+
+    public static class list_sentry_roles_by_user_call extends org.apache.thrift.async.TAsyncMethodCall {
+      private TListSentryRolesForUserRequest request;
+      public list_sentry_roles_by_user_call(TListSentryRolesForUserRequest request, org.apache.thrift.async.AsyncMethodCallback<list_sentry_roles_by_user_call> 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.request = request;
+      }
+
+      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
+        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("list_sentry_roles_by_user", org.apache.thrift.protocol.TMessageType.CALL, 0));
+        list_sentry_roles_by_user_args args = new list_sentry_roles_by_user_args();
+        args.setRequest(request);
+        args.write(prot);
+        prot.writeMessageEnd();
+      }
+
+      public TListSentryRolesResponse getResult() throws 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_sentry_roles_by_user();
+      }
+    }
+
     public void list_sentry_privileges_by_role(TListSentryPrivilegesRequest request, org.apache.thrift.async.AsyncMethodCallback<list_sentry_privileges_by_role_call> resultHandler) throws org.apache.thrift.TException {
       checkReady();
       list_sentry_privileges_by_role_call method_call = new list_sentry_privileges_by_role_call(request, resultHandler, this, ___protocolFactory, ___transport);
@@ -983,7 +1160,10 @@ public class SentryPolicyService {
       processMap.put("alter_sentry_role_revoke_privilege", new alter_sentry_role_revoke_privilege());
       processMap.put("alter_sentry_role_add_groups", new alter_sentry_role_add_groups());
       processMap.put("alter_sentry_role_delete_groups", new alter_sentry_role_delete_groups());
+      processMap.put("alter_sentry_role_add_users", new alter_sentry_role_add_users());
+      processMap.put("alter_sentry_role_delete_users", new alter_sentry_role_delete_users());
       processMap.put("list_sentry_roles_by_group", new list_sentry_roles_by_group());
+      processMap.put("list_sentry_roles_by_user", new list_sentry_roles_by_user());
       processMap.put("list_sentry_privileges_by_role", new list_sentry_privileges_by_role());
       processMap.put("list_sentry_privileges_for_provider", new list_sentry_privileges_for_provider());
       processMap.put("drop_sentry_privilege", new drop_sentry_privilege());
@@ -1115,6 +1295,46 @@ public class SentryPolicyService {
       }
     }
 
+    public static class alter_sentry_role_add_users<I extends Iface> extends org.apache.thrift.ProcessFunction<I, alter_sentry_role_add_users_args> {
+      public alter_sentry_role_add_users() {
+        super("alter_sentry_role_add_users");
+      }
+
+      public alter_sentry_role_add_users_args getEmptyArgsInstance() {
+        return new alter_sentry_role_add_users_args();
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      public alter_sentry_role_add_users_result getResult(I iface, alter_sentry_role_add_users_args args) throws org.apache.thrift.TException {
+        alter_sentry_role_add_users_result result = new alter_sentry_role_add_users_result();
+        result.success = iface.alter_sentry_role_add_users(args.request);
+        return result;
+      }
+    }
+
+    public static class alter_sentry_role_delete_users<I extends Iface> extends org.apache.thrift.ProcessFunction<I, alter_sentry_role_delete_users_args> {
+      public alter_sentry_role_delete_users() {
+        super("alter_sentry_role_delete_users");
+      }
+
+      public alter_sentry_role_delete_users_args getEmptyArgsInstance() {
+        return new alter_sentry_role_delete_users_args();
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      public alter_sentry_role_delete_users_result getResult(I iface, alter_sentry_role_delete_users_args args) throws org.apache.thrift.TException {
+        alter_sentry_role_delete_users_result result = new alter_sentry_role_delete_users_result();
+        result.success = iface.alter_sentry_role_delete_users(args.request);
+        return result;
+      }
+    }
+
     public static class list_sentry_roles_by_group<I extends Iface> extends org.apache.thrift.ProcessFunction<I, list_sentry_roles_by_group_args> {
       public list_sentry_roles_by_group() {
         super("list_sentry_roles_by_group");
@@ -1135,6 +1355,26 @@ public class SentryPolicyService {
       }
     }
 
+    public static class list_sentry_roles_by_user<I extends Iface> extends org.apache.thrift.ProcessFunction<I, list_sentry_roles_by_user_args> {
+      public list_sentry_roles_by_user() {
+        super("list_sentry_roles_by_user");
+      }
+
+      public list_sentry_roles_by_user_args getEmptyArgsInstance() {
+        return new list_sentry_roles_by_user_args();
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      public list_sentry_roles_by_user_result getResult(I iface, list_sentry_roles_by_user_args args) throws org.apache.thrift.TException {
+        list_sentry_roles_by_user_result result = new list_sentry_roles_by_user_result();
+        result.success = iface.list_sentry_roles_by_user(args.request);
+        return result;
+      }
+    }
+
     public static class list_sentry_privileges_by_role<I extends Iface> extends org.apache.thrift.ProcessFunction<I, list_sentry_privileges_by_role_args> {
       public list_sentry_privileges_by_role() {
         super("list_sentry_privileges_by_role");
@@ -5653,18 +5893,18 @@ public class SentryPolicyService {
 
   }
 
-  public static class list_sentry_roles_by_group_args implements org.apache.thrift.TBase<list_sentry_roles_by_group_args, list_sentry_roles_by_group_args._Fields>, java.io.Serializable, Cloneable   {
-    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("list_sentry_roles_by_group_args");
+  public static class alter_sentry_role_add_users_args implements org.apache.thrift.TBase<alter_sentry_role_add_users_args, alter_sentry_role_add_users_args._Fields>, java.io.Serializable, Cloneable   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("alter_sentry_role_add_users_args");
 
     private static final org.apache.thrift.protocol.TField REQUEST_FIELD_DESC = new org.apache.thrift.protocol.TField("request", org.apache.thrift.protocol.TType.STRUCT, (short)1);
 
     private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
     static {
-      schemes.put(StandardScheme.class, new list_sentry_roles_by_group_argsStandardSchemeFactory());
-      schemes.put(TupleScheme.class, new list_sentry_roles_by_group_argsTupleSchemeFactory());
+      schemes.put(StandardScheme.class, new alter_sentry_role_add_users_argsStandardSchemeFactory());
+      schemes.put(TupleScheme.class, new alter_sentry_role_add_users_argsTupleSchemeFactory());
     }
 
-    private TListSentryRolesRequest request; // required
+    private TAlterSentryRoleAddUsersRequest request; // 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 {
@@ -5729,16 +5969,16 @@ public class SentryPolicyService {
     static {
       Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
       tmpMap.put(_Fields.REQUEST, new org.apache.thrift.meta_data.FieldMetaData("request", org.apache.thrift.TFieldRequirementType.DEFAULT, 
-          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TListSentryRolesRequest.class)));
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TAlterSentryRoleAddUsersRequest.class)));
       metaDataMap = Collections.unmodifiableMap(tmpMap);
-      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(list_sentry_roles_by_group_args.class, metaDataMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(alter_sentry_role_add_users_args.class, metaDataMap);
     }
 
-    public list_sentry_roles_by_group_args() {
+    public alter_sentry_role_add_users_args() {
     }
 
-    public list_sentry_roles_by_group_args(
-      TListSentryRolesRequest request)
+    public alter_sentry_role_add_users_args(
+      TAlterSentryRoleAddUsersRequest request)
     {
       this();
       this.request = request;
@@ -5747,14 +5987,14 @@ public class SentryPolicyService {
     /**
      * Performs a deep copy on <i>other</i>.
      */
-    public list_sentry_roles_by_group_args(list_sentry_roles_by_group_args other) {
+    public alter_sentry_role_add_users_args(alter_sentry_role_add_users_args other) {
       if (other.isSetRequest()) {
-        this.request = new TListSentryRolesRequest(other.request);
+        this.request = new TAlterSentryRoleAddUsersRequest(other.request);
       }
     }
 
-    public list_sentry_roles_by_group_args deepCopy() {
-      return new list_sentry_roles_by_group_args(this);
+    public alter_sentry_role_add_users_args deepCopy() {
+      return new alter_sentry_role_add_users_args(this);
     }
 
     @Override
@@ -5762,11 +6002,11 @@ public class SentryPolicyService {
       this.request = null;
     }
 
-    public TListSentryRolesRequest getRequest() {
+    public TAlterSentryRoleAddUsersRequest getRequest() {
       return this.request;
     }
 
-    public void setRequest(TListSentryRolesRequest request) {
+    public void setRequest(TAlterSentryRoleAddUsersRequest request) {
       this.request = request;
     }
 
@@ -5791,7 +6031,7 @@ public class SentryPolicyService {
         if (value == null) {
           unsetRequest();
         } else {
-          setRequest((TListSentryRolesRequest)value);
+          setRequest((TAlterSentryRoleAddUsersRequest)value);
         }
         break;
 
@@ -5824,12 +6064,12 @@ public class SentryPolicyService {
     public boolean equals(Object that) {
       if (that == null)
         return false;
-      if (that instanceof list_sentry_roles_by_group_args)
-        return this.equals((list_sentry_roles_by_group_args)that);
+      if (that instanceof alter_sentry_role_add_users_args)
+        return this.equals((alter_sentry_role_add_users_args)that);
       return false;
     }
 
-    public boolean equals(list_sentry_roles_by_group_args that) {
+    public boolean equals(alter_sentry_role_add_users_args that) {
       if (that == null)
         return false;
 
@@ -5857,13 +6097,13 @@ public class SentryPolicyService {
       return builder.toHashCode();
     }
 
-    public int compareTo(list_sentry_roles_by_group_args other) {
+    public int compareTo(alter_sentry_role_add_users_args other) {
       if (!getClass().equals(other.getClass())) {
         return getClass().getName().compareTo(other.getClass().getName());
       }
 
       int lastComparison = 0;
-      list_sentry_roles_by_group_args typedOther = (list_sentry_roles_by_group_args)other;
+      alter_sentry_role_add_users_args typedOther = (alter_sentry_role_add_users_args)other;
 
       lastComparison = Boolean.valueOf(isSetRequest()).compareTo(typedOther.isSetRequest());
       if (lastComparison != 0) {
@@ -5892,7 +6132,7 @@ public class SentryPolicyService {
 
     @Override
     public String toString() {
-      StringBuilder sb = new StringBuilder("list_sentry_roles_by_group_args(");
+      StringBuilder sb = new StringBuilder("alter_sentry_role_add_users_args(");
       boolean first = true;
 
       sb.append("request:");
@@ -5930,15 +6170,15 @@ public class SentryPolicyService {
       }
     }
 
-    private static class list_sentry_roles_by_group_argsStandardSchemeFactory implements SchemeFactory {
-      public list_sentry_roles_by_group_argsStandardScheme getScheme() {
-        return new list_sentry_roles_by_group_argsStandardScheme();
+    private static class alter_sentry_role_add_users_argsStandardSchemeFactory implements SchemeFactory {
+      public alter_sentry_role_add_users_argsStandardScheme getScheme() {
+        return new alter_sentry_role_add_users_argsStandardScheme();
       }
     }
 
-    private static class list_sentry_roles_by_group_argsStandardScheme extends StandardScheme<list_sentry_roles_by_group_args> {
+    private static class alter_sentry_role_add_users_argsStandardScheme extends StandardScheme<alter_sentry_role_add_users_args> {
 
-      public void read(org.apache.thrift.protocol.TProtocol iprot, list_sentry_roles_by_group_args struct) throws org.apache.thrift.TException {
+      public void read(org.apache.thrift.protocol.TProtocol iprot, alter_sentry_role_add_users_args struct) throws org.apache.thrift.TException {
         org.apache.thrift.protocol.TField schemeField;
         iprot.readStructBegin();
         while (true)
@@ -5950,7 +6190,7 @@ public class SentryPolicyService {
           switch (schemeField.id) {
             case 1: // REQUEST
               if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
-                struct.request = new TListSentryRolesRequest();
+                struct.request = new TAlterSentryRoleAddUsersRequest();
                 struct.request.read(iprot);
                 struct.setRequestIsSet(true);
               } else { 
@@ -5966,7 +6206,7 @@ public class SentryPolicyService {
         struct.validate();
       }
 
-      public void write(org.apache.thrift.protocol.TProtocol oprot, list_sentry_roles_by_group_args struct) throws org.apache.thrift.TException {
+      public void write(org.apache.thrift.protocol.TProtocol oprot, alter_sentry_role_add_users_args struct) throws org.apache.thrift.TException {
         struct.validate();
 
         oprot.writeStructBegin(STRUCT_DESC);
@@ -5981,16 +6221,16 @@ public class SentryPolicyService {
 
     }
 
-    private static class list_sentry_roles_by_group_argsTupleSchemeFactory implements SchemeFactory {
-      public list_sentry_roles_by_group_argsTupleScheme getScheme() {
-        return new list_sentry_roles_by_group_argsTupleScheme();
+    private static class alter_sentry_role_add_users_argsTupleSchemeFactory implements SchemeFactory {
+      public alter_sentry_role_add_users_argsTupleScheme getScheme() {
+        return new alter_sentry_role_add_users_argsTupleScheme();
       }
     }
 
-    private static class list_sentry_roles_by_group_argsTupleScheme extends TupleScheme<list_sentry_roles_by_group_args> {
+    private static class alter_sentry_role_add_users_argsTupleScheme extends TupleScheme<alter_sentry_role_add_users_args> {
 
       @Override
-      public void write(org.apache.thrift.protocol.TProtocol prot, list_sentry_roles_by_group_args struct) throws org.apache.thrift.TException {
+      public void write(org.apache.thrift.protocol.TProtocol prot, alter_sentry_role_add_users_args struct) throws org.apache.thrift.TException {
         TTupleProtocol oprot = (TTupleProtocol) prot;
         BitSet optionals = new BitSet();
         if (struct.isSetRequest()) {
@@ -6003,11 +6243,11 @@ public class SentryPolicyService {
       }
 
       @Override
-      public void read(org.apache.thrift.protocol.TProtocol prot, list_sentry_roles_by_group_args struct) throws org.apache.thrift.TException {
+      public void read(org.apache.thrift.protocol.TProtocol prot, alter_sentry_role_add_users_args struct) throws org.apache.thrift.TException {
         TTupleProtocol iprot = (TTupleProtocol) prot;
         BitSet incoming = iprot.readBitSet(1);
         if (incoming.get(0)) {
-          struct.request = new TListSentryRolesRequest();
+          struct.request = new TAlterSentryRoleAddUsersRequest();
           struct.request.read(iprot);
           struct.setRequestIsSet(true);
         }
@@ -6016,18 +6256,18 @@ public class SentryPolicyService {
 
   }
 
-  public static class list_sentry_roles_by_group_result implements org.apache.thrift.TBase<list_sentry_roles_by_group_result, list_sentry_roles_by_group_result._Fields>, java.io.Serializable, Cloneable   {
-    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("list_sentry_roles_by_group_result");
+  public static class alter_sentry_role_add_users_result implements org.apache.thrift.TBase<alter_sentry_role_add_users_result, alter_sentry_role_add_users_result._Fields>, java.io.Serializable, Cloneable   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("alter_sentry_role_add_users_result");
 
     private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0);
 
     private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
     static {
-      schemes.put(StandardScheme.class, new list_sentry_roles_by_group_resultStandardSchemeFactory());
-      schemes.put(TupleScheme.class, new list_sentry_roles_by_group_resultTupleSchemeFactory());
+      schemes.put(StandardScheme.class, new alter_sentry_role_add_users_resultStandardSchemeFactory());
+      schemes.put(TupleScheme.class, new alter_sentry_role_add_users_resultTupleSchemeFactory());
     }
 
-    private TListSentryRolesResponse success; // required
+    private TAlterSentryRoleAddUsersResponse success; // 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 {
@@ -6092,16 +6332,16 @@ public class SentryPolicyService {
     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, TListSentryRolesResponse.class)));
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TAlterSentryRoleAddUsersResponse.class)));
       metaDataMap = Collections.unmodifiableMap(tmpMap);
-      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(list_sentry_roles_by_group_result.class, metaDataMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(alter_sentry_role_add_users_result.class, metaDataMap);
     }
 
-    public list_sentry_roles_by_group_result() {
+    public alter_sentry_role_add_users_result() {
     }
 
-    public list_sentry_roles_by_group_result(
-      TListSentryRolesResponse success)
+    public alter_sentry_role_add_users_result(
+      TAlterSentryRoleAddUsersResponse success)
     {
       this();
       this.success = success;
@@ -6110,14 +6350,14 @@ public class SentryPolicyService {
     /**
      * Performs a deep copy on <i>other</i>.
      */
-    public list_sentry_roles_by_group_result(list_sentry_roles_by_group_result other) {
+    public alter_sentry_role_add_users_result(alter_sentry_role_add_users_result other) {
       if (other.isSetSuccess()) {
-        this.success = new TListSentryRolesResponse(other.success);
+        this.success = new TAlterSentryRoleAddUsersResponse(other.success);
       }
     }
 
-    public list_sentry_roles_by_group_result deepCopy() {
-      return new list_sentry_roles_by_group_result(this);
+    public alter_sentry_role_add_users_result deepCopy() {
+      return new alter_sentry_role_add_users_result(this);
     }
 
     @Override
@@ -6125,11 +6365,11 @@ public class SentryPolicyService {
       this.success = null;
     }
 
-    public TListSentryRolesResponse getSuccess() {
+    public TAlterSentryRoleAddUsersResponse getSuccess() {
       return this.success;
     }
 
-    public void setSuccess(TListSentryRolesResponse success) {
+    public void setSuccess(TAlterSentryRoleAddUsersResponse success) {
       this.success = success;
     }
 
@@ -6154,7 +6394,7 @@ public class SentryPolicyService {
         if (value == null) {
           unsetSuccess();
         } else {
-          setSuccess((TListSentryRolesResponse)value);
+          setSuccess((TAlterSentryRoleAddUsersResponse)value);
         }
         break;
 
@@ -6187,12 +6427,12 @@ public class SentryPolicyService {
     public boolean equals(Object that) {
       if (that == null)
         return false;
-      if (that instanceof list_sentry_roles_by_group_result)
-        return this.equals((list_sentry_roles_by_group_result)that);
+      if (that instanceof alter_sentry_role_add_users_result)
+        return this.equals((alter_sentry_role_add_users_result)that);
       return false;
     }
 
-    public boolean equals(list_sentry_roles_by_group_result that) {
+    public boolean equals(alter_sentry_role_add_users_result that) {
       if (that == null)
         return false;
 
@@ -6220,13 +6460,13 @@ public class SentryPolicyService {
       return builder.toHashCode();
     }
 
-    public int compareTo(list_sentry_roles_by_group_result other) {
+    public int compareTo(alter_sentry_role_add_users_result other) {
       if (!getClass().equals(other.getClass())) {
         return getClass().getName().compareTo(other.getClass().getName());
       }
 
       int lastComparison = 0;
-      list_sentry_roles_by_group_result typedOther = (list_sentry_roles_by_group_result)other;
+      alter_sentry_role_add_users_result typedOther = (alter_sentry_role_add_users_result)other;
 
       lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(typedOther.isSetSuccess());
       if (lastComparison != 0) {
@@ -6255,7 +6495,7 @@ public class SentryPolicyService {
 
     @Override
     public String toString() {
-      StringBuilder sb = new StringBuilder("list_sentry_roles_by_group_result(");
+      StringBuilder sb = new StringBuilder("alter_sentry_role_add_users_result(");
       boolean first = true;
 
       sb.append("success:");
@@ -6293,15 +6533,15 @@ public class SentryPolicyService {
       }
     }
 
-    private static class list_sentry_roles_by_group_resultStandardSchemeFactory implements SchemeFactory {
-      public list_sentry_roles_by_group_resultStandardScheme getScheme() {
-        return new list_sentry_roles_by_group_resultStandardScheme();
+    private static class alter_sentry_role_add_users_resultStandardSchemeFactory implements SchemeFactory {
+      public alter_sentry_role_add_users_resultStandardScheme getScheme() {
+        return new alter_sentry_role_add_users_resultStandardScheme();
       }
     }
 
-    private static class list_sentry_roles_by_group_resultStandardScheme extends StandardScheme<list_sentry_roles_by_group_result> {
+    private static class alter_sentry_role_add_users_resultStandardScheme extends StandardScheme<alter_sentry_role_add_users_result> {
 
-      public void read(org.apache.thrift.protocol.TProtocol iprot, list_sentry_roles_by_group_result struct) throws org.apache.thrift.TException {
+      public void read(org.apache.thrift.protocol.TProtocol iprot, alter_sentry_role_add_users_result struct) throws org.apache.thrift.TException {
         org.apache.thrift.protocol.TField schemeField;
         iprot.readStructBegin();
         while (true)
@@ -6313,7 +6553,7 @@ public class SentryPolicyService {
           switch (schemeField.id) {
             case 0: // SUCCESS
               if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
-                struct.success = new TListSentryRolesResponse();
+                struct.success = new TAlterSentryRoleAddUsersResponse();
                 struct.success.read(iprot);
                 struct.setSuccessIsSet(true);
               } else { 
@@ -6329,7 +6569,7 @@ public class SentryPolicyService {
         struct.validate();
       }
 
-      public void write(org.apache.thrift.protocol.TProtocol oprot, list_sentry_roles_by_group_result struct) throws org.apache.thrift.TException {
+      public void write(org.apache.thrift.protocol.TProtocol oprot, alter_sentry_role_add_users_result struct) throws org.apache.thrift.TException {
         struct.validate();
 
         oprot.writeStructBegin(STRUCT_DESC);
@@ -6344,16 +6584,16 @@ public class SentryPolicyService {
 
     }
 
-    private static class list_sentry_roles_by_group_resultTupleSchemeFactory implements SchemeFactory {
-      public list_sentry_roles_by_group_resultTupleScheme getScheme() {
-        return new list_sentry_roles_by_group_resultTupleScheme();
+    private static class alter_sentry_role_add_users_resultTupleSchemeFactory implements SchemeFactory {
+      public alter_sentry_role_add_users_resultTupleScheme getScheme() {
+        return new alter_sentry_role_add_users_resultTupleScheme();
       }
     }
 
-    private static class list_sentry_roles_by_group_resultTupleScheme extends TupleScheme<list_sentry_roles_by_group_result> {
+    private static class alter_sentry_role_add_users_resultTupleScheme extends TupleScheme<alter_sentry_role_add_users_result> {
 
       @Override
-      public void write(org.apache.thrift.protocol.TProtocol prot, list_sentry_roles_by_group_result struct) throws org.apache.thrift.TException {
+      public void write(org.apache.thrift.protocol.TProtocol prot, alter_sentry_role_add_users_result struct) throws org.apache.thrift.TException {
         TTupleProtocol oprot = (TTupleProtocol) prot;
         BitSet optionals = new BitSet();
         if (struct.isSetSuccess()) {
@@ -6366,7 +6606,2185 @@ public class SentryPolicyService {
       }
 
       @Override
-      public void read(org.apache.thrift.protocol.TProtocol prot, list_sentry_roles_by_group_result struct) throws org.apache.thrift.TException {
+      public void read(org.apache.thrift.protocol.TProtocol prot, alter_sentry_role_add_users_result struct) throws org.apache.thrift.TException {
+        TTupleProtocol iprot = (TTupleProtocol) prot;
+        BitSet incoming = iprot.readBitSet(1);
+        if (incoming.get(0)) {
+          struct.success = new TAlterSentryRoleAddUsersResponse();
+          struct.success.read(iprot);
+          struct.setSuccessIsSet(true);
+        }
+      }
+    }
+
+  }
+
+  public static class alter_sentry_role_delete_users_args implements org.apache.thrift.TBase<alter_sentry_role_delete_users_args, alter_sentry_role_delete_users_args._Fields>, java.io.Serializable, Cloneable   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("alter_sentry_role_delete_users_args");
+
+    private static final org.apache.thrift.protocol.TField REQUEST_FIELD_DESC = new org.apache.thrift.protocol.TField("request", org.apache.thrift.protocol.TType.STRUCT, (short)1);
+
+    private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+    static {
+      schemes.put(StandardScheme.class, new alter_sentry_role_delete_users_argsStandardSchemeFactory());
+      schemes.put(TupleScheme.class, new alter_sentry_role_delete_users_argsTupleSchemeFactory());
+    }
+
+    private TAlterSentryRoleDeleteUsersRequest request; // 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 {
+      REQUEST((short)1, "request");
+
+      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: // REQUEST
+            return REQUEST;
+          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.REQUEST, new org.apache.thrift.meta_data.FieldMetaData("request", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TAlterSentryRoleDeleteUsersRequest.class)));
+      metaDataMap = Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(alter_sentry_role_delete_users_args.class, metaDataMap);
+    }
+
+    public alter_sentry_role_delete_users_args() {
+    }
+
+    public alter_sentry_role_delete_users_args(
+      TAlterSentryRoleDeleteUsersRequest request)
+    {
+      this();
+      this.request = request;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public alter_sentry_role_delete_users_args(alter_sentry_role_delete_users_args other) {
+      if (other.isSetRequest()) {
+        this.request = new TAlterSentryRoleDeleteUsersRequest(other.request);
+      }
+    }
+
+    public alter_sentry_role_delete_users_args deepCopy() {
+      return new alter_sentry_role_delete_users_args(this);
+    }
+
+    @Override
+    public void clear() {
+      this.request = null;
+    }
+
+    public TAlterSentryRoleDeleteUsersRequest getRequest() {
+      return this.request;
+    }
+
+    public void setRequest(TAlterSentryRoleDeleteUsersRequest request) {
+      this.request = request;
+    }
+
+    public void unsetRequest() {
+      this.request = null;
+    }
+
+    /** Returns true if field request is set (has been assigned a value) and false otherwise */
+    public boolean isSetRequest() {
+      return this.request != null;
+    }
+
+    public void setRequestIsSet(boolean value) {
+      if (!value) {
+        this.request = null;
+      }
+    }
+
+    public void setFieldValue(_Fields field, Object value) {
+      switch (field) {
+      case REQUEST:
+        if (value == null) {
+          unsetRequest();
+        } else {
+          setRequest((TAlterSentryRoleDeleteUsersRequest)value);
+        }
+        break;
+
+      }
+    }
+
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case REQUEST:
+        return getRequest();
+
+      }
+      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 REQUEST:
+        return isSetRequest();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof alter_sentry_role_delete_users_args)
+        return this.equals((alter_sentry_role_delete_users_args)that);
+      return false;
+    }
+
+    public boolean equals(alter_sentry_role_delete_users_args that) {
+      if (that == null)
+        return false;
+
+      boolean this_present_request = true && this.isSetRequest();
+      boolean that_present_request = true && that.isSetRequest();
+      if (this_present_request || that_present_request) {
+        if (!(this_present_request && that_present_request))
+          return false;
+        if (!this.request.equals(that.request))
+          return false;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      HashCodeBuilder builder = new HashCodeBuilder();
+
+      boolean present_request = true && (isSetRequest());
+      builder.append(present_request);
+      if (present_request)
+        builder.append(request);
+
+      return builder.toHashCode();
+    }
+
+    public int compareTo(alter_sentry_role_delete_users_args other) {
+      if (!getClass().equals(other.getClass())) {
+        return getClass().getName().compareTo(other.getClass().getName());
+      }
+
+      int lastComparison = 0;
+      alter_sentry_role_delete_users_args typedOther = (alter_sentry_role_delete_users_args)other;
+
+      lastComparison = Boolean.valueOf(isSetRequest()).compareTo(typedOther.isSetRequest());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetRequest()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.request, typedOther.request);
+        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("alter_sentry_role_delete_users_args(");
+      boolean first = true;
+
+      sb.append("request:");
+      if (this.request == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.request);
+      }
+      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 (request != null) {
+        request.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 alter_sentry_role_delete_users_argsStandardSchemeFactory implements SchemeFactory {
+      public alter_sentry_role_delete_users_argsStandardScheme getScheme() {
+        return new alter_sentry_role_delete_users_argsStandardScheme();
+      }
+    }
+
+    private static class alter_sentry_role_delete_users_argsStandardScheme extends StandardScheme<alter_sentry_role_delete_users_args> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, alter_sentry_role_delete_users_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: // REQUEST
+              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+                struct.request = new TAlterSentryRoleDeleteUsersRequest();
+                struct.request.read(iprot);
+                struct.setRequestIsSet(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, alter_sentry_role_delete_users_args struct) throws org.apache.thrift.TException {
+        struct.validate();
+
+        oprot.writeStructBegin(STRUCT_DESC);
+        if (struct.request != null) {
+          oprot.writeFieldBegin(REQUEST_FIELD_DESC);
+          struct.request.write(oprot);
+          oprot.writeFieldEnd();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class alter_sentry_role_delete_users_argsTupleSchemeFactory implements SchemeFactory {
+      public alter_sentry_role_delete_users_argsTupleScheme getScheme() {
+        return new alter_sentry_role_delete_users_argsTupleScheme();
+      }
+    }
+
+    private static class alter_sentry_role_delete_users_argsTupleScheme extends TupleScheme<alter_sentry_role_delete_users_args> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, alter_sentry_role_delete_users_args struct) throws org.apache.thrift.TException {
+        TTupleProtocol oprot = (TTupleProtocol) prot;
+        BitSet optionals = new BitSet();
+        if (struct.isSetRequest()) {
+          optionals.set(0);
+        }
+        oprot.writeBitSet(optionals, 1);
+        if (struct.isSetRequest()) {
+          struct.request.write(oprot);
+        }
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, alter_sentry_role_delete_users_args struct) throws org.apache.thrift.TException {
+        TTupleProtocol iprot = (TTupleProtocol) prot;
+        BitSet incoming = iprot.readBitSet(1);
+        if (incoming.get(0)) {
+          struct.request = new TAlterSentryRoleDeleteUsersRequest();
+          struct.request.read(iprot);
+          struct.setRequestIsSet(true);
+        }
+      }
+    }
+
+  }
+
+  public static class alter_sentry_role_delete_users_result implements org.apache.thrift.TBase<alter_sentry_role_delete_users_result, alter_sentry_role_delete_users_result._Fields>, java.io.Serializable, Cloneable   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("alter_sentry_role_delete_users_result");
+
+    private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0);
+
+    private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+    static {
+      schemes.put(StandardScheme.class, new alter_sentry_role_delete_users_resultStandardSchemeFactory());
+      schemes.put(TupleScheme.class, new alter_sentry_role_delete_users_resultTupleSchemeFactory());
+    }
+
+    private TAlterSentryRoleDeleteUsersResponse success; // 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");
+
+      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 0: // SUCCESS
+            return SUCCESS;
+          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.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TAlterSentryRoleDeleteUsersResponse.class)));
+      metaDataMap = Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(alter_sentry_role_delete_users_result.class, metaDataMap);
+    }
+
+    public alter_sentry_role_delete_users_result() {
+    }
+
+    public alter_sentry_role_delete_users_result(
+      TAlterSentryRoleDeleteUsersResponse success)
+    {
+      this();
+      this.success = success;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public alter_sentry_role_delete_users_result(alter_sentry_role_delete_users_result other) {
+      if (other.isSetSuccess()) {
+        this.success = new TAlterSentryRoleDeleteUsersResponse(other.success);
+      }
+    }
+
+    public alter_sentry_role_delete_users_result deepCopy() {
+      return new alter_sentry_role_delete_users_result(this);
+    }
+
+    @Override
+    public void clear() {
+      this.success = null;
+    }
+
+    public TAlterSentryRoleDeleteUsersResponse getSuccess() {
+      return this.success;
+    }
+
+    public void setSuccess(TAlterSentryRoleDeleteUsersResponse 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 void setFieldValue(_Fields field, Object value) {
+      switch (field) {
+      case SUCCESS:
+        if (value == null) {
+          unsetSuccess();
+        } else {
+          setSuccess((TAlterSentryRoleDeleteUsersResponse)value);
+        }
+        break;
+
+      }
+    }
+
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case SUCCESS:
+        return getSuccess();
+
+      }
+      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();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof alter_sentry_role_delete_users_result)
+        return this.equals((alter_sentry_role_delete_users_result)that);
+      return false;
+    }
+
+    public boolean equals(alter_sentry_role_delete_users_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;
+      }
+
+      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);
+
+      return builder.toHashCode();
+    }
+
+    public int compareTo(alter_sentry_role_delete_users_result other) {
+      if (!getClass().equals(other.getClass())) {
+        return getClass().getName().compareTo(other.getClass().getName());
+      }
+
+      int lastComparison = 0;
+      alter_sentry_role_delete_users_result typedOther = (alter_sentry_role_delete_users_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;
+        }
+      }
+      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("alter_sentry_role_delete_users_result(");
+      boolean first = true;
+
+      sb.append("success:");
+      if (this.success == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.success);
+      }
+      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 alter_sentry_role_delete_users_resultStandardSchemeFactory implements SchemeFactory {
+      public alter_sentry_role_delete_users_resultStandardScheme getScheme() {
+        return new alter_sentry_role_delete_users_resultStandardScheme();
+      }
+    }
+
+    private static class alter_sentry_role_delete_users_resultStandardScheme extends StandardScheme<alter_sentry_role_delete_users_result> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, alter_sentry_role_delete_users_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 TAlterSentryRoleDeleteUsersResponse();
+                struct.success.read(iprot);
+                struct.setSuccessIsSet(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, alter_sentry_role_delete_users_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();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class alter_sentry_role_delete_users_resultTupleSchemeFactory implements SchemeFactory {
+      public alter_sentry_role_delete_users_resultTupleScheme getScheme() {
+        return new alter_sentry_role_delete_users_resultTupleScheme();
+      }
+    }
+
+    private static class alter_sentry_role_delete_users_resultTupleScheme extends TupleScheme<alter_sentry_role_delete_users_result> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, alter_sentry_role_delete_users_result struct) throws org.apache.thrift.TException {
+        TTupleProtocol oprot = (TTupleProtocol) prot;
+        BitSet optionals = new BitSet();
+        if (struct.isSetSuccess()) {
+          optionals.set(0);
+        }
+        oprot.writeBitSet(optionals, 1);
+        if (struct.isSetSuccess()) {
+          struct.success.write(oprot);
+        }
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, alter_sentry_role_delete_users_result struct) throws org.apache.thrift.TException {
+        TTupleProtocol iprot = (TTupleProtocol) prot;
+        BitSet incoming = iprot.readBitSet(1);
+        if (incoming.get(0)) {
+          struct.success = new TAlterSentryRoleDeleteUsersResponse();
+          struct.success.read(iprot);
+          struct.setSuccessIsSet(true);
+        }
+      }
+    }
+
+  }
+
+  public static class list_sentry_roles_by_group_args implements org.apache.thrift.TBase<list_sentry_roles_by_group_args, list_sentry_roles_by_group_args._Fields>, java.io.Serializable, Cloneable   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("list_sentry_roles_by_group_args");
+
+    private static final org.apache.thrift.protocol.TField REQUEST_FIELD_DESC = new org.apache.thrift.protocol.TField("request", org.apache.thrift.protocol.TType.STRUCT, (short)1);
+
+    private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+    static {
+      schemes.put(StandardScheme.class, new list_sentry_roles_by_group_argsStandardSchemeFactory());
+      schemes.put(TupleScheme.class, new list_sentry_roles_by_group_argsTupleSchemeFactory());
+    }
+
+    private TListSentryRolesRequest request; // 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 {
+      REQUEST((short)1, "request");
+
+      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: // REQUEST
+            return REQUEST;
+          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.REQUEST, new org.apache.thrift.meta_data.FieldMetaData("request", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TListSentryRolesRequest.class)));
+      metaDataMap = Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(list_sentry_roles_by_group_args.class, metaDataMap);
+    }
+
+    public list_sentry_roles_by_group_args() {
+    }
+
+    public list_sentry_roles_by_group_args(
+      TListSentryRolesRequest request)
+    {
+      this();
+      this.request = request;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public list_sentry_roles_by_group_args(list_sentry_roles_by_group_args other) {
+      if (other.isSetRequest()) {
+        this.request = new TListSentryRolesRequest(other.request);
+      }
+    }
+
+    public list_sentry_roles_by_group_args deepCopy() {
+      return new list_sentry_roles_by_group_args(this);
+    }
+
+    @Override
+    public void clear() {
+      this.request = null;
+    }
+
+    public TListSentryRolesRequest getRequest() {
+      return this.request;
+    }
+
+    public void setRequest(TListSentryRolesRequest request) {
+      this.request = request;
+    }
+
+    public void unsetRequest() {
+      this.request = null;
+    }
+
+    /** Returns true if field request is set (has been assigned a value) and false otherwise */
+    public boolean isSetRequest() {
+      return this.request != null;
+    }
+
+    public void setRequestIsSet(boolean value) {
+      if (!value) {
+        this.request = null;
+      }
+    }
+
+    public void setFieldValue(_Fields field, Object value) {
+      switch (field) {
+      case REQUEST:
+        if (value == null) {
+          unsetRequest();
+        } else {
+          setRequest((TListSentryRolesRequest)value);
+        }
+        break;
+
+      }
+    }
+
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case REQUEST:
+        return getRequest();
+
+      }
+      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 REQUEST:
+        return isSetRequest();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof list_sentry_roles_by_group_args)
+        return this.equals((list_sentry_roles_by_group_args)that);
+      return false;
+    }
+
+    public boolean equals(list_sentry_roles_by_group_args that) {
+      if (that == null)
+        return false;
+
+      boolean this_present_request = true && this.isSetRequest();
+      boolean that_present_request = true && that.isSetRequest();
+      if (this_present_request || that_present_request) {
+        if (!(this_present_request && that_present_request))
+          return false;
+        if (!this.request.equals(that.request))
+          return false;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      HashCodeBuilder builder = new HashCodeBuilder();
+
+      boolean present_request = true && (isSetRequest());
+      builder.append(present_request);
+      if (present_request)
+        builder.append(request);
+
+      return builder.toHashCode();
+    }
+
+    public int compareTo(list_sentry_roles_by_group_args other) {
+      if (!getClass().equals(other.getClass())) {
+        return getClass().getName().compareTo(other.getClass().getName());
+      }
+
+      int lastComparison = 0;
+      list_sentry_roles_by_group_args typedOther = (list_sentry_roles_by_group_args)other;
+
+      lastComparison = Boolean.valueOf(isSetRequest()).compareTo(typedOther.isSetRequest());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetRequest()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.request, typedOther.request);
+        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_sentry_roles_by_group_args(");
+      boolean first = true;
+
+      sb.append("request:");
+      if (this.request == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.request);
+      }
+      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 (request != null) {
+        request.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_sentry_roles_by_group_argsStandardSchemeFactory implements SchemeFactory {
+      public list_sentry_roles_by_group_argsStandardScheme getScheme() {
+        return new list_sentry_roles_by_group_argsStandardScheme();
+      }
+    }
+
+    private static class list_sentry_roles_by_group_argsStandardScheme extends StandardScheme<list_sentry_roles_by_group_args> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, list_sentry_roles_by_group_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: // REQUEST
+              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+                struct.request = new TListSentryRolesRequest();
+                struct.request.read(iprot);
+                struct.setRequestIsSet(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_sentry_roles_by_group_args struct) throws org.apache.thrift.TException {
+        struct.validate();
+
+        oprot.writeStructBegin(STRUCT_DESC);
+        if (struct.request != null) {
+          oprot.writeFieldBegin(REQUEST_FIELD_DESC);
+          struct.request.write(oprot);
+          oprot.writeFieldEnd();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class list_sentry_roles_by_group_argsTupleSchemeFactory implements SchemeFactory {
+      public list_sentry_roles_by_group_argsTupleScheme getScheme() {
+        return new list_sentry_roles_by_group_argsTupleScheme();
+      }
+    }
+
+    private static class list_sentry_roles_by_group_argsTupleScheme extends TupleScheme<list_sentry_roles_by_group_args> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, list_sentry_roles_by_group_args struct) throws org.apache.thrift.TException {
+        TTupleProtocol oprot = (TTupleProtocol) prot;
+        BitSet optionals = new BitSet();
+        if (struct.isSetRequest()) {
+          optionals.set(0);
+        }
+        oprot.writeBitSet(optionals, 1);
+        if (struct.isSetRequest()) {
+          struct.request.write(oprot);
+        }
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, list_sentry_roles_by_group_args struct) throws org.apache.thrift.TException {
+        TTupleProtocol iprot = (TTupleProtocol) prot;
+        BitSet incoming = iprot.readBitSet(1);
+        if (incoming.get(0)) {
+          struct.request = new TListSentryRolesRequest();
+          struct.request.read(iprot);
+          struct.setRequestIsSet(true);
+        }
+      }
+    }
+
+  }
+
+  public static class list_sentry_roles_by_group_result implements org.apache.thrift.TBase<list_sentry_roles_by_group_result, list_sentry_roles_by_group_result._Fields>, java.io.Serializable, Cloneable   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("list_sentry_roles_by_group_result");
+
+    private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0);
+
+    private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+    static {
+      schemes.put(StandardScheme.class, new list_sentry_roles_by_group_resultStandardSchemeFactory());
+      schemes.put(TupleScheme.class, new list_sentry_roles_by_group_resultTupleSchemeFactory());
+    }
+
+    private TListSentryRolesResponse success; // 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");
+
+      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 0: // SUCCESS
+            return SUCCESS;
+          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.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TListSentryRolesResponse.class)));
+      metaDataMap = Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(list_sentry_roles_by_group_result.class, metaDataMap);
+    }
+
+    public list_sentry_roles_by_group_result() {
+    }
+
+    public list_sentry_roles_by_group_result(
+      TListSentryRolesResponse success)
+    {
+      this();
+      this.success = success;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public list_sentry_roles_by_group_result(list_sentry_roles_by_group_result other) {
+      if (other.isSetSuccess()) {
+        this.success = new TListSentryRolesResponse(other.success);
+      }
+    }
+
+    public list_sentry_roles_by_group_result deepCopy() {
+      return new list_sentry_roles_by_group_result(this);
+    }
+
+    @Override
+    public void clear() {
+      this.success = null;
+    }
+
+    public TListSentryRolesResponse getSuccess() {
+      return this.success;
+    }
+
+    public void setSuccess(TListSentryRolesResponse 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 void setFieldValue(_Fields field, Object value) {
+      switch (field) {
+      case SUCCESS:
+        if (value == null) {
+          unsetSuccess();
+        } else {
+          setSuccess((TListSentryRolesResponse)value);
+        }
+        break;
+
+      }
+    }
+
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case SUCCESS:
+        return getSuccess();
+
+      }
+      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();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof list_sentry_roles_by_group_result)
+        return this.equals((list_sentry_roles_by_group_result)that);
+      return false;
+    }
+
+    public boolean equals(list_sentry_roles_by_group_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;
+      }
+
+      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);
+
+      return builder.toHashCode();
+    }
+
+    public int compareTo(list_sentry_roles_by_group_result other) {
+      if (!getClass().equals(other.getClass())) {
+        return getClass().getName().compareTo(other.getClass().getName());
+      }
+
+      int lastComparison = 0;
+      list_sentry_roles_by_group_result typedOther = (list_sentry_roles_by_group_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;
+        }
+      }
+      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_sentry_roles_by_group_result(");
+      boolean first = true;
+
+      sb.append("success:");
+      if (this.success == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.success);
+      }
+      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 list_sentry_roles_by_group_resultStandardSchemeFactory implements SchemeFactory {
+      public list_sentry_roles_by_group_resultStandardScheme getScheme() {
+        return new list_sentry_roles_by_group_resultStandardScheme();
+      }
+    }
+
+    private static class list_sentry_roles_by_group_resultStandardScheme extends StandardScheme<list_sentry_roles_by_group_result> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, list_sentry_roles_by_group_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 TListSentryRolesResponse();
+                struct.success.read(iprot);
+                struct.setSuccessIsSet(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(or

<TRUNCATED>

[6/6] sentry git commit: SENTRY-711: Implement grant user to role (Colin Ma, reviewed by Dapeng Sun)

Posted by sd...@apache.org.
SENTRY-711: Implement grant user to role (Colin Ma, reviewed by Dapeng Sun)


Project: http://git-wip-us.apache.org/repos/asf/sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/sentry/commit/68949951
Tree: http://git-wip-us.apache.org/repos/asf/sentry/tree/68949951
Diff: http://git-wip-us.apache.org/repos/asf/sentry/diff/68949951

Branch: refs/heads/master
Commit: 68949951e97b206766bf3e07d24399d80799e7af
Parents: 04881fa
Author: Colin Ma <co...@apache.org>
Authored: Wed Apr 13 15:03:56 2016 +0800
Committer: Colin Ma <co...@apache.org>
Committed: Thu Apr 14 09:21:55 2016 +0800

----------------------------------------------------------------------
 .../binding/hive/HiveAuthzBindingHookBase.java  |    8 +-
 .../hive/ql/exec/SentryGrantRevokeTask.java     |   29 +-
 .../SentryHiveAuthorizationTaskFactoryImpl.java |    4 +-
 .../TestSentryHiveAuthorizationTaskFactory.java |   50 +-
 .../sentry/policy/common/PolicyEngine.java      |   29 +
 .../sentry/policy/db/SimpleDBPolicyEngine.java  |   21 +
 .../indexer/SimpleIndexerPolicyEngine.java      |   21 +-
 .../policy/kafka/SimpleKafkaPolicyEngine.java   |   20 +
 .../policy/search/SimpleSearchPolicyEngine.java |   21 +-
 .../policy/sqoop/SimpleSqoopPolicyEngine.java   |   19 +
 .../sentry/provider/cache/PrivilegeCache.java   |    7 +
 .../cache/SimpleCacheProviderBackend.java       |   11 +
 .../provider/cache/SimplePrivilegeCache.java    |    8 +
 .../provider/cache/PrivilegeCacheTestImpl.java  |    5 +
 .../sentry/provider/common/ProviderBackend.java |    8 +-
 .../common/ResourceAuthorizationProvider.java   |   13 +-
 .../provider/common/TestGetGroupMapping.java    |   19 +-
 .../db/service/thrift/SentryPolicyService.java  | 2564 +++++++++++++++++-
 .../thrift/TAlterSentryRoleAddUsersRequest.java |  740 +++++
 .../TAlterSentryRoleAddUsersResponse.java       |  390 +++
 .../TAlterSentryRoleDeleteGroupsRequest.java    |   36 +-
 .../TAlterSentryRoleDeleteUsersRequest.java     |  740 +++++
 .../TAlterSentryRoleDeleteUsersResponse.java    |  390 +++
 .../TAlterSentryRoleGrantPrivilegeRequest.java  |   36 +-
 .../TAlterSentryRoleGrantPrivilegeResponse.java |   36 +-
 .../TAlterSentryRoleRevokePrivilegeRequest.java |   36 +-
 .../TListSentryPrivilegesByAuthRequest.java     |   68 +-
 .../TListSentryPrivilegesByAuthResponse.java    |   52 +-
 ...TListSentryPrivilegesForProviderRequest.java |  198 +-
 ...ListSentryPrivilegesForProviderResponse.java |   32 +-
 .../thrift/TListSentryPrivilegesResponse.java   |   36 +-
 .../thrift/TListSentryRolesForUserRequest.java  |  587 ++++
 .../thrift/TListSentryRolesResponse.java        |   36 +-
 .../db/service/thrift/TSentryActiveRoleSet.java |   32 +-
 .../db/service/thrift/TSentryMappingData.java   |  148 +-
 .../db/service/thrift/TSentryPrivilegeMap.java  |   76 +-
 .../provider/db/service/thrift/TSentryRole.java |   36 +-
 .../provider/db/SimpleDBProviderBackend.java    |   15 +-
 .../generic/SentryGenericProviderBackend.java   |    7 +
 .../db/log/entity/JsonLogEntityFactory.java     |   40 +
 .../provider/db/log/util/CommandUtil.java       |   28 +-
 .../sentry/provider/db/log/util/Constants.java  |   22 +-
 .../provider/db/service/model/MSentryRole.java  |   29 +-
 .../provider/db/service/model/MSentryUser.java  |  116 +
 .../provider/db/service/model/package.jdo       |   78 +-
 .../db/service/persistent/SentryStore.java      |  254 +-
 .../db/service/thrift/NotificationHandler.java  |    8 +
 .../thrift/NotificationHandlerInvoker.java      |   30 +
 .../thrift/SentryPolicyServiceClient.java       |   19 +-
 .../SentryPolicyServiceClientDefaultImpl.java   |   79 +-
 .../thrift/SentryPolicyStoreProcessor.java      |  155 +-
 .../main/resources/sentry_policy_service.thrift |   37 +-
 .../provider/db/log/util/TestCommandUtil.java   |   42 +-
 .../db/service/persistent/TestSentryStore.java  |  461 +++-
 .../TestSentryServerForHaWithoutKerberos.java   |   60 +-
 .../thrift/TestSentryServerWithoutKerberos.java |   59 +-
 .../thrift/TestSentryServiceIntegration.java    |  226 ++
 .../file/SimpleFileProviderBackend.java         |    7 +
 .../tests/e2e/dbprovider/TestDbDDLAuditLog.java |   18 +
 .../e2e/dbprovider/TestGrantUserToRole.java     |  237 ++
 60 files changed, 7938 insertions(+), 651 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-binding/sentry-binding-hive-common/src/main/java/org/apache/sentry/binding/hive/HiveAuthzBindingHookBase.java
----------------------------------------------------------------------
diff --git a/sentry-binding/sentry-binding-hive-common/src/main/java/org/apache/sentry/binding/hive/HiveAuthzBindingHookBase.java b/sentry-binding/sentry-binding-hive-common/src/main/java/org/apache/sentry/binding/hive/HiveAuthzBindingHookBase.java
index 6df939f..a00f2d5 100644
--- a/sentry-binding/sentry-binding-hive-common/src/main/java/org/apache/sentry/binding/hive/HiveAuthzBindingHookBase.java
+++ b/sentry-binding/sentry-binding-hive-common/src/main/java/org/apache/sentry/binding/hive/HiveAuthzBindingHookBase.java
@@ -75,6 +75,7 @@ import org.slf4j.LoggerFactory;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Splitter;
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Sets;
 
 public abstract class HiveAuthzBindingHookBase extends AbstractSemanticAnalyzerHook {
   private static final Logger LOG = LoggerFactory
@@ -747,9 +748,10 @@ public abstract class HiveAuthzBindingHookBase extends AbstractSemanticAnalyzerH
       String userName) throws SemanticException {
     // get the original HiveAuthzBinding, and get the user's privileges by AuthorizationProvider
     AuthorizationProvider authProvider = hiveAuthzBinding.getCurrentAuthProvider();
-    Set<String> userPrivileges = authProvider.getPolicyEngine().getPrivileges(
-            authProvider.getGroupMapping().getGroups(userName), hiveAuthzBinding.getActiveRoleSet(),
-            hiveAuthzBinding.getAuthServer());
+    Set<String> userPrivileges =
+        authProvider.getPolicyEngine().getPrivileges(
+            authProvider.getGroupMapping().getGroups(userName), Sets.newHashSet(userName),
+            hiveAuthzBinding.getActiveRoleSet(), hiveAuthzBinding.getAuthServer());
 
     // create PrivilegeCache using user's privileges
     PrivilegeCache privilegeCache = new SimplePrivilegeCache(userPrivileges);

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-binding/sentry-binding-hive/src/main/java/org/apache/hadoop/hive/ql/exec/SentryGrantRevokeTask.java
----------------------------------------------------------------------
diff --git a/sentry-binding/sentry-binding-hive/src/main/java/org/apache/hadoop/hive/ql/exec/SentryGrantRevokeTask.java b/sentry-binding/sentry-binding-hive/src/main/java/org/apache/hadoop/hive/ql/exec/SentryGrantRevokeTask.java
index cd8352a..217b7b3 100644
--- a/sentry-binding/sentry-binding-hive/src/main/java/org/apache/hadoop/hive/ql/exec/SentryGrantRevokeTask.java
+++ b/sentry-binding/sentry-binding-hive/src/main/java/org/apache/hadoop/hive/ql/exec/SentryGrantRevokeTask.java
@@ -237,11 +237,14 @@ public class SentryGrantRevokeTask extends Task<DDLWork> implements Serializable
       } else if (operation.equals(RoleDDLDesc.RoleOperation.SHOW_ROLE_GRANT)) {
         Set<TSentryRole> roles;
         PrincipalType principalType = desc.getPrincipalType();
-        if (principalType != PrincipalType.GROUP) {
+        if (principalType == PrincipalType.GROUP) {
+          roles = sentryClient.listRolesByGroupName(subject, name);
+        } else if (principalType == PrincipalType.USER) {
+          roles = sentryClient.listRolesByUserName(subject, name);
+        } else {
           String msg = SentryHiveConstants.GRANT_REVOKE_NOT_SUPPORTED_FOR_PRINCIPAL + principalType;
           throw new HiveException(msg);
         }
-        roles = sentryClient.listRolesByGroupName(subject, desc.getName() );
         writeToFile(writeRoleGrantsInfo(roles), desc.getResFile());
         return RETURN_CODE_SUCCESS;
       } else if(operation.equals(RoleDDLDesc.RoleOperation.SHOW_ROLES)) {
@@ -407,21 +410,35 @@ public class SentryGrantRevokeTask extends Task<DDLWork> implements Serializable
       List<String> roles = desc.getRoles();
       // get principals
       Set<String> groups = Sets.newHashSet();
+      Set<String> users = Sets.newHashSet();
       for (PrincipalDesc principal : principals) {
-        if (principal.getType() != PrincipalType.GROUP) {
+        if (principal.getType() == PrincipalType.GROUP) {
+          groups.add(principal.getName());
+        } else if (principal.getType() == PrincipalType.USER) {
+          users.add(principal.getName());
+        } else {
           String msg = SentryHiveConstants.GRANT_REVOKE_NOT_SUPPORTED_FOR_PRINCIPAL +
               principal.getType();
           throw new HiveException(msg);
         }
-        groups.add(principal.getName());
       }
 
       // grant/revoke role to/from principals
       for (String roleName : roles) {
         if (grantRole) {
-          sentryClient.grantRoleToGroups(subject, roleName, groups);
+          if (groups.size() > 0) {
+            sentryClient.grantRoleToGroups(subject, roleName, groups);
+          }
+          if (users.size() > 0) {
+            sentryClient.grantRoleToUsers(subject, roleName, users);
+          }
         } else {
-          sentryClient.revokeRoleFromGroups(subject, roleName, groups);
+          if (groups.size() > 0) {
+            sentryClient.revokeRoleFromGroups(subject, roleName, groups);
+          }
+          if (users.size() > 0) {
+            sentryClient.revokeRoleFromUsers(subject, roleName, users);
+          }
         }
       }
 

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/SentryHiveAuthorizationTaskFactoryImpl.java
----------------------------------------------------------------------
diff --git a/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/SentryHiveAuthorizationTaskFactoryImpl.java b/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/SentryHiveAuthorizationTaskFactoryImpl.java
index caf32cf..0d1db89 100644
--- a/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/SentryHiveAuthorizationTaskFactoryImpl.java
+++ b/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/SentryHiveAuthorizationTaskFactoryImpl.java
@@ -102,7 +102,7 @@ public class SentryHiveAuthorizationTaskFactoryImpl implements HiveAuthorization
       principalType = PrincipalType.ROLE;
       break;
     }
-    if (principalType != PrincipalType.GROUP) {
+    if (principalType != PrincipalType.GROUP  && principalType != PrincipalType.USER) {
       String msg = SentryHiveConstants.GRANT_REVOKE_NOT_SUPPORTED_FOR_PRINCIPAL + principalType;
       throw new SemanticException(msg);
     }
@@ -241,7 +241,7 @@ public class SentryHiveAuthorizationTaskFactoryImpl implements HiveAuthorization
       roleOwnerName = SessionState.get().getAuthenticator().getUserName();
     }
     for (PrincipalDesc princ : principalDesc) {
-      if (princ.getType() != PrincipalType.GROUP) {
+      if (princ.getType() != PrincipalType.GROUP && princ.getType() != PrincipalType.USER) {
         String msg = SentryHiveConstants.GRANT_REVOKE_NOT_SUPPORTED_ON_OBJECT + princ.getType();
         throw new SemanticException(msg);
       }

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-binding/sentry-binding-hive/src/test/java/org/apache/sentry/binding/hive/TestSentryHiveAuthorizationTaskFactory.java
----------------------------------------------------------------------
diff --git a/sentry-binding/sentry-binding-hive/src/test/java/org/apache/sentry/binding/hive/TestSentryHiveAuthorizationTaskFactory.java b/sentry-binding/sentry-binding-hive/src/test/java/org/apache/sentry/binding/hive/TestSentryHiveAuthorizationTaskFactory.java
index dfe93a5..4fcb71c 100644
--- a/sentry-binding/sentry-binding-hive/src/test/java/org/apache/sentry/binding/hive/TestSentryHiveAuthorizationTaskFactory.java
+++ b/sentry-binding/sentry-binding-hive/src/test/java/org/apache/sentry/binding/hive/TestSentryHiveAuthorizationTaskFactory.java
@@ -17,6 +17,11 @@
  */
 package org.apache.sentry.binding.hive;
 
+import java.io.File;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.List;
+
 import org.junit.Assert;
 
 import org.apache.commons.io.FileUtils;
@@ -54,11 +59,6 @@ import org.mockito.Mockito;
 
 import com.google.common.io.Files;
 
-import java.io.File;
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.List;
-
 public class TestSentryHiveAuthorizationTaskFactory {
 
   private static final String ALL = "ALL";
@@ -237,8 +237,20 @@ public class TestSentryHiveAuthorizationTaskFactory {
    */
   @Test
   public void testGrantRoleUser() throws Exception {
-    expectSemanticException("GRANT ROLE " + ROLE + " TO USER " + USER,
-        SentryHiveConstants.GRANT_REVOKE_NOT_SUPPORTED_ON_OBJECT + "USER");
+    DDLWork work = analyze(parse("GRANT ROLE " + ROLE + " TO USER " + USER));
+    GrantRevokeRoleDDL grantDesc = work.getGrantRevokeRoleDDL();
+    Assert.assertNotNull("Grant should not be null", grantDesc);
+    Assert.assertTrue("Expected grant ", grantDesc.getGrant());
+    Assert.assertFalse("Grant option should be false", grantDesc.isGrantOption());
+    Assert.assertEquals(currentUser, grantDesc.getGrantor());
+    Assert.assertEquals(PrincipalType.USER, grantDesc.getGrantorType());
+    for (String role : assertSize(1, grantDesc.getRoles())) {
+      Assert.assertEquals(ROLE, role);
+    }
+    for (PrincipalDesc principal : assertSize(1, grantDesc.getPrincipalDesc())) {
+      Assert.assertEquals(PrincipalType.USER, principal.getType());
+      Assert.assertEquals(USER, principal.getName());
+    }
   }
 
   /**
@@ -277,8 +289,20 @@ public class TestSentryHiveAuthorizationTaskFactory {
    */
   @Test
   public void testRevokeRoleUser() throws Exception {
-    expectSemanticException("REVOKE ROLE " + ROLE + " FROM USER " + USER,
-        SentryHiveConstants.GRANT_REVOKE_NOT_SUPPORTED_ON_OBJECT + "USER");
+    DDLWork work = analyze(parse("REVOKE ROLE " + ROLE + " FROM USER " + USER));
+    GrantRevokeRoleDDL grantDesc = work.getGrantRevokeRoleDDL();
+    Assert.assertNotNull("Grant should not be null", grantDesc);
+    Assert.assertFalse("Did not expect grant ", grantDesc.getGrant());
+    Assert.assertFalse("Grant option is always true ", grantDesc.isGrantOption());
+    Assert.assertEquals(currentUser, grantDesc.getGrantor());
+    Assert.assertEquals(PrincipalType.USER, grantDesc.getGrantorType());
+    for (String role : assertSize(1, grantDesc.getRoles())) {
+      Assert.assertEquals(ROLE, role);
+    }
+    for (PrincipalDesc principal : assertSize(1, grantDesc.getPrincipalDesc())) {
+      Assert.assertEquals(PrincipalType.USER, principal.getType());
+      Assert.assertEquals(USER, principal.getName());
+    }
   }
 
   /**
@@ -316,8 +340,12 @@ public class TestSentryHiveAuthorizationTaskFactory {
    */
   @Test
   public void testShowRoleGrantUser() throws Exception {
-    expectSemanticException("SHOW ROLE GRANT USER " + USER,
-        SentryHiveConstants.GRANT_REVOKE_NOT_SUPPORTED_FOR_PRINCIPAL + "USER");
+    DDLWork work = analyze(parse("SHOW ROLE GRANT USER " + USER));
+    RoleDDLDesc roleDesc = work.getRoleDDLDesc();
+    Assert.assertNotNull("Role should not be null", roleDesc);
+    Assert.assertEquals(RoleOperation.SHOW_ROLE_GRANT, roleDesc.getOperation());
+    Assert.assertEquals(PrincipalType.USER, roleDesc.getPrincipalType());
+    Assert.assertEquals(USER, roleDesc.getName());
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-policy/sentry-policy-common/src/main/java/org/apache/sentry/policy/common/PolicyEngine.java
----------------------------------------------------------------------
diff --git a/sentry-policy/sentry-policy-common/src/main/java/org/apache/sentry/policy/common/PolicyEngine.java b/sentry-policy/sentry-policy-common/src/main/java/org/apache/sentry/policy/common/PolicyEngine.java
index bbb009c..b7d8c32 100644
--- a/sentry-policy/sentry-policy-common/src/main/java/org/apache/sentry/policy/common/PolicyEngine.java
+++ b/sentry-policy/sentry-policy-common/src/main/java/org/apache/sentry/policy/common/PolicyEngine.java
@@ -53,6 +53,20 @@ public interface PolicyEngine {
       throws SentryConfigurationException;
 
   /**
+   * Get privileges associated with groups and users. Returns Strings which can be resolved by the
+   * caller. Strings are returned to separate the PolicyFile class from the type of privileges used
+   * in a policy file. Additionally it is possible further processing of the privileges is needed
+   * before resolving to a privilege object.
+   *
+   * @param group name
+   * @param user name
+   * @param active role-set
+   * @return non-null immutable set of privileges
+   */
+  ImmutableSet<String> getAllPrivileges(Set<String> groups, Set<String> users, ActiveRoleSet roleSet)
+      throws SentryConfigurationException;
+
+  /**
    * Get privileges associated with a group. Returns Strings which can be resolved
    * by the caller. Strings are returned to separate the PolicyFile class from the
    * type of privileges used in a policy file. Additionally it is possible further
@@ -65,6 +79,21 @@ public interface PolicyEngine {
   ImmutableSet<String> getPrivileges(Set<String> groups, ActiveRoleSet roleSet, Authorizable... authorizableHierarchy)
       throws SentryConfigurationException;
 
+  /**
+   * Get privileges associated with groups and users. Returns Strings which can be resolved by the
+   * caller. Strings are returned to separate the PolicyFile class from the type of privileges used
+   * in a policy file. Additionally it is possible further processing of the privileges is needed
+   * before resolving to a privilege object.
+   *
+   * @param group name
+   * @param user name
+   * @param active role-set
+   * @param authorizable Hierarchy (Can be null)
+   * @return non-null immutable set of privileges
+   */
+  ImmutableSet<String> getPrivileges(Set<String> groups, Set<String> users, ActiveRoleSet roleSet,
+      Authorizable... authorizableHierarchy) throws SentryConfigurationException;
+
   void close();
 
   void validatePolicy(boolean strictValidation) throws SentryConfigurationException;

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-policy/sentry-policy-db/src/main/java/org/apache/sentry/policy/db/SimpleDBPolicyEngine.java
----------------------------------------------------------------------
diff --git a/sentry-policy/sentry-policy-db/src/main/java/org/apache/sentry/policy/db/SimpleDBPolicyEngine.java b/sentry-policy/sentry-policy-db/src/main/java/org/apache/sentry/policy/db/SimpleDBPolicyEngine.java
index b5b584f..9d25592 100644
--- a/sentry-policy/sentry-policy-db/src/main/java/org/apache/sentry/policy/db/SimpleDBPolicyEngine.java
+++ b/sentry-policy/sentry-policy-db/src/main/java/org/apache/sentry/policy/db/SimpleDBPolicyEngine.java
@@ -65,6 +65,12 @@ public class SimpleDBPolicyEngine implements PolicyEngine {
     return getPrivileges(groups, roleSet);
   }
 
+  @Override
+  public ImmutableSet<String> getAllPrivileges(Set<String> groups, Set<String> users,
+      ActiveRoleSet roleSet) throws SentryConfigurationException {
+    return getPrivileges(groups, users, roleSet);
+  }
+
   /**
    * {@inheritDoc}
    */
@@ -82,6 +88,21 @@ public class SimpleDBPolicyEngine implements PolicyEngine {
   }
 
   @Override
+  public ImmutableSet<String> getPrivileges(Set<String> groups, Set<String> users,
+      ActiveRoleSet roleSet, Authorizable... authorizableHierarchy)
+      throws SentryConfigurationException {
+    if (LOGGER.isDebugEnabled()) {
+      LOGGER.debug("Getting permissions for groups: {}, users: {}", groups, users);
+    }
+    ImmutableSet<String> result = providerBackend.getPrivileges(groups, users, roleSet,
+        authorizableHierarchy);
+    if (LOGGER.isDebugEnabled()) {
+      LOGGER.debug("result = " + result);
+    }
+    return result;
+  }
+
+  @Override
   public void validatePolicy(boolean strictValidation) throws SentryConfigurationException {
     this.providerBackend.validatePolicy(strictValidation);
   }

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-policy/sentry-policy-indexer/src/main/java/org/apache/sentry/policy/indexer/SimpleIndexerPolicyEngine.java
----------------------------------------------------------------------
diff --git a/sentry-policy/sentry-policy-indexer/src/main/java/org/apache/sentry/policy/indexer/SimpleIndexerPolicyEngine.java b/sentry-policy/sentry-policy-indexer/src/main/java/org/apache/sentry/policy/indexer/SimpleIndexerPolicyEngine.java
index 2f4bc1d..8914319 100644
--- a/sentry-policy/sentry-policy-indexer/src/main/java/org/apache/sentry/policy/indexer/SimpleIndexerPolicyEngine.java
+++ b/sentry-policy/sentry-policy-indexer/src/main/java/org/apache/sentry/policy/indexer/SimpleIndexerPolicyEngine.java
@@ -21,8 +21,8 @@ import java.util.Set;
 import org.apache.sentry.core.common.ActiveRoleSet;
 import org.apache.sentry.core.common.Authorizable;
 import org.apache.sentry.core.common.SentryConfigurationException;
-import org.apache.sentry.policy.common.PrivilegeFactory;
 import org.apache.sentry.policy.common.PolicyEngine;
+import org.apache.sentry.policy.common.PrivilegeFactory;
 import org.apache.sentry.policy.common.PrivilegeValidator;
 import org.apache.sentry.provider.common.ProviderBackend;
 import org.apache.sentry.provider.common.ProviderBackendContext;
@@ -67,6 +67,12 @@ public class SimpleIndexerPolicyEngine implements PolicyEngine {
     return getPrivileges(groups, roleSet);
   }
 
+  @Override
+  public ImmutableSet<String> getAllPrivileges(Set<String> groups, Set<String> users,
+      ActiveRoleSet roleSet) throws SentryConfigurationException {
+    return getPrivileges(groups, users, roleSet);
+  }
+
   /**
    * {@inheritDoc}
    */
@@ -83,6 +89,19 @@ public class SimpleIndexerPolicyEngine implements PolicyEngine {
   }
 
   @Override
+  public ImmutableSet<String> getPrivileges(Set<String> groups, Set<String> users,
+      ActiveRoleSet roleSet, Authorizable... authorizationHierarchy) {
+    if(LOGGER.isDebugEnabled()) {
+      LOGGER.debug("Getting permissions for groups: {}, users: {}", groups, users);
+    }
+    ImmutableSet<String> result = providerBackend.getPrivileges(groups, users, roleSet);
+    if(LOGGER.isDebugEnabled()) {
+      LOGGER.debug("result = " + result);
+    }
+    return result;
+  }
+
+  @Override
   public void validatePolicy(boolean strictValidation)
       throws SentryConfigurationException {
     throw new SentryConfigurationException("Not implemented yet");

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-policy/sentry-policy-kafka/src/main/java/org/apache/sentry/policy/kafka/SimpleKafkaPolicyEngine.java
----------------------------------------------------------------------
diff --git a/sentry-policy/sentry-policy-kafka/src/main/java/org/apache/sentry/policy/kafka/SimpleKafkaPolicyEngine.java b/sentry-policy/sentry-policy-kafka/src/main/java/org/apache/sentry/policy/kafka/SimpleKafkaPolicyEngine.java
index 7e043e1..4d90544 100644
--- a/sentry-policy/sentry-policy-kafka/src/main/java/org/apache/sentry/policy/kafka/SimpleKafkaPolicyEngine.java
+++ b/sentry-policy/sentry-policy-kafka/src/main/java/org/apache/sentry/policy/kafka/SimpleKafkaPolicyEngine.java
@@ -84,4 +84,24 @@ public class SimpleKafkaPolicyEngine implements PolicyEngine {
     }
   }
 
+  @Override
+  public ImmutableSet<String> getAllPrivileges(Set<String> groups, Set<String> users,
+      ActiveRoleSet roleSet) throws SentryConfigurationException {
+    return getPrivileges(groups, users, roleSet);
+  }
+
+  @Override
+  public ImmutableSet<String> getPrivileges(Set<String> groups, Set<String> users,
+      ActiveRoleSet roleSet, Authorizable... authorizableHierarchy)
+      throws SentryConfigurationException {
+    if(LOGGER.isDebugEnabled()) {
+      LOGGER.debug("Getting permissions for groups: {}, users: {}", groups, users);
+    }
+    ImmutableSet<String> result = providerBackend.getPrivileges(groups, users, roleSet);
+    if(LOGGER.isDebugEnabled()) {
+      LOGGER.debug("result = " + result);
+    }
+    return result;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-policy/sentry-policy-search/src/main/java/org/apache/sentry/policy/search/SimpleSearchPolicyEngine.java
----------------------------------------------------------------------
diff --git a/sentry-policy/sentry-policy-search/src/main/java/org/apache/sentry/policy/search/SimpleSearchPolicyEngine.java b/sentry-policy/sentry-policy-search/src/main/java/org/apache/sentry/policy/search/SimpleSearchPolicyEngine.java
index bc518fb..c71036e 100644
--- a/sentry-policy/sentry-policy-search/src/main/java/org/apache/sentry/policy/search/SimpleSearchPolicyEngine.java
+++ b/sentry-policy/sentry-policy-search/src/main/java/org/apache/sentry/policy/search/SimpleSearchPolicyEngine.java
@@ -21,8 +21,8 @@ import java.util.Set;
 import org.apache.sentry.core.common.ActiveRoleSet;
 import org.apache.sentry.core.common.Authorizable;
 import org.apache.sentry.core.common.SentryConfigurationException;
-import org.apache.sentry.policy.common.PrivilegeFactory;
 import org.apache.sentry.policy.common.PolicyEngine;
+import org.apache.sentry.policy.common.PrivilegeFactory;
 import org.apache.sentry.policy.common.PrivilegeValidator;
 import org.apache.sentry.provider.common.ProviderBackend;
 import org.apache.sentry.provider.common.ProviderBackendContext;
@@ -83,6 +83,25 @@ public class SimpleSearchPolicyEngine implements PolicyEngine {
   }
 
   @Override
+  public ImmutableSet<String> getAllPrivileges(Set<String> groups, Set<String> users,
+      ActiveRoleSet roleSet) throws SentryConfigurationException {
+    return getPrivileges(groups, users, roleSet);
+  }
+
+  @Override
+  public ImmutableSet<String> getPrivileges(Set<String> groups, Set<String> users,
+      ActiveRoleSet roleSet, Authorizable... authorizationHierarchy) {
+    if (LOGGER.isDebugEnabled()) {
+      LOGGER.debug("Getting permissions for groups: {}, users: {}", groups, users);
+    }
+    ImmutableSet<String> result = providerBackend.getPrivileges(groups, users, roleSet);
+    if (LOGGER.isDebugEnabled()) {
+      LOGGER.debug("result = " + result);
+    }
+    return result;
+  }
+
+  @Override
   public void validatePolicy(boolean strictValidation)
       throws SentryConfigurationException {
     providerBackend.validatePolicy(strictValidation);

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-policy/sentry-policy-sqoop/src/main/java/org/apache/sentry/policy/sqoop/SimpleSqoopPolicyEngine.java
----------------------------------------------------------------------
diff --git a/sentry-policy/sentry-policy-sqoop/src/main/java/org/apache/sentry/policy/sqoop/SimpleSqoopPolicyEngine.java b/sentry-policy/sentry-policy-sqoop/src/main/java/org/apache/sentry/policy/sqoop/SimpleSqoopPolicyEngine.java
index e8615a0..13f78c6 100644
--- a/sentry-policy/sentry-policy-sqoop/src/main/java/org/apache/sentry/policy/sqoop/SimpleSqoopPolicyEngine.java
+++ b/sentry-policy/sentry-policy-sqoop/src/main/java/org/apache/sentry/policy/sqoop/SimpleSqoopPolicyEngine.java
@@ -69,6 +69,25 @@ public class SimpleSqoopPolicyEngine implements PolicyEngine {
   }
 
   @Override
+  public ImmutableSet<String> getAllPrivileges(Set<String> groups, Set<String> users,
+      ActiveRoleSet roleSet) throws SentryConfigurationException {
+    return getPrivileges(groups, users, roleSet);
+  }
+
+  @Override
+  public ImmutableSet<String> getPrivileges(Set<String> groups, Set<String> users,
+      ActiveRoleSet roleSet, Authorizable... authorizationHierarchy) {
+    if(LOGGER.isDebugEnabled()) {
+      LOGGER.debug("Getting permissions for groups: {}, users: {}", groups, users);
+    }
+    ImmutableSet<String> result = providerBackend.getPrivileges(groups, users, roleSet);
+    if(LOGGER.isDebugEnabled()) {
+      LOGGER.debug("result = " + result);
+    }
+    return result;
+  }
+
+  @Override
   public void close() {
     if (providerBackend != null) {
       providerBackend.close();

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-cache/src/main/java/org/apache/sentry/provider/cache/PrivilegeCache.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-cache/src/main/java/org/apache/sentry/provider/cache/PrivilegeCache.java b/sentry-provider/sentry-provider-cache/src/main/java/org/apache/sentry/provider/cache/PrivilegeCache.java
index 811b931..28c5b76 100644
--- a/sentry-provider/sentry-provider-cache/src/main/java/org/apache/sentry/provider/cache/PrivilegeCache.java
+++ b/sentry-provider/sentry-provider-cache/src/main/java/org/apache/sentry/provider/cache/PrivilegeCache.java
@@ -29,5 +29,12 @@ public interface PrivilegeCache {
   Set<String> listPrivileges(Set<String> groups,
       ActiveRoleSet roleSet);
 
+  /**
+   * Get the privileges for the give set of groups and users with the give active
+   * roles from the cache.
+   */
+  Set<String> listPrivileges(Set<String> groups, Set<String> users,
+      ActiveRoleSet roleSet);
+
   void close();
 }

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-cache/src/main/java/org/apache/sentry/provider/cache/SimpleCacheProviderBackend.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-cache/src/main/java/org/apache/sentry/provider/cache/SimpleCacheProviderBackend.java b/sentry-provider/sentry-provider-cache/src/main/java/org/apache/sentry/provider/cache/SimpleCacheProviderBackend.java
index 73ed6c2..d8b9063 100644
--- a/sentry-provider/sentry-provider-cache/src/main/java/org/apache/sentry/provider/cache/SimpleCacheProviderBackend.java
+++ b/sentry-provider/sentry-provider-cache/src/main/java/org/apache/sentry/provider/cache/SimpleCacheProviderBackend.java
@@ -66,6 +66,17 @@ public class SimpleCacheProviderBackend implements ProviderBackend {
   }
 
   @Override
+  public ImmutableSet<String> getPrivileges(Set<String> groups, Set<String> users,
+      ActiveRoleSet roleSet, Authorizable... authorizableHierarchy) {
+    if (!initialized()) {
+      throw new IllegalStateException(
+          "Backend has not been properly initialized");
+    }
+    return ImmutableSet.copyOf(cacheHandle.listPrivileges(groups, users,
+        roleSet));
+  }
+
+  @Override
   public ImmutableSet<String> getRoles(Set<String> groups, ActiveRoleSet roleSet) {
     if (!initialized()) {
       throw new IllegalStateException(

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-cache/src/main/java/org/apache/sentry/provider/cache/SimplePrivilegeCache.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-cache/src/main/java/org/apache/sentry/provider/cache/SimplePrivilegeCache.java b/sentry-provider/sentry-provider-cache/src/main/java/org/apache/sentry/provider/cache/SimplePrivilegeCache.java
index 2643a32..dd0c39a 100644
--- a/sentry-provider/sentry-provider-cache/src/main/java/org/apache/sentry/provider/cache/SimplePrivilegeCache.java
+++ b/sentry-provider/sentry-provider-cache/src/main/java/org/apache/sentry/provider/cache/SimplePrivilegeCache.java
@@ -48,4 +48,12 @@ public class SimplePrivilegeCache implements PrivilegeCache {
       cachedPrivileges.clear();
     }
   }
+
+  @Override
+  public Set<String> listPrivileges(Set<String> groups, Set<String> users, ActiveRoleSet roleSet) {
+    if (cachedPrivileges == null) {
+      cachedPrivileges = new HashSet<String>();
+    }
+    return cachedPrivileges;
+  }
 }

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-cache/src/test/java/org/apache/sentry/provider/cache/PrivilegeCacheTestImpl.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-cache/src/test/java/org/apache/sentry/provider/cache/PrivilegeCacheTestImpl.java b/sentry-provider/sentry-provider-cache/src/test/java/org/apache/sentry/provider/cache/PrivilegeCacheTestImpl.java
index a7566e7..79e047e 100644
--- a/sentry-provider/sentry-provider-cache/src/test/java/org/apache/sentry/provider/cache/PrivilegeCacheTestImpl.java
+++ b/sentry-provider/sentry-provider-cache/src/test/java/org/apache/sentry/provider/cache/PrivilegeCacheTestImpl.java
@@ -60,4 +60,9 @@ public class PrivilegeCacheTestImpl implements PrivilegeCache {
       FileUtils.deleteQuietly(baseDir);
     }
   }
+
+  @Override
+  public Set<String> listPrivileges(Set<String> groups, Set<String> users, ActiveRoleSet roleSet) {
+    return backend.getPrivileges(groups, users, roleSet);
+  }
 }

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-common/src/main/java/org/apache/sentry/provider/common/ProviderBackend.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-common/src/main/java/org/apache/sentry/provider/common/ProviderBackend.java b/sentry-provider/sentry-provider-common/src/main/java/org/apache/sentry/provider/common/ProviderBackend.java
index b19a170..ffd3af4 100644
--- a/sentry-provider/sentry-provider-common/src/main/java/org/apache/sentry/provider/common/ProviderBackend.java
+++ b/sentry-provider/sentry-provider-common/src/main/java/org/apache/sentry/provider/common/ProviderBackend.java
@@ -45,11 +45,17 @@ public interface ProviderBackend {
   void initialize(ProviderBackendContext context);
 
   /**
-   * Get the privileges from the backend.
+   * Get the privileges from the backend for groups.
    */
   ImmutableSet<String> getPrivileges(Set<String> groups, ActiveRoleSet roleSet, Authorizable... authorizableHierarchy);
 
   /**
+   * Get the privileges from the backend for users and groups.
+   */
+  ImmutableSet<String> getPrivileges(Set<String> groups, Set<String> users,
+      ActiveRoleSet roleSet, Authorizable... authorizableHierarchy);
+
+  /**
    * Get the roles associated with the groups from the backend.
    */
   ImmutableSet<String> getRoles(Set<String> groups, ActiveRoleSet roleSet);

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-common/src/main/java/org/apache/sentry/provider/common/ResourceAuthorizationProvider.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-common/src/main/java/org/apache/sentry/provider/common/ResourceAuthorizationProvider.java b/sentry-provider/sentry-provider-common/src/main/java/org/apache/sentry/provider/common/ResourceAuthorizationProvider.java
index 0cf0b5d..b023c9a 100644
--- a/sentry-provider/sentry-provider-common/src/main/java/org/apache/sentry/provider/common/ResourceAuthorizationProvider.java
+++ b/sentry-provider/sentry-provider-common/src/main/java/org/apache/sentry/provider/common/ResourceAuthorizationProvider.java
@@ -95,12 +95,14 @@ public abstract class ResourceAuthorizationProvider implements AuthorizationProv
       List<? extends Authorizable> authorizables, Set<? extends Action> actions,
       ActiveRoleSet roleSet) {
     Set<String> groups =  getGroups(subject);
+    Set<String> users = Sets.newHashSet(subject.getName());
     Set<String> hierarchy = new HashSet<String>();
     for (Authorizable authorizable : authorizables) {
       hierarchy.add(KV_JOINER.join(authorizable.getTypeName(), authorizable.getName()));
     }
     List<String> requestPrivileges = buildPermissions(authorizables, actions);
-    Iterable<Privilege> privileges = getPrivileges(groups, roleSet, authorizables.toArray(new Authorizable[0]));
+    Iterable<Privilege> privileges = getPrivileges(groups, users, roleSet,
+        authorizables.toArray(new Authorizable[0]));
     lastFailedPrivileges.get().clear();
 
     for (String requestPrivilege : requestPrivileges) {
@@ -123,8 +125,10 @@ public abstract class ResourceAuthorizationProvider implements AuthorizationProv
     return false;
   }
 
-  private Iterable<Privilege> getPrivileges(Set<String> groups, ActiveRoleSet roleSet, Authorizable[] authorizables) {
-    return Iterables.transform(appendDefaultDBPriv(policy.getPrivileges(groups, roleSet, authorizables), authorizables),
+  private Iterable<Privilege> getPrivileges(Set<String> groups, Set<String> users,
+      ActiveRoleSet roleSet, Authorizable[] authorizables) {
+    ImmutableSet<String> privileges = policy.getPrivileges(groups, users, roleSet, authorizables);
+    return Iterables.transform(appendDefaultDBPriv(privileges, authorizables),
         new Function<String, Privilege>() {
       @Override
       public Privilege apply(String privilege) {
@@ -172,7 +176,8 @@ public abstract class ResourceAuthorizationProvider implements AuthorizationProv
 
   @Override
   public Set<String> listPrivilegesForSubject(Subject subject) throws SentryConfigurationException {
-    return policy.getPrivileges(getGroups(subject), ActiveRoleSet.ALL);
+    return policy.getPrivileges(getGroups(subject), Sets.newHashSet(subject.getName()),
+        ActiveRoleSet.ALL, (Authorizable[]) null);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-common/src/test/java/org/apache/sentry/provider/common/TestGetGroupMapping.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-common/src/test/java/org/apache/sentry/provider/common/TestGetGroupMapping.java b/sentry-provider/sentry-provider-common/src/test/java/org/apache/sentry/provider/common/TestGetGroupMapping.java
index 14af2d4..402574e 100644
--- a/sentry-provider/sentry-provider-common/src/test/java/org/apache/sentry/provider/common/TestGetGroupMapping.java
+++ b/sentry-provider/sentry-provider-common/src/test/java/org/apache/sentry/provider/common/TestGetGroupMapping.java
@@ -20,11 +20,11 @@ import static org.junit.Assert.assertSame;
 
 import java.util.Set;
 
+import org.apache.sentry.core.common.ActiveRoleSet;
 import org.apache.sentry.core.common.Authorizable;
 import org.apache.sentry.core.common.SentryConfigurationException;
-import org.apache.sentry.core.common.ActiveRoleSet;
-import org.apache.sentry.policy.common.PrivilegeFactory;
 import org.apache.sentry.policy.common.PolicyEngine;
+import org.apache.sentry.policy.common.PrivilegeFactory;
 import org.junit.Test;
 
 import com.google.common.collect.ImmutableSet;
@@ -53,7 +53,7 @@ public class TestGetGroupMapping {
       @Override
       public ImmutableSet<String> getAllPrivileges(Set<String> groups,
           ActiveRoleSet roleSet) throws SentryConfigurationException {
-        return getPrivileges(groups, roleSet, null);
+        return getPrivileges(groups, roleSet);
       }
 
       @Override
@@ -67,6 +67,19 @@ public class TestGetGroupMapping {
       }
 
       @Override
+      public ImmutableSet<String> getAllPrivileges(Set<String> groups, Set<String> users,
+          ActiveRoleSet roleSet) throws SentryConfigurationException {
+        return getPrivileges(groups, users, roleSet);
+      }
+
+      @Override
+      public ImmutableSet<String> getPrivileges(Set<String> groups, Set<String> users,
+          ActiveRoleSet roleSet, Authorizable... authorizableHierarchy)
+          throws SentryConfigurationException {
+        return ImmutableSet.of();
+      }
+
+      @Override
       public void close() {}
     };
 


[2/6] sentry git commit: SENTRY-711: Implement grant user to role (Colin Ma, reviewed by Dapeng Sun)

Posted by sd...@apache.org.
http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryPrivilegeMap.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryPrivilegeMap.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryPrivilegeMap.java
index e7beee1..3d85d9f 100644
--- a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryPrivilegeMap.java
+++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryPrivilegeMap.java
@@ -359,26 +359,26 @@ public class TSentryPrivilegeMap implements org.apache.thrift.TBase<TSentryPrivi
           case 1: // PRIVILEGE_MAP
             if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
               {
-                org.apache.thrift.protocol.TMap _map88 = iprot.readMapBegin();
-                struct.privilegeMap = new HashMap<String,Set<TSentryPrivilege>>(2*_map88.size);
-                for (int _i89 = 0; _i89 < _map88.size; ++_i89)
+                org.apache.thrift.protocol.TMap _map112 = iprot.readMapBegin();
+                struct.privilegeMap = new HashMap<String,Set<TSentryPrivilege>>(2*_map112.size);
+                for (int _i113 = 0; _i113 < _map112.size; ++_i113)
                 {
-                  String _key90; // required
-                  Set<TSentryPrivilege> _val91; // required
-                  _key90 = iprot.readString();
+                  String _key114; // required
+                  Set<TSentryPrivilege> _val115; // required
+                  _key114 = iprot.readString();
                   {
-                    org.apache.thrift.protocol.TSet _set92 = iprot.readSetBegin();
-                    _val91 = new HashSet<TSentryPrivilege>(2*_set92.size);
-                    for (int _i93 = 0; _i93 < _set92.size; ++_i93)
+                    org.apache.thrift.protocol.TSet _set116 = iprot.readSetBegin();
+                    _val115 = new HashSet<TSentryPrivilege>(2*_set116.size);
+                    for (int _i117 = 0; _i117 < _set116.size; ++_i117)
                     {
-                      TSentryPrivilege _elem94; // required
-                      _elem94 = new TSentryPrivilege();
-                      _elem94.read(iprot);
-                      _val91.add(_elem94);
+                      TSentryPrivilege _elem118; // required
+                      _elem118 = new TSentryPrivilege();
+                      _elem118.read(iprot);
+                      _val115.add(_elem118);
                     }
                     iprot.readSetEnd();
                   }
-                  struct.privilegeMap.put(_key90, _val91);
+                  struct.privilegeMap.put(_key114, _val115);
                 }
                 iprot.readMapEnd();
               }
@@ -404,14 +404,14 @@ public class TSentryPrivilegeMap implements org.apache.thrift.TBase<TSentryPrivi
         oprot.writeFieldBegin(PRIVILEGE_MAP_FIELD_DESC);
         {
           oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.SET, struct.privilegeMap.size()));
-          for (Map.Entry<String, Set<TSentryPrivilege>> _iter95 : struct.privilegeMap.entrySet())
+          for (Map.Entry<String, Set<TSentryPrivilege>> _iter119 : struct.privilegeMap.entrySet())
           {
-            oprot.writeString(_iter95.getKey());
+            oprot.writeString(_iter119.getKey());
             {
-              oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, _iter95.getValue().size()));
-              for (TSentryPrivilege _iter96 : _iter95.getValue())
+              oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, _iter119.getValue().size()));
+              for (TSentryPrivilege _iter120 : _iter119.getValue())
               {
-                _iter96.write(oprot);
+                _iter120.write(oprot);
               }
               oprot.writeSetEnd();
             }
@@ -439,14 +439,14 @@ public class TSentryPrivilegeMap implements org.apache.thrift.TBase<TSentryPrivi
       TTupleProtocol oprot = (TTupleProtocol) prot;
       {
         oprot.writeI32(struct.privilegeMap.size());
-        for (Map.Entry<String, Set<TSentryPrivilege>> _iter97 : struct.privilegeMap.entrySet())
+        for (Map.Entry<String, Set<TSentryPrivilege>> _iter121 : struct.privilegeMap.entrySet())
         {
-          oprot.writeString(_iter97.getKey());
+          oprot.writeString(_iter121.getKey());
           {
-            oprot.writeI32(_iter97.getValue().size());
-            for (TSentryPrivilege _iter98 : _iter97.getValue())
+            oprot.writeI32(_iter121.getValue().size());
+            for (TSentryPrivilege _iter122 : _iter121.getValue())
             {
-              _iter98.write(oprot);
+              _iter122.write(oprot);
             }
           }
         }
@@ -457,25 +457,25 @@ public class TSentryPrivilegeMap implements org.apache.thrift.TBase<TSentryPrivi
     public void read(org.apache.thrift.protocol.TProtocol prot, TSentryPrivilegeMap struct) throws org.apache.thrift.TException {
       TTupleProtocol iprot = (TTupleProtocol) prot;
       {
-        org.apache.thrift.protocol.TMap _map99 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.SET, iprot.readI32());
-        struct.privilegeMap = new HashMap<String,Set<TSentryPrivilege>>(2*_map99.size);
-        for (int _i100 = 0; _i100 < _map99.size; ++_i100)
+        org.apache.thrift.protocol.TMap _map123 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.SET, iprot.readI32());
+        struct.privilegeMap = new HashMap<String,Set<TSentryPrivilege>>(2*_map123.size);
+        for (int _i124 = 0; _i124 < _map123.size; ++_i124)
         {
-          String _key101; // required
-          Set<TSentryPrivilege> _val102; // required
-          _key101 = iprot.readString();
+          String _key125; // required
+          Set<TSentryPrivilege> _val126; // required
+          _key125 = iprot.readString();
           {
-            org.apache.thrift.protocol.TSet _set103 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
-            _val102 = new HashSet<TSentryPrivilege>(2*_set103.size);
-            for (int _i104 = 0; _i104 < _set103.size; ++_i104)
+            org.apache.thrift.protocol.TSet _set127 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
+            _val126 = new HashSet<TSentryPrivilege>(2*_set127.size);
+            for (int _i128 = 0; _i128 < _set127.size; ++_i128)
             {
-              TSentryPrivilege _elem105; // required
-              _elem105 = new TSentryPrivilege();
-              _elem105.read(iprot);
-              _val102.add(_elem105);
+              TSentryPrivilege _elem129; // required
+              _elem129 = new TSentryPrivilege();
+              _elem129.read(iprot);
+              _val126.add(_elem129);
             }
           }
-          struct.privilegeMap.put(_key101, _val102);
+          struct.privilegeMap.put(_key125, _val126);
         }
       }
       struct.setPrivilegeMapIsSet(true);

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryRole.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryRole.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryRole.java
index 7645e25..0faa12a 100644
--- a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryRole.java
+++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TSentryRole.java
@@ -528,14 +528,14 @@ public class TSentryRole implements org.apache.thrift.TBase<TSentryRole, TSentry
           case 2: // GROUPS
             if (schemeField.type == org.apache.thrift.protocol.TType.SET) {
               {
-                org.apache.thrift.protocol.TSet _set40 = iprot.readSetBegin();
-                struct.groups = new HashSet<TSentryGroup>(2*_set40.size);
-                for (int _i41 = 0; _i41 < _set40.size; ++_i41)
+                org.apache.thrift.protocol.TSet _set56 = iprot.readSetBegin();
+                struct.groups = new HashSet<TSentryGroup>(2*_set56.size);
+                for (int _i57 = 0; _i57 < _set56.size; ++_i57)
                 {
-                  TSentryGroup _elem42; // required
-                  _elem42 = new TSentryGroup();
-                  _elem42.read(iprot);
-                  struct.groups.add(_elem42);
+                  TSentryGroup _elem58; // required
+                  _elem58 = new TSentryGroup();
+                  _elem58.read(iprot);
+                  struct.groups.add(_elem58);
                 }
                 iprot.readSetEnd();
               }
@@ -574,9 +574,9 @@ public class TSentryRole implements org.apache.thrift.TBase<TSentryRole, TSentry
         oprot.writeFieldBegin(GROUPS_FIELD_DESC);
         {
           oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, struct.groups.size()));
-          for (TSentryGroup _iter43 : struct.groups)
+          for (TSentryGroup _iter59 : struct.groups)
           {
-            _iter43.write(oprot);
+            _iter59.write(oprot);
           }
           oprot.writeSetEnd();
         }
@@ -607,9 +607,9 @@ public class TSentryRole implements org.apache.thrift.TBase<TSentryRole, TSentry
       oprot.writeString(struct.roleName);
       {
         oprot.writeI32(struct.groups.size());
-        for (TSentryGroup _iter44 : struct.groups)
+        for (TSentryGroup _iter60 : struct.groups)
         {
-          _iter44.write(oprot);
+          _iter60.write(oprot);
         }
       }
       oprot.writeString(struct.grantorPrincipal);
@@ -621,14 +621,14 @@ public class TSentryRole implements org.apache.thrift.TBase<TSentryRole, TSentry
       struct.roleName = iprot.readString();
       struct.setRoleNameIsSet(true);
       {
-        org.apache.thrift.protocol.TSet _set45 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
-        struct.groups = new HashSet<TSentryGroup>(2*_set45.size);
-        for (int _i46 = 0; _i46 < _set45.size; ++_i46)
+        org.apache.thrift.protocol.TSet _set61 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
+        struct.groups = new HashSet<TSentryGroup>(2*_set61.size);
+        for (int _i62 = 0; _i62 < _set61.size; ++_i62)
         {
-          TSentryGroup _elem47; // required
-          _elem47 = new TSentryGroup();
-          _elem47.read(iprot);
-          struct.groups.add(_elem47);
+          TSentryGroup _elem63; // required
+          _elem63 = new TSentryGroup();
+          _elem63.read(iprot);
+          struct.groups.add(_elem63);
         }
       }
       struct.setGroupsIsSet(true);

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/SimpleDBProviderBackend.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/SimpleDBProviderBackend.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/SimpleDBProviderBackend.java
index b996095..2f5aa9d 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/SimpleDBProviderBackend.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/SimpleDBProviderBackend.java
@@ -63,14 +63,25 @@ public class SimpleDBProviderBackend implements ProviderBackend {
    * {@inheritDoc}
    */
   @Override
-  public ImmutableSet<String> getPrivileges(Set<String> groups, ActiveRoleSet roleSet, Authorizable... authorizableHierarchy) {
+  public ImmutableSet<String> getPrivileges(Set<String> groups, ActiveRoleSet roleSet,
+      Authorizable... authorizableHierarchy) {
+    return getPrivileges(groups, null, roleSet, authorizableHierarchy);
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public ImmutableSet<String> getPrivileges(Set<String> groups, Set<String> users,
+      ActiveRoleSet roleSet, Authorizable... authorizableHierarchy) {
     int retries = Math.max(retryCount + 1, 1); // if customer configs retryCount as Integer.MAX_VALUE, try only once
     while (retries > 0) {
       retries--;
       SentryPolicyServiceClient policyServiceClient = null;
       try {
         policyServiceClient = SentryServiceClientFactory.create(conf);
-        return ImmutableSet.copyOf(policyServiceClient.listPrivilegesForProvider(groups, roleSet, authorizableHierarchy));
+        return ImmutableSet.copyOf(policyServiceClient.listPrivilegesForProvider(groups, users,
+            roleSet, authorizableHierarchy));
       } catch (Exception e) {
         //TODO: differentiate transient errors and permanent errors
         String msg = "Unable to obtain privileges from server: " + e.getMessage() + ".";

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/SentryGenericProviderBackend.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/SentryGenericProviderBackend.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/SentryGenericProviderBackend.java
index 474d05c..222b6fd 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/SentryGenericProviderBackend.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/SentryGenericProviderBackend.java
@@ -140,6 +140,13 @@ public class SentryGenericProviderBackend implements ProviderBackend {
   }
 
   @Override
+  public ImmutableSet<String> getPrivileges(Set<String> groups, Set<String> users,
+                                              ActiveRoleSet roleSet, Authorizable... authorizableHierarchy) {
+    // SentryGenericProviderBackend doesn't support getPrivileges for user now.
+    return getPrivileges(groups, roleSet, authorizableHierarchy);
+  }
+
+  @Override
   public void close() {
   }
 

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/log/entity/JsonLogEntityFactory.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/log/entity/JsonLogEntityFactory.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/log/entity/JsonLogEntityFactory.java
index c29b88e..71402d3 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/log/entity/JsonLogEntityFactory.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/log/entity/JsonLogEntityFactory.java
@@ -30,8 +30,12 @@ import org.apache.sentry.provider.db.log.util.CommandUtil;
 import org.apache.sentry.provider.db.log.util.Constants;
 import org.apache.sentry.provider.db.service.thrift.TAlterSentryRoleAddGroupsRequest;
 import org.apache.sentry.provider.db.service.thrift.TAlterSentryRoleAddGroupsResponse;
+import org.apache.sentry.provider.db.service.thrift.TAlterSentryRoleAddUsersRequest;
+import org.apache.sentry.provider.db.service.thrift.TAlterSentryRoleAddUsersResponse;
 import org.apache.sentry.provider.db.service.thrift.TAlterSentryRoleDeleteGroupsRequest;
 import org.apache.sentry.provider.db.service.thrift.TAlterSentryRoleDeleteGroupsResponse;
+import org.apache.sentry.provider.db.service.thrift.TAlterSentryRoleDeleteUsersRequest;
+import org.apache.sentry.provider.db.service.thrift.TAlterSentryRoleDeleteUsersResponse;
 import org.apache.sentry.provider.db.service.thrift.TAlterSentryRoleGrantPrivilegeRequest;
 import org.apache.sentry.provider.db.service.thrift.TAlterSentryRoleGrantPrivilegeResponse;
 import org.apache.sentry.provider.db.service.thrift.TAlterSentryRoleRevokePrivilegeRequest;
@@ -176,6 +180,42 @@ public class JsonLogEntityFactory {
     return groups.toString();
   }
 
+  public JsonLogEntity createJsonLogEntity(TAlterSentryRoleAddUsersRequest request,
+      TAlterSentryRoleAddUsersResponse response, Configuration conf) {
+    AuditMetadataLogEntity amle = createCommonHAMLE(conf, response.getStatus(),
+        request.getRequestorUserName(), request.getClass().getName());
+    String users = getUsersStr(request.getUsersIterator());
+    amle.setOperationText(CommandUtil.createCmdForRoleAddUser(request.getRoleName(), users));
+
+    return amle;
+  }
+
+  public JsonLogEntity createJsonLogEntity(TAlterSentryRoleDeleteUsersRequest request,
+      TAlterSentryRoleDeleteUsersResponse response, Configuration conf) {
+    AuditMetadataLogEntity amle = createCommonHAMLE(conf, response.getStatus(),
+        request.getRequestorUserName(), request.getClass().getName());
+    String users = getUsersStr(request.getUsersIterator());
+    amle.setOperationText(CommandUtil.createCmdForRoleDeleteUser(request.getRoleName(), users));
+
+    return amle;
+  }
+
+  private String getUsersStr(Iterator<String> iter) {
+    StringBuilder users = new StringBuilder("");
+    if (iter != null) {
+      boolean commaFlg = false;
+      while (iter.hasNext()) {
+        if (commaFlg) {
+          users.append(", ");
+        } else {
+          commaFlg = true;
+        }
+        users.append(iter.next());
+      }
+    }
+    return users.toString();
+  }
+
   public String isAllowed(TSentryResponseStatus status) {
     if (status.equals(Status.OK())) {
       return Constants.TRUE;

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/log/util/CommandUtil.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/log/util/CommandUtil.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/log/util/CommandUtil.java
index d6aecd1..c2c8e4e 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/log/util/CommandUtil.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/log/util/CommandUtil.java
@@ -46,38 +46,46 @@ public class CommandUtil {
   }
 
   public static String createCmdForRoleAddGroup(String roleName, String groups) {
-    return createCmdForRoleAddOrDeleteGroup(roleName, groups, true);
+    return createCmdForRoleGrant(roleName, groups, true, true);
   }
 
   public static String createCmdForRoleDeleteGroup(String roleName, String groups) {
-    return createCmdForRoleAddOrDeleteGroup(roleName, groups, false);
+    return createCmdForRoleGrant(roleName, groups, false, true);
   }
 
-  private static String createCmdForRoleAddOrDeleteGroup(String roleName,
- String groups,
-      boolean isAddGroup) {
+  private static String createCmdForRoleGrant(String roleName, String principals,
+      boolean isGrant, boolean isGroup) {
     StringBuilder sb = new StringBuilder();
-    if (isAddGroup) {
+    if (isGrant) {
       sb.append("GRANT ROLE ");
     } else {
       sb.append("REVOKE ROLE ");
     }
     sb.append(roleName);
-    if (isAddGroup) {
+    if (isGrant) {
       sb.append(" TO ");
     } else {
       sb.append(" FROM ");
     }
 
-    if (!StringUtils.isEmpty(groups)) {
-      sb.append("GROUP ").append(groups);
+    String principalType = isGroup ? "GROUP" : "USER";
+    if (!StringUtils.isEmpty(principals)) {
+      sb.append(principalType).append(" ").append(principals);
     } else {
-      sb = new StringBuilder("Missing group information.");
+      sb = new StringBuilder("Missing " + principalType + " information.");
     }
 
     return sb.toString();
   }
 
+  public static String createCmdForRoleAddUser(String roleName, String users) {
+    return createCmdForRoleGrant(roleName, users, true, false);
+  }
+
+  public static String createCmdForRoleDeleteUser(String roleName, String users) {
+    return createCmdForRoleGrant(roleName, users, false, false);
+  }
+
   public static String createCmdForGrantPrivilege(
       TAlterSentryRoleGrantPrivilegeRequest request) {
     return createCmdForGrantOrRevokePrivileges(request.getRoleName(),

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/log/util/Constants.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/log/util/Constants.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/log/util/Constants.java
index b0a87ae..1a470ab 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/log/util/Constants.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/log/util/Constants.java
@@ -21,12 +21,7 @@ package org.apache.sentry.provider.db.log.util;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.sentry.provider.db.service.thrift.TAlterSentryRoleAddGroupsRequest;
-import org.apache.sentry.provider.db.service.thrift.TAlterSentryRoleDeleteGroupsRequest;
-import org.apache.sentry.provider.db.service.thrift.TAlterSentryRoleGrantPrivilegeRequest;
-import org.apache.sentry.provider.db.service.thrift.TAlterSentryRoleRevokePrivilegeRequest;
-import org.apache.sentry.provider.db.service.thrift.TCreateSentryRoleRequest;
-import org.apache.sentry.provider.db.service.thrift.TDropSentryRoleRequest;
+import org.apache.sentry.provider.db.service.thrift.*;
 
 public class Constants {
   public final static String AUDIT_LOGGER_NAME = "sentry.hive.authorization.ddl.logger";
@@ -51,6 +46,8 @@ public class Constants {
   public final static String OPERATION_DROP_ROLE = "DROP_ROLE";
   public final static String OPERATION_ADD_ROLE = "ADD_ROLE_TO_GROUP";
   public final static String OPERATION_DELETE_ROLE = "DELETE_ROLE_FROM_GROUP";
+  public final static String OPERATION_ADD_ROLE_USER = "ADD_ROLE_TO_USER";
+  public final static String OPERATION_DELETE_ROLE_USER = "DELETE_ROLE_FROM_USER";
   public final static String OPERATION_GRANT_PRIVILEGE = "GRANT_PRIVILEGE";
   public final static String OPERATION_REVOKE_PRIVILEGE = "REVOKE_PRIVILEGE";
 
@@ -81,6 +78,13 @@ public class Constants {
     requestTypeToOperationMap.put(
         TAlterSentryRoleDeleteGroupsRequest.class.getName(),
         Constants.OPERATION_DELETE_ROLE);
+    requestTypeToOperationMap.put(
+        TAlterSentryRoleAddUsersRequest.class.getName(),
+        Constants.OPERATION_ADD_ROLE_USER);
+    requestTypeToOperationMap.put(
+        TAlterSentryRoleDeleteUsersRequest.class.getName(),
+        Constants.OPERATION_DELETE_ROLE_USER);
+
     // for generic model audit log
     requestTypeToOperationMap.put(
         org.apache.sentry.provider.db.generic.service.thrift.TCreateSentryRoleRequest.class
@@ -116,6 +120,12 @@ public class Constants {
         TAlterSentryRoleDeleteGroupsRequest.class.getName(),
         Constants.OBJECT_TYPE_ROLE);
     requestTypeToObjectTypeMap.put(
+        TAlterSentryRoleAddUsersRequest.class.getName(),
+        Constants.OBJECT_TYPE_ROLE);
+    requestTypeToObjectTypeMap.put(
+        TAlterSentryRoleDeleteUsersRequest.class.getName(),
+        Constants.OBJECT_TYPE_ROLE);
+    requestTypeToObjectTypeMap.put(
         TAlterSentryRoleGrantPrivilegeRequest.class.getName(),
         Constants.OBJECT_TYPE_PRINCIPAL);
     requestTypeToObjectTypeMap.put(

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryRole.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryRole.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryRole.java
index 24514ea..0484eaa 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryRole.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryRole.java
@@ -41,6 +41,8 @@ public class MSentryRole {
 
   // set of groups this role belongs to
   private Set<MSentryGroup> groups;
+  // set of users this role belongs to
+  private Set<MSentryUser> users;
   private long createTime;
 
   public MSentryRole(String roleName, long createTime) {
@@ -49,6 +51,7 @@ public class MSentryRole {
     privileges = new HashSet<MSentryPrivilege>();
     gmPrivileges = new HashSet<MSentryGMPrivilege>();
     groups = new HashSet<MSentryGroup>();
+    users = new HashSet<MSentryUser>();
   }
 
   public long getCreateTime() {
@@ -91,6 +94,14 @@ public class MSentryRole {
     return groups;
   }
 
+  public Set<MSentryUser> getUsers() {
+    return users;
+  }
+
+  public void setUsers(Set<MSentryUser> users) {
+    this.users = users;
+  }
+
   public void removePrivilege(MSentryPrivilege privilege) {
     if (privileges.remove(privilege)) {
       privilege.removeRole(this);
@@ -142,6 +153,22 @@ public class MSentryRole {
     }
   }
 
+  public void appendUsers(Set<MSentryUser> users) {
+    this.users.addAll(users);
+  }
+
+  public void appendUser(MSentryUser user) {
+    if (users.add(user)) {
+      user.appendRole(this);
+    }
+  }
+
+  public void removeUser(MSentryUser user) {
+    if (users.remove(user)) {
+      user.removeRole(this);
+    }
+  }
+
   public void removePrivileges() {
     // copy is required since privilege.removeRole will call remotePrivilege
     for (MSentryPrivilege privilege : ImmutableSet.copyOf(privileges)) {
@@ -153,7 +180,7 @@ public class MSentryRole {
   @Override
   public String toString() {
     return "MSentryRole [roleName=" + roleName + ", privileges=[..]" + ", gmPrivileges=[..]"
-        + ", groups=[...]" + ", createTime=" + createTime + "]";
+        + ", groups=[...]" + ", users=[...]" + ", createTime=" + createTime + "]";
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryUser.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryUser.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryUser.java
new file mode 100644
index 0000000..ff57249
--- /dev/null
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/MSentryUser.java
@@ -0,0 +1,116 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.sentry.provider.db.service.model;
+
+import java.util.Set;
+
+import javax.jdo.annotations.PersistenceCapable;
+
+/**
+ * Database backed Sentry User. Any changes to this object
+ * require re-running the maven build so DN an re-enhance.
+ */
+@PersistenceCapable
+public class MSentryUser {
+
+  /**
+   * User name is unique
+   */
+  private String userName;
+  // set of roles granted to this user
+  private Set<MSentryRole> roles;
+  private long createTime;
+
+  public MSentryUser(String userName, long createTime, Set<MSentryRole> roles) {
+    this.setUserName(userName);
+    this.createTime = createTime;
+    this.roles = roles;
+  }
+
+  public long getCreateTime() {
+    return createTime;
+  }
+
+  public void setCreateTime(long createTime) {
+    this.createTime = createTime;
+  }
+
+  public Set<MSentryRole> getRoles() {
+    return roles;
+  }
+
+  public String getUserName() {
+    return userName;
+  }
+
+  public void setUserName(String userName) {
+    this.userName = userName;
+  }
+
+  public void appendRole(MSentryRole role) {
+    if (roles.add(role)) {
+      role.appendUser(this);
+    }
+  }
+
+  public void removeRole(MSentryRole role) {
+    if (roles.remove(role)) {
+      role.removeUser(this);
+    }
+  }
+
+  @Override
+  public String toString() {
+    return "MSentryUser [userName=" + userName + ", roles=[...]" + ", createTime=" + createTime
+        + "]";
+  }
+
+  @Override
+  public int hashCode() {
+    final int prime = 31;
+    int result = 1;
+    result = prime * result + ((userName == null) ? 0 : userName.hashCode());
+    return result;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (this == obj) {
+      return true;
+    }
+    if (obj == null) {
+      return false;
+    }
+    if (getClass() != obj.getClass()) {
+      return false;
+    }
+    MSentryUser other = (MSentryUser) obj;
+    if (createTime != other.createTime) {
+      return false;
+    }
+    if (userName == null) {
+      if (other.userName != null) {
+        return false;
+      }
+    } else if (!userName.equals(other.userName)) {
+      return false;
+    }
+    return true;
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/package.jdo
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/package.jdo b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/package.jdo
index d8f69b5..b3b9494 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/package.jdo
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/package.jdo
@@ -7,15 +7,15 @@
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at
- 
+
       http://www.apache.org/licenses/LICENSE-2.0
- 
+
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
---> 
+-->
 <!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 2.0//EN"
   "http://java.sun.com/dtd/jdo_2_0.dtd">
 <!--
@@ -25,36 +25,54 @@
   Non-indexed VARCHAR: 4000 bytes (max length on Oracle 9i/10g/11g)
 
 -->
-<jdo>  
-  <package name="org.apache.sentry.provider.db.service.model">  
-    <class name="MSentryGroup" identity-type="datastore" table="SENTRY_GROUP" detachable="true">  
+<jdo>
+  <package name="org.apache.sentry.provider.db.service.model">
+    <class name="MSentryGroup" identity-type="datastore" table="SENTRY_GROUP" detachable="true">
       <datastore-identity>
         <column name="GROUP_ID"/>
       </datastore-identity>
-      <field name="groupName">  
+      <field name="groupName">
         <column name="GROUP_NAME" length="128" jdbc-type="VARCHAR"/>
         <index name="SentryGroupName" unique="true"/>
       </field>
       <field name = "createTime">
-      	<column name = "CREATE_TIME" jdbc-type="BIGINT"/>
+        <column name = "CREATE_TIME" jdbc-type="BIGINT"/>
       </field>
 
       <field name="roles" mapped-by="groups">
          <collection element-type="org.apache.sentry.provider.db.service.model.MSentryRole"/>
       </field>
-        
+
+    </class>
+
+    <class name="MSentryUser" identity-type="datastore" table="SENTRY_USER" detachable="true">
+      <datastore-identity>
+        <column name="USER_ID"/>
+      </datastore-identity>
+      <field name="userName">
+        <column name="USER_NAME" length="128" jdbc-type="VARCHAR"/>
+        <index name="SentryUserName" unique="true"/>
+      </field>
+      <field name = "createTime">
+        <column name = "CREATE_TIME" jdbc-type="BIGINT"/>
+      </field>
+
+      <field name="roles" mapped-by="users">
+         <collection element-type="org.apache.sentry.provider.db.service.model.MSentryRole"/>
+      </field>
+
     </class>
-    
-    <class name="MSentryRole" identity-type="datastore" table="SENTRY_ROLE" detachable="true">  
+
+    <class name="MSentryRole" identity-type="datastore" table="SENTRY_ROLE" detachable="true">
       <datastore-identity>
         <column name="ROLE_ID"/>
       </datastore-identity>
-      <field name="roleName">  
+      <field name="roleName">
         <column name="ROLE_NAME" length="128" jdbc-type="VARCHAR"/>
         <index name="SentryRoleName" unique="true"/>
       </field>
       <field name = "createTime">
-      	<column name = "CREATE_TIME" jdbc-type="BIGINT"/>
+        <column name = "CREATE_TIME" jdbc-type="BIGINT"/>
       </field>
       <field name = "privileges" table="SENTRY_ROLE_DB_PRIVILEGE_MAP" default-fetch-group="true">
         <collection element-type="org.apache.sentry.provider.db.service.model.MSentryPrivilege"/>
@@ -76,7 +94,7 @@
             </element>
       </field>
 
-      <field name = "groups" table="SENTRY_ROLE_GROUP_MAP" >
+      <field name = "groups" table="SENTRY_ROLE_GROUP_MAP" default-fetch-group="true">
         <collection element-type="org.apache.sentry.provider.db.service.model.MSentryGroup"/>
             <join>
                 <column name="ROLE_ID"/>
@@ -85,13 +103,23 @@
                 <column name="GROUP_ID"/>
             </element>
       </field>
+
+      <field name = "users" table="SENTRY_ROLE_USER_MAP" default-fetch-group="true">
+        <collection element-type="org.apache.sentry.provider.db.service.model.MSentryUser"/>
+            <join>
+                <column name="ROLE_ID"/>
+            </join>
+            <element>
+                <column name="USER_ID"/>
+            </element>
+      </field>
     </class>
 
     <class name="MSentryPrivilege" identity-type="datastore" table="SENTRY_DB_PRIVILEGE" detachable="true">
       <datastore-identity>
         <column name="DB_PRIVILEGE_ID"/>
       </datastore-identity>
-    <index name="PRIVILEGE_INDEX" unique="true">
+      <index name="PRIVILEGE_INDEX" unique="true">
         <field name="serverName"/>
         <field name="dbName"/>
         <field name="tableName"/>
@@ -99,30 +127,30 @@
         <field name="URI"/>
         <field name="action"/>
         <field name="grantOption"/>
-	  </index>
-      <field name="privilegeScope">  
+      </index>
+      <field name="privilegeScope">
         <column name="PRIVILEGE_SCOPE" length="40" jdbc-type="VARCHAR"/>
       </field>
-      <field name="serverName">  
+      <field name="serverName">
         <column name="SERVER_NAME" length="4000" jdbc-type="VARCHAR"/>
       </field>
-      <field name="dbName">  
+      <field name="dbName">
         <column name="DB_NAME" length="4000" jdbc-type="VARCHAR"/>
       </field>
-      <field name="tableName">  
+      <field name="tableName">
         <column name="TABLE_NAME" length="4000" jdbc-type="VARCHAR"/>
       </field>
       <field name="columnName">
         <column name="COLUMN_NAME" length="4000" jdbc-type="VARCHAR"/>
       </field>
-      <field name="URI">  
+      <field name="URI">
         <column name="URI" length="4000" jdbc-type="VARCHAR"/>
       </field>
-      <field name="action">  
+      <field name="action">
         <column name="ACTION" length="40" jdbc-type="VARCHAR"/>
       </field>
       <field name = "createTime">
-      	<column name = "CREATE_TIME" jdbc-type="BIGINT"/>
+        <column name = "CREATE_TIME" jdbc-type="BIGINT"/>
       </field>
       <field name="grantOption">
         <column name="WITH_GRANT_OPTION" length="1" jdbc-type="CHAR"/>
@@ -136,7 +164,7 @@
       <datastore-identity>
         <column name="GM_PRIVILEGE_ID"/>
       </datastore-identity>
-    <index name="GM_PRIVILEGE_INDEX" unique="true">
+      <index name="GM_PRIVILEGE_INDEX" unique="true">
         <field name="componentName"/>
         <field name="serviceName"/>
         <field name="resourceName0"/>
@@ -149,7 +177,7 @@
         <field name="resourceType3"/>
         <field name="action"/>
         <field name="grantOption"/>
-	  </index>
+      </index>
       <field name="componentName">
         <column name="COMPONENT_NAME" length="100" jdbc-type="VARCHAR"/>
       </field>

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
index 22162eb..9e41a33 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
@@ -58,6 +58,7 @@ import org.apache.sentry.provider.db.SentryNoSuchObjectException;
 import org.apache.sentry.provider.db.service.model.MSentryGroup;
 import org.apache.sentry.provider.db.service.model.MSentryPrivilege;
 import org.apache.sentry.provider.db.service.model.MSentryRole;
+import org.apache.sentry.provider.db.service.model.MSentryUser;
 import org.apache.sentry.provider.db.service.model.MSentryVersion;
 import org.apache.sentry.provider.db.service.thrift.SentryConfigurationException;
 import org.apache.sentry.provider.db.service.thrift.SentryPolicyStoreProcessor;
@@ -369,6 +370,7 @@ public class SentryStore {
       }
     };
   }
+
   public Gauge<Long> getGroupCountGauge() {
     return new Gauge< Long >() {
       @Override
@@ -378,6 +380,15 @@ public class SentryStore {
     };
   }
 
+  public Gauge<Long> getUserCountGauge() {
+    return new Gauge<Long>() {
+      @Override
+      public Long getValue() {
+        return getCount(MSentryUser.class);
+      }
+    };
+  }
+
   /**
    * Lets the test code know how many privs are in the db, so that we know
    * if they are in fact being cleaned up when not being referenced any more.
@@ -396,6 +407,7 @@ public class SentryStore {
       pm = openTransaction();
       pm.newQuery(MSentryRole.class).deletePersistentAll();
       pm.newQuery(MSentryGroup.class).deletePersistentAll();
+      pm.newQuery(MSentryUser.class).deletePersistentAll();
       pm.newQuery(MSentryPrivilege.class).deletePersistentAll();
       commitUpdateTransaction(pm);
       rollbackTransaction = false;
@@ -814,7 +826,7 @@ public class SentryStore {
     }
   }
 
-  public CommitContext alterSentryRoleAddGroups( String grantorPrincipal, String roleName,
+  public CommitContext alterSentryRoleAddGroups(String grantorPrincipal, String roleName,
       Set<TSentryGroup> groupNames)
           throws SentryNoSuchObjectException {
     boolean rollbackTransaction = true;
@@ -861,6 +873,79 @@ public class SentryStore {
     }
   }
 
+  public CommitContext alterSentryRoleAddUsers(String roleName,
+      Set<String> userNames) throws SentryNoSuchObjectException {
+    boolean rollbackTransaction = true;
+    PersistenceManager pm = null;
+    roleName = roleName.trim().toLowerCase();
+    try {
+      pm = openTransaction();
+      MSentryRole role = getMSentryRole(pm, roleName);
+      if (role == null) {
+        throw new SentryNoSuchObjectException("Role: " + roleName);
+      } else {
+        Query query = pm.newQuery(MSentryUser.class);
+        query.setFilter("this.userName == t");
+        query.declareParameters("java.lang.String t");
+        query.setUnique(true);
+        List<MSentryUser> users = Lists.newArrayList();
+        for (String userName : userNames) {
+          userName = userName.trim();
+          MSentryUser user = (MSentryUser) query.execute(userName);
+          if (user == null) {
+            user = new MSentryUser(userName, System.currentTimeMillis(), Sets.newHashSet(role));
+          }
+          user.appendRole(role);
+          users.add(user);
+        }
+        pm.makePersistentAll(users);
+        CommitContext commit = commitUpdateTransaction(pm);
+        rollbackTransaction = false;
+        return commit;
+      }
+    } finally {
+      if (rollbackTransaction) {
+        rollbackTransaction(pm);
+      }
+    }
+  }
+
+  public CommitContext alterSentryRoleDeleteUsers(String roleName, Set<String> userNames)
+      throws SentryNoSuchObjectException {
+    boolean rollbackTransaction = true;
+    PersistenceManager pm = null;
+    roleName = roleName.trim().toLowerCase();
+    try {
+      pm = openTransaction();
+      MSentryRole role = getMSentryRole(pm, roleName);
+      if (role == null) {
+        throw new SentryNoSuchObjectException("Role: " + roleName);
+      } else {
+        Query query = pm.newQuery(MSentryUser.class);
+        query.setFilter("this.userName == t");
+        query.declareParameters("java.lang.String t");
+        query.setUnique(true);
+        List<MSentryUser> users = Lists.newArrayList();
+        for (String userName : userNames) {
+          userName = userName.trim();
+          MSentryUser user = (MSentryUser) query.execute(userName);
+          if (user != null) {
+            user.removeRole(role);
+            users.add(user);
+          }
+        }
+        pm.makePersistentAll(users);
+        CommitContext commit = commitUpdateTransaction(pm);
+        rollbackTransaction = false;
+        return commit;
+      }
+    } finally {
+      if (rollbackTransaction) {
+        rollbackTransaction(pm);
+      }
+    }
+  }
+
   public CommitContext alterSentryRoleDeleteGroups(String roleName,
       Set<TSentryGroup> groupNames)
           throws SentryNoSuchObjectException {
@@ -1064,15 +1149,13 @@ public class SentryStore {
     }
   }
 
-  public TSentryPrivilegeMap listSentryPrivilegesByAuthorizable(
-      Set<String> groups, TSentryActiveRoleSet activeRoles,
+  public TSentryPrivilegeMap listSentryPrivilegesByAuthorizable(Set<String> groups,
+      TSentryActiveRoleSet activeRoles,
       TSentryAuthorizable authHierarchy, boolean isAdmin)
       throws SentryInvalidInputException {
     Map<String, Set<TSentryPrivilege>> resultPrivilegeMap = Maps.newTreeMap();
-    Set<String> roles = Sets.newHashSet();
-    if (groups != null && !groups.isEmpty()) {
-      roles = getRolesToQuery(groups, new TSentryActiveRoleSet(true, null));
-    }
+    Set<String> roles = getRolesToQuery(groups, null, new TSentryActiveRoleSet(true, null));
+
     if (activeRoles != null && !activeRoles.isAll()) {
       // need to check/convert to lowercase here since this is from user input
       for (String aRole : activeRoles.getRoles()) {
@@ -1208,23 +1291,60 @@ public class SentryStore {
   }
 
   public Set<String> getRoleNamesForGroups(Set<String> groups) {
-    Set<String> result = new HashSet<String>();
+    if (groups == null || groups.isEmpty()) {
+      return ImmutableSet.of();
+    }
     boolean rollbackTransaction = true;
     PersistenceManager pm = null;
     try {
       pm = openTransaction();
-      Query query = pm.newQuery(MSentryGroup.class);
-      query.setFilter("this.groupName == t");
-      query.declareParameters("java.lang.String t");
-      query.setUnique(true);
-      for (String group : groups) {
-        MSentryGroup sentryGroup = (MSentryGroup) query.execute(group.trim());
-        if (sentryGroup != null) {
-          for (MSentryRole role : sentryGroup.getRoles()) {
-            result.add(role.getRoleName());
-          }
-        }
+      Set<String> result = getRoleNamesForGroupsCore(pm, groups);
+      rollbackTransaction = false;
+      commitTransaction(pm);
+      return result;
+    } finally {
+      if (rollbackTransaction) {
+        rollbackTransaction(pm);
+      }
+    }
+  }
+
+  private Set<String> getRoleNamesForGroupsCore(PersistenceManager pm, Set<String> groups) {
+    return convertToRoleNameSet(getRolesForGroups(pm, groups));
+  }
+
+  public Set<String> getRoleNamesForUsers(Set<String> users) {
+    if (users == null || users.isEmpty()) {
+      return ImmutableSet.of();
+    }
+    boolean rollbackTransaction = true;
+    PersistenceManager pm = null;
+    try {
+      pm = openTransaction();
+      Set<String> result = getRoleNamesForUsersCore(pm,users);
+      rollbackTransaction = false;
+      commitTransaction(pm);
+      return result;
+    } finally {
+      if (rollbackTransaction) {
+        rollbackTransaction(pm);
       }
+    }
+  }
+
+  private Set<String> getRoleNamesForUsersCore(PersistenceManager pm, Set<String> users) {
+    return convertToRoleNameSet(getRolesForUsers(pm, users));
+  }
+
+  public Set<TSentryRole> getTSentryRolesByUserNames(Set<String> users) {
+    boolean rollbackTransaction = true;
+    PersistenceManager pm = null;
+    try {
+      pm = openTransaction();
+      Set<MSentryRole> mSentryRoles = getRolesForUsers(pm, users);
+      // Since {@link MSentryRole#getGroups()} is lazy-loading, the converting should be call
+      // before transaction committed.
+      Set<TSentryRole> result = convertToTSentryRoles(mSentryRoles);
       rollbackTransaction = false;
       commitTransaction(pm);
       return result;
@@ -1236,31 +1356,50 @@ public class SentryStore {
   }
 
   public Set<MSentryRole> getRolesForGroups(PersistenceManager pm, Set<String> groups) {
-    Set<MSentryRole> result = new HashSet<MSentryRole>();
-    Query query = pm.newQuery(MSentryGroup.class);
-    query.setFilter("this.groupName == t");
-    query.declareParameters("java.lang.String t");
-    query.setUnique(true);
-    for (String group : groups) {
-      MSentryGroup sentryGroup = (MSentryGroup) query.execute(group.trim());
-      if (sentryGroup != null) {
-        result.addAll(sentryGroup.getRoles());
+    Set<MSentryRole> result = Sets.newHashSet();
+    if (groups != null) {
+      Query query = pm.newQuery(MSentryGroup.class);
+      query.setFilter("this.groupName == t");
+      query.declareParameters("java.lang.String t");
+      query.setUnique(true);
+      for (String group : groups) {
+        MSentryGroup sentryGroup = (MSentryGroup) query.execute(group.trim());
+        if (sentryGroup != null) {
+          result.addAll(sentryGroup.getRoles());
+        }
       }
     }
     return result;
   }
 
-  public Set<String> listAllSentryPrivilegesForProvider(Set<String> groups, TSentryActiveRoleSet roleSet) throws SentryInvalidInputException {
-    return listSentryPrivilegesForProvider(groups, roleSet, null);
+  public Set<MSentryRole> getRolesForUsers(PersistenceManager pm, Set<String> users) {
+    Set<MSentryRole> result = Sets.newHashSet();
+    if (users != null) {
+      Query query = pm.newQuery(MSentryUser.class);
+      query.setFilter("this.userName == t");
+      query.declareParameters("java.lang.String t");
+      query.setUnique(true);
+      for (String user : users) {
+        MSentryUser sentryUser = (MSentryUser) query.execute(user.trim());
+        if (sentryUser != null) {
+          result.addAll(sentryUser.getRoles());
+        }
+      }
+    }
+    return result;
+  }
+
+  public Set<String> listAllSentryPrivilegesForProvider(Set<String> groups, Set<String> users,
+      TSentryActiveRoleSet roleSet) throws SentryInvalidInputException {
+    return listSentryPrivilegesForProvider(groups, users, roleSet, null);
   }
 
 
-  public Set<String> listSentryPrivilegesForProvider(Set<String> groups,
+  public Set<String> listSentryPrivilegesForProvider(Set<String> groups, Set<String> users,
       TSentryActiveRoleSet roleSet, TSentryAuthorizable authHierarchy) throws SentryInvalidInputException {
     Set<String> result = Sets.newHashSet();
-    Set<String> rolesToQuery = getRolesToQuery(groups, roleSet);
+    Set<String> rolesToQuery = getRolesToQuery(groups, users, roleSet);
     List<MSentryPrivilege> mSentryPrivileges = getMSentryPrivileges(rolesToQuery, authHierarchy);
-
     for (MSentryPrivilege priv : mSentryPrivileges) {
       result.add(toAuthorizable(priv));
     }
@@ -1268,21 +1407,33 @@ public class SentryStore {
     return result;
   }
 
-
-  public boolean hasAnyServerPrivileges(Set<String> groups, TSentryActiveRoleSet roleSet, String server) {
-    Set<String> rolesToQuery = getRolesToQuery(groups, roleSet);
+  public boolean hasAnyServerPrivileges(Set<String> groups, Set<String> users,
+      TSentryActiveRoleSet roleSet, String server) {
+    Set<String> rolesToQuery = getRolesToQuery(groups, users, roleSet);
     return hasAnyServerPrivileges(rolesToQuery, server);
   }
 
-
-
-  private Set<String> getRolesToQuery(Set<String> groups,
+  private Set<String> getRolesToQuery(Set<String> groups, Set<String> users,
       TSentryActiveRoleSet roleSet) {
     Set<String> activeRoleNames = toTrimedLower(roleSet.getRoles());
 
-    Set<String> roleNamesForGroups = toTrimedLower(getRoleNamesForGroups(groups));
-    Set<String> rolesToQuery = roleSet.isAll() ? roleNamesForGroups : Sets.intersection(activeRoleNames, roleNamesForGroups);
-    return rolesToQuery;
+    Set<String> roleNames = Sets.newHashSet();
+    boolean rollbackTransaction = true;
+    PersistenceManager pm = null;
+    try {
+      pm = openTransaction();
+      roleNames.addAll(toTrimedLower(getRoleNamesForGroupsCore(pm, groups)));
+      roleNames.addAll(toTrimedLower(getRoleNamesForUsersCore(pm, users)));
+      rollbackTransaction = false;
+      commitTransaction(pm);
+      Set<String> rolesToQuery = roleSet.isAll() ? roleNames : Sets.intersection(activeRoleNames,
+          roleNames);
+      return rolesToQuery;
+    } finally {
+      if (rollbackTransaction) {
+        rollbackTransaction(pm);
+      }
+    }
   }
 
   @VisibleForTesting
@@ -1352,6 +1503,14 @@ public class SentryStore {
     return roles;
   }
 
+  private Set<String> convertToRoleNameSet(Set<MSentryRole> mSentryRoles) {
+    Set<String> roleNameSet = Sets.newHashSet();
+    for (MSentryRole role : mSentryRoles) {
+      roleNameSet.add(role.getRoleName());
+    }
+    return roleNameSet;
+  }
+
   private TSentryRole convertToTSentryRole(MSentryRole mSentryRole) {
     TSentryRole role = new TSentryRole();
     role.setRoleName(mSentryRole.getRoleName());
@@ -1696,16 +1855,13 @@ public class SentryStore {
     if (grantorPrincipal == null) {
       throw new SentryInvalidInputException("grantorPrincipal should not be null");
     }
+
     Set<String> groups = SentryPolicyStoreProcessor.getGroupsFromUserName(conf, grantorPrincipal);
-    if (groups == null || groups.isEmpty()) {
-      throw new SentryGrantDeniedException(grantorPrincipal
-          + " has no grant!");
-    }
 
     // if grantor is in adminGroup, don't need to do check
     Set<String> admins = getAdminGroups();
     boolean isAdminGroup = false;
-    if (admins != null && !admins.isEmpty()) {
+    if (groups != null && admins != null && !admins.isEmpty()) {
       for (String g : groups) {
         if (admins.contains(g)) {
           isAdminGroup = true;
@@ -1716,9 +1872,11 @@ public class SentryStore {
 
     if (!isAdminGroup) {
       boolean hasGrant = false;
+      // get all privileges for group and user
       Set<MSentryRole> roles = getRolesForGroups(pm, groups);
+      roles.addAll(getRolesForUsers(pm, Sets.newHashSet(grantorPrincipal)));
       if (roles != null && !roles.isEmpty()) {
-        for (MSentryRole role: roles) {
+        for (MSentryRole role : roles) {
           Set<MSentryPrivilege> privilegeSet = role.getPrivileges();
           if (privilegeSet != null && !privilegeSet.isEmpty()) {
             // if role has a privilege p with grant option

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/NotificationHandler.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/NotificationHandler.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/NotificationHandler.java
index 506d433..b1a4b7f 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/NotificationHandler.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/NotificationHandler.java
@@ -68,4 +68,12 @@ public abstract class NotificationHandler {
     CommitContext context, TAlterSentryRoleDeleteGroupsRequest request,
     TAlterSentryRoleDeleteGroupsResponse response) {
   }
+
+  public void alter_sentry_role_add_users(CommitContext context,
+      TAlterSentryRoleAddUsersRequest request, TAlterSentryRoleAddUsersResponse response) {
+  }
+
+  public void alter_sentry_role_delete_users(CommitContext context,
+      TAlterSentryRoleDeleteUsersRequest request, TAlterSentryRoleDeleteUsersResponse response) {
+  }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/NotificationHandlerInvoker.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/NotificationHandlerInvoker.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/NotificationHandlerInvoker.java
index 9d9e867..856ef9a 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/NotificationHandlerInvoker.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/NotificationHandlerInvoker.java
@@ -143,4 +143,34 @@ public class NotificationHandlerInvoker extends NotificationHandler {
       }
     }
   }
+
+  @Override
+  public void alter_sentry_role_add_users(CommitContext context,
+      TAlterSentryRoleAddUsersRequest request, TAlterSentryRoleAddUsersResponse response) {
+    for (NotificationHandler handler : handlers) {
+      try {
+        LOGGER.debug("Calling " + handler);
+        handler.alter_sentry_role_add_users(context, new TAlterSentryRoleAddUsersRequest(request),
+            new TAlterSentryRoleAddUsersResponse(response));
+      } catch (Exception ex) {
+        LOGGER.error("Unexpected error in " + handler + ". Request: " + request + ", Response: "
+            + response, ex);
+      }
+    }
+  }
+
+  @Override
+  public void alter_sentry_role_delete_users(CommitContext context,
+      TAlterSentryRoleDeleteUsersRequest request, TAlterSentryRoleDeleteUsersResponse response) {
+    for (NotificationHandler handler : handlers) {
+      try {
+        LOGGER.debug("Calling " + handler);
+        handler.alter_sentry_role_delete_users(context, new TAlterSentryRoleDeleteUsersRequest(
+            request), new TAlterSentryRoleDeleteUsersResponse(response));
+      } catch (Exception ex) {
+        LOGGER.error("Unexpected error in " + handler + ". Request: " + request + ", Response: "
+            + response, ex);
+      }
+    }
+  }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyServiceClient.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyServiceClient.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyServiceClient.java
index b6deadb..46f4785 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyServiceClient.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyServiceClient.java
@@ -35,6 +35,9 @@ public interface SentryPolicyServiceClient {
   void dropRoleIfExists(String requestorUserName, String roleName)
       throws SentryUserException;
 
+  Set<TSentryRole> listRolesByUserName(String requestorUserName, String userName)
+      throws SentryUserException;
+
   Set<TSentryRole> listRolesByGroupName(String requestorUserName, String groupName)
       throws SentryUserException;
 
@@ -142,8 +145,8 @@ public interface SentryPolicyServiceClient {
       String db, String table, List<String> columns, String action, Boolean grantOption)
       throws SentryUserException;
 
-  Set<String> listPrivilegesForProvider(Set<String> groups, ActiveRoleSet roleSet,
-      Authorizable... authorizable) throws SentryUserException;
+  Set<String> listPrivilegesForProvider(Set<String> groups, Set<String> users,
+      ActiveRoleSet roleSet, Authorizable... authorizable) throws SentryUserException;
 
   void grantRoleToGroup(String requestorUserName, String groupName, String roleName)
       throws SentryUserException;
@@ -157,6 +160,18 @@ public interface SentryPolicyServiceClient {
   void revokeRoleFromGroups(String requestorUserName, String roleName, Set<String> groups)
       throws SentryUserException;
 
+  void grantRoleToUser(String requestorUserName, String userName, String roleName)
+      throws SentryUserException;
+
+  void revokeRoleFromUser(String requestorUserName, String userName, String roleName)
+      throws SentryUserException;
+
+  void grantRoleToUsers(String requestorUserName, String roleName, Set<String> users)
+      throws SentryUserException;
+
+  void revokeRoleFromUsers(String requestorUserName, String roleName, Set<String> users)
+      throws SentryUserException;
+
   void dropPrivileges(String requestorUserName,
       List<? extends Authorizable> authorizableObjects) throws SentryUserException;
 

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyServiceClientDefaultImpl.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyServiceClientDefaultImpl.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyServiceClientDefaultImpl.java
index 3f8e489..0da3cfd 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyServiceClientDefaultImpl.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyServiceClientDefaultImpl.java
@@ -247,7 +247,34 @@ public class SentryPolicyServiceClientDefaultImpl implements SentryPolicyService
     }
   }
 
-  public synchronized Set<TSentryPrivilege> listAllPrivilegesByRoleName(String requestorUserName, String roleName)
+  /**
+   * Gets sentry role objects for a given userName using the Sentry service
+   *
+   * @param requestorUserName
+   *        : user on whose behalf the request is issued
+   * @param userName
+   *        : userName to look up (can't be empty)
+   * @return Set of thrift sentry role objects
+   * @throws SentryUserException
+   */
+  public Set<TSentryRole> listRolesByUserName(String requestorUserName, String userName)
+      throws SentryUserException {
+    TListSentryRolesForUserRequest request = new TListSentryRolesForUserRequest();
+    request.setProtocol_version(ThriftConstants.TSENTRY_SERVICE_VERSION_CURRENT);
+    request.setRequestorUserName(requestorUserName);
+    request.setUserName(userName);
+    TListSentryRolesResponse response;
+    try {
+      response = client.list_sentry_roles_by_user(request);
+      Status.throwIfNotOk(response.getStatus());
+      return response.getRoles();
+    } catch (TException e) {
+      throw new SentryUserException(THRIFT_EXCEPTION_MESSAGE, e);
+    }
+  }
+
+  public synchronized Set<TSentryPrivilege> listAllPrivilegesByRoleName(String requestorUserName,
+      String roleName)
                  throws SentryUserException {
     return listPrivilegesByRoleName(requestorUserName, roleName, null);
   }
@@ -288,7 +315,10 @@ public class SentryPolicyServiceClientDefaultImpl implements SentryPolicyService
 
   public synchronized Set<TSentryRole> listUserRoles(String requestorUserName)
       throws SentryUserException {
-    return listRolesByGroupName(requestorUserName, AccessConstants.ALL);
+    Set<TSentryRole> tSentryRoles = Sets.newHashSet();
+    tSentryRoles.addAll(listRolesByGroupName(requestorUserName, AccessConstants.ALL));
+    tSentryRoles.addAll(listRolesByUserName(requestorUserName, requestorUserName));
+    return tSentryRoles;
   }
 
   public synchronized TSentryPrivilege grantURIPrivilege(String requestorUserName,
@@ -667,8 +697,8 @@ public class SentryPolicyServiceClientDefaultImpl implements SentryPolicyService
     return TSentryGrantOption.FALSE;
   }
 
-  public synchronized Set<String> listPrivilegesForProvider(Set<String> groups, ActiveRoleSet roleSet, Authorizable... authorizable)
-  throws SentryUserException {
+  public synchronized Set<String> listPrivilegesForProvider(Set<String> groups, Set<String> users,
+      ActiveRoleSet roleSet, Authorizable... authorizable) throws SentryUserException {
     TSentryActiveRoleSet thriftRoleSet = new TSentryActiveRoleSet(roleSet.isAll(), roleSet.getRoles());
     TListSentryPrivilegesForProviderRequest request =
         new TListSentryPrivilegesForProviderRequest(ThriftConstants.
@@ -678,6 +708,9 @@ public class SentryPolicyServiceClientDefaultImpl implements SentryPolicyService
           .newArrayList(authorizable));
       request.setAuthorizableHierarchy(tSentryAuthorizable);
     }
+    if (users != null) {
+      request.setUsers(users);
+    }
     try {
       TListSentryPrivilegesForProviderResponse response = client.list_sentry_privileges_for_provider(request);
       Status.throwIfNotOk(response.getStatus());
@@ -731,6 +764,44 @@ public class SentryPolicyServiceClientDefaultImpl implements SentryPolicyService
     }
   }
 
+  @Override
+  public synchronized void grantRoleToUser(String requestorUserName, String userName,
+      String roleName) throws SentryUserException {
+    grantRoleToUsers(requestorUserName, roleName, Sets.newHashSet(userName));
+  }
+
+  @Override
+  public synchronized void revokeRoleFromUser(String requestorUserName, String userName,
+      String roleName) throws SentryUserException {
+    revokeRoleFromUsers(requestorUserName, roleName, Sets.newHashSet(userName));
+  }
+
+  @Override
+  public synchronized void grantRoleToUsers(String requestorUserName, String roleName,
+      Set<String> users) throws SentryUserException {
+    TAlterSentryRoleAddUsersRequest request = new TAlterSentryRoleAddUsersRequest(
+        ThriftConstants.TSENTRY_SERVICE_VERSION_CURRENT, requestorUserName, roleName, users);
+    try {
+      TAlterSentryRoleAddUsersResponse response = client.alter_sentry_role_add_users(request);
+      Status.throwIfNotOk(response.getStatus());
+    } catch (TException e) {
+      throw new SentryUserException(THRIFT_EXCEPTION_MESSAGE, e);
+    }
+  }
+
+  @Override
+  public synchronized void revokeRoleFromUsers(String requestorUserName, String roleName,
+      Set<String> users) throws SentryUserException {
+    TAlterSentryRoleDeleteUsersRequest request = new TAlterSentryRoleDeleteUsersRequest(
+        ThriftConstants.TSENTRY_SERVICE_VERSION_CURRENT, requestorUserName, roleName, users);
+    try {
+      TAlterSentryRoleDeleteUsersResponse response = client.alter_sentry_role_delete_users(request);
+      Status.throwIfNotOk(response.getStatus());
+    } catch (TException e) {
+      throw new SentryUserException(THRIFT_EXCEPTION_MESSAGE, e);
+    }
+  }
+
   private Set<TSentryGroup> convert2TGroups(Set<String> groups) {
     Set<TSentryGroup> tGroups = Sets.newHashSet();
     if (groups != null) {

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyStoreProcessor.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyStoreProcessor.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyStoreProcessor.java
index 52af345..a922d3b 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyStoreProcessor.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/thrift/SentryPolicyStoreProcessor.java
@@ -27,11 +27,13 @@ import java.util.Map;
 import java.util.Set;
 import java.util.regex.Pattern;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.sentry.SentryUserException;
 import org.apache.sentry.core.model.db.AccessConstants;
 import org.apache.sentry.provider.common.GroupMappingService;
 import org.apache.sentry.provider.common.PolicyFileConstants;
+import org.apache.sentry.provider.common.SentryGroupNotFoundException;
 import org.apache.sentry.provider.db.SentryAccessDeniedException;
 import org.apache.sentry.provider.db.SentryAlreadyExistsException;
 import org.apache.sentry.provider.db.SentryInvalidInputException;
@@ -459,8 +461,9 @@ public class SentryPolicyStoreProcessor implements SentryPolicyService.Iface {
       validateClientVersion(request.getProtocol_version());
       authorize(request.getRequestorUserName(),
           getRequestorGroups(request.getRequestorUserName()));
-      CommitContext commitContext = sentryStore.alterSentryRoleAddGroups(request.getRequestorUserName(),
-                                    request.getRoleName(), request.getGroups());
+      CommitContext commitContext = sentryStore.alterSentryRoleAddGroups(
+          request.getRequestorUserName(), request.getRoleName(),
+          request.getGroups());
       response.setStatus(Status.OK());
       notificationHandlerInvoker.alter_sentry_role_add_groups(commitContext,
           request, response);
@@ -497,6 +500,88 @@ public class SentryPolicyStoreProcessor implements SentryPolicyService.Iface {
   }
 
   @Override
+  public TAlterSentryRoleAddUsersResponse alter_sentry_role_add_users(
+      TAlterSentryRoleAddUsersRequest request) throws TException {
+    final Timer.Context timerContext = sentryMetrics.grantRoleTimer.time();
+    TAlterSentryRoleAddUsersResponse response = new TAlterSentryRoleAddUsersResponse();
+    try {
+      validateClientVersion(request.getProtocol_version());
+      authorize(request.getRequestorUserName(), getRequestorGroups(request.getRequestorUserName()));
+      CommitContext commitContext = sentryStore.alterSentryRoleAddUsers(request.getRoleName(),
+          request.getUsers());
+      response.setStatus(Status.OK());
+      notificationHandlerInvoker.alter_sentry_role_add_users(commitContext, request, response);
+    } catch (SentryNoSuchObjectException e) {
+      String msg = "Role: " + request + " does not exist.";
+      LOGGER.error(msg, e);
+      response.setStatus(Status.NoSuchObject(msg, e));
+    } catch (SentryAccessDeniedException e) {
+      LOGGER.error(e.getMessage(), e);
+      response.setStatus(Status.AccessDenied(e.getMessage(), e));
+    } catch (SentryThriftAPIMismatchException e) {
+      LOGGER.error(e.getMessage(), e);
+      response.setStatus(Status.THRIFT_VERSION_MISMATCH(e.getMessage(), e));
+    } catch (Exception e) {
+      String msg = "Unknown error for request: " + request + ", message: " + e.getMessage();
+      LOGGER.error(msg, e);
+      response.setStatus(Status.RuntimeError(msg, e));
+    } finally {
+      timerContext.stop();
+    }
+
+    try {
+      AUDIT_LOGGER.info(JsonLogEntityFactory.getInstance()
+          .createJsonLogEntity(request, response, conf).toJsonFormatLog());
+    } catch (Exception e) {
+      // if any exception, log the exception.
+      String msg = "Error creating audit log for add role to user: " + e.getMessage();
+      LOGGER.error(msg, e);
+    }
+    return response;
+  }
+
+  @Override
+  public TAlterSentryRoleDeleteUsersResponse alter_sentry_role_delete_users(
+      TAlterSentryRoleDeleteUsersRequest request) throws TException {
+    final Timer.Context timerContext = sentryMetrics.grantRoleTimer.time();
+    TAlterSentryRoleDeleteUsersResponse response = new TAlterSentryRoleDeleteUsersResponse();
+    try {
+      validateClientVersion(request.getProtocol_version());
+      authorize(request.getRequestorUserName(), getRequestorGroups(request.getRequestorUserName()));
+      CommitContext commitContext = sentryStore.alterSentryRoleDeleteUsers(request.getRoleName(),
+          request.getUsers());
+      response.setStatus(Status.OK());
+      notificationHandlerInvoker.alter_sentry_role_delete_users(commitContext, request, response);
+    } catch (SentryNoSuchObjectException e) {
+      String msg = "Role: " + request + " does not exist.";
+      LOGGER.error(msg, e);
+      response.setStatus(Status.NoSuchObject(msg, e));
+    } catch (SentryAccessDeniedException e) {
+      LOGGER.error(e.getMessage(), e);
+      response.setStatus(Status.AccessDenied(e.getMessage(), e));
+    } catch (SentryThriftAPIMismatchException e) {
+      LOGGER.error(e.getMessage(), e);
+      response.setStatus(Status.THRIFT_VERSION_MISMATCH(e.getMessage(), e));
+    } catch (Exception e) {
+      String msg = "Unknown error for request: " + request + ", message: " + e.getMessage();
+      LOGGER.error(msg, e);
+      response.setStatus(Status.RuntimeError(msg, e));
+    } finally {
+      timerContext.stop();
+    }
+
+    try {
+      AUDIT_LOGGER.info(JsonLogEntityFactory.getInstance()
+          .createJsonLogEntity(request, response, conf).toJsonFormatLog());
+   } catch (Exception e) {
+      // if any exception, log the exception.
+      String msg = "Error creating audit log for delete role from user: " + e.getMessage();
+      LOGGER.error(msg, e);
+    }
+    return response;
+  }
+
+  @Override
   public TAlterSentryRoleDeleteGroupsResponse alter_sentry_role_delete_groups(
     TAlterSentryRoleDeleteGroupsRequest request) throws TException {
     final Timer.Context timerContext = sentryMetrics.revokeRoleTimer.time();
@@ -592,6 +677,59 @@ public class SentryPolicyStoreProcessor implements SentryPolicyService.Iface {
     return response;
   }
 
+  public TListSentryRolesResponse list_sentry_roles_by_user(TListSentryRolesForUserRequest request)
+      throws TException {
+    final Timer.Context timerContext = sentryMetrics.listRolesByGroupTimer.time();
+    TListSentryRolesResponse response = new TListSentryRolesResponse();
+    TSentryResponseStatus status;
+    Set<TSentryRole> roleSet = new HashSet<TSentryRole>();
+    String requestor = request.getRequestorUserName();
+    String userName = request.getUserName();
+    boolean checkAllGroups = false;
+    try {
+      validateClientVersion(request.getProtocol_version());
+      // userName can't be empty
+      if (StringUtils.isEmpty(userName)) {
+        throw new SentryAccessDeniedException("The user name can't be empty.");
+      }
+
+      Set<String> requestorGroups = getRequestorGroups(requestor);
+      Set<String> userGroups = getRequestorGroups(userName);
+      boolean isAdmin = inAdminGroups(requestorGroups);
+
+      // Only admin users can list other user's roles in the system
+      // Non admin users are only allowed to list only their own roles related user and group
+      if (!isAdmin && !userName.equals(requestor)) {
+        throw new SentryAccessDeniedException("Access denied to list the roles for " + userName);
+      }
+      roleSet = sentryStore.getTSentryRolesByUserNames(Sets.newHashSet(userName));
+      response.setRoles(roleSet);
+      response.setStatus(Status.OK());
+    } catch (SentryGroupNotFoundException e) {
+      LOGGER.error(e.getMessage(), e);
+      String msg = "Group couldn't be retrieved for " + requestor + " or " + userName + ".";
+      response.setStatus(Status.AccessDenied(msg, e));
+    } catch (SentryNoSuchObjectException e) {
+      response.setRoles(roleSet);
+      String msg = "Role: " + request + " couldn't be retrieved.";
+      LOGGER.error(msg, e);
+      response.setStatus(Status.NoSuchObject(msg, e));
+    } catch (SentryAccessDeniedException e) {
+      LOGGER.error(e.getMessage(), e);
+      response.setStatus(Status.AccessDenied(e.getMessage(), e));
+    } catch (SentryThriftAPIMismatchException e) {
+      LOGGER.error(e.getMessage(), e);
+      response.setStatus(Status.THRIFT_VERSION_MISMATCH(e.getMessage(), e));
+    } catch (Exception e) {
+      String msg = "Unknown error for request: " + request + ", message: " + e.getMessage();
+      LOGGER.error(msg, e);
+      response.setStatus(Status.RuntimeError(msg, e));
+    } finally {
+      timerContext.stop();
+    }
+    return response;
+  }
+
   @Override
   public TListSentryPrivilegesResponse list_sentry_privileges_by_role(
       TListSentryPrivilegesRequest request) throws TException {
@@ -651,12 +789,15 @@ public class SentryPolicyStoreProcessor implements SentryPolicyService.Iface {
     response.setPrivileges(new HashSet<String>());
     try {
       validateClientVersion(request.getProtocol_version());
-      Set<String> privilegesForProvider = sentryStore.listSentryPrivilegesForProvider(
-          request.getGroups(), request.getRoleSet(), request.getAuthorizableHierarchy());
+      Set<String> privilegesForProvider =
+          sentryStore.listSentryPrivilegesForProvider(request.getGroups(), request.getUsers(),
+              request.getRoleSet(), request.getAuthorizableHierarchy());
       response.setPrivileges(privilegesForProvider);
-      if (privilegesForProvider == null || privilegesForProvider.size() == 0 && request.getAuthorizableHierarchy() != null
-        && sentryStore.hasAnyServerPrivileges(
-          request.getGroups(), request.getRoleSet(), request.getAuthorizableHierarchy().getServer())) {
+      if (privilegesForProvider == null
+          || privilegesForProvider.size() == 0
+          && request.getAuthorizableHierarchy() != null
+          && sentryStore.hasAnyServerPrivileges(request.getGroups(), request.getUsers(),
+              request.getRoleSet(), request.getAuthorizableHierarchy().getServer())) {
 
         // REQUIRED for ensuring 'default' Db is accessible by any user
         // with privileges to atleast 1 object with the specific server as root

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/main/resources/sentry_policy_service.thrift
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/resources/sentry_policy_service.thrift b/sentry-provider/sentry-provider-db/src/main/resources/sentry_policy_service.thrift
index f1e577c..2088eae 100644
--- a/sentry-provider/sentry-provider-db/src/main/resources/sentry_policy_service.thrift
+++ b/sentry-provider/sentry-provider-db/src/main/resources/sentry_policy_service.thrift
@@ -89,7 +89,19 @@ struct TAlterSentryRoleAddGroupsResponse {
 1: required sentry_common_service.TSentryResponseStatus status
 }
 
-# REVOLE ROLE r1 FROM GROUP g1
+# GRANT ROLE r1 TO USER u1
+struct TAlterSentryRoleAddUsersRequest {
+1: required i32 protocol_version = sentry_common_service.TSENTRY_SERVICE_V1,
+2: required string requestorUserName, # user on whose behalf the request is issued
+3: required string roleName,
+4: required set<string> users
+}
+
+struct TAlterSentryRoleAddUsersResponse {
+1: required sentry_common_service.TSentryResponseStatus status
+}
+
+# REVOKE ROLE r1 FROM GROUP g1
 struct TAlterSentryRoleDeleteGroupsRequest {
 1: required i32 protocol_version = sentry_common_service.TSENTRY_SERVICE_V2,
 2: required string requestorUserName, # user on whose behalf the request is issued
@@ -100,6 +112,17 @@ struct TAlterSentryRoleDeleteGroupsResponse {
 1: required sentry_common_service.TSentryResponseStatus status
 }
 
+# REVOKE ROLE r1 FROM USER u1
+struct TAlterSentryRoleDeleteUsersRequest {
+1: required i32 protocol_version = sentry_common_service.TSENTRY_SERVICE_V1,
+2: required string requestorUserName, # user on whose behalf the request is issued
+3: required string roleName,
+4: required set<string> users
+}
+struct TAlterSentryRoleDeleteUsersResponse {
+1: required sentry_common_service.TSentryResponseStatus status
+}
+
 # GRANT ... ON ... TO ROLE ...
 struct TAlterSentryRoleGrantPrivilegeRequest {
 1: required i32 protocol_version = sentry_common_service.TSENTRY_SERVICE_V2,
@@ -132,6 +155,13 @@ struct TListSentryRolesRequest {
 2: required string requestorUserName, # user on whose behalf the request is issued
 3: optional string groupName # for this group, or all roles for all groups if null
 }
+
+struct TListSentryRolesForUserRequest {
+1: required i32 protocol_version = sentry_common_service.TSENTRY_SERVICE_V1,
+2: required string requestorUserName, # user on whose behalf the request is issued
+3: required string userName
+}
+
 # used only for TListSentryRolesResponse
 struct TSentryRole {
 1: required string roleName,
@@ -198,6 +228,7 @@ struct TListSentryPrivilegesForProviderRequest {
 2: required set<string> groups,
 3: required TSentryActiveRoleSet roleSet,
 4: optional TSentryAuthorizable authorizableHierarchy,
+5: optional set<string> users
 }
 struct TListSentryPrivilegesForProviderResponse {
 1: required sentry_common_service.TSentryResponseStatus status
@@ -271,7 +302,11 @@ service SentryPolicyService
   TAlterSentryRoleAddGroupsResponse alter_sentry_role_add_groups(1:TAlterSentryRoleAddGroupsRequest request)
   TAlterSentryRoleDeleteGroupsResponse alter_sentry_role_delete_groups(1:TAlterSentryRoleDeleteGroupsRequest request)
 
+  TAlterSentryRoleAddUsersResponse alter_sentry_role_add_users(1:TAlterSentryRoleAddUsersRequest request)
+  TAlterSentryRoleDeleteUsersResponse alter_sentry_role_delete_users(1:TAlterSentryRoleDeleteUsersRequest request)
+
   TListSentryRolesResponse list_sentry_roles_by_group(1:TListSentryRolesRequest request)
+  TListSentryRolesResponse list_sentry_roles_by_user(1:TListSentryRolesForUserRequest request)
 
   TListSentryPrivilegesResponse list_sentry_privileges_by_role(1:TListSentryPrivilegesRequest request)
 

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/log/util/TestCommandUtil.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/log/util/TestCommandUtil.java b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/log/util/TestCommandUtil.java
index 8620f62..8cf0e70 100644
--- a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/log/util/TestCommandUtil.java
+++ b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/log/util/TestCommandUtil.java
@@ -22,8 +22,6 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
 
-import org.junit.Assert;
-
 import org.apache.sentry.core.model.db.AccessConstants;
 import org.apache.sentry.provider.db.generic.service.thrift.TAuthorizable;
 import org.apache.sentry.provider.db.service.thrift.TAlterSentryRoleGrantPrivilegeRequest;
@@ -31,6 +29,7 @@ import org.apache.sentry.provider.db.service.thrift.TAlterSentryRoleRevokePrivil
 import org.apache.sentry.provider.db.service.thrift.TSentryGrantOption;
 import org.apache.sentry.provider.db.service.thrift.TSentryPrivilege;
 import org.apache.sentry.service.thrift.ServiceConstants.PrivilegeScope;
+import org.junit.Assert;
 import org.junit.Test;
 
 import com.google.common.collect.Sets;
@@ -82,6 +81,34 @@ public class TestCommandUtil extends Assert {
   }
 
   @Test
+  public void testCreateCmdForRoleAddOrDeleteUser1() {
+    String createRoleAddGroupCmdResult =
+        CommandUtil.createCmdForRoleAddUser("testRole", getUserStr(1));
+    String createRoleAddGroupCmdExcepted = "GRANT ROLE testRole TO USER testUser1";
+    String createRoleDeleteGroupCmdResult =
+        CommandUtil.createCmdForRoleDeleteUser("testRole", getUserStr(1));
+    String createRoleDeleteGroupCmdExcepted = "REVOKE ROLE testRole FROM USER testUser1";
+
+    assertEquals(createRoleAddGroupCmdExcepted, createRoleAddGroupCmdResult);
+    assertEquals(createRoleDeleteGroupCmdExcepted, createRoleDeleteGroupCmdResult);
+  }
+
+  @Test
+  public void testCreateCmdForRoleAddOrDeleteUser2() {
+    String createRoleAddGroupCmdResult =
+        CommandUtil.createCmdForRoleAddUser("testRole", getUserStr(3));
+    String createRoleAddGroupCmdExcepted =
+        "GRANT ROLE testRole TO USER testUser1, testUser2, testUser3";
+    String createRoleDeleteGroupCmdResult =
+        CommandUtil.createCmdForRoleDeleteUser("testRole", getUserStr(3));
+    String createRoleDeleteGroupCmdExcepted =
+        "REVOKE ROLE testRole FROM USER testUser1, testUser2, testUser3";
+
+    assertEquals(createRoleAddGroupCmdExcepted, createRoleAddGroupCmdResult);
+    assertEquals(createRoleDeleteGroupCmdExcepted, createRoleDeleteGroupCmdResult);
+  }
+
+  @Test
   public void testCreateCmdForGrantOrRevokePrivilege1() {
     TAlterSentryRoleGrantPrivilegeRequest grantRequest = getGrantPrivilegeRequest();
     TAlterSentryRoleRevokePrivilegeRequest revokeRequest = getRevokePrivilegeRequest();
@@ -329,6 +356,17 @@ public class TestCommandUtil extends Assert {
     return sb.toString();
   }
 
+  private String getUserStr(int num) {
+    StringBuilder sb = new StringBuilder();
+    for (int i = 0; i < num; i++) {
+      if (i > 0) {
+        sb.append(", ");
+      }
+      sb.append("testUser" + (i + 1));
+    }
+    return sb.toString();
+  }
+
   private TAlterSentryRoleGrantPrivilegeRequest getGrantPrivilegeRequest() {
     TAlterSentryRoleGrantPrivilegeRequest request = new TAlterSentryRoleGrantPrivilegeRequest();
     request.setRoleName("testRole");


[4/6] sentry git commit: SENTRY-711: Implement grant user to role (Colin Ma, reviewed by Dapeng Sun)

Posted by sd...@apache.org.
http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleAddUsersRequest.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleAddUsersRequest.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleAddUsersRequest.java
new file mode 100644
index 0000000..8a71cff
--- /dev/null
+++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleAddUsersRequest.java
@@ -0,0 +1,740 @@
+/**
+ * Autogenerated by Thrift Compiler (0.9.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ *  @generated
+ */
+package org.apache.sentry.provider.db.service.thrift;
+
+import org.apache.commons.lang.builder.HashCodeBuilder;
+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 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 org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TAlterSentryRoleAddUsersRequest implements org.apache.thrift.TBase<TAlterSentryRoleAddUsersRequest, TAlterSentryRoleAddUsersRequest._Fields>, java.io.Serializable, Cloneable {
+  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TAlterSentryRoleAddUsersRequest");
+
+  private static final org.apache.thrift.protocol.TField PROTOCOL_VERSION_FIELD_DESC = new org.apache.thrift.protocol.TField("protocol_version", org.apache.thrift.protocol.TType.I32, (short)1);
+  private static final org.apache.thrift.protocol.TField REQUESTOR_USER_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("requestorUserName", org.apache.thrift.protocol.TType.STRING, (short)2);
+  private static final org.apache.thrift.protocol.TField ROLE_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("roleName", org.apache.thrift.protocol.TType.STRING, (short)3);
+  private static final org.apache.thrift.protocol.TField USERS_FIELD_DESC = new org.apache.thrift.protocol.TField("users", org.apache.thrift.protocol.TType.SET, (short)4);
+
+  private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+  static {
+    schemes.put(StandardScheme.class, new TAlterSentryRoleAddUsersRequestStandardSchemeFactory());
+    schemes.put(TupleScheme.class, new TAlterSentryRoleAddUsersRequestTupleSchemeFactory());
+  }
+
+  private int protocol_version; // required
+  private String requestorUserName; // required
+  private String roleName; // required
+  private Set<String> users; // 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 {
+    PROTOCOL_VERSION((short)1, "protocol_version"),
+    REQUESTOR_USER_NAME((short)2, "requestorUserName"),
+    ROLE_NAME((short)3, "roleName"),
+    USERS((short)4, "users");
+
+    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: // PROTOCOL_VERSION
+          return PROTOCOL_VERSION;
+        case 2: // REQUESTOR_USER_NAME
+          return REQUESTOR_USER_NAME;
+        case 3: // ROLE_NAME
+          return ROLE_NAME;
+        case 4: // USERS
+          return USERS;
+        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
+  private static final int __PROTOCOL_VERSION_ISSET_ID = 0;
+  private byte __isset_bitfield = 0;
+  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.PROTOCOL_VERSION, new org.apache.thrift.meta_data.FieldMetaData("protocol_version", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
+    tmpMap.put(_Fields.REQUESTOR_USER_NAME, new org.apache.thrift.meta_data.FieldMetaData("requestorUserName", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.ROLE_NAME, new org.apache.thrift.meta_data.FieldMetaData("roleName", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.USERS, new org.apache.thrift.meta_data.FieldMetaData("users", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+        new org.apache.thrift.meta_data.SetMetaData(org.apache.thrift.protocol.TType.SET, 
+            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
+    metaDataMap = Collections.unmodifiableMap(tmpMap);
+    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TAlterSentryRoleAddUsersRequest.class, metaDataMap);
+  }
+
+  public TAlterSentryRoleAddUsersRequest() {
+    this.protocol_version = 1;
+
+  }
+
+  public TAlterSentryRoleAddUsersRequest(
+    int protocol_version,
+    String requestorUserName,
+    String roleName,
+    Set<String> users)
+  {
+    this();
+    this.protocol_version = protocol_version;
+    setProtocol_versionIsSet(true);
+    this.requestorUserName = requestorUserName;
+    this.roleName = roleName;
+    this.users = users;
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public TAlterSentryRoleAddUsersRequest(TAlterSentryRoleAddUsersRequest other) {
+    __isset_bitfield = other.__isset_bitfield;
+    this.protocol_version = other.protocol_version;
+    if (other.isSetRequestorUserName()) {
+      this.requestorUserName = other.requestorUserName;
+    }
+    if (other.isSetRoleName()) {
+      this.roleName = other.roleName;
+    }
+    if (other.isSetUsers()) {
+      Set<String> __this__users = new HashSet<String>();
+      for (String other_element : other.users) {
+        __this__users.add(other_element);
+      }
+      this.users = __this__users;
+    }
+  }
+
+  public TAlterSentryRoleAddUsersRequest deepCopy() {
+    return new TAlterSentryRoleAddUsersRequest(this);
+  }
+
+  @Override
+  public void clear() {
+    this.protocol_version = 1;
+
+    this.requestorUserName = null;
+    this.roleName = null;
+    this.users = null;
+  }
+
+  public int getProtocol_version() {
+    return this.protocol_version;
+  }
+
+  public void setProtocol_version(int protocol_version) {
+    this.protocol_version = protocol_version;
+    setProtocol_versionIsSet(true);
+  }
+
+  public void unsetProtocol_version() {
+    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __PROTOCOL_VERSION_ISSET_ID);
+  }
+
+  /** Returns true if field protocol_version is set (has been assigned a value) and false otherwise */
+  public boolean isSetProtocol_version() {
+    return EncodingUtils.testBit(__isset_bitfield, __PROTOCOL_VERSION_ISSET_ID);
+  }
+
+  public void setProtocol_versionIsSet(boolean value) {
+    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __PROTOCOL_VERSION_ISSET_ID, value);
+  }
+
+  public String getRequestorUserName() {
+    return this.requestorUserName;
+  }
+
+  public void setRequestorUserName(String requestorUserName) {
+    this.requestorUserName = requestorUserName;
+  }
+
+  public void unsetRequestorUserName() {
+    this.requestorUserName = null;
+  }
+
+  /** Returns true if field requestorUserName is set (has been assigned a value) and false otherwise */
+  public boolean isSetRequestorUserName() {
+    return this.requestorUserName != null;
+  }
+
+  public void setRequestorUserNameIsSet(boolean value) {
+    if (!value) {
+      this.requestorUserName = null;
+    }
+  }
+
+  public String getRoleName() {
+    return this.roleName;
+  }
+
+  public void setRoleName(String roleName) {
+    this.roleName = roleName;
+  }
+
+  public void unsetRoleName() {
+    this.roleName = null;
+  }
+
+  /** Returns true if field roleName is set (has been assigned a value) and false otherwise */
+  public boolean isSetRoleName() {
+    return this.roleName != null;
+  }
+
+  public void setRoleNameIsSet(boolean value) {
+    if (!value) {
+      this.roleName = null;
+    }
+  }
+
+  public int getUsersSize() {
+    return (this.users == null) ? 0 : this.users.size();
+  }
+
+  public java.util.Iterator<String> getUsersIterator() {
+    return (this.users == null) ? null : this.users.iterator();
+  }
+
+  public void addToUsers(String elem) {
+    if (this.users == null) {
+      this.users = new HashSet<String>();
+    }
+    this.users.add(elem);
+  }
+
+  public Set<String> getUsers() {
+    return this.users;
+  }
+
+  public void setUsers(Set<String> users) {
+    this.users = users;
+  }
+
+  public void unsetUsers() {
+    this.users = null;
+  }
+
+  /** Returns true if field users is set (has been assigned a value) and false otherwise */
+  public boolean isSetUsers() {
+    return this.users != null;
+  }
+
+  public void setUsersIsSet(boolean value) {
+    if (!value) {
+      this.users = null;
+    }
+  }
+
+  public void setFieldValue(_Fields field, Object value) {
+    switch (field) {
+    case PROTOCOL_VERSION:
+      if (value == null) {
+        unsetProtocol_version();
+      } else {
+        setProtocol_version((Integer)value);
+      }
+      break;
+
+    case REQUESTOR_USER_NAME:
+      if (value == null) {
+        unsetRequestorUserName();
+      } else {
+        setRequestorUserName((String)value);
+      }
+      break;
+
+    case ROLE_NAME:
+      if (value == null) {
+        unsetRoleName();
+      } else {
+        setRoleName((String)value);
+      }
+      break;
+
+    case USERS:
+      if (value == null) {
+        unsetUsers();
+      } else {
+        setUsers((Set<String>)value);
+      }
+      break;
+
+    }
+  }
+
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
+    case PROTOCOL_VERSION:
+      return Integer.valueOf(getProtocol_version());
+
+    case REQUESTOR_USER_NAME:
+      return getRequestorUserName();
+
+    case ROLE_NAME:
+      return getRoleName();
+
+    case USERS:
+      return getUsers();
+
+    }
+    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 PROTOCOL_VERSION:
+      return isSetProtocol_version();
+    case REQUESTOR_USER_NAME:
+      return isSetRequestorUserName();
+    case ROLE_NAME:
+      return isSetRoleName();
+    case USERS:
+      return isSetUsers();
+    }
+    throw new IllegalStateException();
+  }
+
+  @Override
+  public boolean equals(Object that) {
+    if (that == null)
+      return false;
+    if (that instanceof TAlterSentryRoleAddUsersRequest)
+      return this.equals((TAlterSentryRoleAddUsersRequest)that);
+    return false;
+  }
+
+  public boolean equals(TAlterSentryRoleAddUsersRequest that) {
+    if (that == null)
+      return false;
+
+    boolean this_present_protocol_version = true;
+    boolean that_present_protocol_version = true;
+    if (this_present_protocol_version || that_present_protocol_version) {
+      if (!(this_present_protocol_version && that_present_protocol_version))
+        return false;
+      if (this.protocol_version != that.protocol_version)
+        return false;
+    }
+
+    boolean this_present_requestorUserName = true && this.isSetRequestorUserName();
+    boolean that_present_requestorUserName = true && that.isSetRequestorUserName();
+    if (this_present_requestorUserName || that_present_requestorUserName) {
+      if (!(this_present_requestorUserName && that_present_requestorUserName))
+        return false;
+      if (!this.requestorUserName.equals(that.requestorUserName))
+        return false;
+    }
+
+    boolean this_present_roleName = true && this.isSetRoleName();
+    boolean that_present_roleName = true && that.isSetRoleName();
+    if (this_present_roleName || that_present_roleName) {
+      if (!(this_present_roleName && that_present_roleName))
+        return false;
+      if (!this.roleName.equals(that.roleName))
+        return false;
+    }
+
+    boolean this_present_users = true && this.isSetUsers();
+    boolean that_present_users = true && that.isSetUsers();
+    if (this_present_users || that_present_users) {
+      if (!(this_present_users && that_present_users))
+        return false;
+      if (!this.users.equals(that.users))
+        return false;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    HashCodeBuilder builder = new HashCodeBuilder();
+
+    boolean present_protocol_version = true;
+    builder.append(present_protocol_version);
+    if (present_protocol_version)
+      builder.append(protocol_version);
+
+    boolean present_requestorUserName = true && (isSetRequestorUserName());
+    builder.append(present_requestorUserName);
+    if (present_requestorUserName)
+      builder.append(requestorUserName);
+
+    boolean present_roleName = true && (isSetRoleName());
+    builder.append(present_roleName);
+    if (present_roleName)
+      builder.append(roleName);
+
+    boolean present_users = true && (isSetUsers());
+    builder.append(present_users);
+    if (present_users)
+      builder.append(users);
+
+    return builder.toHashCode();
+  }
+
+  public int compareTo(TAlterSentryRoleAddUsersRequest other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+    TAlterSentryRoleAddUsersRequest typedOther = (TAlterSentryRoleAddUsersRequest)other;
+
+    lastComparison = Boolean.valueOf(isSetProtocol_version()).compareTo(typedOther.isSetProtocol_version());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetProtocol_version()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.protocol_version, typedOther.protocol_version);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetRequestorUserName()).compareTo(typedOther.isSetRequestorUserName());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetRequestorUserName()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.requestorUserName, typedOther.requestorUserName);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetRoleName()).compareTo(typedOther.isSetRoleName());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetRoleName()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.roleName, typedOther.roleName);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetUsers()).compareTo(typedOther.isSetUsers());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetUsers()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.users, typedOther.users);
+      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("TAlterSentryRoleAddUsersRequest(");
+    boolean first = true;
+
+    sb.append("protocol_version:");
+    sb.append(this.protocol_version);
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("requestorUserName:");
+    if (this.requestorUserName == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.requestorUserName);
+    }
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("roleName:");
+    if (this.roleName == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.roleName);
+    }
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("users:");
+    if (this.users == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.users);
+    }
+    first = false;
+    sb.append(")");
+    return sb.toString();
+  }
+
+  public void validate() throws org.apache.thrift.TException {
+    // check for required fields
+    if (!isSetProtocol_version()) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'protocol_version' is unset! Struct:" + toString());
+    }
+
+    if (!isSetRequestorUserName()) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'requestorUserName' is unset! Struct:" + toString());
+    }
+
+    if (!isSetRoleName()) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'roleName' is unset! Struct:" + toString());
+    }
+
+    if (!isSetUsers()) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'users' 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 {
+      // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
+      __isset_bitfield = 0;
+      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 TAlterSentryRoleAddUsersRequestStandardSchemeFactory implements SchemeFactory {
+    public TAlterSentryRoleAddUsersRequestStandardScheme getScheme() {
+      return new TAlterSentryRoleAddUsersRequestStandardScheme();
+    }
+  }
+
+  private static class TAlterSentryRoleAddUsersRequestStandardScheme extends StandardScheme<TAlterSentryRoleAddUsersRequest> {
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot, TAlterSentryRoleAddUsersRequest 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: // PROTOCOL_VERSION
+            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
+              struct.protocol_version = iprot.readI32();
+              struct.setProtocol_versionIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 2: // REQUESTOR_USER_NAME
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.requestorUserName = iprot.readString();
+              struct.setRequestorUserNameIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 3: // ROLE_NAME
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.roleName = iprot.readString();
+              struct.setRoleNameIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 4: // USERS
+            if (schemeField.type == org.apache.thrift.protocol.TType.SET) {
+              {
+                org.apache.thrift.protocol.TSet _set8 = iprot.readSetBegin();
+                struct.users = new HashSet<String>(2*_set8.size);
+                for (int _i9 = 0; _i9 < _set8.size; ++_i9)
+                {
+                  String _elem10; // required
+                  _elem10 = iprot.readString();
+                  struct.users.add(_elem10);
+                }
+                iprot.readSetEnd();
+              }
+              struct.setUsersIsSet(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, TAlterSentryRoleAddUsersRequest struct) throws org.apache.thrift.TException {
+      struct.validate();
+
+      oprot.writeStructBegin(STRUCT_DESC);
+      oprot.writeFieldBegin(PROTOCOL_VERSION_FIELD_DESC);
+      oprot.writeI32(struct.protocol_version);
+      oprot.writeFieldEnd();
+      if (struct.requestorUserName != null) {
+        oprot.writeFieldBegin(REQUESTOR_USER_NAME_FIELD_DESC);
+        oprot.writeString(struct.requestorUserName);
+        oprot.writeFieldEnd();
+      }
+      if (struct.roleName != null) {
+        oprot.writeFieldBegin(ROLE_NAME_FIELD_DESC);
+        oprot.writeString(struct.roleName);
+        oprot.writeFieldEnd();
+      }
+      if (struct.users != null) {
+        oprot.writeFieldBegin(USERS_FIELD_DESC);
+        {
+          oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, struct.users.size()));
+          for (String _iter11 : struct.users)
+          {
+            oprot.writeString(_iter11);
+          }
+          oprot.writeSetEnd();
+        }
+        oprot.writeFieldEnd();
+      }
+      oprot.writeFieldStop();
+      oprot.writeStructEnd();
+    }
+
+  }
+
+  private static class TAlterSentryRoleAddUsersRequestTupleSchemeFactory implements SchemeFactory {
+    public TAlterSentryRoleAddUsersRequestTupleScheme getScheme() {
+      return new TAlterSentryRoleAddUsersRequestTupleScheme();
+    }
+  }
+
+  private static class TAlterSentryRoleAddUsersRequestTupleScheme extends TupleScheme<TAlterSentryRoleAddUsersRequest> {
+
+    @Override
+    public void write(org.apache.thrift.protocol.TProtocol prot, TAlterSentryRoleAddUsersRequest struct) throws org.apache.thrift.TException {
+      TTupleProtocol oprot = (TTupleProtocol) prot;
+      oprot.writeI32(struct.protocol_version);
+      oprot.writeString(struct.requestorUserName);
+      oprot.writeString(struct.roleName);
+      {
+        oprot.writeI32(struct.users.size());
+        for (String _iter12 : struct.users)
+        {
+          oprot.writeString(_iter12);
+        }
+      }
+    }
+
+    @Override
+    public void read(org.apache.thrift.protocol.TProtocol prot, TAlterSentryRoleAddUsersRequest struct) throws org.apache.thrift.TException {
+      TTupleProtocol iprot = (TTupleProtocol) prot;
+      struct.protocol_version = iprot.readI32();
+      struct.setProtocol_versionIsSet(true);
+      struct.requestorUserName = iprot.readString();
+      struct.setRequestorUserNameIsSet(true);
+      struct.roleName = iprot.readString();
+      struct.setRoleNameIsSet(true);
+      {
+        org.apache.thrift.protocol.TSet _set13 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
+        struct.users = new HashSet<String>(2*_set13.size);
+        for (int _i14 = 0; _i14 < _set13.size; ++_i14)
+        {
+          String _elem15; // required
+          _elem15 = iprot.readString();
+          struct.users.add(_elem15);
+        }
+      }
+      struct.setUsersIsSet(true);
+    }
+  }
+
+}
+

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleAddUsersResponse.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleAddUsersResponse.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleAddUsersResponse.java
new file mode 100644
index 0000000..d94a72b
--- /dev/null
+++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleAddUsersResponse.java
@@ -0,0 +1,390 @@
+/**
+ * Autogenerated by Thrift Compiler (0.9.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ *  @generated
+ */
+package org.apache.sentry.provider.db.service.thrift;
+
+import org.apache.commons.lang.builder.HashCodeBuilder;
+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 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 org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TAlterSentryRoleAddUsersResponse implements org.apache.thrift.TBase<TAlterSentryRoleAddUsersResponse, TAlterSentryRoleAddUsersResponse._Fields>, java.io.Serializable, Cloneable {
+  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TAlterSentryRoleAddUsersResponse");
+
+  private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.STRUCT, (short)1);
+
+  private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+  static {
+    schemes.put(StandardScheme.class, new TAlterSentryRoleAddUsersResponseStandardSchemeFactory());
+    schemes.put(TupleScheme.class, new TAlterSentryRoleAddUsersResponseTupleSchemeFactory());
+  }
+
+  private org.apache.sentry.service.thrift.TSentryResponseStatus status; // 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 {
+    STATUS((short)1, "status");
+
+    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: // STATUS
+          return STATUS;
+        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.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.sentry.service.thrift.TSentryResponseStatus.class)));
+    metaDataMap = Collections.unmodifiableMap(tmpMap);
+    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TAlterSentryRoleAddUsersResponse.class, metaDataMap);
+  }
+
+  public TAlterSentryRoleAddUsersResponse() {
+  }
+
+  public TAlterSentryRoleAddUsersResponse(
+    org.apache.sentry.service.thrift.TSentryResponseStatus status)
+  {
+    this();
+    this.status = status;
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public TAlterSentryRoleAddUsersResponse(TAlterSentryRoleAddUsersResponse other) {
+    if (other.isSetStatus()) {
+      this.status = new org.apache.sentry.service.thrift.TSentryResponseStatus(other.status);
+    }
+  }
+
+  public TAlterSentryRoleAddUsersResponse deepCopy() {
+    return new TAlterSentryRoleAddUsersResponse(this);
+  }
+
+  @Override
+  public void clear() {
+    this.status = null;
+  }
+
+  public org.apache.sentry.service.thrift.TSentryResponseStatus getStatus() {
+    return this.status;
+  }
+
+  public void setStatus(org.apache.sentry.service.thrift.TSentryResponseStatus status) {
+    this.status = status;
+  }
+
+  public void unsetStatus() {
+    this.status = null;
+  }
+
+  /** Returns true if field status is set (has been assigned a value) and false otherwise */
+  public boolean isSetStatus() {
+    return this.status != null;
+  }
+
+  public void setStatusIsSet(boolean value) {
+    if (!value) {
+      this.status = null;
+    }
+  }
+
+  public void setFieldValue(_Fields field, Object value) {
+    switch (field) {
+    case STATUS:
+      if (value == null) {
+        unsetStatus();
+      } else {
+        setStatus((org.apache.sentry.service.thrift.TSentryResponseStatus)value);
+      }
+      break;
+
+    }
+  }
+
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
+    case STATUS:
+      return getStatus();
+
+    }
+    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 STATUS:
+      return isSetStatus();
+    }
+    throw new IllegalStateException();
+  }
+
+  @Override
+  public boolean equals(Object that) {
+    if (that == null)
+      return false;
+    if (that instanceof TAlterSentryRoleAddUsersResponse)
+      return this.equals((TAlterSentryRoleAddUsersResponse)that);
+    return false;
+  }
+
+  public boolean equals(TAlterSentryRoleAddUsersResponse that) {
+    if (that == null)
+      return false;
+
+    boolean this_present_status = true && this.isSetStatus();
+    boolean that_present_status = true && that.isSetStatus();
+    if (this_present_status || that_present_status) {
+      if (!(this_present_status && that_present_status))
+        return false;
+      if (!this.status.equals(that.status))
+        return false;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    HashCodeBuilder builder = new HashCodeBuilder();
+
+    boolean present_status = true && (isSetStatus());
+    builder.append(present_status);
+    if (present_status)
+      builder.append(status);
+
+    return builder.toHashCode();
+  }
+
+  public int compareTo(TAlterSentryRoleAddUsersResponse other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+    TAlterSentryRoleAddUsersResponse typedOther = (TAlterSentryRoleAddUsersResponse)other;
+
+    lastComparison = Boolean.valueOf(isSetStatus()).compareTo(typedOther.isSetStatus());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetStatus()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, typedOther.status);
+      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("TAlterSentryRoleAddUsersResponse(");
+    boolean first = true;
+
+    sb.append("status:");
+    if (this.status == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.status);
+    }
+    first = false;
+    sb.append(")");
+    return sb.toString();
+  }
+
+  public void validate() throws org.apache.thrift.TException {
+    // check for required fields
+    if (!isSetStatus()) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' is unset! Struct:" + toString());
+    }
+
+    // check for sub-struct validity
+    if (status != null) {
+      status.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 TAlterSentryRoleAddUsersResponseStandardSchemeFactory implements SchemeFactory {
+    public TAlterSentryRoleAddUsersResponseStandardScheme getScheme() {
+      return new TAlterSentryRoleAddUsersResponseStandardScheme();
+    }
+  }
+
+  private static class TAlterSentryRoleAddUsersResponseStandardScheme extends StandardScheme<TAlterSentryRoleAddUsersResponse> {
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot, TAlterSentryRoleAddUsersResponse 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: // STATUS
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+              struct.status = new org.apache.sentry.service.thrift.TSentryResponseStatus();
+              struct.status.read(iprot);
+              struct.setStatusIsSet(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, TAlterSentryRoleAddUsersResponse struct) throws org.apache.thrift.TException {
+      struct.validate();
+
+      oprot.writeStructBegin(STRUCT_DESC);
+      if (struct.status != null) {
+        oprot.writeFieldBegin(STATUS_FIELD_DESC);
+        struct.status.write(oprot);
+        oprot.writeFieldEnd();
+      }
+      oprot.writeFieldStop();
+      oprot.writeStructEnd();
+    }
+
+  }
+
+  private static class TAlterSentryRoleAddUsersResponseTupleSchemeFactory implements SchemeFactory {
+    public TAlterSentryRoleAddUsersResponseTupleScheme getScheme() {
+      return new TAlterSentryRoleAddUsersResponseTupleScheme();
+    }
+  }
+
+  private static class TAlterSentryRoleAddUsersResponseTupleScheme extends TupleScheme<TAlterSentryRoleAddUsersResponse> {
+
+    @Override
+    public void write(org.apache.thrift.protocol.TProtocol prot, TAlterSentryRoleAddUsersResponse struct) throws org.apache.thrift.TException {
+      TTupleProtocol oprot = (TTupleProtocol) prot;
+      struct.status.write(oprot);
+    }
+
+    @Override
+    public void read(org.apache.thrift.protocol.TProtocol prot, TAlterSentryRoleAddUsersResponse struct) throws org.apache.thrift.TException {
+      TTupleProtocol iprot = (TTupleProtocol) prot;
+      struct.status = new org.apache.sentry.service.thrift.TSentryResponseStatus();
+      struct.status.read(iprot);
+      struct.setStatusIsSet(true);
+    }
+  }
+
+}
+

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleDeleteGroupsRequest.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleDeleteGroupsRequest.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleDeleteGroupsRequest.java
index da4d76c..fce68e5 100644
--- a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleDeleteGroupsRequest.java
+++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleDeleteGroupsRequest.java
@@ -631,14 +631,14 @@ public class TAlterSentryRoleDeleteGroupsRequest implements org.apache.thrift.TB
           case 5: // GROUPS
             if (schemeField.type == org.apache.thrift.protocol.TType.SET) {
               {
-                org.apache.thrift.protocol.TSet _set8 = iprot.readSetBegin();
-                struct.groups = new HashSet<TSentryGroup>(2*_set8.size);
-                for (int _i9 = 0; _i9 < _set8.size; ++_i9)
+                org.apache.thrift.protocol.TSet _set16 = iprot.readSetBegin();
+                struct.groups = new HashSet<TSentryGroup>(2*_set16.size);
+                for (int _i17 = 0; _i17 < _set16.size; ++_i17)
                 {
-                  TSentryGroup _elem10; // required
-                  _elem10 = new TSentryGroup();
-                  _elem10.read(iprot);
-                  struct.groups.add(_elem10);
+                  TSentryGroup _elem18; // required
+                  _elem18 = new TSentryGroup();
+                  _elem18.read(iprot);
+                  struct.groups.add(_elem18);
                 }
                 iprot.readSetEnd();
               }
@@ -677,9 +677,9 @@ public class TAlterSentryRoleDeleteGroupsRequest implements org.apache.thrift.TB
         oprot.writeFieldBegin(GROUPS_FIELD_DESC);
         {
           oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, struct.groups.size()));
-          for (TSentryGroup _iter11 : struct.groups)
+          for (TSentryGroup _iter19 : struct.groups)
           {
-            _iter11.write(oprot);
+            _iter19.write(oprot);
           }
           oprot.writeSetEnd();
         }
@@ -707,9 +707,9 @@ public class TAlterSentryRoleDeleteGroupsRequest implements org.apache.thrift.TB
       oprot.writeString(struct.roleName);
       {
         oprot.writeI32(struct.groups.size());
-        for (TSentryGroup _iter12 : struct.groups)
+        for (TSentryGroup _iter20 : struct.groups)
         {
-          _iter12.write(oprot);
+          _iter20.write(oprot);
         }
       }
     }
@@ -724,14 +724,14 @@ public class TAlterSentryRoleDeleteGroupsRequest implements org.apache.thrift.TB
       struct.roleName = iprot.readString();
       struct.setRoleNameIsSet(true);
       {
-        org.apache.thrift.protocol.TSet _set13 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
-        struct.groups = new HashSet<TSentryGroup>(2*_set13.size);
-        for (int _i14 = 0; _i14 < _set13.size; ++_i14)
+        org.apache.thrift.protocol.TSet _set21 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
+        struct.groups = new HashSet<TSentryGroup>(2*_set21.size);
+        for (int _i22 = 0; _i22 < _set21.size; ++_i22)
         {
-          TSentryGroup _elem15; // required
-          _elem15 = new TSentryGroup();
-          _elem15.read(iprot);
-          struct.groups.add(_elem15);
+          TSentryGroup _elem23; // required
+          _elem23 = new TSentryGroup();
+          _elem23.read(iprot);
+          struct.groups.add(_elem23);
         }
       }
       struct.setGroupsIsSet(true);

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleDeleteUsersRequest.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleDeleteUsersRequest.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleDeleteUsersRequest.java
new file mode 100644
index 0000000..cb8be6d
--- /dev/null
+++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleDeleteUsersRequest.java
@@ -0,0 +1,740 @@
+/**
+ * Autogenerated by Thrift Compiler (0.9.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ *  @generated
+ */
+package org.apache.sentry.provider.db.service.thrift;
+
+import org.apache.commons.lang.builder.HashCodeBuilder;
+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 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 org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TAlterSentryRoleDeleteUsersRequest implements org.apache.thrift.TBase<TAlterSentryRoleDeleteUsersRequest, TAlterSentryRoleDeleteUsersRequest._Fields>, java.io.Serializable, Cloneable {
+  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TAlterSentryRoleDeleteUsersRequest");
+
+  private static final org.apache.thrift.protocol.TField PROTOCOL_VERSION_FIELD_DESC = new org.apache.thrift.protocol.TField("protocol_version", org.apache.thrift.protocol.TType.I32, (short)1);
+  private static final org.apache.thrift.protocol.TField REQUESTOR_USER_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("requestorUserName", org.apache.thrift.protocol.TType.STRING, (short)2);
+  private static final org.apache.thrift.protocol.TField ROLE_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("roleName", org.apache.thrift.protocol.TType.STRING, (short)3);
+  private static final org.apache.thrift.protocol.TField USERS_FIELD_DESC = new org.apache.thrift.protocol.TField("users", org.apache.thrift.protocol.TType.SET, (short)4);
+
+  private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+  static {
+    schemes.put(StandardScheme.class, new TAlterSentryRoleDeleteUsersRequestStandardSchemeFactory());
+    schemes.put(TupleScheme.class, new TAlterSentryRoleDeleteUsersRequestTupleSchemeFactory());
+  }
+
+  private int protocol_version; // required
+  private String requestorUserName; // required
+  private String roleName; // required
+  private Set<String> users; // 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 {
+    PROTOCOL_VERSION((short)1, "protocol_version"),
+    REQUESTOR_USER_NAME((short)2, "requestorUserName"),
+    ROLE_NAME((short)3, "roleName"),
+    USERS((short)4, "users");
+
+    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: // PROTOCOL_VERSION
+          return PROTOCOL_VERSION;
+        case 2: // REQUESTOR_USER_NAME
+          return REQUESTOR_USER_NAME;
+        case 3: // ROLE_NAME
+          return ROLE_NAME;
+        case 4: // USERS
+          return USERS;
+        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
+  private static final int __PROTOCOL_VERSION_ISSET_ID = 0;
+  private byte __isset_bitfield = 0;
+  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.PROTOCOL_VERSION, new org.apache.thrift.meta_data.FieldMetaData("protocol_version", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
+    tmpMap.put(_Fields.REQUESTOR_USER_NAME, new org.apache.thrift.meta_data.FieldMetaData("requestorUserName", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.ROLE_NAME, new org.apache.thrift.meta_data.FieldMetaData("roleName", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.USERS, new org.apache.thrift.meta_data.FieldMetaData("users", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+        new org.apache.thrift.meta_data.SetMetaData(org.apache.thrift.protocol.TType.SET, 
+            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
+    metaDataMap = Collections.unmodifiableMap(tmpMap);
+    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TAlterSentryRoleDeleteUsersRequest.class, metaDataMap);
+  }
+
+  public TAlterSentryRoleDeleteUsersRequest() {
+    this.protocol_version = 1;
+
+  }
+
+  public TAlterSentryRoleDeleteUsersRequest(
+    int protocol_version,
+    String requestorUserName,
+    String roleName,
+    Set<String> users)
+  {
+    this();
+    this.protocol_version = protocol_version;
+    setProtocol_versionIsSet(true);
+    this.requestorUserName = requestorUserName;
+    this.roleName = roleName;
+    this.users = users;
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public TAlterSentryRoleDeleteUsersRequest(TAlterSentryRoleDeleteUsersRequest other) {
+    __isset_bitfield = other.__isset_bitfield;
+    this.protocol_version = other.protocol_version;
+    if (other.isSetRequestorUserName()) {
+      this.requestorUserName = other.requestorUserName;
+    }
+    if (other.isSetRoleName()) {
+      this.roleName = other.roleName;
+    }
+    if (other.isSetUsers()) {
+      Set<String> __this__users = new HashSet<String>();
+      for (String other_element : other.users) {
+        __this__users.add(other_element);
+      }
+      this.users = __this__users;
+    }
+  }
+
+  public TAlterSentryRoleDeleteUsersRequest deepCopy() {
+    return new TAlterSentryRoleDeleteUsersRequest(this);
+  }
+
+  @Override
+  public void clear() {
+    this.protocol_version = 1;
+
+    this.requestorUserName = null;
+    this.roleName = null;
+    this.users = null;
+  }
+
+  public int getProtocol_version() {
+    return this.protocol_version;
+  }
+
+  public void setProtocol_version(int protocol_version) {
+    this.protocol_version = protocol_version;
+    setProtocol_versionIsSet(true);
+  }
+
+  public void unsetProtocol_version() {
+    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __PROTOCOL_VERSION_ISSET_ID);
+  }
+
+  /** Returns true if field protocol_version is set (has been assigned a value) and false otherwise */
+  public boolean isSetProtocol_version() {
+    return EncodingUtils.testBit(__isset_bitfield, __PROTOCOL_VERSION_ISSET_ID);
+  }
+
+  public void setProtocol_versionIsSet(boolean value) {
+    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __PROTOCOL_VERSION_ISSET_ID, value);
+  }
+
+  public String getRequestorUserName() {
+    return this.requestorUserName;
+  }
+
+  public void setRequestorUserName(String requestorUserName) {
+    this.requestorUserName = requestorUserName;
+  }
+
+  public void unsetRequestorUserName() {
+    this.requestorUserName = null;
+  }
+
+  /** Returns true if field requestorUserName is set (has been assigned a value) and false otherwise */
+  public boolean isSetRequestorUserName() {
+    return this.requestorUserName != null;
+  }
+
+  public void setRequestorUserNameIsSet(boolean value) {
+    if (!value) {
+      this.requestorUserName = null;
+    }
+  }
+
+  public String getRoleName() {
+    return this.roleName;
+  }
+
+  public void setRoleName(String roleName) {
+    this.roleName = roleName;
+  }
+
+  public void unsetRoleName() {
+    this.roleName = null;
+  }
+
+  /** Returns true if field roleName is set (has been assigned a value) and false otherwise */
+  public boolean isSetRoleName() {
+    return this.roleName != null;
+  }
+
+  public void setRoleNameIsSet(boolean value) {
+    if (!value) {
+      this.roleName = null;
+    }
+  }
+
+  public int getUsersSize() {
+    return (this.users == null) ? 0 : this.users.size();
+  }
+
+  public java.util.Iterator<String> getUsersIterator() {
+    return (this.users == null) ? null : this.users.iterator();
+  }
+
+  public void addToUsers(String elem) {
+    if (this.users == null) {
+      this.users = new HashSet<String>();
+    }
+    this.users.add(elem);
+  }
+
+  public Set<String> getUsers() {
+    return this.users;
+  }
+
+  public void setUsers(Set<String> users) {
+    this.users = users;
+  }
+
+  public void unsetUsers() {
+    this.users = null;
+  }
+
+  /** Returns true if field users is set (has been assigned a value) and false otherwise */
+  public boolean isSetUsers() {
+    return this.users != null;
+  }
+
+  public void setUsersIsSet(boolean value) {
+    if (!value) {
+      this.users = null;
+    }
+  }
+
+  public void setFieldValue(_Fields field, Object value) {
+    switch (field) {
+    case PROTOCOL_VERSION:
+      if (value == null) {
+        unsetProtocol_version();
+      } else {
+        setProtocol_version((Integer)value);
+      }
+      break;
+
+    case REQUESTOR_USER_NAME:
+      if (value == null) {
+        unsetRequestorUserName();
+      } else {
+        setRequestorUserName((String)value);
+      }
+      break;
+
+    case ROLE_NAME:
+      if (value == null) {
+        unsetRoleName();
+      } else {
+        setRoleName((String)value);
+      }
+      break;
+
+    case USERS:
+      if (value == null) {
+        unsetUsers();
+      } else {
+        setUsers((Set<String>)value);
+      }
+      break;
+
+    }
+  }
+
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
+    case PROTOCOL_VERSION:
+      return Integer.valueOf(getProtocol_version());
+
+    case REQUESTOR_USER_NAME:
+      return getRequestorUserName();
+
+    case ROLE_NAME:
+      return getRoleName();
+
+    case USERS:
+      return getUsers();
+
+    }
+    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 PROTOCOL_VERSION:
+      return isSetProtocol_version();
+    case REQUESTOR_USER_NAME:
+      return isSetRequestorUserName();
+    case ROLE_NAME:
+      return isSetRoleName();
+    case USERS:
+      return isSetUsers();
+    }
+    throw new IllegalStateException();
+  }
+
+  @Override
+  public boolean equals(Object that) {
+    if (that == null)
+      return false;
+    if (that instanceof TAlterSentryRoleDeleteUsersRequest)
+      return this.equals((TAlterSentryRoleDeleteUsersRequest)that);
+    return false;
+  }
+
+  public boolean equals(TAlterSentryRoleDeleteUsersRequest that) {
+    if (that == null)
+      return false;
+
+    boolean this_present_protocol_version = true;
+    boolean that_present_protocol_version = true;
+    if (this_present_protocol_version || that_present_protocol_version) {
+      if (!(this_present_protocol_version && that_present_protocol_version))
+        return false;
+      if (this.protocol_version != that.protocol_version)
+        return false;
+    }
+
+    boolean this_present_requestorUserName = true && this.isSetRequestorUserName();
+    boolean that_present_requestorUserName = true && that.isSetRequestorUserName();
+    if (this_present_requestorUserName || that_present_requestorUserName) {
+      if (!(this_present_requestorUserName && that_present_requestorUserName))
+        return false;
+      if (!this.requestorUserName.equals(that.requestorUserName))
+        return false;
+    }
+
+    boolean this_present_roleName = true && this.isSetRoleName();
+    boolean that_present_roleName = true && that.isSetRoleName();
+    if (this_present_roleName || that_present_roleName) {
+      if (!(this_present_roleName && that_present_roleName))
+        return false;
+      if (!this.roleName.equals(that.roleName))
+        return false;
+    }
+
+    boolean this_present_users = true && this.isSetUsers();
+    boolean that_present_users = true && that.isSetUsers();
+    if (this_present_users || that_present_users) {
+      if (!(this_present_users && that_present_users))
+        return false;
+      if (!this.users.equals(that.users))
+        return false;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    HashCodeBuilder builder = new HashCodeBuilder();
+
+    boolean present_protocol_version = true;
+    builder.append(present_protocol_version);
+    if (present_protocol_version)
+      builder.append(protocol_version);
+
+    boolean present_requestorUserName = true && (isSetRequestorUserName());
+    builder.append(present_requestorUserName);
+    if (present_requestorUserName)
+      builder.append(requestorUserName);
+
+    boolean present_roleName = true && (isSetRoleName());
+    builder.append(present_roleName);
+    if (present_roleName)
+      builder.append(roleName);
+
+    boolean present_users = true && (isSetUsers());
+    builder.append(present_users);
+    if (present_users)
+      builder.append(users);
+
+    return builder.toHashCode();
+  }
+
+  public int compareTo(TAlterSentryRoleDeleteUsersRequest other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+    TAlterSentryRoleDeleteUsersRequest typedOther = (TAlterSentryRoleDeleteUsersRequest)other;
+
+    lastComparison = Boolean.valueOf(isSetProtocol_version()).compareTo(typedOther.isSetProtocol_version());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetProtocol_version()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.protocol_version, typedOther.protocol_version);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetRequestorUserName()).compareTo(typedOther.isSetRequestorUserName());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetRequestorUserName()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.requestorUserName, typedOther.requestorUserName);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetRoleName()).compareTo(typedOther.isSetRoleName());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetRoleName()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.roleName, typedOther.roleName);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetUsers()).compareTo(typedOther.isSetUsers());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetUsers()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.users, typedOther.users);
+      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("TAlterSentryRoleDeleteUsersRequest(");
+    boolean first = true;
+
+    sb.append("protocol_version:");
+    sb.append(this.protocol_version);
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("requestorUserName:");
+    if (this.requestorUserName == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.requestorUserName);
+    }
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("roleName:");
+    if (this.roleName == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.roleName);
+    }
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("users:");
+    if (this.users == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.users);
+    }
+    first = false;
+    sb.append(")");
+    return sb.toString();
+  }
+
+  public void validate() throws org.apache.thrift.TException {
+    // check for required fields
+    if (!isSetProtocol_version()) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'protocol_version' is unset! Struct:" + toString());
+    }
+
+    if (!isSetRequestorUserName()) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'requestorUserName' is unset! Struct:" + toString());
+    }
+
+    if (!isSetRoleName()) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'roleName' is unset! Struct:" + toString());
+    }
+
+    if (!isSetUsers()) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'users' 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 {
+      // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
+      __isset_bitfield = 0;
+      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 TAlterSentryRoleDeleteUsersRequestStandardSchemeFactory implements SchemeFactory {
+    public TAlterSentryRoleDeleteUsersRequestStandardScheme getScheme() {
+      return new TAlterSentryRoleDeleteUsersRequestStandardScheme();
+    }
+  }
+
+  private static class TAlterSentryRoleDeleteUsersRequestStandardScheme extends StandardScheme<TAlterSentryRoleDeleteUsersRequest> {
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot, TAlterSentryRoleDeleteUsersRequest 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: // PROTOCOL_VERSION
+            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
+              struct.protocol_version = iprot.readI32();
+              struct.setProtocol_versionIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 2: // REQUESTOR_USER_NAME
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.requestorUserName = iprot.readString();
+              struct.setRequestorUserNameIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 3: // ROLE_NAME
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.roleName = iprot.readString();
+              struct.setRoleNameIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 4: // USERS
+            if (schemeField.type == org.apache.thrift.protocol.TType.SET) {
+              {
+                org.apache.thrift.protocol.TSet _set24 = iprot.readSetBegin();
+                struct.users = new HashSet<String>(2*_set24.size);
+                for (int _i25 = 0; _i25 < _set24.size; ++_i25)
+                {
+                  String _elem26; // required
+                  _elem26 = iprot.readString();
+                  struct.users.add(_elem26);
+                }
+                iprot.readSetEnd();
+              }
+              struct.setUsersIsSet(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, TAlterSentryRoleDeleteUsersRequest struct) throws org.apache.thrift.TException {
+      struct.validate();
+
+      oprot.writeStructBegin(STRUCT_DESC);
+      oprot.writeFieldBegin(PROTOCOL_VERSION_FIELD_DESC);
+      oprot.writeI32(struct.protocol_version);
+      oprot.writeFieldEnd();
+      if (struct.requestorUserName != null) {
+        oprot.writeFieldBegin(REQUESTOR_USER_NAME_FIELD_DESC);
+        oprot.writeString(struct.requestorUserName);
+        oprot.writeFieldEnd();
+      }
+      if (struct.roleName != null) {
+        oprot.writeFieldBegin(ROLE_NAME_FIELD_DESC);
+        oprot.writeString(struct.roleName);
+        oprot.writeFieldEnd();
+      }
+      if (struct.users != null) {
+        oprot.writeFieldBegin(USERS_FIELD_DESC);
+        {
+          oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, struct.users.size()));
+          for (String _iter27 : struct.users)
+          {
+            oprot.writeString(_iter27);
+          }
+          oprot.writeSetEnd();
+        }
+        oprot.writeFieldEnd();
+      }
+      oprot.writeFieldStop();
+      oprot.writeStructEnd();
+    }
+
+  }
+
+  private static class TAlterSentryRoleDeleteUsersRequestTupleSchemeFactory implements SchemeFactory {
+    public TAlterSentryRoleDeleteUsersRequestTupleScheme getScheme() {
+      return new TAlterSentryRoleDeleteUsersRequestTupleScheme();
+    }
+  }
+
+  private static class TAlterSentryRoleDeleteUsersRequestTupleScheme extends TupleScheme<TAlterSentryRoleDeleteUsersRequest> {
+
+    @Override
+    public void write(org.apache.thrift.protocol.TProtocol prot, TAlterSentryRoleDeleteUsersRequest struct) throws org.apache.thrift.TException {
+      TTupleProtocol oprot = (TTupleProtocol) prot;
+      oprot.writeI32(struct.protocol_version);
+      oprot.writeString(struct.requestorUserName);
+      oprot.writeString(struct.roleName);
+      {
+        oprot.writeI32(struct.users.size());
+        for (String _iter28 : struct.users)
+        {
+          oprot.writeString(_iter28);
+        }
+      }
+    }
+
+    @Override
+    public void read(org.apache.thrift.protocol.TProtocol prot, TAlterSentryRoleDeleteUsersRequest struct) throws org.apache.thrift.TException {
+      TTupleProtocol iprot = (TTupleProtocol) prot;
+      struct.protocol_version = iprot.readI32();
+      struct.setProtocol_versionIsSet(true);
+      struct.requestorUserName = iprot.readString();
+      struct.setRequestorUserNameIsSet(true);
+      struct.roleName = iprot.readString();
+      struct.setRoleNameIsSet(true);
+      {
+        org.apache.thrift.protocol.TSet _set29 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
+        struct.users = new HashSet<String>(2*_set29.size);
+        for (int _i30 = 0; _i30 < _set29.size; ++_i30)
+        {
+          String _elem31; // required
+          _elem31 = iprot.readString();
+          struct.users.add(_elem31);
+        }
+      }
+      struct.setUsersIsSet(true);
+    }
+  }
+
+}
+

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleDeleteUsersResponse.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleDeleteUsersResponse.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleDeleteUsersResponse.java
new file mode 100644
index 0000000..449cd66
--- /dev/null
+++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleDeleteUsersResponse.java
@@ -0,0 +1,390 @@
+/**
+ * Autogenerated by Thrift Compiler (0.9.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ *  @generated
+ */
+package org.apache.sentry.provider.db.service.thrift;
+
+import org.apache.commons.lang.builder.HashCodeBuilder;
+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 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 org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TAlterSentryRoleDeleteUsersResponse implements org.apache.thrift.TBase<TAlterSentryRoleDeleteUsersResponse, TAlterSentryRoleDeleteUsersResponse._Fields>, java.io.Serializable, Cloneable {
+  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TAlterSentryRoleDeleteUsersResponse");
+
+  private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.STRUCT, (short)1);
+
+  private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+  static {
+    schemes.put(StandardScheme.class, new TAlterSentryRoleDeleteUsersResponseStandardSchemeFactory());
+    schemes.put(TupleScheme.class, new TAlterSentryRoleDeleteUsersResponseTupleSchemeFactory());
+  }
+
+  private org.apache.sentry.service.thrift.TSentryResponseStatus status; // 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 {
+    STATUS((short)1, "status");
+
+    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: // STATUS
+          return STATUS;
+        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.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.sentry.service.thrift.TSentryResponseStatus.class)));
+    metaDataMap = Collections.unmodifiableMap(tmpMap);
+    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TAlterSentryRoleDeleteUsersResponse.class, metaDataMap);
+  }
+
+  public TAlterSentryRoleDeleteUsersResponse() {
+  }
+
+  public TAlterSentryRoleDeleteUsersResponse(
+    org.apache.sentry.service.thrift.TSentryResponseStatus status)
+  {
+    this();
+    this.status = status;
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public TAlterSentryRoleDeleteUsersResponse(TAlterSentryRoleDeleteUsersResponse other) {
+    if (other.isSetStatus()) {
+      this.status = new org.apache.sentry.service.thrift.TSentryResponseStatus(other.status);
+    }
+  }
+
+  public TAlterSentryRoleDeleteUsersResponse deepCopy() {
+    return new TAlterSentryRoleDeleteUsersResponse(this);
+  }
+
+  @Override
+  public void clear() {
+    this.status = null;
+  }
+
+  public org.apache.sentry.service.thrift.TSentryResponseStatus getStatus() {
+    return this.status;
+  }
+
+  public void setStatus(org.apache.sentry.service.thrift.TSentryResponseStatus status) {
+    this.status = status;
+  }
+
+  public void unsetStatus() {
+    this.status = null;
+  }
+
+  /** Returns true if field status is set (has been assigned a value) and false otherwise */
+  public boolean isSetStatus() {
+    return this.status != null;
+  }
+
+  public void setStatusIsSet(boolean value) {
+    if (!value) {
+      this.status = null;
+    }
+  }
+
+  public void setFieldValue(_Fields field, Object value) {
+    switch (field) {
+    case STATUS:
+      if (value == null) {
+        unsetStatus();
+      } else {
+        setStatus((org.apache.sentry.service.thrift.TSentryResponseStatus)value);
+      }
+      break;
+
+    }
+  }
+
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
+    case STATUS:
+      return getStatus();
+
+    }
+    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 STATUS:
+      return isSetStatus();
+    }
+    throw new IllegalStateException();
+  }
+
+  @Override
+  public boolean equals(Object that) {
+    if (that == null)
+      return false;
+    if (that instanceof TAlterSentryRoleDeleteUsersResponse)
+      return this.equals((TAlterSentryRoleDeleteUsersResponse)that);
+    return false;
+  }
+
+  public boolean equals(TAlterSentryRoleDeleteUsersResponse that) {
+    if (that == null)
+      return false;
+
+    boolean this_present_status = true && this.isSetStatus();
+    boolean that_present_status = true && that.isSetStatus();
+    if (this_present_status || that_present_status) {
+      if (!(this_present_status && that_present_status))
+        return false;
+      if (!this.status.equals(that.status))
+        return false;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    HashCodeBuilder builder = new HashCodeBuilder();
+
+    boolean present_status = true && (isSetStatus());
+    builder.append(present_status);
+    if (present_status)
+      builder.append(status);
+
+    return builder.toHashCode();
+  }
+
+  public int compareTo(TAlterSentryRoleDeleteUsersResponse other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+    TAlterSentryRoleDeleteUsersResponse typedOther = (TAlterSentryRoleDeleteUsersResponse)other;
+
+    lastComparison = Boolean.valueOf(isSetStatus()).compareTo(typedOther.isSetStatus());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetStatus()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, typedOther.status);
+      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("TAlterSentryRoleDeleteUsersResponse(");
+    boolean first = true;
+
+    sb.append("status:");
+    if (this.status == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.status);
+    }
+    first = false;
+    sb.append(")");
+    return sb.toString();
+  }
+
+  public void validate() throws org.apache.thrift.TException {
+    // check for required fields
+    if (!isSetStatus()) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' is unset! Struct:" + toString());
+    }
+
+    // check for sub-struct validity
+    if (status != null) {
+      status.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 TAlterSentryRoleDeleteUsersResponseStandardSchemeFactory implements SchemeFactory {
+    public TAlterSentryRoleDeleteUsersResponseStandardScheme getScheme() {
+      return new TAlterSentryRoleDeleteUsersResponseStandardScheme();
+    }
+  }
+
+  private static class TAlterSentryRoleDeleteUsersResponseStandardScheme extends StandardScheme<TAlterSentryRoleDeleteUsersResponse> {
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot, TAlterSentryRoleDeleteUsersResponse 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: // STATUS
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+              struct.status = new org.apache.sentry.service.thrift.TSentryResponseStatus();
+              struct.status.read(iprot);
+              struct.setStatusIsSet(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, TAlterSentryRoleDeleteUsersResponse struct) throws org.apache.thrift.TException {
+      struct.validate();
+
+      oprot.writeStructBegin(STRUCT_DESC);
+      if (struct.status != null) {
+        oprot.writeFieldBegin(STATUS_FIELD_DESC);
+        struct.status.write(oprot);
+        oprot.writeFieldEnd();
+      }
+      oprot.writeFieldStop();
+      oprot.writeStructEnd();
+    }
+
+  }
+
+  private static class TAlterSentryRoleDeleteUsersResponseTupleSchemeFactory implements SchemeFactory {
+    public TAlterSentryRoleDeleteUsersResponseTupleScheme getScheme() {
+      return new TAlterSentryRoleDeleteUsersResponseTupleScheme();
+    }
+  }
+
+  private static class TAlterSentryRoleDeleteUsersResponseTupleScheme extends TupleScheme<TAlterSentryRoleDeleteUsersResponse> {
+
+    @Override
+    public void write(org.apache.thrift.protocol.TProtocol prot, TAlterSentryRoleDeleteUsersResponse struct) throws org.apache.thrift.TException {
+      TTupleProtocol oprot = (TTupleProtocol) prot;
+      struct.status.write(oprot);
+    }
+
+    @Override
+    public void read(org.apache.thrift.protocol.TProtocol prot, TAlterSentryRoleDeleteUsersResponse struct) throws org.apache.thrift.TException {
+      TTupleProtocol iprot = (TTupleProtocol) prot;
+      struct.status = new org.apache.sentry.service.thrift.TSentryResponseStatus();
+      struct.status.read(iprot);
+      struct.setStatusIsSet(true);
+    }
+  }
+
+}
+

http://git-wip-us.apache.org/repos/asf/sentry/blob/68949951/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleGrantPrivilegeRequest.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleGrantPrivilegeRequest.java b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleGrantPrivilegeRequest.java
index aafa91e..d95752f 100644
--- a/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleGrantPrivilegeRequest.java
+++ b/sentry-provider/sentry-provider-db/src/gen/thrift/gen-javabean/org/apache/sentry/provider/db/service/thrift/TAlterSentryRoleGrantPrivilegeRequest.java
@@ -721,14 +721,14 @@ public class TAlterSentryRoleGrantPrivilegeRequest implements org.apache.thrift.
           case 6: // PRIVILEGES
             if (schemeField.type == org.apache.thrift.protocol.TType.SET) {
               {
-                org.apache.thrift.protocol.TSet _set16 = iprot.readSetBegin();
-                struct.privileges = new HashSet<TSentryPrivilege>(2*_set16.size);
-                for (int _i17 = 0; _i17 < _set16.size; ++_i17)
+                org.apache.thrift.protocol.TSet _set32 = iprot.readSetBegin();
+                struct.privileges = new HashSet<TSentryPrivilege>(2*_set32.size);
+                for (int _i33 = 0; _i33 < _set32.size; ++_i33)
                 {
-                  TSentryPrivilege _elem18; // required
-                  _elem18 = new TSentryPrivilege();
-                  _elem18.read(iprot);
-                  struct.privileges.add(_elem18);
+                  TSentryPrivilege _elem34; // required
+                  _elem34 = new TSentryPrivilege();
+                  _elem34.read(iprot);
+                  struct.privileges.add(_elem34);
                 }
                 iprot.readSetEnd();
               }
@@ -775,9 +775,9 @@ public class TAlterSentryRoleGrantPrivilegeRequest implements org.apache.thrift.
           oprot.writeFieldBegin(PRIVILEGES_FIELD_DESC);
           {
             oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, struct.privileges.size()));
-            for (TSentryPrivilege _iter19 : struct.privileges)
+            for (TSentryPrivilege _iter35 : struct.privileges)
             {
-              _iter19.write(oprot);
+              _iter35.write(oprot);
             }
             oprot.writeSetEnd();
           }
@@ -818,9 +818,9 @@ public class TAlterSentryRoleGrantPrivilegeRequest implements org.apache.thrift.
       if (struct.isSetPrivileges()) {
         {
           oprot.writeI32(struct.privileges.size());
-          for (TSentryPrivilege _iter20 : struct.privileges)
+          for (TSentryPrivilege _iter36 : struct.privileges)
           {
-            _iter20.write(oprot);
+            _iter36.write(oprot);
           }
         }
       }
@@ -843,14 +843,14 @@ public class TAlterSentryRoleGrantPrivilegeRequest implements org.apache.thrift.
       }
       if (incoming.get(1)) {
         {
-          org.apache.thrift.protocol.TSet _set21 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
-          struct.privileges = new HashSet<TSentryPrivilege>(2*_set21.size);
-          for (int _i22 = 0; _i22 < _set21.size; ++_i22)
+          org.apache.thrift.protocol.TSet _set37 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
+          struct.privileges = new HashSet<TSentryPrivilege>(2*_set37.size);
+          for (int _i38 = 0; _i38 < _set37.size; ++_i38)
           {
-            TSentryPrivilege _elem23; // required
-            _elem23 = new TSentryPrivilege();
-            _elem23.read(iprot);
-            struct.privileges.add(_elem23);
+            TSentryPrivilege _elem39; // required
+            _elem39 = new TSentryPrivilege();
+            _elem39.read(iprot);
+            struct.privileges.add(_elem39);
           }
         }
         struct.setPrivilegesIsSet(true);