Search in sources :

Example 36 with SiteNode

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

the class NodeSelectDialog method getTreeSite.

private JTree getTreeSite() {
    if (treeSite == null) {
        this.siteTree = this.emptySiteTree();
        treeSite = new JTree(this.siteTree);
        treeSite.setShowsRootHandles(true);
        treeSite.setName("nodeSelectTree");
        treeSite.setToggleClickCount(1);
        treeSite.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
        treeSite.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {

            @Override
            public void valueChanged(javax.swing.event.TreeSelectionEvent e) {
                SiteNode node = (SiteNode) treeSite.getLastSelectedPathComponent();
                getSelectButton().setEnabled(node != null && (node.getParent() != null || allowRoot));
            }
        });
        treeSite.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) {
                // right mouse button action
                if (treeSite.getLastSelectedPathComponent() != null) {
                    // They selected a site node, deselect any context
                    getTreeContext().clearSelection();
                }
                if (e.getClickCount() > 1) {
                    // Its a double click - close the dialog to select this node
                    nodeSelected();
                }
            }
        });
        treeSite.setCellRenderer(new SiteMapTreeCellRenderer(new ArrayList<SiteMapListener>()));
    }
    return treeSite;
}
Also used : JTree(javax.swing.JTree) ArrayList(java.util.ArrayList) SiteNode(org.parosproxy.paros.model.SiteNode)

Example 37 with SiteNode

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

the class NodeSelectDialog method nodeSelected.

private void nodeSelected() {
    SiteNode node = (SiteNode) treeSite.getLastSelectedPathComponent();
    if (node != null && (node.getParent() != null || allowRoot)) {
        selectedSiteNode = (SiteNode) node.getUserObject();
        selectedTarget = null;
        NodeSelectDialog.this.setVisible(false);
    }
}
Also used : SiteNode(org.parosproxy.paros.model.SiteNode)

Example 38 with SiteNode

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

the class NodeSelectDialog method populateContexts.

private void populateContexts(SiteNode root) {
    // Uncomment to hide contexts tree if there are no valid contexts - 
    // not sure if this is a good idea or not :/ 
    //int contexts = 0;
    int contextsInScope = 0;
    for (Context ctx : Model.getSingleton().getSession().getContexts()) {
        // TODO ignore handle protected mode?
        if (ctx.getIncludeInContextRegexs().size() > 0) {
            SiteNode node = new SiteNode(null, HistoryReference.TYPE_PROXIED, ctx.getName());
            node.setUserObject(new Target(ctx));
            root.add(node);
            //contexts ++;
            if (ctx.isInScope()) {
                contextsInScope++;
            }
        }
    }
    if (contextsInScope > 1) {
        // Allow user to choose everything in scope
        SiteNode node = new SiteNode(null, HistoryReference.TYPE_PROXIED, Constant.messages.getString("context.allInScope"));
        node.setUserObject(new Target(null, null, true, true));
        root.add(node);
    }
    //this.getTreeContext().setVisible(contexts > 0);
    this.getTreeContext().expandRow(0);
}
Also used : Context(org.zaproxy.zap.model.Context) Target(org.zaproxy.zap.model.Target) SiteNode(org.parosproxy.paros.model.SiteNode)

Example 39 with SiteNode

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

the class NodeSelectDialog method populateNode.

private void populateNode(SiteNode src, SiteNode dest, SiteNode defaultNode) {
    if (src.equals(defaultNode)) {
        // Flag this for use later..
        this.selectedSiteNode = dest;
    }
    for (int i = 0; i < src.getChildCount(); i++) {
        SiteNode child = (SiteNode) src.getChildAt(i);
        SiteNode copy = new SiteNode(null, HistoryReference.TYPE_PROXIED, child.getNodeName());
        copy.setUserObject(child);
        dest.add(copy);
        this.populateNode(child, copy, defaultNode);
    }
}
Also used : SiteNode(org.parosproxy.paros.model.SiteNode)

Example 40 with SiteNode

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

the class ContextsTreeCellRenderer method getTreeCellRendererComponent.

/**
	 * Sets custom tree node logos.
	 */
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
    SiteNode node = null;
    Target target = null;
    if (value instanceof SiteNode) {
        node = (SiteNode) value;
        if (node.getUserObject() instanceof Target) {
            target = (Target) node.getUserObject();
        }
    }
    if (node != null) {
        if (node.isRoot()) {
            setIcon(DisplayUtils.getScaledIcon(ROOT_ICON));
        } else if (target != null) {
            if (target.getContext() != null) {
                if (target.getContext().isInScope()) {
                    setIcon(DisplayUtils.getScaledIcon(CONTEXT_IN_SCOPE_ICON));
                } else {
                    setIcon(DisplayUtils.getScaledIcon(CONTEXT_ICON));
                }
            } else if (target.isInScopeOnly()) {
                setIcon(DisplayUtils.getScaledIcon(ALL_IN_SCOPE_ICON));
            }
        }
    }
    return this;
}
Also used : Target(org.zaproxy.zap.model.Target) SiteNode(org.parosproxy.paros.model.SiteNode)

Aggregations

SiteNode (org.parosproxy.paros.model.SiteNode)53 DatabaseException (org.parosproxy.paros.db.DatabaseException)10 HistoryReference (org.parosproxy.paros.model.HistoryReference)10 JTree (javax.swing.JTree)9 Target (org.zaproxy.zap.model.Target)8 SiteMap (org.parosproxy.paros.model.SiteMap)7 ArrayList (java.util.ArrayList)6 TreePath (javax.swing.tree.TreePath)6 Alert (org.parosproxy.paros.core.scanner.Alert)6 HttpMalformedHeaderException (org.parosproxy.paros.network.HttpMalformedHeaderException)4 Context (org.zaproxy.zap.model.Context)4 StructuralSiteNode (org.zaproxy.zap.model.StructuralSiteNode)4 IOException (java.io.IOException)3 InvalidParameterException (java.security.InvalidParameterException)3 List (java.util.List)3 PatternSyntaxException (java.util.regex.PatternSyntaxException)3 ImageIcon (javax.swing.ImageIcon)3 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)3 URIException (org.apache.commons.httpclient.URIException)3 Session (org.parosproxy.paros.model.Session)3