class ActivityPermissionsFilter extends CheMethodInvokerFilter {

  @Override
  protected void filter(GenericResourceMethod genericResourceMethod, Object[] arguments)
      throws ApiException {
    final String methodName = genericResourceMethod.getMethod().getName();

    final Subject currentSubject = EnvironmentContext.getCurrent().getSubject();
    String domain;
    String action;
    String instance;

    switch (methodName) {
      case "active":
        domain = WorkspaceDomain.DOMAIN_ID;
        instance = (String) arguments[0];
        action = WorkspaceDomain.USE;
        break;
      case "getWorkspacesByActivity":
        domain = SystemDomain.DOMAIN_ID;
        instance = null;
        action = SystemDomain.MONITOR_SYSTEM_ACTION;
        break;
      default:
        throw new ForbiddenException("The user does not have permission to perform this operation");
    }
    currentSubject.checkPermission(domain, instance, action);
  }

}