Search in sources :

Example 21 with SiteNode

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

the class PopupMenuExportSelectedURLs method getOutputSet.

private SortedSet<String> getOutputSet(TreePath[] startingPoints) {
    JTree siteTree = extension.getView().getSiteTreePanel().getTreeSite();
    ArrayList<TreePath> startingPts = new ArrayList<TreePath>();
    if (ArrayUtils.isEmpty(startingPoints)) {
        startingPts.add(new TreePath(siteTree.getModel().getRoot()));
    } else {
        startingPts.addAll(Arrays.asList(startingPoints));
    }
    SortedSet<String> outputSet = new TreeSet<String>();
    for (TreePath aPath : startingPts) {
        Enumeration<?> en = (((SiteNode) aPath.getLastPathComponent()).preorderEnumeration());
        while (en.hasMoreElements()) {
            SiteNode node = (SiteNode) en.nextElement();
            if (node.isRoot()) {
                continue;
            }
            HistoryReference nodeHR = node.getHistoryReference();
            if (nodeHR != null && !HistoryReference.getTemporaryTypes().contains(nodeHR.getHistoryType())) {
                outputSet.add(nodeHR.getURI().toString());
            }
        }
    }
    return outputSet;
}
Also used : HistoryReference(org.parosproxy.paros.model.HistoryReference) JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) SiteNode(org.parosproxy.paros.model.SiteNode)

Example 22 with SiteNode

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

the class NodeSelectDialog method contextSelected.

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

Example 23 with SiteNode

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

the class NodeSelectDialog method showDialog.

public SiteNode showDialog(SiteNode defaultNode) {
    // Assume Contexts cant be selected
    this.getTreeContext().setVisible(false);
    SiteNode siteRoot = (SiteNode) Model.getSingleton().getSession().getSiteTree().getRoot();
    populateNode(siteRoot, (SiteNode) this.siteTree.getRoot(), defaultNode);
    if (selectedSiteNode != null) {
        // Found the default node, select it
        TreePath path = new TreePath(this.siteTree.getPathToRoot(selectedSiteNode));
        this.getTreeSite().setExpandsSelectedPaths(true);
        this.getTreeSite().setSelectionPath(path);
        this.getTreeSite().scrollPathToVisible(path);
        this.getTreeSite().expandPath(path);
    } else {
        // no default path, just expand the top level
        TreePath path = new TreePath(this.siteTree.getPathToRoot((TreeNode) this.siteTree.getRoot()));
        this.getTreeSite().expandPath(path);
    }
    this.setVisible(true);
    // The dialog is modal so this wont return until the dialog visibility is unset
    return selectedSiteNode;
}
Also used : TreePath(javax.swing.tree.TreePath) TreeNode(javax.swing.tree.TreeNode) SiteNode(org.parosproxy.paros.model.SiteNode)

Example 24 with SiteNode

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

the class NodeSelectDialog method getTreeContext.

private JTree getTreeContext() {
    if (treeContext == null) {
        this.contextTree = this.emptyContextTree();
        treeContext = new JTree(this.contextTree);
        treeContext.setShowsRootHandles(true);
        treeContext.setName("nodeContextTree");
        treeContext.setToggleClickCount(1);
        treeContext.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
        treeContext.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {

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

Example 25 with SiteNode

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

the class NodeSelectDialog method emptySiteTree.

private DefaultTreeModel emptySiteTree() {
    // Make a very sparse copy of the site tree
    SiteNode siteRoot = (SiteNode) Model.getSingleton().getSession().getSiteTree().getRoot();
    SiteNode root = new SiteNode(null, -1, Constant.messages.getString("tab.sites"));
    root.setUserObject(siteRoot);
    return new DefaultTreeModel(root);
}
Also used : DefaultTreeModel(javax.swing.tree.DefaultTreeModel) 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