Program: 105857
Project: 105857
Buggy source:
@Override public boolean checkAccess(Account caller,ControlledEntity entity,AccessType accessType,String action) throws PermissionDeniedException {
  if (entity == null && action != null) {
    List<IAMPolicy> policies=_iamSrv.listIAMPolicies(caller.getAccountId());
    boolean isAllowed=_iamSrv.isActionAllowedForPolicies(action,policies);
    if (!isAllowed) {
      throw new PermissionDeniedException("String_Node_Str" + action + "String_Node_Str"+ caller);
    }
    return true;
  }
  String entityType=entity.getEntityType().toString();
  if (accessType == null) {
    accessType=AccessType.UseEntry;
  }
  List<IAMPolicy> policies=getEffectivePolicies(caller,entity);
  HashMap<IAMPolicy,Boolean> policyPermissionMap=new HashMap<IAMPolicy,Boolean>();
  for (  IAMPolicy policy : policies) {
    List<IAMPolicyPermission> permissions=new ArrayList<IAMPolicyPermission>();
    if (action != null) {
      permissions=_iamSrv.listPolicyPermissionByActionAndEntity(policy.getId(),action,entityType);
      if (permissions.isEmpty()) {
        if (accessType != null) {
          permissions.addAll(_iamSrv.listPolicyPermissionByAccessAndEntity(policy.getId(),accessType.toString(),entityType));
        }
      }
    }
 else {
      if (accessType != null) {
        permissions.addAll(_iamSrv.listPolicyPermissionByAccessAndEntity(policy.getId(),accessType.toString(),entityType));
      }
    }
    for (    IAMPolicyPermission permission : permissions) {
      if (checkPermissionScope(caller,permission.getScope(),permission.getScopeId(),entity)) {
        if (permission.getEntityType().equals(entityType)) {
          policyPermissionMap.put(policy,permission.getPermission().isGranted());
          break;
        }
 else         if (permission.getEntityType().equals("String_Node_Str")) {
          policyPermissionMap.put(policy,permission.getPermission().isGranted());
        }
      }
    }
    if (policyPermissionMap.containsKey(policy) && policyPermissionMap.get(policy)) {
      return true;
    }
  }
  if (!policies.isEmpty()) {
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str" + caller + "String_Node_Str"+ entity+ "String_Node_Str"+ accessType);
    }
    throw new PermissionDeniedException(caller + "String_Node_Str" + entity);
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkAccess(Account caller,ControlledEntity entity,AccessType accessType,String action) throws PermissionDeniedException {
  if (entity == null && action != null) {
    List<IAMPolicy> policies=_iamSrv.listIAMPolicies(caller.getAccountId());
    boolean isAllowed=_iamSrv.isActionAllowedForPolicies(action,policies);
    if (!isAllowed) {
      throw new PermissionDeniedException("String_Node_Str" + action + "String_Node_Str"+ caller);
    }
    return true;
  }
  if (entity == null) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  String entityType=null;
  if (entity.getEntityType() != null) {
    entityType=entity.getEntityType().toString();
  }
  if (accessType == null) {
    accessType=AccessType.UseEntry;
  }
  List<IAMPolicy> policies=getEffectivePolicies(caller,entity);
  HashMap<IAMPolicy,Boolean> policyPermissionMap=new HashMap<IAMPolicy,Boolean>();
  for (  IAMPolicy policy : policies) {
    List<IAMPolicyPermission> permissions=new ArrayList<IAMPolicyPermission>();
    if (action != null) {
      permissions=_iamSrv.listPolicyPermissionByActionAndEntity(policy.getId(),action,entityType);
      if (permissions.isEmpty()) {
        if (accessType != null) {
          permissions.addAll(_iamSrv.listPolicyPermissionByAccessAndEntity(policy.getId(),accessType.toString(),entityType));
        }
      }
    }
 else {
      if (accessType != null) {
        permissions.addAll(_iamSrv.listPolicyPermissionByAccessAndEntity(policy.getId(),accessType.toString(),entityType));
      }
    }
    for (    IAMPolicyPermission permission : permissions) {
      if (checkPermissionScope(caller,permission.getScope(),permission.getScopeId(),entity)) {
        if (permission.getEntityType().equals(entityType)) {
          policyPermissionMap.put(policy,permission.getPermission().isGranted());
          break;
        }
 else         if (permission.getEntityType().equals("String_Node_Str")) {
          policyPermissionMap.put(policy,permission.getPermission().isGranted());
        }
      }
    }
    if (policyPermissionMap.containsKey(policy) && policyPermissionMap.get(policy)) {
      return true;
    }
  }
  if (!policies.isEmpty()) {
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str" + caller + "String_Node_Str"+ entity+ "String_Node_Str"+ accessType);
    }
    throw new PermissionDeniedException(caller + "String_Node_Str" + entity);
  }
  return false;
}