public void grantPrivilege(PrivilegeObject privilege,MSentryRole role, PersistenceManager pm) throws SentryUserException { MSentryGMPrivilege mPrivilege = convertToPrivilege(privilege); grantRolePartial(mPrivilege, role, pm); }
private MSentryGMPrivilege convertToPrivilege(PrivilegeObject privilege) { return new MSentryGMPrivilege(privilege.getComponent(), privilege.getService(), privilege.getAuthorizables(), privilege.getAction(), privilege.getGrantOption()); }
public PrivilegeObject build() { Preconditions.checkNotNull(component); Preconditions.checkNotNull(service); Preconditions.checkNotNull(action); //CaseInsensitive authorizable name List<? extends Authorizable> newAuthorizable = toLowerAuthorizableName(authorizables); return new PrivilegeObject(component.toLowerCase(), service.toLowerCase(), action.toLowerCase(), grantOption, newAuthorizable); } }
@BeforeClass public static void setup() throws Exception { conf = new Configuration(false); setup(conf); sentryStore = new DelegateSentryStore(conf); }
@Override public List<? extends BitFieldAction> getActionsByCode(int actionCode) { List<MyComponentAction> actions = Lists.newArrayList(); for (MyComponentActionType action : MyComponentActionType.getActionByCode(actionCode)) { actions.add(new MyComponentAction(action)); } return actions; }
@Override public Object alterRoleDeleteGroups(String component, String role, Set<String> groups, String requestor) throws Exception { delegate.alterSentryRoleDeleteGroups(role, toTSentryGroups(groups)); return null; }
public MyComponentAction(String name) { this(MyComponentActionType.getActionByName(name)); } public MyComponentAction(MyComponentActionType myComponentActionType) {
/** * Grant query privilege to role r1 */ @Test public void testGrantPrivilege() throws Exception { testGrantPrivilege(sentryStore, SEARCH); }
@Override public BitFieldAction getActionByName(String name) { // Check the name is All if (SqoopActionConstant.ALL_NAME.equalsIgnoreCase(name)) { return new MyComponentAction(MyComponentActionType.ALL); } return new MyComponentAction(name); } }
@Test(expected=Exception.class) public void testCreateDuplicateRole() throws Exception { String roleName = "test-dup-role"; String grantor = "grantor"; sentryStore.createRole(SEARCH, roleName, grantor); sentryStore.createRole(SEARCH, roleName, grantor); }
@Test(expected=SentryNoSuchObjectException.class) public void testDropNotExistRole() throws Exception { String roleName = "not-exist"; String grantor = "grantor"; sentryStore.dropRole(SEARCH, roleName, grantor); }
private MSentryGMPrivilege convertToPrivilege(PrivilegeObject privilege) { return new MSentryGMPrivilege(privilege.getComponent(), privilege.getService(), privilege.getAuthorizables(), privilege.getAction(), privilege.getGrantOption()); }
@BeforeClass public static void setup() throws Exception { conf = new Configuration(true); setup(conf); sentryStore = new DelegateSentryStore(conf); }
public void grantPrivilege(PrivilegeObject privilege,MSentryRole role, PersistenceManager pm) throws SentryUserException { MSentryGMPrivilege mPrivilege = convertToPrivilege(privilege); grantRolePartial(mPrivilege, role, pm); }
@Override public List<? extends BitFieldAction> getActionsByCode(int actionCode) { List<MyComponentAction> actions = Lists.newArrayList(); for (MyComponentActionType action : MyComponentActionType.getActionByCode(actionCode)) { actions.add(new MyComponentAction(action)); } return actions; }
public PrivilegeObject build() { Preconditions.checkNotNull(component); Preconditions.checkNotNull(service); Preconditions.checkNotNull(action); //CaseInsensitive authorizable name List<? extends Authorizable> newAuthorizable = toLowerAuthorizableName(authorizables); return new PrivilegeObject(component.toLowerCase(), service.toLowerCase(), action.toLowerCase(), grantOption, newAuthorizable); } }
@Override public Object alterRoleAddGroups(String component, String role, Set<String> groups, String requestor) throws Exception { delegate.alterSentryRoleAddGroups(requestor, role, toTSentryGroups(groups)); return null; }
public MyComponentAction(String name) { this(MyComponentActionType.getActionByName(name)); } public MyComponentAction(MyComponentActionType myComponentActionType) {
/** * Grant query privilege to role r1 */ @Test public void testGrantPrivilege() throws Exception { testGrantPrivilege(sentryStore, SEARCH); }
@Override public CommitContext alterRoleDeleteGroups(String component, String role, Set<String> groups, String requestor) throws SentryNoSuchObjectException { //called to old sentryStore return delegate.alterSentryRoleDeleteGroups(role, toTSentryGroups(groups)); }