use of org.zaproxy.zap.model.Target in project zaproxy by zaproxy.
the class ExtensionActiveScan method showCustomScanDialog.
public void showCustomScanDialog(SiteNode node) {
if (customScanDialog == null) {
// Work out the tabs
String[] tabs = CustomScanDialog.STD_TAB_LABELS;
if (this.customScanPanels.size() > 0) {
List<String> tabList = new ArrayList<String>();
for (String str : CustomScanDialog.STD_TAB_LABELS) {
tabList.add(str);
}
for (CustomScanPanel csp : customScanPanels) {
tabList.add(csp.getLabel());
}
tabs = tabList.toArray(new String[tabList.size()]);
}
customScanDialog = new CustomScanDialog(this, tabs, this.customScanPanels, View.getSingleton().getMainFrame(), new Dimension(700, 500));
}
if (customScanDialog.isVisible()) {
customScanDialog.requestFocus();
// Its behind you! Actually not needed no the window is alwaysOnTop, but keeping in case we change that ;)
customScanDialog.toFront();
return;
}
if (node != null) {
customScanDialog.init(new Target(node));
} else {
// Keep the previously selected target
customScanDialog.init(null);
}
customScanDialog.setVisible(true);
}
use of org.zaproxy.zap.model.Target in project zaproxy by zaproxy.
the class SiteMapPanel method contextChanged.
public void contextChanged(Context c) {
getTreeContext();
SiteNode root = (SiteNode) this.contextTree.getRoot();
for (int i = 0; i < root.getChildCount(); i++) {
SiteNode node = (SiteNode) root.getChildAt(i);
Target target = (Target) node.getUserObject();
if (c.getId() == target.getContext().getId()) {
target.setContext(c);
if (node.getNodeName().equals(c.getName())) {
this.contextTree.nodeChanged(node);
} else {
this.reloadContextTree();
}
break;
}
}
}
use of org.zaproxy.zap.model.Target in project zaproxy by zaproxy.
the class SiteMapPanel method getTreeContext.
private JTree getTreeContext() {
if (treeContext == null) {
reloadContextTree();
treeContext = new JTree(this.contextTree);
treeContext.setShowsRootHandles(true);
treeContext.setName(CONTEXT_TREE_COMPONENT_NAME);
treeContext.setToggleClickCount(1);
treeContext.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
treeContext.addMouseListener(new java.awt.event.MouseAdapter() {
@Override
public void mousePressed(java.awt.event.MouseEvent e) {
}
@Override
public void mouseReleased(java.awt.event.MouseEvent e) {
mouseClicked(e);
}
@Override
public void mouseClicked(java.awt.event.MouseEvent e) {
TreePath path = treeContext.getClosestPathForLocation(e.getX(), e.getY());
if (treeSite.getLastSelectedPathComponent() != null) {
getTreeSite().clearSelection();
}
if (path != null) {
if (((SiteNode) path.getLastPathComponent()).isRoot()) {
treeContext.removeSelectionPath(path);
}
}
if (e.getClickCount() > 1) {
// Its a double click - show the relevant context dialog
SiteNode node = (SiteNode) treeContext.getLastSelectedPathComponent();
if (node != null && node.getUserObject() != null) {
Target target = (Target) node.getUserObject();
String panelName = ContextGeneralPanel.getPanelName(target.getContext());
getView().getSessionDialog().expandParamPanelNode(panelName);
if (getView().getSessionDialog().isParamPanelOrChildSelected(panelName)) {
panelName = null;
}
getView().showSessionDialog(Model.getSingleton().getSession(), panelName);
}
}
}
});
treeContext.setComponentPopupMenu(new ContextsCustomPopupMenu());
treeContext.setCellRenderer(new ContextsTreeCellRenderer());
DeleteContextAction delContextAction = new DeleteContextAction() {
private static final long serialVersionUID = 1L;
@Override
protected List<Context> getContexts() {
return getSelectedContexts();
}
@Override
protected Context getContext() {
return getSelectedContext();
}
};
treeContext.getInputMap().put((KeyStroke) delContextAction.getValue(DeleteContextAction.ACCELERATOR_KEY), DeleteContextAction.ACTION_NAME);
treeContext.getActionMap().put(DeleteContextAction.ACTION_NAME, delContextAction);
}
return treeContext;
}
use of org.zaproxy.zap.model.Target in project zaproxy by zaproxy.
the class SiteMapPanel method reloadContextTree.
public void reloadContextTree() {
SiteNode root;
if (this.contextTree == null) {
root = new SiteNode(null, -1, Constant.messages.getString("context.list"));
this.contextTree = new DefaultTreeModel(root);
} else {
root = (SiteNode) this.contextTree.getRoot();
root.removeAllChildren();
}
for (Context ctx : Model.getSingleton().getSession().getContexts()) {
if (ctx.isInScope() || !this.getScopeButton().isSelected()) {
// Add all in scope contexts, and out of scope ones if scope button not pressed
SiteNode node = new SiteNode(null, HistoryReference.TYPE_PROXIED, ctx.getName());
node.setUserObject(new Target(ctx));
root.add(node);
}
}
this.contextTree.nodeStructureChanged(root);
}
use of org.zaproxy.zap.model.Target in project zaproxy by zaproxy.
the class ActiveScanPanel method getNewScanButton.
@Override
public JButton getNewScanButton() {
if (scanButton == null) {
scanButton = new JButton(Constant.messages.getString("ascan.toolbar.button.new"));
scanButton.setIcon(DisplayUtils.getScaledIcon(new ImageIcon(ActiveScanPanel.class.getResource("/resource/icon/16/093.png"))));
scanButton.addActionListener(e -> extension.showCustomScanDialog((Target) null));
}
return scanButton;
}
Aggregations