use of org.zaproxy.zap.model.Context in project zaproxy by zaproxy.
the class PopupMenuItemContextDataDriven method reCreateSubMenu.
protected void reCreateSubMenu(SiteNode sn) {
final List<JMenuItem> mainPopupMenuItems = View.getSingleton().getPopupList();
for (ExtensionPopupMenuItem menu : subMenus) {
mainPopupMenuItems.remove(menu);
}
subMenus.clear();
Session session = Model.getSingleton().getSession();
List<Context> contexts = session.getContexts();
for (Context context : contexts) {
if (context.isIncluded(sn)) {
ExtensionPopupMenuItem piicm = createPopupDataDrivenNodeMenu(context);
piicm.setMenuIndex(this.getMenuIndex());
mainPopupMenuItems.add(piicm);
this.subMenus.add(piicm);
}
}
}
use of org.zaproxy.zap.model.Context in project zaproxy by zaproxy.
the class PopupMenuItemContextExclude method reCreateSubMenu.
protected void reCreateSubMenu() {
final List<JMenuItem> mainPopupMenuItems = View.getSingleton().getPopupList();
for (ExtensionPopupMenuItem menu : subMenus) {
mainPopupMenuItems.remove(menu);
}
subMenus.clear();
Session session = Model.getSingleton().getSession();
List<Context> contexts = session.getContexts();
for (Context context : contexts) {
ExtensionPopupMenuItem piicm = createPopupExcludeFromContextMenu(context);
piicm.setMenuIndex(this.getMenuIndex());
mainPopupMenuItems.add(piicm);
this.subMenus.add(piicm);
}
}
use of org.zaproxy.zap.model.Context in project zaproxy by zaproxy.
the class ContextSelectComboBox method reloadContexts.
/**
* Reloads/refreshes the list of {@link Context Contexts} from the {@link Session}.
*
* @param keepSelected whether the previously selected context is tried to be restored. If
* {@code false}, defaults to no selection.
*/
public void reloadContexts(boolean keepSelected) {
Context selected = null;
if (keepSelected)
selected = (Context) getSelectedItem();
List<Context> contexts = Model.getSingleton().getSession().getContexts();
Context[] contextsArray = contexts.toArray(new Context[contexts.size()]);
ComboBoxModel<Context> model = new DefaultComboBoxModel<>(contextsArray);
// No matter what, set selected item, so it either defaults to 'nothing selected' or
// restores the previously selected item
model.setSelectedItem(selected);
this.setModel(model);
}
use of org.zaproxy.zap.model.Context in project zaproxy by zaproxy.
the class ExtensionSessionManagementUnitTest method shouldImportContextWithScriptSessionMgmtType.
@Test
void shouldImportContextWithScriptSessionMgmtType() throws ConfigurationException {
// Given
Context context = mock(Context.class);
Configuration config = new ZapXmlConfiguration();
int sessMgmtTypeId = 2;
config.addProperty(ExtensionSessionManagement.CONTEXT_CONFIG_SESSION_TYPE, sessMgmtTypeId);
// When
extSessMgmt.importContextData(context, config);
// Then
verify(context).setSessionManagementMethod(any(ScriptBasedSessionManagementMethod.class));
}
use of org.zaproxy.zap.model.Context in project zaproxy by zaproxy.
the class ExtensionSessionManagementUnitTest method shouldImportContextWithUnknownSessionMgmtType.
@Test
void shouldImportContextWithUnknownSessionMgmtType() throws ConfigurationException {
// Given
Context context = mock(Context.class);
Configuration config = new ZapXmlConfiguration();
int sessMgmtTypeId = 100;
config.addProperty(ExtensionSessionManagement.CONTEXT_CONFIG_SESSION_TYPE, sessMgmtTypeId);
// When
extSessMgmt.importContextData(context, config);
// Then
verify(context, times(0)).setSessionManagementMethod(any());
}
Aggregations