String grantor = "g1";
sentryStore.createSentryRole(roleName1, grantor);
sentryStore.createSentryRole(roleName2, grantor);
sentryStore.createSentryRole(roleName3, grantor);
TSentryPrivilege privilege_tbl1 = new TSentryPrivilege();
privilege_tbl1.setPrivilegeScope("TABLE");
privilege_tbl1.setServerName("server1");
privilege_tbl1.setDbName("db1");
privilege_tbl1.setTableName("tbl1");
privilege_tbl1.setGrantorPrincipal(grantor);
privilege_tbl1.setCreateTime(System.currentTimeMillis());
privilege_tbl1.setPrivilegeName(SentryStore.constructPrivilegeName(privilege_tbl1));
TSentryPrivilege privilege1 = new TSentryPrivilege(privilege_tbl1);
privilege1.setAction("SELECT");
privilege1.setPrivilegeName(SentryStore.constructPrivilegeName(privilege1));
TSentryPrivilege privilege2_1 = new TSentryPrivilege(privilege_tbl1);
privilege2_1.setAction("INSERT");
privilege2_1.setPrivilegeName(SentryStore.constructPrivilegeName(privilege2_1));
TSentryPrivilege privilege3_1 = new TSentryPrivilege(privilege_tbl1);
privilege3_1.setAction("*");
privilege3_1.setPrivilegeName(SentryStore.constructPrivilegeName(privilege3_1));
TSentryPrivilege privilege_server = new TSentryPrivilege();
privilege_server.setPrivilegeScope("SERVER");
privilege_server.setServerName("server1");
privilege_server.setGrantorPrincipal(grantor);
privilege_server.setCreateTime(System.currentTimeMillis());
privilege_server.setPrivilegeName(SentryStore.constructPrivilegeName(privilege_server));
TSentryPrivilege privilege_tbl2 = new TSentryPrivilege();
privilege_tbl2.setPrivilegeScope("TABLE");
privilege_tbl2.setServerName("server1");
privilege_tbl2.setDbName("db1");
privilege_tbl2.setTableName("tbl2");
privilege_tbl2.setGrantorPrincipal(grantor);
privilege_tbl2.setCreateTime(System.currentTimeMillis());
TSentryPrivilege privilege2_3 = new TSentryPrivilege(privilege_tbl2);
privilege2_3.setAction("SELECT");
privilege2_3.setPrivilegeName(SentryStore
.constructPrivilegeName(privilege2_3));
TSentryPrivilege privilege3_2 = new TSentryPrivilege(privilege_tbl2);
privilege3_2.setAction("INSERT");
privilege2_3.setPrivilegeName(SentryStore.constructPrivilegeName(privilege2_3));
sentryStore.alterSentryRoleGrantPrivilege(roleName1, privilege1);
sentryStore.alterSentryRoleGrantPrivilege(roleName2, privilege2_1);