use of org.zaproxy.zap.model.Context 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.Context in project zaproxy by zaproxy.
the class SpiderDialog method targetSelected.
@Override
public void targetSelected(String field, Target node) {
List<String> ctxNames = new ArrayList<String>();
if (node != null) {
// The user has selected a new node
this.target = node;
if (node.getStartNode() != null) {
Session session = Model.getSingleton().getSession();
List<Context> contexts = session.getContextsForNode(node.getStartNode());
for (Context context : contexts) {
ctxNames.add(context.getName());
}
} else if (node.getContext() != null) {
ctxNames.add(node.getContext().getName());
}
}
this.setComboFields(FIELD_CONTEXT, ctxNames, "");
this.getField(FIELD_CONTEXT).setEnabled(ctxNames.size() > 0);
}
use of org.zaproxy.zap.model.Context in project zaproxy by zaproxy.
the class SessionManagementAPI method handleApiAction.
@Override
public ApiResponse handleApiAction(String name, JSONObject params) throws ApiException {
log.debug("handleApiAction " + name + " " + params.toString());
switch(name) {
case ACTION_SET_METHOD:
// Prepare the params
JSONObject actionParams;
if (params.has(PARAM_METHOD_CONFIG_PARAMS))
actionParams = API.getParams(params.getString(PARAM_METHOD_CONFIG_PARAMS));
else
actionParams = new JSONObject();
Context context = getContext(params);
actionParams.put(PARAM_CONTEXT_ID, context.getIndex());
// Run the method
getSetMethodActionImplementor(params).handleAction(actionParams);
context.save();
return ApiResponseElement.OK;
default:
throw new ApiException(Type.BAD_ACTION);
}
}
use of org.zaproxy.zap.model.Context in project zaproxy by zaproxy.
the class SessionManagementAPI method getContext.
/**
* Gets the context from the parameters or throws a Missing Parameter exception, if any problems
* occured.
*
* @param params the params
* @return the context
* @throws ApiException the api exception
*/
private Context getContext(JSONObject params) throws ApiException {
int contextId = getContextId(params);
Context context = Model.getSingleton().getSession().getContext(contextId);
if (context == null)
throw new ApiException(Type.CONTEXT_NOT_FOUND, PARAM_CONTEXT_ID);
return context;
}
use of org.zaproxy.zap.model.Context in project zaproxy by zaproxy.
the class ExtensionStdMenus method getPopupContextTreeMenuExport.
private PopupContextTreeMenu getPopupContextTreeMenuExport() {
if (popupContextTreeMenuExport == null) {
popupContextTreeMenuExport = new PopupContextTreeMenu();
popupContextTreeMenuExport.setText(Constant.messages.getString("menu.file.context.export"));
popupContextTreeMenuExport.setIcon(DisplayUtils.getScaledIcon(new ImageIcon(ExtensionStdMenus.class.getResource("/resource/icon/fugue/application-blue-export.png"))));
popupContextTreeMenuExport.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
Context context = Model.getSingleton().getSession().getContext(popupContextTreeMenuExport.getContextId());
ContextExportDialog exportDialog = new ContextExportDialog(View.getSingleton().getMainFrame());
exportDialog.setSelectedContext(context);
exportDialog.setVisible(true);
}
});
}
return popupContextTreeMenuExport;
}
Aggregations