mirror of
https://github.com/apache/sqoop.git
synced 2025-05-17 01:11:07 +08:00
SQOOP-2739: Sqoop2: Use resource name instead of resource id in authorization engine
(Colin Ma via Jarek Jarcec Cecho)
This commit is contained in:
parent
c5962f8e15
commit
f4909a5634
@ -33,18 +33,14 @@
|
||||
|
||||
public class AuthorizationEngine {
|
||||
|
||||
private static String getResourceName(MResource.TYPE resourceType, long resourceId) {
|
||||
Repository repository = RepositoryManager.getInstance().getRepository();
|
||||
|
||||
switch (resourceType) {
|
||||
case CONNECTOR:
|
||||
return repository.findConnector(resourceId).getUniqueName();
|
||||
case LINK:
|
||||
return repository.findLink(resourceId).getName();
|
||||
case JOB:
|
||||
return repository.findJob(resourceId).getName();
|
||||
private static String getResourceName(Object resource) {
|
||||
if (resource instanceof MConnector) {
|
||||
return ((MConnector)resource).getUniqueName();
|
||||
} else if (resource instanceof MLink) {
|
||||
return ((MLink)resource).getName();
|
||||
} else if (resource instanceof MJob) {
|
||||
return ((MJob)resource).getName();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -56,7 +52,7 @@ public static <T extends MPersistableEntity> List<T> filterResource(final String
|
||||
@Override
|
||||
public boolean apply(T input) {
|
||||
try {
|
||||
String name = getResourceName(type, input.getPersistenceId());
|
||||
String name = getResourceName(input);
|
||||
checkPrivilege(doUserName, getPrivilege(type, name, MPrivilege.ACTION.READ));
|
||||
// add valid resource
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user