0

我有一个用例,我想测试用户是否有分配给他的特定资源。我正在使用下面的代码,但即使用户拥有该资源,它也会返回 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;
}

任何帮助将不胜感激。

4

0 回答 0