use of org.parosproxy.paros.model.SiteNode in project zaproxy by zaproxy.
the class Context method fillNodesInContext.
/**
* Fills a given list with nodes in scope, searching recursively.
*
* @param rootNode the root node
* @param nodesList the nodes list
*/
private void fillNodesInContext(SiteNode rootNode, List<SiteNode> nodesList) {
@SuppressWarnings("unchecked") Enumeration<SiteNode> en = rootNode.children();
while (en.hasMoreElements()) {
SiteNode sn = en.nextElement();
if (isInContext(sn)) {
nodesList.add(sn);
}
fillNodesInContext(sn, nodesList);
}
}
use of org.parosproxy.paros.model.SiteNode in project zaproxy by zaproxy.
the class SessionStructure method find.
public static StructuralNode find(long sessionId, URI uri, String method, String postData) throws DatabaseException, URIException {
Model model = Model.getSingleton();
if (!Constant.isLowMemoryOptionSet()) {
SiteNode node = model.getSession().getSiteTree().findNode(uri, method, postData);
if (node == null) {
return null;
}
return new StructuralSiteNode(node);
}
String nodeName = getNodeName(sessionId, uri, method, postData);
RecordStructure rs = model.getDb().getTableStructure().find(sessionId, nodeName, method);
if (rs == null) {
return null;
}
return new StructuralTableNode(rs);
}
use of org.parosproxy.paros.model.SiteNode 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.SINGLE_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) {
if (treeSite.getLastSelectedPathComponent() != null) {
// They selected a context node, deselect any context
getTreeSite().clearSelection();
}
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();
getView().showSessionDialog(Model.getSingleton().getSession(), ContextGeneralPanel.getPanelName(target.getContext()));
}
}
}
});
treeContext.setComponentPopupMenu(new ContextsCustomPopupMenu());
treeContext.setCellRenderer(new ContextsTreeCellRenderer());
}
return treeContext;
}
use of org.parosproxy.paros.model.SiteNode 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.parosproxy.paros.model.SiteNode 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.getIndex() == target.getContext().getIndex()) {
target.setContext(c);
if (node.getNodeName().equals(c.getName())) {
this.contextTree.nodeChanged(node);
} else {
this.reloadContextTree();
}
break;
}
}
}
Aggregations