@Override public Object alterRoleGrantPrivilege(final String component, final String role, final PrivilegeObject privilege, final String grantorPrincipal) throws Exception { delegate.getTransactionManager().executeTransactionWithRetry( pm -> { pm.setDetachAllOnCommit(false); // No need to detach objects String trimmedRole = toTrimmedLower(role); MSentryRole mRole = getRole(trimmedRole, pm); if (mRole == null) { throw new SentryNoSuchObjectException("Role: " + trimmedRole); } // check with grant option grantOptionCheck(privilege, grantorPrincipal, pm); privilegeOperator.grantPrivilege(privilege, mRole, pm); return null; }); return null; }
@Override public Object alterRoleRevokePrivilege(final String component, final String role, final PrivilegeObject privilege, final String grantorPrincipal) throws Exception { delegate.getTransactionManager().executeTransactionWithRetry( pm -> { pm.setDetachAllOnCommit(false); // No need to detach objects String trimmedRole = toTrimmedLower(role); MSentryRole mRole = getRole(trimmedRole, pm); if (mRole == null) { throw new SentryNoSuchObjectException("Role: " + trimmedRole); } // check with grant option grantOptionCheck(privilege, grantorPrincipal, pm); privilegeOperator.revokePrivilege(privilege, mRole, pm); return null; }); return null; }
@Override public CommitContext alterRoleRevokePrivilege(String component, String role, PrivilegeObject privilege, String grantorPrincipal) throws SentryUserException { role = toTrimmedLower(role); PersistenceManager pm = null; boolean rollbackTransaction = true; try{ pm = openTransaction(); MSentryRole mRole = getRole(role, pm); if (mRole == null) { throw new SentryNoSuchObjectException("Role: " + role + " doesn't exist"); } /** * check with grant option */ grantOptionCheck(privilege, grantorPrincipal, pm); privilegeOperator.revokePrivilege(privilege, mRole, pm); CommitContext commitContext = commitUpdateTransaction(pm); rollbackTransaction = false; return commitContext; } finally { if (rollbackTransaction) { rollbackTransaction(pm); } } }
@Override public CommitContext alterRoleGrantPrivilege(String component, String role, PrivilegeObject privilege, String grantorPrincipal) throws SentryUserException { role = toTrimmedLower(role); PersistenceManager pm = null; boolean rollbackTransaction = true; try{ pm = openTransaction(); MSentryRole mRole = getRole(role, pm); if (mRole == null) { throw new SentryNoSuchObjectException("Role: " + role + " doesn't exist"); } /** * check with grant option */ grantOptionCheck(privilege, grantorPrincipal, pm); privilegeOperator.grantPrivilege(privilege, mRole, pm); CommitContext commitContext = delegate.commitUpdateTransaction(pm); rollbackTransaction = false; return commitContext; } finally { if (rollbackTransaction) { rollbackTransaction(pm); } } }