我有一个用例,我想测试用户是否有分配给他的特定资源。我使用下面的代码,但它返回false,即使用户有该资源。
public static boolean isUserGrantedResource()
{
String resource = "RESOURCE_NAME";
boolean userHasPermission = false;
try
{
String resourceType = "ResourceType";
String action = "launch";
SecurityContext securityCtx =
ADFContext.getCurrent().getSecurityContext();
ResourcePermission resourcePermission =
new ResourcePermission(resourceType, resource, action);
userHasPermission = securityCtx.hasPermission(resourcePermission);
}
catch (Exception e)
{
//TODO
}
return userHasPermission;
}
任何帮助将不胜感激。