mirror of
https://github.com/apache/sqoop.git
synced 2025-05-17 09:20:43 +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 {
|
public class AuthorizationEngine {
|
||||||
|
|
||||||
private static String getResourceName(MResource.TYPE resourceType, long resourceId) {
|
private static String getResourceName(Object resource) {
|
||||||
Repository repository = RepositoryManager.getInstance().getRepository();
|
if (resource instanceof MConnector) {
|
||||||
|
return ((MConnector)resource).getUniqueName();
|
||||||
switch (resourceType) {
|
} else if (resource instanceof MLink) {
|
||||||
case CONNECTOR:
|
return ((MLink)resource).getName();
|
||||||
return repository.findConnector(resourceId).getUniqueName();
|
} else if (resource instanceof MJob) {
|
||||||
case LINK:
|
return ((MJob)resource).getName();
|
||||||
return repository.findLink(resourceId).getName();
|
|
||||||
case JOB:
|
|
||||||
return repository.findJob(resourceId).getName();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +52,7 @@ public static <T extends MPersistableEntity> List<T> filterResource(final String
|
|||||||
@Override
|
@Override
|
||||||
public boolean apply(T input) {
|
public boolean apply(T input) {
|
||||||
try {
|
try {
|
||||||
String name = getResourceName(type, input.getPersistenceId());
|
String name = getResourceName(input);
|
||||||
checkPrivilege(doUserName, getPrivilege(type, name, MPrivilege.ACTION.READ));
|
checkPrivilege(doUserName, getPrivilege(type, name, MPrivilege.ACTION.READ));
|
||||||
// add valid resource
|
// add valid resource
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user