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<>();
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 getContext.
/**
* Gets the context from the parameters or throws a Missing Parameter exception, if any problems
* occurred.
*
* @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 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.getId());
// 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 ExtensionStdMenus method getPopupContextTreeMenuExport.
private PopupContextTreeMenu getPopupContextTreeMenuExport() {
if (popupContextTreeMenuExport == null) {
popupContextTreeMenuExport = new PopupContextTreeMenu(false);
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(getView().getMainFrame());
exportDialog.setSelectedContext(context);
exportDialog.setVisible(true);
}
});
}
return popupContextTreeMenuExport;
}
use of org.zaproxy.zap.model.Context in project zaproxy by zaproxy.
the class PopupContextMenuItemHolder method resetMenu.
private void resetMenu() {
final List<JMenuItem> mainPopupMenuItems = View.getSingleton().getPopupList();
// Remove existing popup menu items
if (visibleItself)
this.removeAll();
else {
for (ExtensionPopupMenuItem menu : getSubmenuItems()) {
mainPopupMenuItems.remove(menu);
}
subMenuItems.clear();
}
// Add a popup menu item for each existing context
Session session = Model.getSingleton().getSession();
List<Context> contexts = session.getContexts();
for (Context context : contexts) {
ExtensionPopupMenuItem piicm;
if (visibleItself) {
piicm = getPopupContextMenu(context, this.getText());
this.add(piicm);
} else {
piicm = getPopupContextMenu(context, this.parentName);
piicm.setMenuIndex(this.getMenuIndex());
mainPopupMenuItems.add(piicm);
subMenuItems.add(piicm);
}
}
}
Aggregations