class FreeResourcesLimitServicePermissionsFilter extends CheMethodInvokerFilter {

  @Override
  protected void filter(GenericResourceMethod genericMethodResource, Object[] arguments)
      throws ApiException {
    switch (genericMethodResource.getMethod().getName()) {
      case STORE_FREE_RESOURCES_LIMIT_METHOD:
      case GET_FREE_RESOURCES_LIMITS_METHOD:
      case GET_FREE_RESOURCES_LIMIT_METHOD:
      case REMOVE_FREE_RESOURCES_LIMIT_METHOD:
        final Subject currentSubject = EnvironmentContext.getCurrent().getSubject();
        if (currentSubject.hasPermission(
            SystemDomain.DOMAIN_ID, null, SystemDomain.MANAGE_SYSTEM_ACTION)) {
          return;
        }
        // fall through
        // user doesn't have permissions and request should not be processed
      default:
        throw new ForbiddenException("The user does not have permission to perform this operation");
    }
  }

}