Search in sources :

Example 36 with HistoryReference

use of org.parosproxy.paros.model.HistoryReference in project zaproxy by zaproxy.

the class AlertAddDialog method getBtnOk.

/**
	 * This method initializes btnStart	
	 * 	
	 * @return javax.swing.JButton	
	 */
private JButton getBtnOk() {
    if (btnOk == null) {
        btnOk = new JButton();
        btnOk.setText(Constant.messages.getString("alert.add.button.save"));
        btnOk.addActionListener(new java.awt.event.ActionListener() {

            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                Alert alert = alertViewPanel.getAlert();
                try {
                    ExtensionAlert extAlert = (ExtensionAlert) Control.getSingleton().getExtensionLoader().getExtension(ExtensionAlert.NAME);
                    if (alert.getAlertId() >= 0) {
                        // Its an existing alert so save it
                        if (extAlert != null) {
                            extAlert.updateAlert(alert);
                        } else if (historyRef != null) {
                            // Update history tree
                            historyRef.updateAlert(alert);
                            extension.notifyHistoryItemChanged(historyRef);
                        }
                    } else {
                        if (httpMessage != null) {
                            historyRef = new HistoryReference(Model.getSingleton().getSession(), historyType, httpMessage);
                        }
                        alert.setSource(Alert.Source.MANUAL);
                        // Raise it
                        if (extAlert != null) {
                            extAlert.alertFound(alert, historyRef);
                        } else {
                            historyRef.addAlert(alert);
                            extension.notifyHistoryItemChanged(historyRef);
                        }
                    }
                } catch (Exception ex) {
                    logger.error(ex.getMessage(), ex);
                }
                clearAndCloseDialog();
            }
        });
    }
    return btnOk;
}
Also used : HistoryReference(org.parosproxy.paros.model.HistoryReference) JButton(javax.swing.JButton) Alert(org.parosproxy.paros.core.scanner.Alert) ExtensionAlert(org.zaproxy.zap.extension.alert.ExtensionAlert) ExtensionAlert(org.zaproxy.zap.extension.alert.ExtensionAlert) HeadlessException(java.awt.HeadlessException)

Aggregations

HistoryReference (org.parosproxy.paros.model.HistoryReference)36 DatabaseException (org.parosproxy.paros.db.DatabaseException)11 SiteNode (org.parosproxy.paros.model.SiteNode)10 HttpMalformedHeaderException (org.parosproxy.paros.network.HttpMalformedHeaderException)7 ArrayList (java.util.ArrayList)6 Alert (org.parosproxy.paros.core.scanner.Alert)6 HttpMessage (org.parosproxy.paros.network.HttpMessage)6 JTree (javax.swing.JTree)5 ExtensionHistory (org.parosproxy.paros.extension.history.ExtensionHistory)5 TreePath (javax.swing.tree.TreePath)4 IOException (java.io.IOException)3 TreeSet (java.util.TreeSet)3 Session (org.parosproxy.paros.model.Session)3 SiteMap (org.parosproxy.paros.model.SiteMap)3 Component (java.awt.Component)2 MalformedURLException (java.net.MalformedURLException)2 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 URIException (org.apache.commons.httpclient.URIException)2 Event (org.zaproxy.zap.eventBus.Event)2 AlertNode (org.zaproxy.zap.extension.alert.AlertNode)2