Exemplo n.º 1
0
  private void moveToDetails() {
    AlertItem item;
    synchronized (alerts) {
      int row = table.getSelectedRow();
      item = (AlertItem) model.getAlert(row);
    }

    if (item != null) {
      showInDetails(item.getFlowId().getSourceIP());
    }
  }
Exemplo n.º 2
0
  public void insertAlertItem(AlertItem ai, int type) {
    HostResolver.addRequest(ai);
    ai.getPolicyItem().addAlerts(1);
    if (ai.getStatus() == AlertItem.NEW) {
      ai.getPolicyItem().addNewAlerts(1);
    }

    synchronized (alerts) {
      alerts.add(ai);
      model.addAlert(ai);
    }
  }
Exemplo n.º 3
0
  public void locateAndShowHost(long ip) {
    synchronized (alerts) {
      int size = model.getRowCount();
      for (int i = 0; i < size; i++) {
        AlertItem item = model.getAlert(i);
        if (item.getFlowId().getSourceIP() == ip) {
          table.setRowSelectionInterval(i, i);
          table.scrollRectToVisible(table.getCellRect(i, 0, true));
          break;
        }
      }
    }

    showInDetails(ip);
  }
Exemplo n.º 4
0
  public void deleteAlertsForPolicy(PolicyItem pi) {
    List ids = new ArrayList();
    synchronized (alerts) {
      Iterator it = alerts.iterator();
      while (it.hasNext()) {
        AlertItem alert = (AlertItem) it.next();
        if (alert.getPolicyItem() == pi) {
          ids.add(alert);
        }
      }
    }

    Iterator it = ids.iterator();
    while (it.hasNext()) {
      AlertItem alert = (AlertItem) it.next();
      model.removeAlert(alert);
      deleteFromSource(alert);
    }
  }
Exemplo n.º 5
0
  private void deleteAlerts(int[] rows) {
    long[] alertsIds = new long[rows.length];
    AlertItem[] alerts = new AlertItem[rows.length];

    for (int i = 0; i < rows.length; i++) {
      AlertItem item = model.getAlert(rows[i]);
      alerts[i] = item;
      alertsIds[i] = item.getAlertID();
    }

    for (int i = 0; i < alerts.length; i++) {
      model.removeAlert(alerts[i]);
      deleteFromSource(alerts[i]);
    }

    if (alertsIds != null) {
      try {
        main.deleteAlertList(alertsIds);
      } catch (IOException ex) {
      }
    }
  }
Exemplo n.º 6
0
  private void deleteAlertTypeForHost() {
    List ids = new ArrayList();
    long[] lids = null;

    synchronized (alerts) {
      int row = table.getSelectedRow();
      AlertItem item = (AlertItem) model.getAlert(row);

      if (item != null) {
        long ip = item.getFlowId().getSourceIP();
        long pId = item.getPolicyID();

        Iterator it = alerts.iterator();
        while (it.hasNext()) {
          AlertItem alert = (AlertItem) it.next();
          if (alert.getPolicyID() == pId && alert.getFlowId().getSourceIP() == ip) {
            ids.add(alert);
          }
        }
      }
    }

    if (JOptionPane.showConfirmDialog(this, "Delete " + ids.size() + " Alerts?")
        != JOptionPane.YES_OPTION) {
      return;
    }

    lids = new long[ids.size()];
    for (int i = 0; i < lids.length; i++) {
      AlertItem alert = (AlertItem) ids.get(i);
      lids[i] = alert.getAlertID();
      model.removeAlert(alert);
      deleteFromSource(alert);
    }

    try {
      main.deleteAlertList(lids);
    } catch (IOException ex) {
      ex.printStackTrace();
    }
  }
Exemplo n.º 7
0
  private void markAlerts(int[] items, int mark) {
    List list = new ArrayList();
    for (int i = 0; i < items.length; i++) {
      AlertItem item = model.getAlert(items[i]);
      if (item.getStatus() != mark) {
        if (item.getStatus() == AlertItem.NEW) {
          item.getPolicyItem().addNewAlerts(-1);
        } else {
          item.getPolicyItem().addNewAlerts(mark == AlertItem.NEW ? 1 : 0);
        }

        list.add(item);
        item.setStatus(mark);
      }
    }

    try {
      main.saveAlertList(list);
    } catch (IOException ex) {
      ex.printStackTrace();
    }
  }