0

I have a use case where I want to test if a user has a particular resource assigned to him. I am using below code but it returns false, even if the user has that resource.

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;
}

Any help will be appreciated.

0 Answers0