Oracle:如何以编程方式检查用户是否分配了给定的资源?

时间:2017-03-01 10:27:57

标签: java oracle oracle11g security-context

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

任何帮助将不胜感激。

0 个答案:

没有答案